collabmd 0.1.54 → 0.1.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/bin/collabmd.js +19 -38
  2. package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-cMeDxAEL.js +1 -0
  3. package/dist/client/assets/{abnfDiagram-VCTEODGH-DxNxad6-.js → abnfDiagram-VCTEODGH-D2UdmYvj.js} +1 -1
  4. package/dist/client/assets/{abnfDiagram-O67JEVCF-Dwt6a0Ds.js → abnfDiagram-YUKMZFIV-DbmU4Q-X.js} +1 -1
  5. package/dist/client/assets/api-client-utils-C5ESDKMG.js +1 -0
  6. package/dist/client/assets/architecture-7GRP2DOG-BBwRXFv3.js +1 -1
  7. package/dist/client/assets/architecture-WOLXFQ4H-C0NxYiG7.js +1 -0
  8. package/dist/client/assets/{architectureDiagram-NJMV4G6O-D5CGiX3G.js → architectureDiagram-47P4ROYG-C7OjXK9S.js} +3 -3
  9. package/dist/client/assets/{architectureDiagram-5GKGNRK7-C1uvg5id.js → architectureDiagram-5GKGNRK7-CSiUzzeN.js} +1 -1
  10. package/dist/client/assets/base-CaIEJUF9.css +1 -0
  11. package/dist/client/assets/{blockDiagram-BEXU5L5S-BgTM0var.js → blockDiagram-E7TT5TSB-DMG-YlZw.js} +3 -3
  12. package/dist/client/assets/{blockDiagram-I7D4REHJ-B2YonsoG.js → blockDiagram-I7D4REHJ-sXfAgK2w.js} +1 -1
  13. package/dist/client/assets/{browser-BKLM0ThC-BCLQGPD6-K2seJgRL.js → browser-BKLM0ThC-BCLQGPD6-CcMAHZXi.js} +1 -1
  14. package/dist/client/assets/{c4Diagram-7LVT6UL2-r4IwomZm.js → c4Diagram-7LVT6UL2-C88V_K-8.js} +1 -1
  15. package/dist/client/assets/{c4Diagram-YGBWAQC7-_xZPrNkB.js → c4Diagram-CRA5TL53-D3F9ElJv.js} +2 -2
  16. package/dist/client/assets/canvasEditor-BJkwGzO1.css +1 -0
  17. package/dist/client/assets/canvasEditor-sBK7KfrD.js +1 -0
  18. package/dist/client/assets/{chunk-6AZGARVD--pTGpDnx.js → chunk-24IY7LWP-flnn6SWX.js} +1 -1
  19. package/dist/client/assets/chunk-2BW5OAIV-CNFO1U_e.js +10 -0
  20. package/dist/client/assets/{chunk-2E4U76K2-CIQUuV9n.js → chunk-2E4U76K2-DEnS5IbF.js} +1 -1
  21. package/dist/client/assets/{chunk-5V3GS4D5-B5uC2oxu.js → chunk-3M4EKCLJ-D-sZGCtO.js} +1 -1
  22. package/dist/client/assets/chunk-3YJQHVM4-Ctp__8EK.js +2 -0
  23. package/dist/client/assets/{chunk-7PRAP22T-9uTvtc_-.js → chunk-4EA7E6EY-bU4wRJot.js} +1 -1
  24. package/dist/client/assets/{chunk-4HAMMTFA-q0ldNVvr.js → chunk-4HAMMTFA-CQy6Skzw.js} +1 -1
  25. package/dist/client/assets/{chunk-6K3QC6MW-JnuvEGV4.js → chunk-4S7OKTRW-BpUW13a3.js} +1 -1
  26. package/dist/client/assets/{chunk-ICYGCRZG-odvlDZyA.js → chunk-53FOQ5SW-5lPdGYP4.js} +1 -1
  27. package/dist/client/assets/{chunk-75Z2AOVW-DitkSoSG.js → chunk-75Z2AOVW-BRdhvVTZ.js} +1 -1
  28. package/dist/client/assets/{chunk-GWA4HPMP-CGmv2yIq.js → chunk-7TKQ45FW-rA2u-WUl.js} +1 -1
  29. package/dist/client/assets/{chunk-GTNCS2PH-ChgkzEIi.js → chunk-AW2ZBBNX-DL0KGAdi.js} +3 -3
  30. package/dist/client/assets/{chunk-747NJXEK-BjqqAsS9.js → chunk-BP2KR52E-DAQ1pzDV.js} +1 -1
  31. package/dist/client/assets/{chunk-CLGD4ZFX-BfYJtJm1.js → chunk-CLGD4ZFX-DJiSE0gD.js} +1 -1
  32. package/dist/client/assets/{chunk-5DYCD2WN-BKWCKnK-.js → chunk-DBDB3WZW-CXleNlok.js} +1 -1
  33. package/dist/client/assets/{chunk-DU6HZSFF-CWlP1Dk_.js → chunk-DU6HZSFF-C-18UZkS.js} +1 -1
  34. package/dist/client/assets/{chunk-MBY4JIJT-DTJ4UcAm.js → chunk-E2ZNV5FY-D_07zfWd.js} +3 -3
  35. package/dist/client/assets/chunk-EU5HNXII-CETVNUXF.js +213 -0
  36. package/dist/client/assets/{chunk-F27PBJKO-DPcsPcEs.js → chunk-F27PBJKO-_beIJos4.js} +1 -1
  37. package/dist/client/assets/{chunk-2ZTRR5NV-DcPRfelM.js → chunk-F6S3BTY2-DVWKCAHp.js} +1 -1
  38. package/dist/client/assets/{chunk-ISPTBLVO-BMsDq9Ha.js → chunk-FLFP27SU-CydzbSsY.js} +2 -2
  39. package/dist/client/assets/chunk-FVRAUYC3-C7b9SJ81.js +1 -0
  40. package/dist/client/assets/{chunk-GMAD6QVW-Bgk8qnty.js → chunk-GMAD6QVW-DnZH7DxV.js} +1 -1
  41. package/dist/client/assets/{chunk-GVQU2GXP-CQ8cl-Uu.js → chunk-GVQU2GXP-B0Vm415C.js} +1 -1
  42. package/dist/client/assets/chunk-H5A3YXKD-ChP7mNJq.js +41 -0
  43. package/dist/client/assets/{chunk-742MDFTN-D1nh6vNv.js → chunk-HJ2JQQFS-DQX7RePR.js} +1 -1
  44. package/dist/client/assets/{chunk-NETBCI7D-CmUwDWUZ.js → chunk-HTAEGDNF-C0PA_N-c.js} +1 -1
  45. package/dist/client/assets/{chunk-IMKFNOWR-CBqxfpcP.js → chunk-IMKFNOWR-DoO8IHzF.js} +1 -1
  46. package/dist/client/assets/{chunk-IH6LHLGP-BNevEHZK.js → chunk-KPI5JJXK-B2ld5-w4.js} +1 -1
  47. package/dist/client/assets/{chunk-WEXAMYUT-DDlVNp8J.js → chunk-KQW6MTUR-OQ4MyMr_.js} +1 -1
  48. package/dist/client/assets/{chunk-L3NEJ4N5-BflzkdTI.js → chunk-L3NEJ4N5-CvHossEU.js} +1 -1
  49. package/dist/client/assets/chunk-NGNAAXSQ-DqoPQk1a.js +136 -0
  50. package/dist/client/assets/{chunk-UA2S7LBM-DicYDjDM.js → chunk-NTY3LDVX-CVWLK_fh.js} +1 -1
  51. package/dist/client/assets/{chunk-UY3FDG6J-QT-rkt0y.js → chunk-OD3NTWWA-Dz9nCUGX.js} +1 -1
  52. package/dist/client/assets/{chunk-OSK3NFVY-DqeKV_pg.js → chunk-OSK3NFVY-C3JOcBao.js} +1 -1
  53. package/dist/client/assets/{chunk-P2QGCYS3-BA--DhpW.js → chunk-P2QGCYS3-Bfo8qS8r.js} +1 -1
  54. package/dist/client/assets/{chunk-POPQ4Y6H-V_NEc45n.js → chunk-POPQ4Y6H-sv6rCftH.js} +1 -1
  55. package/dist/client/assets/{chunk-PWAF6VOD-D_kLse-N.js → chunk-PWAF6VOD-B-AT-L2H.js} +1 -1
  56. package/dist/client/assets/{chunk-3Z5EZCMW-BAnA6eQ7.js → chunk-QNH66VMT-Cb9xxTwQ.js} +1 -1
  57. package/dist/client/assets/{chunk-SHT3W25Y-YM3S-A_M.js → chunk-SHT3W25Y-C1lu518T.js} +1 -1
  58. package/dist/client/assets/{chunk-GNY47TPC-CTrH5O5R.js → chunk-SVEVUXB4-BnM-LXop.js} +1 -1
  59. package/dist/client/assets/{chunk-SVP7TREG-DdNhDOmW.js → chunk-SVP7TREG-CKqt0syj.js} +1 -1
  60. package/dist/client/assets/{chunk-TICWLB2K-BGGgCr4x.js → chunk-TICWLB2K-D2ZnWAfF.js} +1 -1
  61. package/dist/client/assets/{chunk-TLUHSLCS-DCZhIDYA.js → chunk-TLUHSLCS-BMIhqv1X.js} +1 -1
  62. package/dist/client/assets/{chunk-6EIED4P4-DBVWq7Tz.js → chunk-TPMEZKFX-DIPHIqGb.js} +1 -1
  63. package/dist/client/assets/{chunk-6TQVIW2G-BSj0l_pu.js → chunk-VPELOWWC-DXayM28-.js} +1 -1
  64. package/dist/client/assets/chunk-VPRB5NB3-BqaJfj_v.js +127 -0
  65. package/dist/client/assets/{chunk-I5DQTOEV-aBZooNp1.js → chunk-VTWWFHGB-SZnJiyWY.js} +1 -1
  66. package/dist/client/assets/{chunk-KI3K4JFJ-FTtDwx3-.js → chunk-VZTHESGH-eHyXmK8W.js} +1 -1
  67. package/dist/client/assets/{chunk-7INBJB4K-CDmiHbaX.js → chunk-XC4XBNZT-D9oehSn8.js} +20 -20
  68. package/dist/client/assets/{chunk-XHIXRSVI-DN_fEwws.js → chunk-YK26KJH5-DVy3MGMd.js} +1 -1
  69. package/dist/client/assets/{chunk-6AEJRKK7-DTVZj5bY.js → chunk-Z6ETV63D-DOcrnz-P.js} +1 -1
  70. package/dist/client/assets/{chunk-OUJLGHUK-75UXlPjl.js → chunk-ZO67DCNQ-BAOMIkLF.js} +1 -1
  71. package/dist/client/assets/classDiagram-ZZMXUADV-BmETdFmC.js +1 -0
  72. package/dist/client/assets/{classDiagram-v2-NBCMYWYE-3TQORq33.js → classDiagram-v2-K4WV4PDN-eaadfJDB.js} +3 -3
  73. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BmETdFmC.js +1 -0
  74. package/dist/client/assets/{comment-markdown-renderer-Bxi_JRSR.js → comment-markdown-renderer-CpBKaj7H.js} +1 -1
  75. package/dist/client/assets/comment-thread-store-DUQsWtnu.js +1 -0
  76. package/dist/client/assets/comment-threads-DnfkLVJA.js +4 -0
  77. package/dist/client/assets/comment-ui-shared-D_pgPUti.js +7 -0
  78. package/dist/client/assets/cynefin-EF2NZ3EQ-DVkJeZ8i.js +1 -0
  79. package/dist/client/assets/cynefin-OW5HDTMX-CF3N9j1_.js +1 -1
  80. package/dist/client/assets/{cynefinDiagram-VND7K2PF-DwfMZ3vk.js → cynefinDiagram-3GCD6N5R-DjpAsBHC.js} +1 -1
  81. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-DTnLZaO7.js → cynefinDiagram-5FMLGOSQ-D2rFQG67.js} +1 -1
  82. package/dist/client/assets/dagre-C-rnJpZF.js +1 -0
  83. package/dist/client/assets/{dagre-GXQ25YYZ-Vtyx08Qh.js → dagre-GXQ25YYZ-Cku9eia9.js} +2 -2
  84. package/dist/client/assets/{dagre-6A5THRUB-DewyAGK6.js → dagre-W4DXFKR2-DOMOIsPd.js} +2 -2
  85. package/dist/client/assets/deferred-collab-C9aa9cvT.css +1 -0
  86. package/dist/client/assets/deferred-git-BPQ-UgrN.css +1 -0
  87. package/dist/client/assets/deferred-preview-B-RebLry.css +1 -0
  88. package/dist/client/assets/{diagram-22UHCM2B-DbZirFfl.js → diagram-2UJZ2QOL-D8WvnEyx.js} +6 -6
  89. package/dist/client/assets/{diagram-3UASUU5V-DmhdYv6_.js → diagram-OVF4WLC6-D8_escYE.js} +2 -2
  90. package/dist/client/assets/{diagram-CDSNMT55-D_qyS11R.js → diagram-PFPMY2P6-B1izZfrN.js} +3 -3
  91. package/dist/client/assets/{diagram-S7CK7UJ4-CGTzfo2f.js → diagram-S7CK7UJ4-BzicH2t-.js} +1 -1
  92. package/dist/client/assets/{diagram-MLGK6HIB-DIBG6Ivu.js → diagram-UMYRVEAY-Djf7WDjZ.js} +1 -1
  93. package/dist/client/assets/{diagram-UQ7AKVKN-CWZS8QtB.js → diagram-UQ7AKVKN-DqX4zTtr.js} +1 -1
  94. package/dist/client/assets/{diagram-VSXAHHWV-DaO1nOZF.js → diagram-VSXAHHWV-DnVbfI4Y.js} +1 -1
  95. package/dist/client/assets/{diagram-VX7I27RA-B54P6Cyf.js → diagram-VX7I27RA-D-Dj0TQC.js} +1 -1
  96. package/dist/client/assets/{diagram-MPIPVDR6-D9XsALDV.js → diagram-YEKJPTXX-B40bP3Yr.js} +2 -2
  97. package/dist/client/assets/{diagram-Z3DM3KII-Cl2EXiXp.js → diagram-Z3DM3KII-_iT7Uz5p.js} +1 -1
  98. package/dist/client/assets/diagram-ZIFT7M5P-BUUK0oNw.js +3 -0
  99. package/dist/client/assets/{direct-engine-DVLMOJWp-C-YL5NFb.js → direct-engine-DVLMOJWp-DWtWIifK.js} +1 -1
  100. package/dist/client/assets/dist-26Ce-5t4.js +1 -0
  101. package/dist/client/assets/dist-8MLNn-I6.js +1 -0
  102. package/dist/client/assets/dist-Amm5Pr1C.js +1 -0
  103. package/dist/client/assets/dist-BXXPaoUV.js +1 -0
  104. package/dist/client/assets/{dist-CoXN2D3R.js → dist-Bkb-_VdB.js} +1 -1
  105. package/dist/client/assets/dist-Bl4yuUS9.js +1 -0
  106. package/dist/client/assets/{dist-lw5TGjI6.js → dist-C2CGvCPd.js} +1 -1
  107. package/dist/client/assets/dist-C2niyEh0.js +1 -0
  108. package/dist/client/assets/{dist-DOHWxIty.js → dist-CFCSUmJk.js} +1 -1
  109. package/dist/client/assets/dist-CHUI56fT.js +6 -0
  110. package/dist/client/assets/dist-CJh3Qrid.js +13 -0
  111. package/dist/client/assets/{dist-Ch6Sr9KF.js → dist-CKxETpSC.js} +3 -3
  112. package/dist/client/assets/dist-CSHJthAI.js +2 -0
  113. package/dist/client/assets/dist-CbKnZGN4.js +1 -0
  114. package/dist/client/assets/{dist-KrdpB_GB.js → dist-Cik4RJXj.js} +1 -1
  115. package/dist/client/assets/{dist-uk11ih8u.js → dist-CqkAY6Ot.js} +2 -2
  116. package/dist/client/assets/dist-D2ql2LCd.js +1 -0
  117. package/dist/client/assets/{dist-BpAUe9sL.js → dist-D47MOYFN.js} +1 -1
  118. package/dist/client/assets/dist-DBhUaexM.js +1 -0
  119. package/dist/client/assets/dist-DJux6Vc5.js +1 -0
  120. package/dist/client/assets/{dist-9Eodxf4G.js → dist-DLNdMWPH.js} +1 -1
  121. package/dist/client/assets/dist-DPJj-Y3l.js +1 -0
  122. package/dist/client/assets/{dist-BSAZ-Hek.js → dist-DRYFMufe.js} +6 -6
  123. package/dist/client/assets/{dist-BrKhPlc9.js → dist-DTGcVSU8.js} +1 -1
  124. package/dist/client/assets/dist-DlOxjzWi.js +9 -0
  125. package/dist/client/assets/{dist-BT9gJXCb.js → dist-DogjjM_B.js} +1 -1
  126. package/dist/client/assets/dist-Dyv_RvyB.js +23 -0
  127. package/dist/client/assets/dist-FUFeH5Cx.js +1 -0
  128. package/dist/client/assets/dist-It70ktCU.js +1 -0
  129. package/dist/client/assets/dist-QMvcnJHf.js +1 -0
  130. package/dist/client/assets/dist-QN1K2czv.js +11 -0
  131. package/dist/client/assets/dist-W8ilOKl3.js +1 -0
  132. package/dist/client/assets/dist-_17-t9qP.js +1 -0
  133. package/dist/client/assets/{dist-DeCV9FU4.js → dist-uE774WWs.js} +1 -1
  134. package/dist/client/assets/document-formatter-DtXmKZcy.js +1 -0
  135. package/dist/client/assets/drawioEditor-DO6IOaJ1.js +9 -0
  136. package/dist/client/assets/{ebnfDiagram-PWID7BFC-PfC84FyI.js → ebnfDiagram-PWID7BFC-IemGPf9X.js} +1 -1
  137. package/dist/client/assets/{ebnfDiagram-ZINNZB2B-DYvm_QtE.js → ebnfDiagram-VR2GEFS7-9fXqy1DI.js} +1 -1
  138. package/dist/client/assets/editor-session-CPsqXY_A.js +13 -0
  139. package/dist/client/assets/elk-IJKZMXRS-DsbrbBYg.js +27 -0
  140. package/dist/client/assets/embedded-editor-base-C44ZcCZv.css +1 -0
  141. package/dist/client/assets/{embedpdf-TkbBYowM.js → embedpdf-BfUI-3pv.js} +1 -1
  142. package/dist/client/assets/{embedpdf-cl9qiF45-itpgqvGY.js → embedpdf-cl9qiF45-CLMxJTMP.js} +2 -2
  143. package/dist/client/assets/en-7ZVUCEYH-C_VXKxxb.js +1 -0
  144. package/dist/client/assets/{erDiagram-OPXOYQCR-o8GRv8A_.js → erDiagram-O2IAPWRE-Cdadm-HN.js} +2 -2
  145. package/dist/client/assets/{erDiagram-RLTQ6QDP-C9cJl5NB.js → erDiagram-RLTQ6QDP-CGGmjm8t.js} +1 -1
  146. package/dist/client/assets/eventmodeling-K75KTNOO-BWBlZ5cR.js +1 -0
  147. package/dist/client/assets/eventmodeling-NTZA5JFV-CDy1bN6j.js +1 -1
  148. package/dist/client/assets/excalidraw-element-link-NQnskRkm.js +1 -0
  149. package/dist/client/assets/excalidraw-scene-DLlw4jyc.js +1 -0
  150. package/dist/client/assets/excalidrawEditor-DiKOIudt.css +1 -0
  151. package/dist/client/assets/excalidrawEditor-W2lZ5Mej.js +9 -0
  152. package/dist/client/assets/export-page-Bomh9oEr.js +46 -0
  153. package/dist/client/assets/exportDocument-BFIOECJ3.js +2 -0
  154. package/dist/client/assets/exportDocument-D0mONgQ4.css +1 -0
  155. package/dist/client/assets/file-kind-BGxTVHan.js +1 -0
  156. package/dist/client/assets/{file-search-BA8o_gs0.js → file-search-Dk2O14Vw.js} +1 -1
  157. package/dist/client/assets/flowDiagram-HODETNUW-DcVVYJUZ.js +1 -0
  158. package/dist/client/assets/flowDiagram-OXPTDLAJ-Dy6y46oF.js +1 -0
  159. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-x40PW0Ah.js → ganttDiagram-EL5Y4UJY-Duu4KnsU.js} +1 -1
  160. package/dist/client/assets/ganttDiagram-R7TSEDQI-BWy52pjn.js +292 -0
  161. package/dist/client/assets/gitGraph-4MIJSDKK-B-rpDYbz.js +1 -1
  162. package/dist/client/assets/gitGraph-VSP46ZUC-1499lQAI.js +1 -0
  163. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-ahsNaZsp.js → gitGraphDiagram-WWUBYQGX-CaJ0vC1a.js} +1 -1
  164. package/dist/client/assets/gitGraphDiagram-XJZIOB7I-DJwp9ilx.js +106 -0
  165. package/dist/client/assets/graphlib-DS17s2tU.js +1 -0
  166. package/dist/client/assets/image-6XY3GD3F-DCWbu6d4.js +1 -0
  167. package/dist/client/assets/image-lightbox-controller-DAcXEXxT.js +184 -0
  168. package/dist/client/assets/index-CglpXOg7.css +1 -0
  169. package/dist/client/assets/index-D3WGkxfI.js +960 -0
  170. package/dist/client/assets/info-A6RAGUB7-BlutK7BT.js +1 -1
  171. package/dist/client/assets/info-OHQRW6UA-BDFQOo4H.js +1 -0
  172. package/dist/client/assets/{infoDiagram-27XIBGKW-MrZyptIy.js → infoDiagram-27XIBGKW-DBJh7QOu.js} +1 -1
  173. package/dist/client/assets/{infoDiagram-VRGFBTTK-KkUjDRAQ.js → infoDiagram-5W2HQ5XZ-DmWsqJ0w.js} +1 -1
  174. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-Bnt9yM0O.js → ishikawaDiagram-5VMMS53U-CeEbSJem.js} +1 -1
  175. package/dist/client/assets/{ishikawaDiagram-OU5B5YK6-Di9BcpOY.js → ishikawaDiagram-K3B6WC7H-DH1NI35G.js} +2 -2
  176. package/dist/client/assets/{journeyDiagram-3NMN7TZE-Bl0abK1r.js → journeyDiagram-3NMN7TZE-BoIEEr6U.js} +1 -1
  177. package/dist/client/assets/{journeyDiagram-ZHPQQLJL-J-sGrs9e.js → journeyDiagram-COXZFDF6-CnHV2f9V.js} +3 -3
  178. package/dist/client/assets/{kanban-definition-PNTS6WVX-5ZDV_yIa.js → kanban-definition-P3RFRI5V-Cxvn5ZAG.js} +4 -4
  179. package/dist/client/assets/{kanban-definition-UXKFOSKX-DMgUfNt0.js → kanban-definition-UXKFOSKX-BY16Tgbr.js} +1 -1
  180. package/dist/client/assets/keyboard-shortcuts-BWNCBJqw.js +1 -0
  181. package/dist/client/assets/lobby-presence-DNNXcuwR.js +1 -0
  182. package/dist/client/assets/{markdown-CZ1tYEW8.js → markdown-DU84620G.js} +1 -1
  183. package/dist/client/assets/markdown-headings-zYEUahfW.js +41 -0
  184. package/dist/client/assets/{markdown-math-CyyBVuDO.js → markdown-math-B96cnrz1.js} +11 -11
  185. package/dist/client/assets/{mermaid-parser.core-Bpogunsh.js → mermaid-parser.core-R-uwU5kf.js} +3 -3
  186. package/dist/client/assets/{mermaid-parser.core-DBy--Jc0.js → mermaid-parser.core-mE6t1qEO.js} +1 -1
  187. package/dist/client/assets/mermaid.core-D8Z6LN7O.js +10 -0
  188. package/dist/client/assets/{mindmap-definition-NLK3R4M7-ByVb-0vj.js → mindmap-definition-LZFPQGKD-DVfFenfJ.js} +3 -3
  189. package/dist/client/assets/{mindmap-definition-YA3MSWOX-DBZN5_GH.js → mindmap-definition-YA3MSWOX-DtiE80UJ.js} +1 -1
  190. package/dist/client/assets/packet-AYTQ26CC-DvbY8dI6.js +1 -1
  191. package/dist/client/assets/packet-JDAUHWVQ-DJ9K2MA4.js +1 -0
  192. package/dist/client/assets/{pegDiagram-GJSIUBJH-aost1sSO.js → pegDiagram-BGZESJAR-DxfvEcwv.js} +1 -1
  193. package/dist/client/assets/{pegDiagram-XKGWAZYB-DRo8CZu3.js → pegDiagram-XKGWAZYB-CyozY-Kt.js} +1 -1
  194. package/dist/client/assets/pie-WAS4IAKB-DWSm9SSD.js +1 -1
  195. package/dist/client/assets/pie-XZMESJXO-CQIQasY-.js +1 -0
  196. package/dist/client/assets/{pieDiagram-5QR66LMP-BICdpEuz.js → pieDiagram-CAPJLFHJ-CRlMcrv3.js} +2 -2
  197. package/dist/client/assets/{pieDiagram-E7YTZNPT-CZThaHsc.js → pieDiagram-E7YTZNPT-BRdmTkDq.js} +1 -1
  198. package/dist/client/assets/preload-helper-CYtfOYgs.js +1 -0
  199. package/dist/client/assets/preview-render-compiler-D_aJv7Ew.js +3 -0
  200. package/dist/client/assets/{preview-render-worker-BA4VK_GY.js → preview-render-worker-dFNyrVyB.js} +46 -42
  201. package/dist/client/assets/prod-ItolaHmf.js +145 -0
  202. package/dist/client/assets/prod-rdly4JJQ.js +1 -0
  203. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-C5iowkl_.js → quadrantDiagram-AXDQQJYC-7QyPIXkF.js} +1 -1
  204. package/dist/client/assets/{quadrantDiagram-O4NWA36T-Bgx5bF97.js → quadrantDiagram-GDMTTRAM-DE30uqTl.js} +3 -3
  205. package/dist/client/assets/quick-switcher-controller-DsK70I7K.js +1 -0
  206. package/dist/client/assets/radar-ABXABTNO-ByfpCXh9.js +1 -0
  207. package/dist/client/assets/radar-RG4KPBEZ-BfNQUEQy.js +1 -1
  208. package/dist/client/assets/railroad-74A4TZTK-BaQ6U6eJ.js +1 -1
  209. package/dist/client/assets/railroad-I3PHUGI6-CTUn9HhI.js +1 -0
  210. package/dist/client/assets/railroad-abnf-HS5TGJTU-BJ3KZw7J.js +1 -1
  211. package/dist/client/assets/railroad-abnf-LNEFI6M7-Ct-b-y0F.js +1 -0
  212. package/dist/client/assets/railroad-ebnf-DWYD2UWJ-BZMYMWOe.js +1 -0
  213. package/dist/client/assets/railroad-ebnf-LZEXJU2U-DA0sEq7w.js +1 -1
  214. package/dist/client/assets/railroad-peg-JR7BVNR7-Dj23PxYc.js +1 -0
  215. package/dist/client/assets/railroad-peg-WCYAUIDC-DCmlICzO.js +1 -1
  216. package/dist/client/assets/{railroadDiagram-O6MQD6OU-BTt_rKjT.js → railroadDiagram-O6MQD6OU-BPk3RS2D.js} +1 -1
  217. package/dist/client/assets/{railroadDiagram-XR7U4H2S-DbVoNgSz.js → railroadDiagram-SM67HX2B-CZRXJ647.js} +1 -1
  218. package/dist/client/assets/{requirementDiagram-BXWQKSXE-BkvazG7r.js → requirementDiagram-BXWQKSXE-BRwfym6z.js} +1 -1
  219. package/dist/client/assets/{requirementDiagram-PLB6GJNP-BT0j9C40.js → requirementDiagram-X7JNWC4A-BofCuLJA.js} +4 -4
  220. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-C_IemB9h.js → sankeyDiagram-P5KCCOFB-D4LcrKpW.js} +1 -1
  221. package/dist/client/assets/{sankeyDiagram-IPEJSGJF-X1BCUIrf.js → sankeyDiagram-UM26HJRW-CLKMDbej.js} +3 -3
  222. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CxFBgLGd.js → sequenceDiagram-WJ2MYXX4-DQjtv-Bs.js} +1 -1
  223. package/dist/client/assets/sequenceDiagram-ZO4K6R2Y-CDP_m6ma.js +169 -0
  224. package/dist/client/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  225. package/dist/client/assets/sizeCapture-INFHLROL-BMR1ovSU.js +1 -0
  226. package/dist/client/assets/src-D5mvpivG.js +2 -0
  227. package/dist/client/assets/{standalone-DbyFjvTU.js → standalone-D_lg5NC9.js} +1 -1
  228. package/dist/client/assets/{stateDiagram-D77RDMKH-BaSQ6Owj.js → stateDiagram-D77RDMKH-DSMvV-kF.js} +1 -1
  229. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-ClmOOUsT.js +1 -0
  230. package/dist/client/assets/{stateDiagram-v2-GCMORJYK-CsVcfwVp.js → stateDiagram-v2-TBUQTH76-Dc5-FKzd.js} +2 -2
  231. package/dist/client/assets/{swimlanes-42K2YHIH-CALFEmiS.js → swimlanes-42K2YHIH-BUz31lO3.js} +1 -1
  232. package/dist/client/assets/{swimlanes-2SLR337P-CnYTVqRX.js → swimlanes-N4OXWK64-Dd3dFdPD.js} +1 -1
  233. package/dist/client/assets/swimlanesDiagram-K3J5GTZL-Bz9gFdls.js +8 -0
  234. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DoDs3zod.js +8 -0
  235. package/dist/client/assets/{timeline-definition-24CTP7MA-zse-5Dbm.js → timeline-definition-24CTP7MA-BvqCvSjy.js} +1 -1
  236. package/dist/client/assets/{timeline-definition-EJHVYXUP-BhqPlKkN.js → timeline-definition-YOQAKGHF-D2XWPSLs.js} +3 -3
  237. package/dist/client/assets/treeView-D4JQ5SDB-DcX7Bx0H.js +1 -0
  238. package/dist/client/assets/treeView-Q6P3EWNA-BvHOzbu9.js +1 -1
  239. package/dist/client/assets/treemap-SAJKECNS-BcCHmcAX.js +1 -0
  240. package/dist/client/assets/treemap-WGGIJYW6-oety7paS.js +1 -1
  241. package/dist/client/assets/usecaseDiagram-VIAY4XPW-CDe-IMjS.js +328 -0
  242. package/dist/client/assets/vault-api-client-DrRW0QwO.js +7 -0
  243. package/dist/client/assets/{vennDiagram-4TSXK5OY-DgHr6cJD.js → vennDiagram-4TSXK5OY-BW6Qp12d.js} +1 -1
  244. package/dist/client/assets/{vennDiagram-UO4OBE2U-BRwLn2Q1.js → vennDiagram-BLWOH2XV-KxIPKpHi.js} +3 -3
  245. package/dist/client/assets/wardley-7MLQ67FV-DOahSwbZ.js +1 -0
  246. package/dist/client/assets/wardley-WFR3VGLG-BdwDpX_I.js +1 -1
  247. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-9A60XZis.js → wardleyDiagram-VM6X3IG4-BoCETVsK.js} +1 -1
  248. package/dist/client/assets/{wardleyDiagram-VNRHLVJA-B_tMcVFG.js → wardleyDiagram-YMQ3BMBF-BNYqEy7M.js} +4 -4
  249. package/dist/client/assets/{wiki-link-resolver-Dch88erO.js → wiki-link-resolver-BCdGUpdu.js} +1 -1
  250. package/dist/client/assets/{worker-engine-BCCrxWYm-CX0qJ_cG.js → worker-engine-BCCrxWYm-1fphds7O.js} +1 -1
  251. package/dist/client/assets/workspace-sync-client-C_P9wtjf.js +1 -0
  252. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-D00iy-wB.js → xychartDiagram-S5SC5T6Z-eB5Fu9P7.js} +1 -1
  253. package/dist/client/assets/xychartDiagram-TAQBALBS-Sv6aaptV.js +7 -0
  254. package/dist/client/assets/yjs-Jd9fna_Y.js +4 -0
  255. package/dist/client/assets/yjs-provider-reset-guard-Cqu0Z6xH.js +1 -0
  256. package/dist/client/canvas-editor.html +16 -0
  257. package/dist/client/drawio-editor.html +7 -6
  258. package/dist/client/excalidraw-editor.html +31 -30
  259. package/dist/client/export-document.html +4 -3
  260. package/dist/client/index.html +2 -2
  261. package/package.json +27 -29
  262. package/scripts/local-compose.mjs +101 -0
  263. package/src/client/app/canvas-editor.html +13 -0
  264. package/src/client/application/app-shell/git-feature.js +3 -2
  265. package/src/client/application/app-shell/ui-feature-identity.js +1 -0
  266. package/src/client/application/app-shell/ui-feature-shell.js +2 -0
  267. package/src/client/application/app-shell/ui-feature-tab-activity.js +4 -0
  268. package/src/client/application/app-shell/workspace-feature.js +8 -34
  269. package/src/client/application/diagram-chrome.js +8 -11
  270. package/src/client/application/diagram-preview-hydrator.js +5 -5
  271. package/src/client/application/mermaid-preview-hydrator.js +3 -2
  272. package/src/client/application/plantuml-preview-hydrator.js +6 -0
  273. package/src/client/application/preview-render-compiler.js +34 -98
  274. package/src/client/application/preview-render-executor.js +3 -0
  275. package/src/client/application/preview-render-worker.js +2 -0
  276. package/src/client/application/preview-renderer.js +9 -5
  277. package/src/client/application/workspace-coordinator.js +18 -10
  278. package/src/client/application/workspace-preview-controller.js +105 -158
  279. package/src/client/application/workspace-route-controller.js +29 -54
  280. package/src/client/bootstrap/canvas-markdown-preview.js +87 -0
  281. package/src/client/bootstrap/collabmd-app-shell.js +28 -13
  282. package/src/client/canvas-editor.js +143 -0
  283. package/src/client/domain/canvas-view.js +50 -0
  284. package/src/client/domain/excalidraw-scene.js +4 -49
  285. package/src/client/domain/highlight-runtime.js +0 -4
  286. package/src/client/domain/markdown-formatting.js +12 -94
  287. package/src/client/domain/markdown-headings.js +98 -0
  288. package/src/client/domain/wiki-link-completions.js +42 -10
  289. package/src/client/infrastructure/browser-preferences-port.js +27 -33
  290. package/src/client/infrastructure/canvas-room-client.js +210 -0
  291. package/src/client/infrastructure/canvas-text-editor.js +36 -0
  292. package/src/client/infrastructure/comment-thread-store.js +19 -77
  293. package/src/client/infrastructure/editor-view-adapter.js +0 -30
  294. package/src/client/infrastructure/excalidraw-room-client.js +22 -10
  295. package/src/client/infrastructure/hosted-api-client.js +4 -2
  296. package/src/client/infrastructure/vault-api-client.js +4 -4
  297. package/src/client/presentation/canvas-editor-view.js +1028 -0
  298. package/src/client/presentation/canvas-embed-controller.js +116 -0
  299. package/src/client/presentation/canvas-picker.js +111 -0
  300. package/src/client/presentation/drawio-embed-controller.js +1 -3
  301. package/src/client/presentation/excalidraw-embed-controller.js +10 -3
  302. package/src/client/presentation/file-action-controller.js +37 -0
  303. package/src/client/presentation/file-explorer-controller.js +1 -2
  304. package/src/client/presentation/file-explorer-view.js +7 -1
  305. package/src/client/presentation/file-icon-svg.js +1 -1
  306. package/src/client/presentation/file-tree-state.js +4 -1
  307. package/src/client/presentation/image-lightbox-controller.js +1 -5
  308. package/src/client/presentation/team-settings-controller.js +44 -10
  309. package/src/client/styles/components/actions.css +4 -16
  310. package/src/client/styles/components/surfaces.css +0 -7
  311. package/src/client/styles/features/comment-card.css +1 -2
  312. package/src/client/styles/features/comment-markdown.css +0 -18
  313. package/src/client/styles/features/diagram-preview.css +0 -18
  314. package/src/client/styles/features/git-branch.css +0 -4
  315. package/src/client/styles/foundation/themes.css +6 -0
  316. package/src/client/styles/foundation/utilities.css +1 -2
  317. package/src/client/styles/layout/editor-page.css +0 -13
  318. package/src/client/styles/layout/responsive.css +2 -7
  319. package/src/client/styles/layout/shell.css +13 -1
  320. package/src/client/styles/layout/view-modes.css +1 -0
  321. package/src/client/styles/surfaces/canvas-editor.css +239 -0
  322. package/src/domain/canvas-room-codec.js +359 -0
  323. package/src/domain/collabmd-content-capabilities.js +10 -1
  324. package/src/domain/comment-threads.js +49 -5
  325. package/src/domain/excalidraw-room-codec.js +23 -73
  326. package/src/domain/excalidraw-scene.js +48 -0
  327. package/src/domain/file-kind.js +13 -1
  328. package/src/server/application/workspace-reconciliation.js +0 -14
  329. package/src/server/domain/backlink-index.js +1 -36
  330. package/src/server/domain/bases/base-index-snapshot-store.js +41 -24
  331. package/src/server/domain/bases/base-query-service.js +1 -47
  332. package/src/server/domain/collaboration/collaboration-room.js +149 -15
  333. package/src/server/domain/collaboration/room-registry.js +7 -7
  334. package/src/server/domain/hosted-workspace.js +29 -2
  335. package/src/server/domain/plantuml-encoder.js +7 -43
  336. package/src/server/infrastructure/git/diff-service.js +1 -5
  337. package/src/server/infrastructure/git/history-service.js +18 -2
  338. package/src/server/infrastructure/git/untracked-files.js +1 -1
  339. package/src/server/infrastructure/http/create-git-api-command-handler.js +60 -149
  340. package/src/server/infrastructure/http/create-hosted-api-handler.js +5 -2
  341. package/src/server/infrastructure/http/create-vault-api-query-handler.js +2 -2
  342. package/src/server/infrastructure/http/http-response.js +2 -36
  343. package/src/server/infrastructure/http/request-body.js +14 -49
  344. package/src/server/infrastructure/persistence/hosted-metadata-store.js +12 -3
  345. package/src/server/infrastructure/persistence/path-utils.js +8 -2
  346. package/src/server/infrastructure/persistence/vault-file-store.js +26 -60
  347. package/src/server/{infrastructure/git → shared}/image-mime.js +2 -2
  348. package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-kJfwukbn.js +0 -1
  349. package/dist/client/assets/_basePickBy-QJXUw_pr.js +0 -1
  350. package/dist/client/assets/_baseUniq-DR4vVjyC.js +0 -1
  351. package/dist/client/assets/architecture-7GRP2DOG-DJVtYNt-.js +0 -1
  352. package/dist/client/assets/browser-utils-S4QYY31r.js +0 -1
  353. package/dist/client/assets/chunk-3FUC2YCW-8tZlhTGX.js +0 -1
  354. package/dist/client/assets/chunk-7M6MHVWA-BDakkknV.js +0 -213
  355. package/dist/client/assets/chunk-FOHPRMQF-Dmmo5Kak.js +0 -161
  356. package/dist/client/assets/chunk-O7XYJQB3-D0_ZY2za.js +0 -126
  357. package/dist/client/assets/chunk-T5WUORNS-DD7KlyY6.js +0 -40
  358. package/dist/client/assets/chunk-Z7XXMR3K-P4Vaq8hD.js +0 -10
  359. package/dist/client/assets/chunk-ZIGJFQKS-b8OUHKK5.js +0 -2
  360. package/dist/client/assets/classDiagram-ZZMXUADV-QLbh_Nkf.js +0 -1
  361. package/dist/client/assets/classDiagram-v2-VYDZK3BY-QLbh_Nkf.js +0 -1
  362. package/dist/client/assets/comment-thread-store-CHvy8GF8.js +0 -1
  363. package/dist/client/assets/comment-threads-nJhK1yfc.js +0 -4
  364. package/dist/client/assets/cynefin-OW5HDTMX-e-Quc9Yl.js +0 -1
  365. package/dist/client/assets/dagre-D7FiCLLP.js +0 -1
  366. package/dist/client/assets/deferred-collab-D4cxEdad.css +0 -1
  367. package/dist/client/assets/deferred-git-BHKtkFYi.css +0 -1
  368. package/dist/client/assets/deferred-preview-BAXYgf4T.css +0 -1
  369. package/dist/client/assets/diagram-ATOU4E4O-B5uX-jVO.js +0 -3
  370. package/dist/client/assets/dist-B2ZNQifU.js +0 -1
  371. package/dist/client/assets/dist-B6QCMNze.js +0 -1
  372. package/dist/client/assets/dist-BIAv19LO.js +0 -1
  373. package/dist/client/assets/dist-BKYp1-dl.js +0 -13
  374. package/dist/client/assets/dist-BSTbcioM.js +0 -11
  375. package/dist/client/assets/dist-BTVg1m-V.js +0 -1
  376. package/dist/client/assets/dist-Bi9ZIYXq.js +0 -9
  377. package/dist/client/assets/dist-Bqo-XRVG.js +0 -1
  378. package/dist/client/assets/dist-CBsvKPcT.js +0 -1
  379. package/dist/client/assets/dist-CJBYh9Wy.js +0 -23
  380. package/dist/client/assets/dist-CRwfjtwz.js +0 -2
  381. package/dist/client/assets/dist-CX7Kc61C.js +0 -1
  382. package/dist/client/assets/dist-CYfPeupF.js +0 -1
  383. package/dist/client/assets/dist-CucpLxUY.js +0 -1
  384. package/dist/client/assets/dist-DHBMeCxC.js +0 -6
  385. package/dist/client/assets/dist-DLEg9d4u.js +0 -1
  386. package/dist/client/assets/dist-DYFBD-wW.js +0 -1
  387. package/dist/client/assets/dist-DugWGOjQ.js +0 -1
  388. package/dist/client/assets/dist-NNrRnB-f.js +0 -1
  389. package/dist/client/assets/dist-PUxZqhFe.js +0 -1
  390. package/dist/client/assets/dist-cYiJMWHJ.js +0 -1
  391. package/dist/client/assets/dist-iKC7go4m.js +0 -1
  392. package/dist/client/assets/document-formatter-6I63vstk.js +0 -1
  393. package/dist/client/assets/drawioEditor-DNTjsjzJ.js +0 -9
  394. package/dist/client/assets/editor-session-D8GGkJak.js +0 -14
  395. package/dist/client/assets/elk-276RUBZZ-B8LB3Pac.js +0 -27
  396. package/dist/client/assets/embedded-editor-base-elU0Avik.css +0 -1
  397. package/dist/client/assets/en-JTHJ2SIP-DBz9bRq4.js +0 -1
  398. package/dist/client/assets/eventmodeling-NTZA5JFV-Dxtv5D-P.js +0 -1
  399. package/dist/client/assets/excalidraw-element-link-BRZOTIeI.js +0 -7
  400. package/dist/client/assets/excalidraw-scene-6uROebca.js +0 -1
  401. package/dist/client/assets/excalidrawEditor-BCTFp_CV.css +0 -1
  402. package/dist/client/assets/excalidrawEditor-D0orhhku.js +0 -9
  403. package/dist/client/assets/export-page-CVJNMERq.js +0 -46
  404. package/dist/client/assets/exportDocument-Ba-n1X4U.css +0 -1
  405. package/dist/client/assets/exportDocument-DSshnmnZ.js +0 -2
  406. package/dist/client/assets/file-kind-BwMIcZbi.js +0 -1
  407. package/dist/client/assets/flowDiagram-HODETNUW-Bq4470NR.js +0 -1
  408. package/dist/client/assets/flowDiagram-KWPJA3E3-DQG9qGiU.js +0 -1
  409. package/dist/client/assets/ganttDiagram-FUAMR5RP-BQpsI7gQ.js +0 -292
  410. package/dist/client/assets/gitGraph-4MIJSDKK-ZaBIE4Lb.js +0 -1
  411. package/dist/client/assets/gitGraphDiagram-X574FWY7-wbs_2m9f.js +0 -106
  412. package/dist/client/assets/graphlib-C9Tl7QrK.js +0 -1
  413. package/dist/client/assets/image-I42VHMUI-B2-c_ifV.js +0 -1
  414. package/dist/client/assets/index-BCgNcVNs.css +0 -1
  415. package/dist/client/assets/index-BpmR5Qqk.js +0 -1140
  416. package/dist/client/assets/info-A6RAGUB7-BcGxhjED.js +0 -1
  417. package/dist/client/assets/lobby-presence-KJrYhMdN.js +0 -1
  418. package/dist/client/assets/mermaid.core-BeOUPE3Q.js +0 -10
  419. package/dist/client/assets/packet-AYTQ26CC-CqpSjTWl.js +0 -1
  420. package/dist/client/assets/pie-WAS4IAKB-Bg2eCNl5.js +0 -1
  421. package/dist/client/assets/preload-helper-BAlEavIC.js +0 -1
  422. package/dist/client/assets/preview-render-compiler-BmWQStaL.js +0 -43
  423. package/dist/client/assets/prod-CA0ie9yD.js +0 -145
  424. package/dist/client/assets/prod-yKJZ3E4s.js +0 -1
  425. package/dist/client/assets/quick-switcher-controller-B5vT9Vj5.js +0 -1
  426. package/dist/client/assets/radar-RG4KPBEZ-DxExotg6.js +0 -1
  427. package/dist/client/assets/railroad-74A4TZTK-FfHmeIQk.js +0 -1
  428. package/dist/client/assets/railroad-abnf-HS5TGJTU-CLkdDRsJ.js +0 -1
  429. package/dist/client/assets/railroad-ebnf-LZEXJU2U-B162zvcG.js +0 -1
  430. package/dist/client/assets/railroad-peg-WCYAUIDC-CGs5GeJ5.js +0 -1
  431. package/dist/client/assets/sequenceDiagram-PO4LG4MO-B-2QfXhV.js +0 -169
  432. package/dist/client/assets/sizeCapture-INFHLROL-B0uUizjq.js +0 -1
  433. package/dist/client/assets/sizeCapture-INFHLROL-DrzwYt5z.js +0 -1
  434. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CLlwrdvU.js +0 -1
  435. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-Bh4tmz27.js +0 -8
  436. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-xhehUG9e.js +0 -8
  437. package/dist/client/assets/treeView-Q6P3EWNA-Cccy0ngL.js +0 -1
  438. package/dist/client/assets/treemap-WGGIJYW6-sMRCjCtX.js +0 -1
  439. package/dist/client/assets/usecaseDiagram-POWQR4AR-DR2LHQYs.js +0 -328
  440. package/dist/client/assets/vault-api-client-NS_EVHJ3.js +0 -7
  441. package/dist/client/assets/wardley-WFR3VGLG-Y7xty_3m.js +0 -1
  442. package/dist/client/assets/workspace-sync-client-BrMtf6zN.js +0 -1
  443. package/dist/client/assets/xychartDiagram-PMCCYNJV-fRpZ1MA5.js +0 -7
  444. package/dist/client/assets/yjs-B41tM6Sz.js +0 -4
  445. package/dist/client/assets/yjs-provider-reset-guard-DpntzUDR.js +0 -1
  446. package/scripts/local-plantuml-compose.mjs +0 -92
  447. package/scripts/local-structurizr-compose.mjs +0 -101
@@ -0,0 +1,145 @@
1
+ import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./preload-helper-CYtfOYgs.js";import{n as r,t as i}from"./jsx-runtime-DKj5X9O4.js";import{$ as a,$a as o,$c as s,$i as c,$l as l,$n as u,$o as d,$r as f,$s as p,$t as m,A as h,Aa as g,Ac as _,Ai as v,Al as y,An as b,Ao as x,Ar as S,As as C,At as w,Ba as T,Bc as E,Bi as D,Bl as ee,Bn as O,Bo as k,Br as te,Bs as A,Bt as j,C as ne,Ca as re,Cc as ie,Ci as ae,Cl as oe,Cn as se,Co as ce,Cr as le,Cs as ue,Ct as de,D as fe,Da as pe,Dc as me,Di as he,Dl as ge,Dn as _e,Do as ve,Dr as ye,Ds as be,Dt as xe,E as Se,Ea as Ce,Ec as we,Ei as Te,El as Ee,En as De,Eo as Oe,Er as ke,Es as Ae,Et as je,F as Me,Fa as Ne,Fc as Pe,Fi as Fe,Fl as Ie,Fn as Le,Fo as Re,Fr as ze,Fs as Be,Ft as Ve,G as He,Ga as Ue,Gc as We,Gi as Ge,Gl as Ke,Gn as qe,Go as Je,Gr as Ye,Gs as Xe,Gt as Ze,Ha as Qe,Hc as $e,Hi as et,Hl as tt,Hn as nt,Ho as rt,Hr as it,Hs as at,Ht as ot,I as st,Ia as ct,Ic as lt,Ii as ut,Il as dt,In as ft,Io as pt,Ir as mt,Is as M,It as ht,J as gt,Ja as _t,Jc as vt,Ji as yt,Jl as bt,Jn as xt,Jo as St,Jr as Ct,Js as wt,Jt as Tt,K as Et,Ka as Dt,Kc as Ot,Ki as kt,Kl as At,Kn as jt,Ko as Mt,Kr as Nt,Ks as Pt,Kt as Ft,L as It,La as Lt,Lc as Rt,Li as zt,Ll as Bt,Ln as Vt,Lo as Ht,Lr as Ut,Ls as Wt,Lt as Gt,M as Kt,Ma as qt,Mc as Jt,Mi as Yt,Ml as Xt,Mn as N,Mo as Zt,Mr as Qt,Ms as $t,Mt as en,N as tn,Na as nn,Nc as rn,Ni as an,Nn as on,No as sn,Nr as cn,Ns as ln,Nt as un,O as dn,Oa as fn,Oc as pn,Oi as mn,Ol as hn,On as gn,Oo as _n,Or as vn,Os as yn,Ot as bn,P as xn,Pa as Sn,Pc as Cn,Pi as wn,Pl as Tn,Pn as En,Po as Dn,Pr as On,Ps as kn,Pt as An,Q as jn,Qa as Mn,Qc as Nn,Qi as Pn,Ql as Fn,Qn as In,Qo as Ln,Qr as Rn,Qs as zn,Qt as Bn,R as Vn,Ra as Hn,Rc as Un,Ri as Wn,Rl as Gn,Rn as Kn,Ro as qn,Rr as Jn,Rs as Yn,Rt as Xn,S as Zn,Sa as Qn,Sc as $n,Si as er,Sl as tr,Sn as nr,So as rr,Sr as ir,Ss as ar,St as or,T as sr,Ta as cr,Tc as lr,Ti as ur,Tl as dr,Tn as fr,To as pr,Tr as mr,Ts as P,Tt as hr,U as gr,Ua as _r,Uc as vr,Ui as yr,Ul as br,Un as xr,Uo as Sr,Ur as Cr,Us as wr,Ut as Tr,V as Er,Va as Dr,Vc as Or,Vi as kr,Vl as Ar,Vn as jr,Vo as Mr,Vr as Nr,Vs as Pr,Vt as Fr,Wa as Ir,Wc as Lr,Wi as Rr,Wl as zr,Wn as Br,Wo as Vr,Wr as Hr,Ws as Ur,Wt as Wr,X as Gr,Xa as Kr,Xc as qr,Xi as Jr,Xl as Yr,Xn as Xr,Xo as Zr,Xr as Qr,Xs as $r,Xt as ei,Y as ti,Ya as ni,Yc as ri,Yi as ii,Yl as ai,Yn as oi,Yo as si,Yr as ci,Ys as li,Yt as ui,Z as di,Za as fi,Zc as pi,Zi as mi,Zl as hi,Zn as gi,Zo as _i,Zr as vi,Zs as yi,Zt as bi,_ as xi,_a as Si,_c as Ci,_i as wi,_l as Ti,_n as Ei,_o as Di,_r as Oi,_s as ki,_t as Ai,a as ji,aa as Mi,ac as Ni,ai as Pi,al as Fi,an as Ii,ao as Li,ar as Ri,as as zi,at as Bi,au as Vi,b as Hi,ba as Ui,bc as Wi,bi as Gi,bl as Ki,bn as qi,bo as Ji,br as Yi,bs as Xi,bt as Zi,c as Qi,ca as $i,cc as ea,ci as ta,cl as na,cn as ra,co as ia,cr as aa,cs as oa,ct as sa,cu as ca,d as la,da as ua,dc as da,di as fa,dl as pa,dn as ma,do as ha,dr as ga,ds as _a,dt as va,ea as ya,ec as ba,el as xa,en as Sa,eo as Ca,er as wa,es as Ta,et as Ea,eu as Da,f as Oa,fa as ka,fc as Aa,fi as ja,fl as Ma,fn as F,fo as Na,fr as Pa,fs as Fa,ft as Ia,g as La,ga as Ra,gi as za,gl as Ba,gn as Va,go as Ha,gr as Ua,gs as Wa,gt as Ga,h as Ka,ha as qa,hc as Ja,hi as Ya,hl as Xa,hn as Za,ho as Qa,hr as $a,hs as eo,i as to,ia as no,ic as ro,ii as io,il as ao,in as oo,io as so,ir as co,is as lo,it as uo,iu as fo,j as po,ja as mo,jc as ho,ji as go,jl as _o,jn as vo,jo as yo,jr as bo,js as xo,jt as So,k as Co,ka as wo,kc as To,ki as I,kn as Eo,ko as Do,kr as Oo,ks as ko,kt as Ao,l as jo,la as Mo,lc as No,li as Po,ll as Fo,ln as Io,lo as Lo,lr as Ro,ls as zo,m as Bo,ma as Vo,mc as Ho,mi as Uo,ml as Wo,mn as Go,mo as Ko,mr as qo,ms as Jo,mt as Yo,n as Xo,na as Zo,nc as Qo,ni as $o,nl as es,nn as ts,no as ns,nr as rs,ns as is,nt as as,nu as os,o as ss,oa as cs,oc as ls,oi as us,ol as ds,on as fs,oo as ps,or as ms,os as hs,ot as gs,ou as L,p as _s,pa as vs,pc as ys,pi as bs,pl as xs,po as Ss,pr as Cs,ps as ws,pt as Ts,q as Es,qa as Ds,qc as Os,qi as ks,ql as As,qn as js,qo as Ms,qr as Ns,qs as Ps,qt as Fs,r as Is,ra as Ls,rc as Rs,ri as zs,rl as Bs,rn as Vs,ro as Hs,rr as Us,rs as Ws,rt as Gs,ru as Ks,s as qs,sa as Js,sc as Ys,si as Xs,sl as Zs,sn as Qs,so as $s,sr as ec,ss as tc,st as nc,su as rc,t as ic,ta as ac,tc as oc,ti as sc,tl as cc,tn as lc,to as uc,tr as R,ts as dc,tt as fc,tu as pc,u as mc,ua as hc,uc as gc,ui as _c,ul as vc,un as yc,uo as bc,ur as xc,us as Sc,ut as Cc,v as wc,va as Tc,vc as Ec,vi as Dc,vl as Oc,vn as kc,vo as Ac,vr as jc,vs as z,vt as Mc,wc as Nc,wi as Pc,wl as Fc,wn as Ic,wo as Lc,wr as Rc,ws as zc,wt as Bc,x as Vc,xa as Hc,xc as Uc,xi as Wc,xl as Gc,xn as Kc,xo as qc,xr as Jc,xs as Yc,xt as Xc,y as Zc,ya as Qc,yc as $c,yi as el,yl as tl,yn as nl,yo as rl,yr as il,ys as al,yt as ol,z as sl,za as cl,zc as ll,zi as ul,zl as dl,zn as fl,zr as pl,zs as ml,zt as hl}from"./chunk-H5A3YXKD-ChP7mNJq.js";import{i as B,n as gl,r as _l}from"./chunk-SRAX5OIU-KFQikY-4.js";import{v as vl}from"./chunk-FLFP27SU-CydzbSsY.js";import{r as yl}from"./chunk-DYU5D34O-DN0WQZBm.js";import{t as bl}from"./dist-CKxETpSC.js";var xl=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.0`})),Sl=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=xl()})),V=e(r(),1),Cl=e(Sl(),1);function wl(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=wl(e[t]))&&(r&&(r+=` `),r+=n);else for(t in e)e[t]&&(r&&(r+=` `),r+=t)}return r}function H(){for(var e=0,t,n,r=``;e<arguments.length;)(t=arguments[e++])&&(n=wl(t))&&(r&&(r+=` `),r+=n);return r}var Tl=e(t(((e,t)=>{var n=`Expected a function`,r=NaN,i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,l=typeof global==`object`&&global&&global.Object===Object&&global,u=typeof self==`object`&&self&&self.Object===Object&&self,d=l||u||Function(`return this`)(),f=Object.prototype.toString,p=Math.max,m=Math.min,h=function(){return d.Date.now()};function g(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,g=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?p(x(r.maxWait)||0,t):o,g=`trailing`in r?!!r.trailing:g);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?m(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=h();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,g&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(h())}function D(){var e=h(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function _(e,t,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError(n);return v(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),g(e,t,{leading:i,maxWait:t,trailing:a})}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&f.call(e)==`[object Symbol]`}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(i,``);var n=o.test(e);return n||s.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}t.exports=_}))(),1),El=0;function Dl(e,t){let n=`atom${++El}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=Ol,r.write=kl),t&&(r.write=t),r}function Ol(e){return e(this)}function kl(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var Al=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,jl=e=>`init`in e,Ml=e=>!!e.write,Nl=new WeakMap,Pl=e=>Ll(e)&&!Nl.get(e)?.[1],Fl=(e,t)=>{let n=Nl.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},Il=e=>{if(Nl.has(e))return;let t=[new Set,!1];Nl.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},Ll=e=>typeof e?.then==`function`,Rl=e=>`v`in e||`e`in e,zl=e=>{if(`e`in e)throw e.e;return e.v},Bl=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},Vl=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),Pl(n.v)&&Bl(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&Gl(e,r,t)},Hl=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),Ul=(e,t,n)=>{e[t].add(n)},Wl=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),Ul(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>Ul(e,`M`,t))}))},Gl=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},Kl=(e,t)=>e.D.get(t),ql=e=>{let t,n=!1,r=e=>{try{e()}catch(e){n||=(t=e,!0)}};for(;e.H.size||e.M.size||e.L.size;)e.D.clear(),e.H.forEach(r),e.H.clear(),e.M.forEach(r),e.M.clear(),e.L.forEach(r),e.L.clear();if(n)throw t},Jl=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=Pl(n.v)?n.v:null;if(Ll(r)){Il(r);for(let i of n.d.keys())Bl(t,r,e(i));n.v=r}else n.v=r;delete n.e,delete n.x,(!i||!Object.is(a,n.v))&&(++n.n,o&&Fl(o,r))},a=(n,r)=>{var o;let s=e(r);if(Rl(s)&&(s.m&&!s.x||Array.from(s.d).every(([e,t])=>a(n,e).n===t)))return s;s.d.clear();let c=!0,l=t=>{if(Al(r,t)){let n=e(t);if(!Rl(n)){if(jl(t))i(t,n,t.init);else throw Error(`no atom init`)}return zl(n)}let o=a(n,t);try{return zl(o)}finally{if(c)Vl(n,r,s,t,o);else{let e=Hl();Vl(e,r,s,t,o),d(e,r,s),ql(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&Ml(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),Ll(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=Hl();d(e,r,s),ql(e)}};e.then(t,t)}return s}catch(e){return delete s.v,s.e=e,delete s.x,++s.n,s}finally{c=!1}},o=e=>zl(a(void 0,e)),s=(t,n,r)=>{var i;let a=new Map;for(let t of r.m?.t||[]){let n=e(t);n.m&&a.set(t,n)}for(let t of r.p)a.set(t,e(t));return(i=Kl(t,n))==null||i.forEach(t=>{a.set(t,e(t))}),a},c=(e,t,n)=>{let r=[],i=new Set,o=new Set,c=[[t,n]];for(;c.length>0;){let[t,n]=c[c.length-1];if(o.has(t)){c.pop();continue}if(i.has(t)){r.push([t,n,n.n]),o.add(t),n.x=!0,c.pop();continue}i.add(t);for(let[r,a]of s(e,t,n))t!==r&&!i.has(r)&&c.push([r,a])}Ul(e,`H`,()=>{let n=new Set([t]);for(let t=r.length-1;t>=0;--t){let[i,o,s]=r[t],c=!1;for(let e of o.d.keys())if(e!==i&&n.has(e)){c=!0;break}c&&(a(e,i),d(e,i,o),s!==o.n&&(Wl(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>zl(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(Al(r,n)){if(!jl(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(Wl(t,n,o),c(t,n,o));return}return l(t,n,...a)}finally{s||ql(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=Hl();try{return l(n,e,...t)}finally{ql(n)}},d=(t,n,r)=>{if(r.m&&!Pl(r.v)){for(let i of r.d.keys())r.m.d.has(i)||(f(t,i,e(i)).t.add(n),r.m.d.add(i));for(let i of r.m.d||[])r.d.has(i)||(r.m.d.delete(i),p(t,i,e(i))?.t.delete(n))}},f=(t,n,i)=>{if(!i.m){a(t,n);for(let r of i.d.keys())f(t,r,e(r)).t.add(n);if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},Ml(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||ql(e)}};try{return t()}finally{r=!1}};Ul(t,`L`,()=>{let i=o(t,()=>r(n,(...e)=>a(...e)));i&&(e.u=e=>o(e,i))})}}return i.m},p=(t,n,r)=>{if(r.m&&!r.m.l.size&&!Array.from(r.m.t).some(t=>e(t).m?.d.has(n))){let i=r.m.u;i&&Ul(t,`L`,()=>i(t)),delete r.m;for(let i of r.d.keys())p(t,i,e(i))?.t.delete(n);return}return r.m};return{get:o,set:u,sub:(t,n)=>{let r=Hl(),i=e(t),a=f(r,t,i).l;return a.add(n),ql(r),()=>{a.delete(n);let e=Hl();p(e,t,i),ql(e)}},unstable_derive:i=>Jl(...i(e,t,n,r))}},Yl=()=>{let e=new WeakMap;return Jl(t=>{let n=e.get(t);return n||(n={d:new Map,p:new Set,n:0},e.set(t,n)),n},(e,...t)=>e.read(...t),(e,...t)=>e.write(...t),(e,...t)=>e.onMount?.call(e,...t))},Xl,Zl=()=>(Xl||=Yl(),Xl),Ql=(0,V.createContext)(void 0),$l=e=>{let t=(0,V.useContext)(Ql);return e?.store||t||Zl()},eu=e=>typeof e?.then==`function`,tu=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},nu=V.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(tu(e),e)}),ru=new WeakMap,iu=e=>{let t=ru.get(e);return t||(t=new Promise((n,r)=>{let i=e,a=e=>t=>{i===e&&n(t)},o=e=>t=>{i===e&&r(t)},s=e=>{`onCancel`in e&&typeof e.onCancel==`function`&&e.onCancel(e=>{eu(e)?(ru.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),ru.set(e,t)),t};function au(e,t){let n=$l(t),[[r,i,a],o]=(0,V.useReducer)(t=>{let r=n.get(e);return Object.is(t[0],r)&&t[1]===n&&t[2]===e?t:[r,n,e]},void 0,()=>[n.get(e),n,e]),s=r;(i!==n||a!==e)&&(o(),s=n.get(e));let c=t?.delay;return(0,V.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);eu(t)&&tu(iu(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,V.useDebugValue)(s),eu(s)?nu(iu(s)):s}function ou(e,t){let n=$l(t);return(0,V.useCallback)((...t)=>n.set(e,...t),[n,e])}function su(e,t){return[au(e,t),ou(e,t)]}var U=i(),cu=new WeakMap;function lu(e,t){let n=$l(t),r=uu(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var uu=e=>{let t=cu.get(e);return t||(t=new WeakSet,cu.set(e,t)),t};function du(){return du=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},du.apply(this,arguments)}function fu(){let e=(0,V.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,V.useRef)(t);return i.current||=Yl(),lu(n,{store:i.current}),(0,U.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,V.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return $l(du({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return su(e,du({store:r},t))},useAtomValue:(e,t)=>{let r=n();return au(e,du({store:r},t))},useSetAtom:(e,t)=>{let r=n();return ou(e,du({store:r},t))}}}var{read:pu,write:mu}=Dl(null);(0,V.createContext)({scope:void 0,baseStore:void 0});function hu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function gu(...e){return t=>{let n=!1,r=e.map(e=>{let r=hu(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():hu(e[t],null)}}}}function _u(...e){return V.useCallback(gu(...e),e)}function vu(e){let t=yu(e),n=V.forwardRef((e,n)=>{let{children:r,...i}=e,a=V.Children.toArray(r),o=a.find(xu);if(o){let e=o.props.children,r=a.map(t=>t===o?V.Children.count(e)>1?V.Children.only(null):V.isValidElement(e)?e.props.children:null:t);return(0,U.jsx)(t,{...i,ref:n,children:V.isValidElement(e)?V.cloneElement(e,void 0,r):null})}return(0,U.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function yu(e){let t=V.forwardRef((e,t)=>{let{children:n,...r}=e;if(V.isValidElement(n)){let e=Cu(n),i=Su(r,n.props);return n.type!==V.Fragment&&(i.ref=t?gu(t,e):e),V.cloneElement(n,i)}return V.Children.count(n)>1?V.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bu=Symbol(`radix.slottable`);function xu(e){return V.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===bu}function Su(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Cu(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wu=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=vu(`Primitive.${t}`),r=V.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,U.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Tu(e,t){e&&Cl.flushSync(()=>e.dispatchEvent(t))}function Eu(e,t=[]){let n=[];function r(t,r){let i=V.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=V.useMemo(()=>o,Object.values(o));return(0,U.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=V.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>V.createContext(e));return function(n){let r=n?.[e]||t;return V.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Du(i,...t)]}function Du(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return V.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Ou(e){let t=e+`CollectionProvider`,[n,r]=Eu(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=V.useRef(null),a=V.useRef(new Map).current;return(0,U.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=vu(s),l=V.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=_u(t,a(s,n).collectionRef);return(0,U.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=vu(u),p=V.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=V.useRef(null),s=_u(t,o),c=a(u,n);return V.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,U.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return V.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}typeof window<`u`&&window.document&&window.document.createElement;function W(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var ku=globalThis?.document?V.useLayoutEffect:()=>{},Au=V.useInsertionEffect||ku;function ju({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Mu({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=V.useRef(e!==void 0);V.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,V.useCallback(t=>{if(s){let n=Nu(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Mu({defaultProp:e,onChange:t}){let[n,r]=V.useState(e),i=V.useRef(n),a=V.useRef(t);return Au(()=>{a.current=t},[t]),V.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Nu(e){return typeof e==`function`}function Pu(e,t){return V.useReducer((e,n)=>t[e][n]??e,e)}var Fu=e=>{let{present:t,children:n}=e,r=Iu(t),i=typeof n==`function`?n({present:r.isPresent}):V.Children.only(n),a=_u(r.ref,Ru(i));return typeof n==`function`||r.isPresent?V.cloneElement(i,{ref:a}):null};Fu.displayName=`Presence`;function Iu(e){let[t,n]=V.useState(),r=V.useRef(null),i=V.useRef(e),a=V.useRef(`none`),[o,s]=Pu(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return V.useEffect(()=>{let e=Lu(r.current);a.current=o===`mounted`?e:`none`},[o]),ku(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Lu(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),ku(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Lu(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=Lu(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:V.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function Lu(e){return e?.animationName||`none`}function Ru(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zu=V.useId||(()=>void 0),Bu=0;function Vu(e){let[t,n]=V.useState(zu());return ku(()=>{e||n(e=>e??String(Bu++))},[e]),e||(t?`radix-${t}`:``)}var Hu=V.createContext(void 0);function Uu(e){let t=V.useContext(Hu);return e||t||`ltr`}function Wu(e){let t=V.useRef(e);return V.useEffect(()=>{t.current=e}),V.useMemo(()=>(...e)=>t.current?.(...e),[])}function Gu(e,t=globalThis?.document){let n=Wu(e);V.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Ku=`DismissableLayer`,qu=`dismissableLayer.update`,Ju=`dismissableLayer.pointerDownOutside`,Yu=`dismissableLayer.focusOutside`,Xu,Zu=V.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Qu=V.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=V.useContext(Zu),[u,d]=V.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=V.useState({}),m=_u(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=td(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));b&&!n&&(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=nd(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Gu(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),V.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Xu=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),rd(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Xu)}},[u,f,n,l]),V.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),rd())},[u,l]),V.useEffect(()=>{let e=()=>p({});return document.addEventListener(qu,e),()=>document.removeEventListener(qu,e)},[]),(0,U.jsx)(wu.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:W(e.onFocusCapture,S.onFocusCapture),onBlurCapture:W(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:W(e.onPointerDownCapture,x.onPointerDownCapture)})});Qu.displayName=Ku;var $u=`DismissableLayerBranch`,ed=V.forwardRef((e,t)=>{let n=V.useContext(Zu),r=V.useRef(null),i=_u(t,r);return V.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,U.jsx)(wu.div,{...e,ref:i})});ed.displayName=$u;function td(e,t=globalThis?.document){let n=Wu(e),r=V.useRef(!1),i=V.useRef(()=>{});return V.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){id(Ju,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function nd(e,t=globalThis?.document){let n=Wu(e),r=V.useRef(!1);return V.useEffect(()=>{let e=e=>{e.target&&!r.current&&id(Yu,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function rd(){let e=new CustomEvent(qu);document.dispatchEvent(e)}function id(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Tu(i,a):i.dispatchEvent(a)}var ad=`focusScope.autoFocusOnMount`,od=`focusScope.autoFocusOnUnmount`,sd={bubbles:!1,cancelable:!0},cd=`FocusScope`,ld=V.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=V.useState(null),l=Wu(i),u=Wu(a),d=V.useRef(null),f=_u(t,e=>c(e)),p=V.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;V.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:gd(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||gd(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&gd(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),V.useEffect(()=>{if(s){_d.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(ad,sd);s.addEventListener(ad,l),s.dispatchEvent(t),t.defaultPrevented||(ud(bd(fd(s)),{select:!0}),document.activeElement===e&&gd(s))}return()=>{s.removeEventListener(ad,l),setTimeout(()=>{let t=new CustomEvent(od,sd);s.addEventListener(od,u),s.dispatchEvent(t),t.defaultPrevented||gd(e??document.body,{select:!0}),s.removeEventListener(od,u),_d.remove(p)},0)}}},[s,l,u,p]);let m=V.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=dd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&gd(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&gd(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,U.jsx)(wu.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ld.displayName=cd;function ud(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(gd(r,{select:t}),document.activeElement!==n)return}function dd(e){let t=fd(e);return[pd(t,e),pd(t.reverse(),e)]}function fd(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pd(e,t){for(let n of e)if(!md(n,{upTo:t}))return n}function md(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function hd(e){return e instanceof HTMLInputElement&&`select`in e}function gd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&hd(e)&&t&&e.select()}}var _d=vd();function vd(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=yd(e,t),e.unshift(t)},remove(t){e=yd(e,t),e[0]?.resume()}}}function yd(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bd(e){return e.filter(e=>e.tagName!==`A`)}var xd=`Portal`,Sd=V.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=V.useState(!1);ku(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Cl.createPortal((0,U.jsx)(wu.div,{...r,ref:t}),o):null});Sd.displayName=xd;var Cd=0;function wd(){V.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Td()),document.body.insertAdjacentElement(`beforeend`,e[1]??Td()),Cd++,()=>{Cd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Cd--}},[])}function Td(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Ed=function(){return Ed=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ed.apply(this,arguments)};function Dd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Od(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var kd=`right-scroll-bar-position`,Ad=`width-before-scroll-bar`,jd=`with-scroll-bars-hidden`,Md=`--removed-body-scroll-bar-size`;function Nd(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Pd(e,t){var n=(0,V.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Fd=typeof window<`u`?V.useLayoutEffect:V.useEffect,Id=new WeakMap;function Ld(e,t){var n=Pd(t||null,function(t){return e.forEach(function(e){return Nd(e,t)})});return Fd(function(){var t=Id.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Nd(e,null)}),i.forEach(function(e){r.has(e)||Nd(e,a)})}Id.set(n,e)},[e]),n}function Rd(e){return e}function zd(e,t){t===void 0&&(t=Rd);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Bd(e){e===void 0&&(e={});var t=zd(null);return t.options=Ed({async:!0,ssr:!1},e),t}var Vd=function(e){var t=e.sideCar,n=Dd(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return V.createElement(r,Ed({},n))};Vd.isSideCarExport=!0;function Hd(e,t){return e.useMedium(t),Vd}var Ud=Bd(),Wd=function(){},Gd=V.forwardRef(function(e,t){var n=V.useRef(null),r=V.useState({onScrollCapture:Wd,onWheelCapture:Wd,onTouchMoveCapture:Wd}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Dd(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=Ld([n,t]),C=Ed(Ed({},b),i);return V.createElement(V.Fragment,null,u&&V.createElement(x,{sideCar:Ud,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?V.cloneElement(V.Children.only(s),Ed(Ed({},C),{ref:S})):V.createElement(v,Ed({},C,{className:c,ref:S}),s))});Gd.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Gd.classNames={fullWidth:Ad,zeroRight:kd};var Kd=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function qd(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Kd();return t&&e.setAttribute(`nonce`,t),e}function Jd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yd(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Xd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qd())&&(Jd(t,n),Yd(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zd=function(){var e=Xd();return function(t,n){V.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Qd=function(){var e=Zd();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},$d={left:0,top:0,right:0,gap:0},ef=function(e){return parseInt(e||``,10)||0},tf=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ef(n),ef(r),ef(i)]},nf=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return $d;var t=tf(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},rf=Qd(),af=`data-scroll-locked`,of=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
+ .${jd} {
3
+ overflow: hidden ${r};
4
+ padding-right: ${s}px ${r};
5
+ }
6
+ body[${af}] {
7
+ overflow: hidden ${r};
8
+ overscroll-behavior: contain;
9
+ ${[t&&`position: relative ${r};`,n===`margin`&&`
10
+ padding-left: ${i}px;
11
+ padding-top: ${a}px;
12
+ padding-right: ${o}px;
13
+ margin-left:0;
14
+ margin-top:0;
15
+ margin-right: ${s}px ${r};
16
+ `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
17
+ }
18
+
19
+ .${kd} {
20
+ right: ${s}px ${r};
21
+ }
22
+
23
+ .${Ad} {
24
+ margin-right: ${s}px ${r};
25
+ }
26
+
27
+ .${kd} .${kd} {
28
+ right: 0 ${r};
29
+ }
30
+
31
+ .${Ad} .${Ad} {
32
+ margin-right: 0 ${r};
33
+ }
34
+
35
+ body[${af}] {
36
+ ${Md}: ${s}px;
37
+ }
38
+ `},sf=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},cf=function(){V.useEffect(function(){return document.body.setAttribute(af,(sf()+1).toString()),function(){var e=sf()-1;e<=0?document.body.removeAttribute(af):document.body.setAttribute(af,e.toString())}},[])},lf=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;cf();var a=V.useMemo(function(){return nf(i)},[i]);return V.createElement(rf,{styles:of(a,!t,i,n?``:`!important`)})},uf=!1;if(typeof window<`u`)try{var df=Object.defineProperty({},"passive",{get:function(){return uf=!0,!0}});window.addEventListener(`test`,df,df),window.removeEventListener(`test`,df,df)}catch{uf=!1}var ff=uf?{passive:!1}:!1,pf=function(e){return e.tagName===`TEXTAREA`},mf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!pf(e)&&n[t]===`visible`)},hf=function(e){return mf(e,`overflowY`)},gf=function(e){return mf(e,`overflowX`)},_f=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),bf(e,r)){var i=xf(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},vf=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},yf=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},bf=function(e,t){return e===`v`?hf(t):gf(t)},xf=function(e,t){return e===`v`?vf(t):yf(t)},Sf=function(e,t){return e===`h`&&t===`rtl`?-1:1},Cf=function(e,t,n,r,i){var a=Sf(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=xf(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&bf(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},wf=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Tf=function(e){return[e.deltaX,e.deltaY]},Ef=function(e){return e&&`current`in e?e.current:e},Df=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Of=function(e){return`
39
+ .block-interactivity-${e} {pointer-events: none;}
40
+ .allow-interactivity-${e} {pointer-events: all;}
41
+ `},kf=0,Af=[];function jf(e){var t=V.useRef([]),n=V.useRef([0,0]),r=V.useRef(),i=V.useState(kf++)[0],a=V.useState(Qd)[0],o=V.useRef(e);V.useEffect(function(){o.current=e},[e]),V.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Od([e.lockRef.current],(e.shards||[]).map(Ef),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=V.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=wf(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=_f(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=_f(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Cf(h,t,e,h===`h`?s:c,!0)},[]),c=V.useCallback(function(e){var n=e;if(Af.length&&Af[Af.length-1]===a){var r=`deltaY`in n?Tf(n):wf(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Df(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Ef).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=V.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Mf(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=V.useCallback(function(e){n.current=wf(e),r.current=void 0},[]),d=V.useCallback(function(t){l(t.type,Tf(t),t.target,s(t,e.lockRef.current))},[]),f=V.useCallback(function(t){l(t.type,wf(t),t.target,s(t,e.lockRef.current))},[]);V.useEffect(function(){return Af.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ff),document.addEventListener(`touchmove`,c,ff),document.addEventListener(`touchstart`,u,ff),function(){Af=Af.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ff),document.removeEventListener(`touchmove`,c,ff),document.removeEventListener(`touchstart`,u,ff)}},[]);var p=e.removeScrollBar,m=e.inert;return V.createElement(V.Fragment,null,m?V.createElement(a,{styles:Of(i)}):null,p?V.createElement(lf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Mf(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Nf=Hd(Ud,jf),Pf=V.forwardRef(function(e,t){return V.createElement(Gd,Ed({},e,{ref:t,sideCar:Nf}))});Pf.classNames=Gd.classNames;var Ff=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},If=new WeakMap,Lf=new WeakMap,Rf={},zf=0,Bf=function(e){return e&&(e.host||Bf(e.parentNode))},Vf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Bf(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Hf=function(e,t,n,r){var i=Vf(t,Array.isArray(e)?e:[e]);Rf[n]||(Rf[n]=new WeakMap);var a=Rf[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(If.get(e)||0)+1,l=(a.get(e)||0)+1;If.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Lf.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),zf++,function(){o.forEach(function(e){var t=If.get(e)-1,i=a.get(e)-1;If.set(e,t),a.set(e,i),t||(Lf.has(e)||e.removeAttribute(r),Lf.delete(e)),i||e.removeAttribute(n)}),zf--,zf||(If=new WeakMap,If=new WeakMap,Lf=new WeakMap,Rf={})}},Uf=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Ff(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Hf(r,i,n,`aria-hidden`)):function(){return null}},Wf=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Gf=t(((e,t)=>{t.exports=Wf()}));function Kf(e){let[t,n]=V.useState(void 0);return ku(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}var qf=[`top`,`right`,`bottom`,`left`],Jf=Math.min,Yf=Math.max,Xf=Math.round,Zf=Math.floor,Qf=e=>({x:e,y:e}),$f={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ep(e,t,n){return Yf(e,Jf(t,n))}function tp(e,t){return typeof e==`function`?e(t):e}function np(e){return e.split(`-`)[0]}function rp(e){return e.split(`-`)[1]}function ip(e){return e===`x`?`y`:`x`}function ap(e){return e===`y`?`height`:`width`}function op(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function sp(e){return ip(op(e))}function cp(e,t,n){n===void 0&&(n=!1);let r=rp(e),i=sp(e),a=ap(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=_p(o)),[o,_p(o)]}function lp(e){let t=_p(e);return[up(e),t,up(t)]}function up(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var dp=[`left`,`right`],fp=[`right`,`left`],pp=[`top`,`bottom`],mp=[`bottom`,`top`];function hp(e,t,n){switch(e){case`top`:case`bottom`:return n?t?fp:dp:t?dp:fp;case`left`:case`right`:return t?pp:mp;default:return[]}}function gp(e,t,n,r){let i=rp(e),a=hp(np(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(up)))),a}function _p(e){let t=np(e);return $f[t]+e.slice(t.length)}function vp(e){return{top:0,right:0,bottom:0,left:0,...e}}function yp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:vp(e)}function bp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function xp(e,t,n){let{reference:r,floating:i}=e,a=op(t),o=sp(t),s=ap(o),c=np(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(rp(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}async function Sp(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=tp(t,e),p=yp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=bp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=bp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Cp=50,wp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Sp},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=xp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Cp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=xp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Tp=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=tp(e,t)||{};if(l==null)return{};let d=yp(u),f={x:n,y:r},p=sp(i),m=ap(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Jf(d[_],T),D=Jf(d[v],T),ee=E,O=C-h[m]-D,k=C/2-h[m]/2+w,te=ep(ee,k,O),A=!c.arrow&&rp(i)!=null&&k!==te&&a.reference[m]/2-(k<ee?E:D)-h[m]/2<0,j=A?k<ee?k-ee:k-O:0;return{[p]:f[p]+j,data:{[p]:te,centerOffset:k-te-j,...A&&{alignmentOffset:j}},reset:A}}}),Ep=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=tp(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=np(r),_=op(o),v=np(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[_p(o)]:lp(o)),x=p!==`none`;!d&&x&&b.push(...gp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=cp(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===op(t)||T.every(e=>op(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=op(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Dp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Op(e){return qf.some(t=>e[t]>=0)}var kp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=tp(e,t);switch(i){case`referenceHidden`:{let e=Dp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Op(e)}}}case`escaped`:{let e=Dp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Op(e)}}}default:return{}}}}},Ap=new Set([`left`,`top`]);async function jp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=np(n),s=rp(n),c=op(n)===`y`,l=Ap.has(o)?-1:1,u=a&&c?-1:1,d=tp(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Mp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await jp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Np=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=tp(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=op(np(i)),p=ip(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=ep(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=ep(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Pp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=tp(e,t),u={x:n,y:r},d=op(i),f=ip(d),p=u[f],m=u[d],h=tp(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ap.has(np(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Fp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=tp(e,t),u=await o.detectOverflow(t,l),d=np(i),f=rp(i),p=op(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Jf(h-u[g],v),x=Jf(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Yf(u.left,0),t=Yf(u.right,0),n=Yf(u.top,0),r=Yf(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Yf(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Yf(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ip(){return typeof window<`u`}function Lp(e){return Bp(e)?(e.nodeName||``).toLowerCase():`#document`}function Rp(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zp(e){return((Bp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Bp(e){return Ip()?e instanceof Node||e instanceof Rp(e).Node:!1}function Vp(e){return Ip()?e instanceof Element||e instanceof Rp(e).Element:!1}function Hp(e){return Ip()?e instanceof HTMLElement||e instanceof Rp(e).HTMLElement:!1}function Up(e){return!Ip()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Rp(e).ShadowRoot}function Wp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=tm(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Gp(e){return/^(table|td|th)$/.test(Lp(e))}function Kp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var qp=/transform|translate|scale|rotate|perspective|filter/,Jp=/paint|layout|strict|content/,Yp=e=>!!e&&e!==`none`,Xp;function Zp(e){let t=Vp(e)?tm(e):e;return Yp(t.transform)||Yp(t.translate)||Yp(t.scale)||Yp(t.rotate)||Yp(t.perspective)||!$p()&&(Yp(t.backdropFilter)||Yp(t.filter))||qp.test(t.willChange||``)||Jp.test(t.contain||``)}function Qp(e){let t=rm(e);for(;Hp(t)&&!em(t);){if(Zp(t))return t;if(Kp(t))return null;t=rm(t)}return null}function $p(){return Xp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Xp}function em(e){return/^(html|body|#document)$/.test(Lp(e))}function tm(e){return Rp(e).getComputedStyle(e)}function nm(e){return Vp(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rm(e){if(Lp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Up(e)&&e.host||zp(e);return Up(t)?t.host:t}function im(e){let t=rm(e);return em(t)?e.ownerDocument?e.ownerDocument.body:e.body:Hp(t)&&Wp(t)?t:im(t)}function am(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=im(e),i=r===e.ownerDocument?.body,a=Rp(r);if(i){let e=om(a);return t.concat(a,a.visualViewport||[],Wp(r)?r:[],e&&n?am(e):[])}return t.concat(r,am(r,[],n))}function om(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sm(e){let t=tm(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Hp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Xf(n)!==a||Xf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function cm(e){return Vp(e)?e:e.contextElement}function lm(e){let t=cm(e);if(!Hp(t))return Qf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=sm(t),o=(a?Xf(n.width):n.width)/r,s=(a?Xf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var um=Qf(0);function dm(e){let t=Rp(e);return!$p()||!t.visualViewport?um:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function fm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Rp(e)?!1:t}function pm(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=cm(e),o=Qf(1);t&&(r?Vp(r)&&(o=lm(r)):o=lm(e));let s=fm(a,n,r)?dm(a):Qf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=Rp(a),t=r&&Vp(r)?Rp(r):r,n=e,i=om(n);for(;i&&r&&t!==n;){let e=lm(i),t=i.getBoundingClientRect(),r=tm(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Rp(i),i=om(n)}}return bp({width:u,height:d,x:c,y:l})}function mm(e,t){let n=nm(e).scrollLeft;return t?t.left+n:pm(zp(e)).left+n}function hm(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-mm(e,n),y:n.top+t.scrollTop}}function gm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=zp(r),s=t?Kp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Qf(1),u=Qf(0),d=Hp(r);if((d||!d&&!a)&&((Lp(r)!==`body`||Wp(o))&&(c=nm(r)),d)){let e=pm(r);l=lm(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?hm(o,c):Qf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function _m(e){return Array.from(e.getClientRects())}function vm(e){let t=zp(e),n=nm(e),r=e.ownerDocument.body,i=Yf(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Yf(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+mm(e),s=-n.scrollTop;return tm(r).direction===`rtl`&&(o+=Yf(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var ym=25;function bm(e,t){let n=Rp(e),r=zp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=$p();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=mm(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=ym&&(a-=o)}else l<=ym&&(a+=l);return{width:a,height:o,x:s,y:c}}function xm(e,t){let n=pm(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Hp(e)?lm(e):Qf(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Sm(e,t,n){let r;if(t===`viewport`)r=bm(e,n);else if(t===`document`)r=vm(zp(e));else if(Vp(t))r=xm(t,n);else{let n=dm(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return bp(r)}function Cm(e,t){let n=rm(e);return n===t||!Vp(n)||em(n)?!1:tm(n).position===`fixed`||Cm(n,t)}function wm(e,t){let n=t.get(e);if(n)return n;let r=am(e,[],!1).filter(e=>Vp(e)&&Lp(e)!==`body`),i=null,a=tm(e).position===`fixed`,o=a?rm(e):e;for(;Vp(o)&&!em(o);){let t=tm(o),n=Zp(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Wp(o)&&!n&&Cm(e,o))?r=r.filter(e=>e!==o):i=t,o=rm(o)}return t.set(e,r),r}function Tm(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Kp(t)?[]:wm(t,this._c):[].concat(n),r],o=Sm(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Sm(t,a[e],i);s=Yf(n.top,s),c=Jf(n.right,c),l=Jf(n.bottom,l),u=Yf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Em(e){let{width:t,height:n}=sm(e);return{width:t,height:n}}function Dm(e,t,n){let r=Hp(t),i=zp(t),a=n===`fixed`,o=pm(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Qf(0);function l(){c.x=mm(i)}if(r||!r&&!a){if((Lp(t)!==`body`||Wp(i))&&(s=nm(t)),r){let e=pm(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l()}a&&!r&&i&&l();let u=i&&!r&&!a?hm(i,s):Qf(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Om(e){return tm(e).position===`static`}function km(e,t){if(!Hp(e)||tm(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return zp(e)===n&&(n=n.ownerDocument.body),n}function Am(e,t){let n=Rp(e);if(Kp(e))return n;if(!Hp(e)){let t=rm(e);for(;t&&!em(t);){if(Vp(t)&&!Om(t))return t;t=rm(t)}return n}let r=km(e,t);for(;r&&Gp(r)&&Om(r);)r=km(r,t);return r&&em(r)&&Om(r)&&!Zp(r)?n:r||Qp(e)||n}var jm=async function(e){let t=this.getOffsetParent||Am,n=this.getDimensions,r=await n(e.floating);return{reference:Dm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mm(e){return tm(e).direction===`rtl`}var Nm={convertOffsetParentRelativeRectToViewportRelativeRect:gm,getDocumentElement:zp,getClippingRect:Tm,getOffsetParent:Am,getElementRects:jm,getClientRects:_m,getDimensions:Em,getScale:lm,isElement:Vp,isRTL:Mm};function Pm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fm(e,t){let n=null,r,i=zp(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Zf(d),h=Zf(i.clientWidth-(u+f)),g=Zf(i.clientHeight-(d+p)),_=Zf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Yf(0,Jf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Pm(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Im(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=cm(e),u=i||a?[...l?am(l):[],...t?am(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Fm(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?pm(e):null;c&&g();function g(){let t=pm(e);h&&!Pm(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Lm=Mp,Rm=Np,zm=Ep,Bm=Fp,Vm=kp,Hm=Tp,Um=Pp,Wm=(e,t,n)=>{let r=new Map,i={platform:Nm,...n},a={...i.platform,_c:r};return wp(e,t,{...i,platform:a})},Gm=typeof document<`u`?V.useLayoutEffect:function(){};function Km(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Km(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Km(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function qm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jm(e,t){let n=qm(e);return Math.round(t*n)/n}function Ym(e){let t=V.useRef(e);return Gm(()=>{t.current=e}),t}function Xm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=V.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=V.useState(r);Km(f,r)||p(r);let[m,h]=V.useState(null),[g,_]=V.useState(null),v=V.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=V.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=V.useRef(null),C=V.useRef(null),w=V.useRef(u),T=c!=null,E=Ym(c),D=Ym(i),ee=Ym(l),O=V.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Wm(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};k.current&&!Km(w.current,t)&&(w.current=t,Cl.flushSync(()=>{d(t)}))})},[f,t,n,D,ee]);Gm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let k=V.useRef(!1);Gm(()=>(k.current=!0,()=>{k.current=!1}),[]),Gm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,O);O()}},[b,x,O,E,T]);let te=V.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),A=V.useMemo(()=>({reference:b,floating:x}),[b,x]),j=V.useMemo(()=>{let e={position:n,left:0,top:0};if(!A.floating)return e;let t=Jm(A.floating,u.x),r=Jm(A.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...qm(A.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,A.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:O,refs:te,elements:A,floatingStyles:j}),[u,O,te,A,j])}var Zm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Hm({element:r.current,padding:i}).fn(n):r?Hm({element:r,padding:i}).fn(n):{}}}},Qm=(e,t)=>{let n=Lm(e);return{name:n.name,fn:n.fn,options:[e,t]}},$m=(e,t)=>{let n=Rm(e);return{name:n.name,fn:n.fn,options:[e,t]}},eh=(e,t)=>({fn:Um(e).fn,options:[e,t]}),th=(e,t)=>{let n=zm(e);return{name:n.name,fn:n.fn,options:[e,t]}},nh=(e,t)=>{let n=Bm(e);return{name:n.name,fn:n.fn,options:[e,t]}},rh=(e,t)=>{let n=Vm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ih=(e,t)=>{let n=Zm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ah=`Arrow`,oh=V.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,U.jsx)(wu.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,U.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});oh.displayName=ah;var sh=oh,ch=`Popper`,[lh,uh]=Eu(ch),[dh,fh]=lh(ch),ph=e=>{let{__scopePopper:t,children:n}=e,[r,i]=V.useState(null);return(0,U.jsx)(dh,{scope:t,anchor:r,onAnchorChange:i,children:n})};ph.displayName=ch;var mh=`PopperAnchor`,hh=V.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=fh(mh,n),o=V.useRef(null),s=_u(t,o),c=V.useRef(null);return V.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,U.jsx)(wu.div,{...i,ref:s})});hh.displayName=mh;var gh=`PopperContent`,[_h,vh]=lh(gh),yh=V.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=fh(gh,n),[_,v]=V.useState(null),y=_u(t,e=>v(e)),[b,x]=V.useState(null),S=Kf(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],ee=D.length>0,O={padding:E,boundary:D.filter(Ch),altBoundary:ee},{refs:k,floatingStyles:te,placement:A,isPositioned:j,middlewareData:ne}=Xm({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Im(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Qm({mainAxis:i+w,alignmentAxis:o}),c&&$m({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?eh():void 0,...O}),c&&th({...O}),nh({...O,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&ih({element:b,padding:s}),wh({arrowWidth:C,arrowHeight:w}),f&&rh({strategy:`referenceHidden`,...O})]}),[re,ie]=Th(A),ae=Wu(m);ku(()=>{j&&ae?.()},[j,ae]);let oe=ne.arrow?.x,se=ne.arrow?.y,ce=ne.arrow?.centerOffset!==0,[le,ue]=V.useState();return ku(()=>{_&&ue(window.getComputedStyle(_).zIndex)},[_]),(0,U.jsx)(`div`,{ref:k.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:j?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:le,"--radix-popper-transform-origin":[ne.transformOrigin?.x,ne.transformOrigin?.y].join(` `),...ne.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,U.jsx)(_h,{scope:n,placedSide:re,onArrowChange:x,arrowX:oe,arrowY:se,shouldHideArrow:ce,children:(0,U.jsx)(wu.div,{"data-side":re,"data-align":ie,...h,ref:y,style:{...h.style,animation:j?void 0:`none`}})})})});yh.displayName=gh;var bh=`PopperArrow`,xh={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Sh=V.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=vh(bh,n),a=xh[i.placedSide];return(0,U.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,U.jsx)(sh,{...r,ref:t,style:{...r.style,display:`block`}})})});Sh.displayName=bh;function Ch(e){return e!==null}var wh=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Th(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Th(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Eh=ph,Dh=hh,Oh=yh,kh=Sh,Ah=`rovingFocusGroup.onEntryFocus`,jh={bubbles:!1,cancelable:!0},Mh=`RovingFocusGroup`,[Nh,Ph,Fh]=Ou(Mh),[Ih,Lh]=Eu(Mh,[Fh]),[Rh,zh]=Ih(Mh),Bh=V.forwardRef((e,t)=>(0,U.jsx)(Nh.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(Nh.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,U.jsx)(Vh,{...e,ref:t})})}));Bh.displayName=Mh;var Vh=V.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=V.useRef(null),p=_u(t,f),m=Uu(a),[h,g]=ju({prop:o,defaultProp:s??null,onChange:c,caller:Mh}),[_,v]=V.useState(!1),y=Wu(l),b=Ph(n),x=V.useRef(!1),[S,C]=V.useState(0);return V.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Ah,y),()=>e.removeEventListener(Ah,y)},[y]),(0,U.jsx)(Rh,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:V.useCallback(e=>g(e),[g]),onItemShiftTab:V.useCallback(()=>v(!0),[]),onFocusableItemAdd:V.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:V.useCallback(()=>C(e=>e-1),[]),children:(0,U.jsx)(wu.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:W(e.onMouseDown,()=>{x.current=!0}),onFocus:W(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Ah,jh);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);qh([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:W(e.onBlur,()=>v(!1))})})}),Hh=`RovingFocusGroupItem`,Uh=V.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Vu(),l=a||c,u=zh(Hh,n),d=u.currentTabStopId===l,f=Ph(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return V.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,U.jsx)(Nh.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,U.jsx)(wu.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:W(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:W(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:W(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Kh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Jh(n,r+1):n.slice(r+1)}setTimeout(()=>qh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Uh.displayName=Hh;var Wh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Gh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Kh(e,t,n){let r=Gh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Wh[r]}function qh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Jh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yh=Bh,Xh=Uh,Zh=[`Enter`,` `],Qh=[`ArrowDown`,`PageUp`,`Home`],$h=[`ArrowUp`,`PageDown`,`End`],eg=[...Qh,...$h],tg={ltr:[...Zh,`ArrowRight`],rtl:[...Zh,`ArrowLeft`]},ng={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},rg=`Menu`,[ig,ag,og]=Ou(rg),[sg,cg]=Eu(rg,[og,uh,Lh]),lg=uh(),ug=Lh(),[dg,fg]=sg(rg),[pg,mg]=sg(rg),hg=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=lg(t),[c,l]=V.useState(null),u=V.useRef(!1),d=Wu(a),f=Uu(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,U.jsx)(Eh,{...s,children:(0,U.jsx)(dg,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,U.jsx)(pg,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};hg.displayName=rg;var gg=`MenuAnchor`,_g=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=lg(n);return(0,U.jsx)(Dh,{...i,...r,ref:t})});_g.displayName=gg;var vg=`MenuPortal`,[yg,bg]=sg(vg,{forceMount:void 0}),xg=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=fg(vg,t);return(0,U.jsx)(yg,{scope:t,forceMount:n,children:(0,U.jsx)(Fu,{present:n||a.open,children:(0,U.jsx)(Sd,{asChild:!0,container:i,children:r})})})};xg.displayName=vg;var Sg=`MenuContent`,[Cg,wg]=sg(Sg),Tg=V.forwardRef((e,t)=>{let n=bg(Sg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=fg(Sg,e.__scopeMenu),o=mg(Sg,e.__scopeMenu);return(0,U.jsx)(ig.Provider,{scope:e.__scopeMenu,children:(0,U.jsx)(Fu,{present:r||a.open,children:(0,U.jsx)(ig.Slot,{scope:e.__scopeMenu,children:o.modal?(0,U.jsx)(Eg,{...i,ref:t}):(0,U.jsx)(Dg,{...i,ref:t})})})})}),Eg=V.forwardRef((e,t)=>{let n=fg(Sg,e.__scopeMenu),r=V.useRef(null),i=_u(t,r);return V.useEffect(()=>{let e=r.current;if(e)return Uf(e)},[]),(0,U.jsx)(kg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Dg=V.forwardRef((e,t)=>{let n=fg(Sg,e.__scopeMenu);return(0,U.jsx)(kg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Og=vu(`MenuContent.ScrollLock`),kg=V.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=fg(Sg,n),_=mg(Sg,n),v=lg(n),y=ug(n),b=ag(n),[x,S]=V.useState(null),C=V.useRef(null),w=_u(t,C,g.onContentChange),T=V.useRef(0),E=V.useRef(``),D=V.useRef(0),ee=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),te=m?Pf:V.Fragment,A=m?{as:Og,allowPinchZoom:!0}:void 0,j=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=p_(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};V.useEffect(()=>()=>window.clearTimeout(T.current),[]),wd();let ne=V.useCallback(e=>O.current===ee.current?.side&&h_(e,ee.current?.area),[]);return(0,U.jsx)(Cg,{scope:n,searchRef:E,onItemEnter:V.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),onItemLeave:V.useCallback(e=>{ne(e)||(C.current?.focus(),S(null))},[ne]),onTriggerLeave:V.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),pointerGraceTimerRef:D,onPointerGraceIntentChange:V.useCallback(e=>{ee.current=e},[]),children:(0,U.jsx)(te,{...A,children:(0,U.jsx)(ld,{asChild:!0,trapped:i,onMountAutoFocus:W(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,U.jsx)(Qu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,U.jsx)(Yh,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:W(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,U.jsx)(Oh,{role:`menu`,"aria-orientation":`vertical`,"data-state":c_(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:W(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=C.current;if(e.target!==i||!eg.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);$h.includes(e.key)&&a.reverse(),d_(a)}),onBlur:W(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:W(e.onPointerMove,g_(e=>{let t=e.target,n=k.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>k.current?`right`:`left`;O.current=t,k.current=e.clientX}}))})})})})})})});Tg.displayName=Sg;var Ag=`MenuGroup`,jg=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,U.jsx)(wu.div,{role:`group`,...r,ref:t})});jg.displayName=Ag;var Mg=`MenuLabel`,Ng=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,U.jsx)(wu.div,{...r,ref:t})});Ng.displayName=Mg;var Pg=`MenuItem`,Fg=`menu.itemSelect`,Ig=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=mg(Pg,e.__scopeMenu),s=wg(Pg,e.__scopeMenu),c=_u(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Fg,{bubbles:!0,cancelable:!0});e.addEventListener(Fg,e=>r?.(e),{once:!0}),Tu(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,U.jsx)(Lg,{...i,ref:c,disabled:n,onClick:W(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:W(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:W(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Zh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Ig.displayName=Pg;var Lg=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=wg(Pg,n),s=ug(n),c=V.useRef(null),l=_u(t,c),[u,d]=V.useState(!1),[f,p]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,U.jsx)(ig.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,U.jsx)(Xh,{asChild:!0,...s,focusable:!r,children:(0,U.jsx)(wu.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:W(e.onPointerMove,g_(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:W(e.onPointerLeave,g_(e=>o.onItemLeave(e))),onFocus:W(e.onFocus,()=>d(!0)),onBlur:W(e.onBlur,()=>d(!1))})})})}),Rg=`MenuCheckboxItem`,zg=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,U.jsx)(qg,{scope:e.__scopeMenu,checked:n,children:(0,U.jsx)(Ig,{role:`menuitemcheckbox`,"aria-checked":l_(n)?`mixed`:n,...i,ref:t,"data-state":u_(n),onSelect:W(i.onSelect,()=>r?.(l_(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zg.displayName=Rg;var Bg=`MenuRadioGroup`,[Vg,Hg]=sg(Bg,{value:void 0,onValueChange:()=>{}}),Ug=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Wu(r);return(0,U.jsx)(Vg,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,U.jsx)(jg,{...i,ref:t})})});Ug.displayName=Bg;var Wg=`MenuRadioItem`,Gg=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=Hg(Wg,e.__scopeMenu),a=n===i.value;return(0,U.jsx)(qg,{scope:e.__scopeMenu,checked:a,children:(0,U.jsx)(Ig,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":u_(a),onSelect:W(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Gg.displayName=Wg;var Kg=`MenuItemIndicator`,[qg,Jg]=sg(Kg,{checked:!1}),Yg=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Jg(Kg,n);return(0,U.jsx)(Fu,{present:r||l_(a.checked)||a.checked===!0,children:(0,U.jsx)(wu.span,{...i,ref:t,"data-state":u_(a.checked)})})});Yg.displayName=Kg;var Xg=`MenuSeparator`,Zg=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,U.jsx)(wu.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Zg.displayName=Xg;var Qg=`MenuArrow`,$g=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=lg(n);return(0,U.jsx)(kh,{...i,...r,ref:t})});$g.displayName=Qg;var e_=`MenuSub`,[t_,n_]=sg(e_),r_=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=fg(e_,t),o=lg(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=Wu(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,U.jsx)(Eh,{...o,children:(0,U.jsx)(dg,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,U.jsx)(t_,{scope:t,contentId:Vu(),triggerId:Vu(),trigger:s,onTriggerChange:c,children:n})})})};r_.displayName=e_;var i_=`MenuSubTrigger`,a_=V.forwardRef((e,t)=>{let n=fg(i_,e.__scopeMenu),r=mg(i_,e.__scopeMenu),i=n_(i_,e.__scopeMenu),a=wg(i_,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,U.jsx)(_g,{asChild:!0,...l,children:(0,U.jsx)(Lg,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":c_(n.open),...e,ref:gu(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:W(e.onPointerMove,g_(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:W(e.onPointerLeave,g_(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:W(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||tg[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});a_.displayName=i_;var o_=`MenuSubContent`,s_=V.forwardRef((e,t)=>{let n=bg(Sg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=fg(Sg,e.__scopeMenu),o=mg(Sg,e.__scopeMenu),s=n_(o_,e.__scopeMenu),c=V.useRef(null),l=_u(t,c);return(0,U.jsx)(ig.Provider,{scope:e.__scopeMenu,children:(0,U.jsx)(Fu,{present:r||a.open,children:(0,U.jsx)(ig.Slot,{scope:e.__scopeMenu,children:(0,U.jsx)(kg,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:W(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:W(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=ng[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});s_.displayName=o_;function c_(e){return e?`open`:`closed`}function l_(e){return e===`indeterminate`}function u_(e){return l_(e)?`indeterminate`:e?`checked`:`unchecked`}function d_(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function f_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function p_(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=f_(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function m_(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function h_(e,t){return t?m_({x:e.clientX,y:e.clientY},t):!1}function g_(e){return t=>t.pointerType===`mouse`?e(t):void 0}var __=hg,v_=_g,y_=xg,b_=Tg,x_=jg,S_=Ng,C_=Ig,w_=zg,T_=Ug,E_=Gg,D_=Yg,O_=Zg,k_=$g,A_=r_,j_=a_,M_=s_,N_=`ContextMenu`,[P_,F_]=Eu(N_,[cg]),I_=cg(),[L_,R_]=P_(N_),z_=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=V.useState(!1),c=I_(t),l=Wu(r),u=V.useCallback(e=>{s(e),l(e)},[l]);return(0,U.jsx)(L_,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,U.jsx)(__,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};z_.displayName=N_;var B_=`ContextMenuTrigger`,V_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=R_(B_,n),o=I_(n),s=V.useRef({x:0,y:0}),c=V.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=V.useRef(0),u=V.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return V.useEffect(()=>u,[u]),V.useEffect(()=>void(r&&u()),[r,u]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v_,{...o,virtualRef:c}),(0,U.jsx)(wu.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:W(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:W(e.onPointerDown,mv(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:W(e.onPointerMove,mv(u)),onPointerCancel:r?e.onPointerCancel:W(e.onPointerCancel,mv(u)),onPointerUp:r?e.onPointerUp:W(e.onPointerUp,mv(u))})]})});V_.displayName=B_;var H_=`ContextMenuPortal`,U_=e=>{let{__scopeContextMenu:t,...n}=e,r=I_(t);return(0,U.jsx)(y_,{...r,...n})};U_.displayName=H_;var W_=`ContextMenuContent`,G_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=R_(W_,n),a=I_(n),o=V.useRef(!1);return(0,U.jsx)(b_,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});G_.displayName=W_;var K_=`ContextMenuGroup`,q_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(x_,{...i,...r,ref:t})});q_.displayName=K_;var J_=`ContextMenuLabel`,Y_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(S_,{...i,...r,ref:t})});Y_.displayName=J_;var X_=`ContextMenuItem`,Z_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(C_,{...i,...r,ref:t})});Z_.displayName=X_;var Q_=`ContextMenuCheckboxItem`,$_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(w_,{...i,...r,ref:t})});$_.displayName=Q_;var ev=`ContextMenuRadioGroup`,tv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(T_,{...i,...r,ref:t})});tv.displayName=ev;var nv=`ContextMenuRadioItem`,rv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(E_,{...i,...r,ref:t})});rv.displayName=nv;var iv=`ContextMenuItemIndicator`,av=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(D_,{...i,...r,ref:t})});av.displayName=iv;var ov=`ContextMenuSeparator`,sv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(O_,{...i,...r,ref:t})});sv.displayName=ov;var cv=`ContextMenuArrow`,lv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(k_,{...i,...r,ref:t})});lv.displayName=cv;var uv=`ContextMenuSubTrigger`,dv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(j_,{...i,...r,ref:t})});dv.displayName=uv;var fv=`ContextMenuSubContent`,pv=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=I_(n);return(0,U.jsx)(M_,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pv.displayName=fv;function mv(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var hv=z_,gv=V_,_v=U_,vv=G_,yv=Z_,bv=`DropdownMenu`,[xv,Sv]=Eu(bv,[cg]),Cv=cg(),[wv,Tv]=xv(bv),Ev=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Cv(t),l=V.useRef(null),[u,d]=ju({prop:i,defaultProp:a??!1,onChange:o,caller:bv});return(0,U.jsx)(wv,{scope:t,triggerId:Vu(),triggerRef:l,contentId:Vu(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,U.jsx)(__,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Ev.displayName=bv;var Dv=`DropdownMenuTrigger`,Ov=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Tv(Dv,n),o=Cv(n);return(0,U.jsx)(v_,{asChild:!0,...o,children:(0,U.jsx)(wu.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:gu(t,a.triggerRef),onPointerDown:W(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:W(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Ov.displayName=Dv;var kv=`DropdownMenuContent`,Av=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Tv(kv,n),a=Cv(n),o=V.useRef(!1);return(0,U.jsx)(b_,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:W(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Av.displayName=kv;var jv=`DropdownMenuGroup`,Mv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(x_,{...i,...r,ref:t})});Mv.displayName=jv;var Nv=`DropdownMenuLabel`,Pv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(S_,{...i,...r,ref:t})});Pv.displayName=Nv;var Fv=`DropdownMenuItem`,Iv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(C_,{...i,...r,ref:t})});Iv.displayName=Fv;var Lv=`DropdownMenuCheckboxItem`,Rv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(w_,{...i,...r,ref:t})});Rv.displayName=Lv;var zv=`DropdownMenuRadioGroup`,Bv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(T_,{...i,...r,ref:t})});Bv.displayName=zv;var Vv=`DropdownMenuRadioItem`,Hv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(E_,{...i,...r,ref:t})});Hv.displayName=Vv;var Uv=`DropdownMenuItemIndicator`,Wv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(D_,{...i,...r,ref:t})});Wv.displayName=Uv;var Gv=`DropdownMenuSeparator`,Kv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(O_,{...i,...r,ref:t})});Kv.displayName=Gv;var qv=`DropdownMenuArrow`,Jv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(k_,{...i,...r,ref:t})});Jv.displayName=qv;var Yv=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=Cv(t),[s,c]=ju({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,U.jsx)(A_,{...o,open:s,onOpenChange:c,children:n})},Xv=`DropdownMenuSubTrigger`,Zv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(j_,{...i,...r,ref:t})});Zv.displayName=Xv;var Qv=`DropdownMenuSubContent`,$v=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,U.jsx)(M_,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});$v.displayName=Qv;var ey=Ev,ty=Ov,ny=Av,ry=Iv,iy=Yv,ay=Zv,oy=$v,sy=`Popover`,[cy,ly]=Eu(sy,[uh]),uy=uh(),[dy,fy]=cy(sy),py=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=uy(t),c=V.useRef(null),[l,u]=V.useState(!1),[d,f]=ju({prop:r,defaultProp:i??!1,onChange:a,caller:sy});return(0,U.jsx)(Eh,{...s,children:(0,U.jsx)(dy,{scope:t,contentId:Vu(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:V.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:V.useCallback(()=>u(!0),[]),onCustomAnchorRemove:V.useCallback(()=>u(!1),[]),modal:o,children:n})})};py.displayName=sy;var my=`PopoverAnchor`,hy=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=fy(my,n),a=uy(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return V.useEffect(()=>(o(),()=>s()),[o,s]),(0,U.jsx)(Dh,{...a,...r,ref:t})});hy.displayName=my;var gy=`PopoverTrigger`,_y=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=fy(gy,n),a=uy(n),o=_u(t,i.triggerRef),s=(0,U.jsx)(wu.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":My(i.open),...r,ref:o,onClick:W(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,U.jsx)(Dh,{asChild:!0,...a,children:s})});_y.displayName=gy;var vy=`PopoverPortal`,[yy,by]=cy(vy,{forceMount:void 0}),xy=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=fy(vy,t);return(0,U.jsx)(yy,{scope:t,forceMount:n,children:(0,U.jsx)(Fu,{present:n||a.open,children:(0,U.jsx)(Sd,{asChild:!0,container:i,children:r})})})};xy.displayName=vy;var Sy=`PopoverContent`,Cy=V.forwardRef((e,t)=>{let n=by(Sy,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=fy(Sy,e.__scopePopover);return(0,U.jsx)(Fu,{present:r||a.open,children:a.modal?(0,U.jsx)(Ty,{...i,ref:t}):(0,U.jsx)(Ey,{...i,ref:t})})});Cy.displayName=Sy;var wy=vu(`PopoverContent.RemoveScroll`),Ty=V.forwardRef((e,t)=>{let n=fy(Sy,e.__scopePopover),r=V.useRef(null),i=_u(t,r),a=V.useRef(!1);return V.useEffect(()=>{let e=r.current;if(e)return Uf(e)},[]),(0,U.jsx)(Pf,{as:wy,allowPinchZoom:!0,children:(0,U.jsx)(Dy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ey=V.forwardRef((e,t)=>{let n=fy(Sy,e.__scopePopover),r=V.useRef(!1),i=V.useRef(!1);return(0,U.jsx)(Dy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Dy=V.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=fy(Sy,n),p=uy(n);return wd(),(0,U.jsx)(ld,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,U.jsx)(Qu,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,U.jsx)(Oh,{"data-state":My(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Oy=`PopoverClose`,ky=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=fy(Oy,n);return(0,U.jsx)(wu.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})});ky.displayName=Oy;var Ay=`PopoverArrow`,jy=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=uy(n);return(0,U.jsx)(kh,{...i,...r,ref:t})});jy.displayName=Ay;function My(e){return e?`open`:`closed`}var Ny=py,Py=_y,Fy=xy,Iy=Cy,Ly=ky,Ry=jy,zy=`Tabs`,[By,Vy]=Eu(zy,[Lh]),Hy=Lh(),[Uy,Wy]=By(zy),Gy=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Uu(s),[d,f]=ju({prop:r,onChange:i,defaultProp:a??``,caller:zy});return(0,U.jsx)(Uy,{scope:n,baseId:Vu(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,U.jsx)(wu.div,{dir:u,"data-orientation":o,...l,ref:t})})});Gy.displayName=zy;var Ky=`TabsList`,qy=V.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Wy(Ky,n),o=Hy(n);return(0,U.jsx)(Yh,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,U.jsx)(wu.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});qy.displayName=Ky;var Jy=`TabsTrigger`,Yy=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Wy(Jy,n),s=Hy(n),c=Qy(o.baseId,r),l=$y(o.baseId,r),u=r===o.value;return(0,U.jsx)(Xh,{asChild:!0,...s,focusable:!i,active:u,children:(0,U.jsx)(wu.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:W(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:W(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Yy.displayName=Jy;var Xy=`TabsContent`,Zy=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Wy(Xy,n),c=Qy(s.baseId,r),l=$y(s.baseId,r),u=r===s.value,d=V.useRef(u);return V.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,U.jsx)(Fu,{present:i||u,children:({present:n})=>(0,U.jsx)(wu.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Zy.displayName=Xy;function Qy(e,t){return`${e}-trigger-${t}`}function $y(e,t){return`${e}-content-${t}`}var eb=Gy,tb=qy,nb=Yy,rb=Zy,ib=e(t(((e,t)=>{(function(){var n=this,r={};e===void 0?n.fuzzy=r:t.exports=r,r.simpleFilter=function(e,t){return t.filter(function(t){return r.test(e,t)})},r.test=function(e,t){return r.match(e,t)!==null},r.match=function(e,t,n){n||={};var r=0,i=[],a=t.length,o=0,s=0,c=n.pre||``,l=n.post||``,u=n.caseSensitive&&t||t.toLowerCase(),d;e=n.caseSensitive&&e||e.toLowerCase();for(var f=0;f<a;f++)d=t[f],u[f]===e[r]?(d=c+d+l,r+=1,s+=1+s):s=0,o+=s,i[i.length]=d;return r===e.length?(o=u===e?1/0:o,{rendered:i.join(``),score:o}):null},r.filter=function(e,t,n){return!t||t.length===0?[]:typeof e==`string`?(n||={},t.reduce(function(t,i,a,o){var s=i;n.extract&&(s=n.extract(i));var c=r.match(e,s,n);return c!=null&&(t[t.length]={string:c.rendered,score:c.score,index:a,original:i}),t},[]).sort(function(e,t){return t.score-e.score||e.index-t.index})):t}})()}))(),1);function ab(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function ob(e,t,n){let r=ab(t,n);if(r===0)return ab(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),ab(e,sb(t,n,i))}function sb(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function cb(e,t){return lb(e,0,e.length,t)}function lb(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=ob(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(lb(e,t,l+1,r,a),lb(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function ub(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function db(e){return[-e[0],-e[1]]}function fb(e,t){return[e[0]+t[0],e[1]+t[1]]}function pb(e,t){return[e[0]-t[0],e[1]-t[1]]}function mb(e,t){return[e[0]*t,e[1]*t]}function hb(e,t){return[e[0]/t,e[1]/t]}function gb(e){return[e[1],-e[0]]}function _b(e,t){return e[0]*t[0]+e[1]*t[1]}function vb(e,t){return e[0]===t[0]&&e[1]===t[1]}function yb(e){return Math.hypot(e[0],e[1])}function bb(e){return e[0]*e[0]+e[1]*e[1]}function xb(e,t){return bb(pb(e,t))}function Sb(e){return hb(e,yb(e))}function Cb(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function wb(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function Tb(e,t,n){return fb(e,mb(pb(t,e),n))}function Eb(e,t,n){return fb(e,mb(t,n))}var{min:Db,PI:Ob}=Math,kb=.275,Ab=Ob+1e-4;function jb(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=Db(1,t.distance/n);r=Db(1,e+(Db(1,1-i)-e)*(i*kb))}return(e+r)/2},e[0].pressure),x=ub(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,ee=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=Db(1,l/n),t=Db(1,1-e);r=Db(1,b+(t-b)*(e*kb))}x=ub(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,O=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,O));let k=(t<e.length-1?e[t+1]:e[t]).vector,te=t<e.length-1?_b(c,k):1,A=_b(c,C)<0&&!ee,j=te!==null&&te<0;if(A||j){let e=mb(gb(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=wb(pb(s,e),s,Ab*t),v.push(E),D=wb(fb(s,e),s,Ab*-t),y.push(D);w=E,T=D,j&&(ee=!0);continue}if(ee=!1,t===e.length-1){let e=mb(gb(c),x);v.push(pb(s,e)),y.push(fb(s,e));continue}let ne=mb(gb(Tb(k,c,te)),x);E=pb(s,ne),(t<=1||xb(w,E)>_)&&(v.push(E),w=E),D=fb(s,ne),(t<=1||xb(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let O=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):fb(e[0].point,[1,1]),te=[],A=[];if(e.length===1){if(!(h||g)||l){let e=Eb(O,Sb(gb(pb(O,k))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(wb(e,O,Ab*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=wb(y[0],O,Ab*t);te.push(e)}else{let e=pb(v[0],y[0]),t=mb(e,.5),n=mb(e,.51);te.push(pb(O,t),pb(O,n),fb(O,n),fb(O,t))}}let t=gb(db(e[e.length-1].vector));if(g||h&&e.length===1)A.push(k);else if(f){let e=Eb(k,t,x);for(let t=1/29,n=t;n<1;n+=t)A.push(wb(e,k,Ab*3*n))}else A.push(fb(k,mb(t,x)),fb(k,mb(t,x*.99)),pb(k,mb(t,x*.99)),pb(k,mb(t,x)))}return v.concat(A,y.reverse(),te)}function Mb(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(Tb(o[0],e,t/4))}o.length===1&&(o=[...o,[...fb(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?o[e].slice(0,2):Tb(u.point,o[e],a);if(vb(u.point,t))continue;let n=Cb(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}u={point:t,pressure:o[e][2]>=0?o[e][2]:.5,vector:Sb(pb(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function Nb(e,t={}){return jb(Mb(e,t),t)}var Pb=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Fb=e=>e?Pb(e):Pb,Ib=t((e=>{var t=r(),n=Gf();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Lb=e(t(((e,t)=>{t.exports=Ib()}))(),1),{useDebugValue:Rb}=V.default,{useSyncExternalStoreWithSelector:zb}=Lb.default,Bb=e=>e;function Vb(e,t=Bb,n){let r=zb(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Rb(r),r}var Hb=e=>{let t=typeof e==`function`?Fb(e):e,n=(e,n)=>Vb(t,e,n);return Object.assign(n,t),n},Ub=e=>e?Hb(e):Hb,Wb,Gb=typeof window<`u`&&((Wb=window.document)!=null&&Wb.createElement||window.navigator?.product===`ReactNative`)?V.useLayoutEffect:V.useEffect;function Kb(){let e=Ub(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return Gb(()=>{n(e=>({version:e.version+1}))},[]),Gb(()=>(n(({current:e})=>({current:[...e,t]})),()=>n(({current:e})=>({current:e.filter(e=>e!==t)}))),[t,r]),null},Out:()=>{let t=e(e=>e.current);return V.createElement(V.Fragment,null,t)}}}var qb=e(t(((e,t)=>{var n=NaN,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=typeof global==`object`&&global&&global.Object===Object&&global,l=typeof self==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,h=!0;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=y(t)||0,g(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?f(y(n.maxWait)||0,t):a,h=`trailing`in n?!!n.trailing:h);function _(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function v(e){return l=e,s=setTimeout(S,t),u?_(e):o}function b(e){var n=e-c,r=e-l,i=t-n;return d?p(i,a-r):i}function x(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function S(){var e=m();if(x(e))return C(e);s=setTimeout(S,b(e))}function C(e){return s=void 0,h&&r?_(e):(r=i=void 0,o)}function w(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function T(){return s===void 0?o:C(m())}function E(){var e=m(),n=x(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return v(c);if(d)return s=setTimeout(S,t),_(c)}return s===void 0&&(s=setTimeout(S,t)),o}return E.cancel=w,E.flush=T,E}function g(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function _(e){return!!e&&typeof e==`object`}function v(e){return typeof e==`symbol`||_(e)&&d.call(e)==`[object Symbol]`}function y(e){if(typeof e==`number`)return e;if(v(e))return n;if(g(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=g(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?n:+e}t.exports=h}))(),1),Jb=fu(),{useAtom:Yb,useSetAtom:Xb,useAtomValue:Zb,useStore:Qb}=Jb,$b=Jb.Provider,ex=Yl(),tx=gl({"./locales/ar-SA.json":()=>n(()=>import(`./ar-SA-5WIASEJP-Di7OimCN.js`),[],import.meta.url),"./locales/az-AZ.json":()=>n(()=>import(`./az-AZ-V5EUQD6C-C19OGTT_.js`),[],import.meta.url),"./locales/bg-BG.json":()=>n(()=>import(`./bg-BG-EXASCMTR-BIt0xWyb.js`),[],import.meta.url),"./locales/bn-BD.json":()=>n(()=>import(`./bn-BD-U4SYNFCO-CdNaPy4Q.js`),[],import.meta.url),"./locales/bn-IN.json":()=>n(()=>import(`./bn-IN-HKDJIITE-CdNaPy4Q.js`),[],import.meta.url),"./locales/ca-ES.json":()=>n(()=>import(`./ca-ES-2KGUU5XB-C9t-c0cH.js`),[],import.meta.url),"./locales/cs-CZ.json":()=>n(()=>import(`./cs-CZ-VUCGPRML-BfCoYAgj.js`),[],import.meta.url),"./locales/da-DK.json":()=>n(()=>import(`./da-DK-NNDP2IVP-DBw9ZNTR.js`),[],import.meta.url),"./locales/de-CH.json":()=>n(()=>import(`./de-CH-I7RAVIZN-DYW18Vsr.js`),[],import.meta.url),"./locales/de-DE.json":()=>n(()=>import(`./de-DE-WBQ3DQLR-DYW18Vsr.js`),[],import.meta.url),"./locales/el-GR.json":()=>n(()=>import(`./el-GR-TYQHVGXW-Dx82YYAS.js`),[],import.meta.url),"./locales/en.json":()=>n(()=>import(`./en-7ZVUCEYH-C_VXKxxb.js`),[],import.meta.url),"./locales/es-ES.json":()=>n(()=>import(`./es-ES-JEUOREKJ-Rx0NUQDl.js`),[],import.meta.url),"./locales/eu-ES.json":()=>n(()=>import(`./eu-ES-SO5DEEAN-CDYm-BcK.js`),[],import.meta.url),"./locales/fa-IR.json":()=>n(()=>import(`./fa-IR-I4JNTJHK-CFtHZqoT.js`),[],import.meta.url),"./locales/fi-FI.json":()=>n(()=>import(`./fi-FI-REAEF6HQ-BIpjJqIb.js`),[],import.meta.url),"./locales/fr-FR.json":()=>n(()=>import(`./fr-FR-SUCL7J6B-DGAKE8jH.js`),[],import.meta.url),"./locales/gl-ES.json":()=>n(()=>import(`./gl-ES-KHCSOGVH-DWKh0CMu.js`),[],import.meta.url),"./locales/he-IL.json":()=>n(()=>import(`./he-IL-JYXVXV2Q-zqbcM-4g.js`),[],import.meta.url),"./locales/hi-IN.json":()=>n(()=>import(`./hi-IN-BU52H3BO-CY8v6eG9.js`),[],import.meta.url),"./locales/hu-HU.json":()=>n(()=>import(`./hu-HU-OWADXDQ3-CEl6Udfh.js`),[],import.meta.url),"./locales/id-ID.json":()=>n(()=>import(`./id-ID-2WY7E4VX-CCAeQpPr.js`),[],import.meta.url),"./locales/it-IT.json":()=>n(()=>import(`./it-IT-INVHSAJF-DytAgndh.js`),[],import.meta.url),"./locales/ja-JP.json":()=>n(()=>import(`./ja-JP-JBNTKYP4-BflWlGhw.js`),[],import.meta.url),"./locales/kaa.json":()=>n(()=>import(`./kaa-TC3VIB7V-B-xtZfy0.js`),[],import.meta.url),"./locales/kab-KAB.json":()=>n(()=>import(`./kab-KAB-UOUDSQKM-BmO0O4Y4.js`),[],import.meta.url),"./locales/kk-KZ.json":()=>n(()=>import(`./kk-KZ-P5H2X7YS-CSQFB8IN.js`),[],import.meta.url),"./locales/km-KH.json":()=>n(()=>import(`./km-KH-IHMV2US7-BxrjuEzr.js`),[],import.meta.url),"./locales/ko-KR.json":()=>n(()=>import(`./ko-KR-ZTMANIDF-BnNRXd5J.js`),[],import.meta.url),"./locales/ku-TR.json":()=>n(()=>import(`./ku-TR-GPJTRB5G-BZM7f2aT.js`),[],import.meta.url),"./locales/lt-LT.json":()=>n(()=>import(`./lt-LT-V3XDOK3P-MVQBOHmF.js`),[],import.meta.url),"./locales/lv-LV.json":()=>n(()=>import(`./lv-LV-DVQ3FADO-CrenwAhS.js`),[],import.meta.url),"./locales/mr-IN.json":()=>n(()=>import(`./mr-IN-VZ6HH5FE-B-PHPglH.js`),[],import.meta.url),"./locales/my-MM.json":()=>n(()=>import(`./my-MM-XYKWHRK6-Be5sYp5q.js`),[],import.meta.url),"./locales/nb-NO.json":()=>n(()=>import(`./nb-NO-UNO2GGZJ-BvSKGdja.js`),[],import.meta.url),"./locales/nl-NL.json":()=>n(()=>import(`./nl-NL-76EFHT4P-C2yNx1Cj.js`),[],import.meta.url),"./locales/nn-NO.json":()=>n(()=>import(`./nn-NO-CFKD7ABE-4NsqlDRP.js`),[],import.meta.url),"./locales/oc-FR.json":()=>n(()=>import(`./oc-FR-YBJTCJ3J-B4OTQsWW.js`),[],import.meta.url),"./locales/pa-IN.json":()=>n(()=>import(`./pa-IN-SNOXSMRV-CKj_sOG7.js`),[],import.meta.url),"./locales/percentages.json":()=>n(()=>import(`./percentages-LWOC67ZH-VhvllE7L.js`),[],import.meta.url),"./locales/pl-PL.json":()=>n(()=>import(`./pl-PL-BSY6YFZ3-CFuzA6L0.js`),[],import.meta.url),"./locales/pt-BR.json":()=>n(()=>import(`./pt-BR-CZDV62R3-CkPMtyNx.js`),[],import.meta.url),"./locales/pt-PT.json":()=>n(()=>import(`./pt-PT-JO57XJJW-CBSnfGtF.js`),[],import.meta.url),"./locales/ro-RO.json":()=>n(()=>import(`./ro-RO-UZ5ICYYN-BOuntc_r.js`),[],import.meta.url),"./locales/ru-RU.json":()=>n(()=>import(`./ru-RU-AN7JPREC-D-ow3SNR.js`),[],import.meta.url),"./locales/si-LK.json":()=>n(()=>import(`./si-LK-7CBLD6QQ-c91EepX0.js`),[],import.meta.url),"./locales/sk-SK.json":()=>n(()=>import(`./sk-SK-SWR6DKBI-D5vFMIL6.js`),[],import.meta.url),"./locales/sl-SI.json":()=>n(()=>import(`./sl-SI-QY5KCFGA-RZhwMpQL.js`),[],import.meta.url),"./locales/sv-SE.json":()=>n(()=>import(`./sv-SE-O3OFCY3J-DnS86_7q.js`),[],import.meta.url),"./locales/ta-IN.json":()=>n(()=>import(`./ta-IN-V6NHHU6Z-D5jy7_AE.js`),[],import.meta.url),"./locales/th-TH.json":()=>n(()=>import(`./th-TH-WLSZUSBX-DHehoYR2.js`),[],import.meta.url),"./locales/tr-TR.json":()=>n(()=>import(`./tr-TR-GUFYG22B-ClVaf8h1.js`),[],import.meta.url),"./locales/uk-UA.json":()=>n(()=>import(`./uk-UA-K6SV5NFQ-BLTTtyNB.js`),[],import.meta.url),"./locales/uz-UZ.json":()=>n(()=>import(`./uz-UZ-TVKTZO2G-Bm02Eg3D.js`),[],import.meta.url),"./locales/vi-VN.json":()=>n(()=>import(`./vi-VN-7FKFXJNO-CL3WPhmG.js`),[],import.meta.url),"./locales/zh-CN.json":()=>n(()=>import(`./zh-CN-AOKVLNNK-DGidDH2b.js`),[],import.meta.url),"./locales/zh-HK.json":()=>n(()=>import(`./zh-HK-CDKPF5DC-CRcNR3rk.js`),[],import.meta.url),"./locales/zh-TW.json":()=>n(()=>import(`./zh-TW-ZVGYESGW-C7Qji1y6.js`),[],import.meta.url)}),nx=85,rx={code:`en`,label:`English`},ix=[rx,...[{code:`ar-SA`,label:`العربية`,rtl:!0},{code:`bg-BG`,label:`Български`},{code:`ca-ES`,label:`Català`},{code:`cs-CZ`,label:`Česky`},{code:`de-DE`,label:`Deutsch`},{code:`el-GR`,label:`Ελληνικά`},{code:`es-ES`,label:`Español`},{code:`eu-ES`,label:`Euskara`},{code:`fa-IR`,label:`فارسی`,rtl:!0},{code:`fi-FI`,label:`Suomi`},{code:`fr-FR`,label:`Français`},{code:`gl-ES`,label:`Galego`},{code:`he-IL`,label:`עברית`,rtl:!0},{code:`hi-IN`,label:`हिन्दी`},{code:`hu-HU`,label:`Magyar`},{code:`id-ID`,label:`Bahasa Indonesia`},{code:`it-IT`,label:`Italiano`},{code:`ja-JP`,label:`日本語`},{code:`kab-KAB`,label:`Taqbaylit`},{code:`kk-KZ`,label:`Қазақ тілі`},{code:`ko-KR`,label:`한국어`},{code:`ku-TR`,label:`Kurdî`},{code:`lt-LT`,label:`Lietuvių`},{code:`lv-LV`,label:`Latviešu`},{code:`my-MM`,label:`Burmese`},{code:`nb-NO`,label:`Norsk bokmål`},{code:`nl-NL`,label:`Nederlands`},{code:`nn-NO`,label:`Norsk nynorsk`},{code:`oc-FR`,label:`Occitan`},{code:`pa-IN`,label:`ਪੰਜਾਬੀ`},{code:`pl-PL`,label:`Polski`},{code:`pt-BR`,label:`Português Brasileiro`},{code:`pt-PT`,label:`Português`},{code:`ro-RO`,label:`Română`},{code:`ru-RU`,label:`Русский`},{code:`sk-SK`,label:`Slovenčina`},{code:`sv-SE`,label:`Svenska`},{code:`sl-SI`,label:`Slovenščina`},{code:`tr-TR`,label:`Türkçe`},{code:`uk-UA`,label:`Українська`},{code:`zh-CN`,label:`简体中文`},{code:`zh-TW`,label:`繁體中文`},{code:`vi-VN`,label:`Tiếng Việt`},{code:`mr-IN`,label:`मराठी`}].filter(e=>yl[e.code]>=nx).sort((e,t)=>e.label>t.label?1:-1)],ax=`__test__`;Ae()&&ix.unshift({code:ax,label:`test language`},{code:`${ax}.rtl`,label:`‪test language (rtl)‬`,rtl:!0});var ox=rx,sx={},cx=async e=>{if(ox=e,document.documentElement.dir=ox.rtl?`rtl`:`ltr`,document.documentElement.lang=ox.code,e.code.startsWith(ax))sx={};else try{sx=await tx(`./locales/${ox.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),sx=vl}ex.set(dx,e.code)},lx=()=>ox,ux=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];if(e[r]===void 0)return;e=e[r]}if(typeof e==`string`)return e},G=(e,t,n)=>{if(ox.code.startsWith(ax))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split(`.`),i=ux(sx,r)||ux(vl,r)||n;if(i===void 0){let t=`Can't find translation for ${e}`;if(ca.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)i=i.replace(`{{${e}}}`,String(t[e]));return i},dx=Dl(rx.code),fx=()=>({t:G,langCode:Zb(dx)}),px=e=>`var(--icon-fill-color)`,mx=e=>e===M.LIGHT?`#fff`:`#1e1e1e`,K=(e,t=512)=>{let{width:n=512,height:r=n,mirror:i,style:a,...o}=typeof t==`number`?{width:t}:t;return(0,U.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,role:`img`,viewBox:`0 0 ${n} ${r}`,className:H({"rtl-mirror":i}),style:a,...o,children:typeof e==`string`?(0,U.jsx)(`path`,{fill:`currentColor`,d:e}):e})},q={width:24,height:24,fill:`none`,strokeWidth:2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},J={width:20,height:20,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},hx={width:40,height:20};K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,U.jsx)(`line`,{x1:12,y1:8,x2:12,y2:21}),(0,U.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7`}),(0,U.jsx)(`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5`})]}),q);var gx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,U.jsx)(`path`,{d:`M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,U.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3`,y2:`19`}),(0,U.jsx)(`line`,{x1:`12`,y1:`6`,x2:`12`,y2:`19`}),(0,U.jsx)(`line`,{x1:`21`,y1:`6`,x2:`21`,y2:`19`})]}),q),_x=K((0,U.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,U.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),q),vx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`})]}),q),yx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,U.jsx)(`path`,{d:`M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,U.jsx)(`path`,{d:`M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]}),q),bx=K((0,U.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M9 4v6l-2 4v2h10v-2l-2 -4v-6`}),(0,U.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`21`}),(0,U.jsx)(`line`,{x1:`8`,y1:`4`,x2:`16`,y2:`4`})]}),q),xx=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M6.5 9.5l3.5 -3`}),(0,U.jsx)(`path`,{d:`M14 5.5l3 1.5`}),(0,U.jsx)(`path`,{d:`M18.5 10l-2.5 7`}),(0,U.jsx)(`path`,{d:`M13.5 17.5l-7 -5`})]}),q),Sx=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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`}),(0,U.jsx)(`mask`,{id:`UnlockedIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:6,y:1,width:9,height:9,children:(0,U.jsx)(`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`})}),(0,U.jsx)(`g`,{mask:`url(#UnlockedIcon)`,children:(0,U.jsx)(`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`})})]}),J),Cx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z`}),(0,U.jsx)(`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`})]}),J),wx=K((0,U.jsx)(`g`,{fill:`currentColor`,children:(0,U.jsx)(`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}),Tx=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z`,fill:`currentColor`}),(0,U.jsx)(`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`}),Ex=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z`,fill:`currentColor`}),(0,U.jsx)(`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`}),Dx=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z`,fill:`currentColor`}),(0,U.jsx)(`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`});K((0,U.jsx)(`g`,{fill:`currentColor`,children:(0,U.jsx)(`path`,{d:`M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z`,fill:`currentColor`})}),{width:40,height:40,fill:`none`});var Ox=K((0,U.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M13.5 13.5l4.5 4.5`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),kx=K((0,U.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M5 17c0 1.42 .316 2.805 1 4`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),Ax=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})]}),q),jx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`})]}),q),Mx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),q),Nx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,U.jsx)(`line`,{x1:`15`,y1:`16`,x2:`19`,y2:`12`}),(0,U.jsx)(`line`,{x1:`15`,y1:`8`,x2:`19`,y2:`12`})]}),q),Px=K((0,U.jsx)(`path`,{d:`M4.167 10h11.666`,strokeWidth:`1.5`}),J),Fx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z`}),(0,U.jsx)(`path`,{d:`M16 7h4`}),(0,U.jsx)(`path`,{d:`M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3`})]}),q),Ix=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`m11.25 5.417 3.333 3.333`})]}),J),Lx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`20`,x2:`7`,y2:`20`}),(0,U.jsx)(`line`,{x1:`14`,y1:`20`,x2:`21`,y2:`20`}),(0,U.jsx)(`line`,{x1:`6.9`,y1:`15`,x2:`13.8`,y2:`15`}),(0,U.jsx)(`line`,{x1:`10.2`,y1:`6.3`,x2:`16`,y2:`20`}),(0,U.jsx)(`polyline`,{points:`5 20 11 4 13 4 20 20`})]}),q),Rx=K((0,U.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,U.jsx)(`path`,{d:`M10 5v14`}),(0,U.jsx)(`path`,{d:`M12 19h-4`}),(0,U.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,U.jsx)(`path`,{d:`M18 12v7`}),(0,U.jsx)(`path`,{d:`M17 19h2`})]}),q),zx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M12.5 6.667h.01`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166`}),(0,U.jsx)(`path`,{d:`m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667`})]}),J),Bx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M18 13.3l-6.3 -6.3`})]}),q),Vx=K((0,U.jsx)(`path`,{strokeWidth:`1.25`,d:`M10 4.167v11.666M4.167 10h11.666`}),J),Hx=K((0,U.jsx)(`path`,{d:`M5 10h10`,strokeWidth:`1.25`}),J),Ux=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M21 21l-6 -6`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M3 4v4h4`})]}),q),Wx=K((0,U.jsx)(`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`}),J),Gx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`polyline`,{points:`12 16 18 10 12 4`}),(0,U.jsx)(`polyline`,{points:`8 4 2 10 8 16`})]}),J),Kx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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`})]}),J),qx=K((0,U.jsx)(`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`}),J),Jx=K((0,U.jsx)(`g`,{stroke:`currentColor`,strokeLinejoin:`round`,children:(0,U.jsx)(`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`})}),{...J,strokeWidth:1.5}),Yx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`6`,x2:`20`,y2:`6`}),(0,U.jsx)(`line`,{x1:`4`,y1:`12`,x2:`20`,y2:`12`}),(0,U.jsx)(`line`,{x1:`4`,y1:`18`,x2:`20`,y2:`18`})]}),q),Xx=K((0,U.jsx)(`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`}),J),Zx=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,U.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q),Qx=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,U.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,U.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q),$x=K((0,U.jsx)(`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`}),J),eS=K((0,U.jsx)(`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`}),J),tS=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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`})]}),J),nS=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 4l11.733 16h4.267l-11.733 -16z`}),(0,U.jsx)(`path`,{d:`M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772`})]}),q),rS=K((0,U.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,points:`20 6 9 17 4 12`}),{width:24,height:24}),iS=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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`})]}),J),aS=K(`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}),oS=K(`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}),sS=K((0,U.jsx)(`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`}),J);K(`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}),K(`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`);var cS=[`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`],lS=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),cS.map(e=>(0,U.jsx)(`path`,{d:e},e))]}),q),uS=K((0,U.jsx)(`g`,{strokeWidth:1.5,children:(0,U.jsx)(`path`,{d:`M6 18l12 -12`})}),q),dS=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M15 8h.01`}),(0,U.jsx)(`path`,{d:`M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5`}),(0,U.jsx)(`path`,{d:`M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4`}),(0,U.jsx)(`path`,{d:`M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598`}),(0,U.jsx)(`path`,{d:`M19 16v6`}),(0,U.jsx)(`path`,{d:`M22 19l-3 3l-3 -3`})]}),q),fS=K(`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});K(`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}),K(`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});var pS=K(`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`);K(`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`);var mS=K((0,U.jsx)(`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`}),J),hS=K((0,U.jsx)(`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`}),J),gS=K(`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}),_S=K((0,U.jsx)(`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`}),J);K(`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`),K(`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}),K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M12 14v-11`}),(0,U.jsx)(`path`,{d:`M9 6l3 -3l3 3`})]}),q),K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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}),K((0,U.jsx)(`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});var vS=(0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 10l0 10`}),(0,U.jsx)(`path`,{d:`M12 10l4 4`}),(0,U.jsx)(`path`,{d:`M12 10l-4 4`}),(0,U.jsx)(`path`,{d:`M4 4l16 0`})]}),yS=(0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 5l0 14`}),(0,U.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,U.jsx)(`path`,{d:`M8 9l4 -4`})]}),bS=K(yS,q),xS=K(yS,{...q,style:{transform:`rotate(180deg)`}}),SS=K(vS,q),CS=K(vS,{...q,style:{transform:`rotate(180deg)`}}),wS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M3.333 3.333h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),TS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),ES=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),DS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M16.667 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),OS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M16.667 3.333v13.334M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),kS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M3.333 3.333h13.334M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),AS=K((0,U.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M1.667 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M8.333 10h3.334`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M15.417 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),J),jS=K((0,U.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M10 18.333v-2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M10 11.667V8.333`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M10 4.583V1.667`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`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`})]}),J),MS=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,U.jsx)(`path`,{d:`M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`}),(0,U.jsx)(`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`}),(0,U.jsx)(`path`,{d:`M21 21v-2a4 4 0 0 0 -3 -3.85`})]}),q);K(`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`);var NS=K(`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`),PS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`M15 5 5 15M5 5l10 10`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J);K(`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}),K(`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}),K(`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});var FS=V.memo(({theme:e})=>K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M25 26H111V111H25`,fill:px(e)}),(0,U.jsx)(`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:px(e),strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M100 100H160V160H100`,fill:px(e)}),(0,U.jsx)(`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:px(e),strokeWidth:`2`}),(0,U.jsxs)(`g`,{fill:mx(e),stroke:px(e),strokeWidth:`6`,children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`2.5`,y:`149.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`147.5`,y:`2.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),IS=V.memo(({theme:e})=>K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M25 26H111V111H25`,fill:px(e)}),(0,U.jsx)(`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:px(e),strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M100 100H160V160H100`,fill:px(e)}),(0,U.jsx)(`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:px(e),strokeWidth:`2`}),(0,U.jsxs)(`g`,{fill:mx(e),stroke:px(e),strokeWidth:`6`,children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`78.5`,y:`149.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`147.5`,y:`78.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`105.5`,y:`2.5`,width:`30`,height:`30`}),(0,U.jsx)(`rect`,{x:`2.5`,y:`102.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),LS=K((0,U.jsx)(`g`,{strokeWidth:1.25,children:(0,U.jsx)(`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`})}),J),RS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`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`}),(0,U.jsx)(`mask`,{id:`FillHachureIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:2,y:2,width:16,height:16,children:(0,U.jsx)(`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`})}),(0,U.jsx)(`g`,{mask:`url(#FillHachureIcon)`,children:(0,U.jsx)(`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`})})]}),J),zS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`g`,{clipPath:`url(#a)`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`mask`,{id:`FillCrossHatchIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:-1,y:-1,width:22,height:22,children:(0,U.jsx)(`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`})}),(0,U.jsx)(`g`,{mask:`url(#FillCrossHatchIcon)`,children:(0,U.jsx)(`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`})})]}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),BS=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`g`,{clipPath:`url(#a)`,children:(0,U.jsx)(`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`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),{...J,fill:`currentColor`}),VS=K((0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`path`,{d:`M4.167 10h11.666`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),J),HS=K((0,U.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),J),US=K((0,U.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`3.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),J);V.memo(({theme:e})=>K((0,U.jsx)(`path`,{d:`M6 10H34`,stroke:px(e),strokeWidth:2,fill:`none`,strokeLinecap:`round`}),{width:40,height:20}));var WS=K((0,U.jsxs)(`g`,{strokeWidth:`2`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M5 12h2`}),(0,U.jsx)(`path`,{d:`M17 12h2`}),(0,U.jsx)(`path`,{d:`M11 12h2`})]}),q),GS=K((0,U.jsxs)(`g`,{strokeWidth:`2`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 12v.01`}),(0,U.jsx)(`path`,{d:`M8 12v.01`}),(0,U.jsx)(`path`,{d:`M12 12v.01`}),(0,U.jsx)(`path`,{d:`M16 12v.01`}),(0,U.jsx)(`path`,{d:`M20 12v.01`})]}),q),KS=K((0,U.jsx)(`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`}),J),qS=K((0,U.jsx)(`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`}),J),JS=K((0,U.jsx)(`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`}),J),YS=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),q),XS=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,U.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`3.25`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),q),ZS=K((0,U.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M13.3333 3.33331V3.34331`}),(0,U.jsx)(`path`,{d:`M16.6667 3.33331V3.34331`}),(0,U.jsx)(`path`,{d:`M16.6667 6.66669V6.67669`}),(0,U.jsx)(`path`,{d:`M16.6667 10V10.01`}),(0,U.jsx)(`path`,{d:`M3.33334 13.3333V13.3433`}),(0,U.jsx)(`path`,{d:`M16.6667 13.3333V13.3433`}),(0,U.jsx)(`path`,{d:`M3.33334 16.6667V16.6767`}),(0,U.jsx)(`path`,{d:`M6.66666 16.6667V16.6767`}),(0,U.jsx)(`path`,{d:`M10 16.6667V16.6767`}),(0,U.jsx)(`path`,{d:`M13.3333 16.6667V16.6767`}),(0,U.jsx)(`path`,{d:`M16.6667 16.6667V16.6767`})]}),J),QS=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 12v-4a4 4 0 0 1 4 -4h4`}),(0,U.jsx)(`line`,{x1:`16`,y1:`4`,x2:`16`,y2:`4.01`}),(0,U.jsx)(`line`,{x1:`20`,y1:`4`,x2:`20`,y2:`4.01`}),(0,U.jsx)(`line`,{x1:`20`,y1:`8`,x2:`20`,y2:`8.01`}),(0,U.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`12.01`}),(0,U.jsx)(`line`,{x1:`4`,y1:`16`,x2:`4`,y2:`16.01`}),(0,U.jsx)(`line`,{x1:`20`,y1:`16`,x2:`20`,y2:`16.01`}),(0,U.jsx)(`line`,{x1:`4`,y1:`20`,x2:`4`,y2:`20.01`}),(0,U.jsx)(`line`,{x1:`8`,y1:`20`,x2:`8`,y2:`20.01`}),(0,U.jsx)(`line`,{x1:`12`,y1:`20`,x2:`12`,y2:`20.01`}),(0,U.jsx)(`line`,{x1:`16`,y1:`20`,x2:`16`,y2:`20.01`}),(0,U.jsx)(`line`,{x1:`20`,y1:`20`,x2:`20`,y2:`20.01`})]}),q),$S=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,opacity:.3,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:[(0,U.jsx)(`path`,{d:`M7,11 H19`}),(0,U.jsx)(`path`,{d:`M25,6 L33,16 M33,6 L25,16`})]}),hx)),eC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`M7,11 H33 M23,5 L33,11 L23,17`})}),hx)),tC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M7,11 H23`,strokeWidth:2,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),hx)),nC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,children:[(0,U.jsx)(`path`,{d:`M7,11 H23`}),(0,U.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),hx)),rC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,children:[(0,U.jsx)(`path`,{d:`M7,11 H25`,strokeWidth:2,strokeLinecap:`round`}),(0,U.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),hx)),iC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,children:[(0,U.jsx)(`path`,{d:`M7,11 H25`,strokeLinecap:`round`}),(0,U.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),hx)),aC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{d:`M7,11 H21`,strokeWidth:2,strokeLinecap:`round`}),(0,U.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),hx)),oC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,strokeWidth:2,strokeLinecap:`round`,children:[(0,U.jsx)(`path`,{d:`M7,11 H21`}),(0,U.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),hx)),sC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:(0,U.jsx)(`path`,{d:`M11,11 H31 M31,5 V17`})}),hx)),cC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,U.jsx)(`path`,{d:`M35,11 H7 M15,5 V17`})}),hx)),lC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,U.jsx)(`path`,{d:`M35,11 H7 M15,11 L7,5 M15,11 L7,17`})}),hx)),uC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,U.jsx)(`path`,{d:`M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17`})}),hx)),dC=V.memo(({flip:e=!1})=>K((0,U.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,U.jsx)(`path`,{d:`M35,11 H7 M15,5 V17 M7,5 V17`})}),hx)),fC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,U.jsx)(`path`,{d:`M35,11 H19 M11,11 H7 M7,5 V17`}),(0,U.jsx)(`circle`,{cx:`15`,cy:`11`,r:`4`})]}),hx)),pC=V.memo(({flip:e=!1})=>K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,U.jsx)(`path`,{d:`M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17`}),(0,U.jsx)(`circle`,{cx:`23`,cy:`11`,r:`4`})]}),hx)),mC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`g`,{clipPath:`url(#a)`,children:(0,U.jsx)(`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`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),hC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`g`,{clipPath:`url(#a)`,children:(0,U.jsx)(`path`,{d:`M5 16.667V3.333L10 15l5-11.667v13.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),gC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`g`,{clipPath:`url(#a)`,children:(0,U.jsx)(`path`,{d:`M5.833 3.333v13.334h8.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,U.jsx)(`defs`,{children:(0,U.jsx)(`clipPath`,{id:`a`,children:(0,U.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),_C=K((0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`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`})}),J),vC=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,U.jsx)(`path`,{d:`M10 5v14`}),(0,U.jsx)(`path`,{d:`M12 19h-4`}),(0,U.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,U.jsx)(`path`,{d:`M18 12v7`}),(0,U.jsx)(`path`,{d:`M17 19h2`})]}),q),yC=K((0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M7 12h10`}),(0,U.jsx)(`path`,{d:`M7 5v14`}),(0,U.jsx)(`path`,{d:`M17 5v14`}),(0,U.jsx)(`path`,{d:`M15 19h4`}),(0,U.jsx)(`path`,{d:`M15 5h4`}),(0,U.jsx)(`path`,{d:`M5 19h4`}),(0,U.jsx)(`path`,{d:`M5 5h4`})]})}),q),bC=K((0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`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`})})}),J),xC=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M7 8l-4 4l4 4`}),(0,U.jsx)(`path`,{d:`M17 8l4 4l-4 4`}),(0,U.jsx)(`path`,{d:`M14 4l-4 16`})]}),q),SC=xC,CC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,U.jsx)(`line`,{x1:`4`,y1:`12`,x2:`12`,y2:`12`}),(0,U.jsx)(`line`,{x1:`4`,y1:`16`,x2:`16`,y2:`16`})]}),q),wC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,U.jsx)(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`}),(0,U.jsx)(`line`,{x1:`6`,y1:`16`,x2:`18`,y2:`16`})]}),q),TC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,U.jsx)(`line`,{x1:`10`,y1:`12`,x2:`20`,y2:`12`}),(0,U.jsx)(`line`,{x1:`8`,y1:`16`,x2:`20`,y2:`16`})]}),q),EC=V.memo(({theme:e})=>K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`4`,x2:`20`,y2:`4`}),(0,U.jsx)(`rect`,{x:`9`,y:`8`,width:`6`,height:`12`,rx:`2`})]}),q)),DC=V.memo(({theme:e})=>K((0,U.jsxs)(`g`,{strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`20`,x2:`20`,y2:`20`}),(0,U.jsx)(`rect`,{x:`9`,y:`4`,width:`6`,height:`12`,rx:`2`})]}),q)),OC=V.memo(({theme:e})=>K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`line`,{x1:`4`,y1:`12`,x2:`9`,y2:`12`}),(0,U.jsx)(`line`,{x1:`15`,y1:`12`,x2:`20`,y2:`12`}),(0,U.jsx)(`rect`,{x:`9`,y:`6`,width:`6`,height:`12`,rx:`2`})]}),q)),kC=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M21 19h-18l9 -15`}),(0,U.jsx)(`path`,{d:`M20.615 15.171h.015`}),(0,U.jsx)(`path`,{d:`M19.515 11.771h.015`}),(0,U.jsx)(`path`,{d:`M17.715 8.671h.015`}),(0,U.jsx)(`path`,{d:`M15.415 5.971h.015`})]}),q),AC=K((0,U.jsx)(`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});K((0,U.jsx)(`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`}));var jC=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,U.jsx)(`path`,{d:`M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5`}),(0,U.jsx)(`path`,{d:`M14 5.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,U.jsx)(`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`})]}),q),MC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`}),(0,U.jsx)(`path`,{d:`M7 11l5 5l5 -5`}),(0,U.jsx)(`path`,{d:`M12 4l0 12`})]}),q),NC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2`})]}),q),PC=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,U.jsx)(`path`,{d:`M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,U.jsx)(`path`,{d:`M9.15 14.85l8.85 -10.85`}),(0,U.jsx)(`path`,{d:`M6 4l8.85 10.85`})]}),q),FC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`}),(0,U.jsx)(`path`,{d:`M12 17l0 .01`}),(0,U.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q);K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M7 4v16l13 -8z`})]}),q),K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`})]}),q);var IC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M5 12l5 5l10 -10`})]}),q),LC=K((0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M12 9v4`}),(0,U.jsx)(`path`,{d:`M12 17h.01`})]}),q),RC=[`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`],zC=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),RC.map(e=>(0,U.jsx)(`path`,{d:e},e))]}),q),BC=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 7l16 0`}),(0,U.jsx)(`path`,{d:`M4 17l16 0`}),(0,U.jsx)(`path`,{d:`M7 4l0 16`}),(0,U.jsx)(`path`,{d:`M17 4l0 16`})]}),q),VC=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 4h12a2 2 0 0 1 2 2v9l-5 5h-9a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2z`}),(0,U.jsx)(`path`,{d:`M14 20v-4a2 2 0 0 1 2 -2h4`}),(0,U.jsx)(`path`,{d:`M8 9h8`}),(0,U.jsx)(`path`,{d:`M8 13h5`})]}),q),HC=K((0,U.jsx)(`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`})),UC=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`}),(0,U.jsx)(`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`})]}),q),WC=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 10l-2 1l8 4l8 -4l-2 -1`}),(0,U.jsx)(`path`,{d:`M4 15l8 4l8 -4`}),(0,U.jsx)(`path`,{d:`M12 4v7`}),(0,U.jsx)(`path`,{d:`M15 8l-3 3l-3 -3`})]}),q),GC=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{d:`M4.16602 10H15.8327`}),(0,U.jsx)(`path`,{d:`M12.5 13.3333L15.8333 10`}),(0,U.jsx)(`path`,{d:`M12.5 6.66666L15.8333 9.99999`})]}),J),KC=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0`}),(0,U.jsx)(`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`})]}),q),qC=K((0,U.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,transform:`rotate(90 10 10)`,children:[(0,U.jsx)(`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`}),(0,U.jsx)(`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),JC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,U.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,U.jsx)(`path`,{d:`M15 6l3 3`}),(0,U.jsx)(`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`}),(0,U.jsx)(`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`})]}),q);K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,U.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,U.jsx)(`path`,{d:`M15 6l3 3`}),(0,U.jsx)(`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`}),(0,U.jsx)(`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`})]}),q),K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35`}),(0,U.jsx)(`path`,{d:`M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45`}),(0,U.jsx)(`path`,{d:`M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946`}),(0,U.jsx)(`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`})]}),q);var YC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`}),(0,U.jsx)(`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`}),(0,U.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`}),(0,U.jsx)(`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`})]}),q),XC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`}),(0,U.jsx)(`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`})]}),q),ZC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M3 3l18 18`})]}),q),QC=K((0,U.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,U.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,U.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,U.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),q),$C=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,U.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,U.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,U.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),q),ew=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`}),(0,U.jsx)(`path`,{d:`M21 21l-6 -6`})]}),q),tw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M20.984 12.53a9 9 0 1 0 -7.552 8.355`}),(0,U.jsx)(`path`,{d:`M12 7v5l3 3`}),(0,U.jsx)(`path`,{d:`M19 16l-2 3h4l-2 3`})]}),q),nw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 8l0 4l2 2`}),(0,U.jsx)(`path`,{d:`M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5`})]}),q),rw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M5 10a7 7 0 0 0 14 0`}),(0,U.jsx)(`path`,{d:`M8 21l8 0`}),(0,U.jsx)(`path`,{d:`M12 17l0 4`})]}),q),iw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 3l18 18`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85`}),(0,U.jsx)(`path`,{d:`M8 21l8 0`}),(0,U.jsx)(`path`,{d:`M12 17l0 4`})]}),q),aw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`})]}),q),ow=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M12 20v.01`}),(0,U.jsx)(`path`,{d:`M16 20v.01`}),(0,U.jsx)(`path`,{d:`M8 20v.01`}),(0,U.jsx)(`path`,{d:`M4 20v.01`}),(0,U.jsx)(`path`,{d:`M4 16v.01`}),(0,U.jsx)(`path`,{d:`M4 12v.01`}),(0,U.jsx)(`path`,{d:`M4 8v.01`}),(0,U.jsx)(`path`,{d:`M4 4v.01`}),(0,U.jsx)(`path`,{d:`M8 4v.01`}),(0,U.jsx)(`path`,{d:`M12 4v.01`}),(0,U.jsx)(`path`,{d:`M16 4v.01`}),(0,U.jsx)(`path`,{d:`M20 4v.01`}),(0,U.jsx)(`path`,{d:`M20 8v.01`}),(0,U.jsx)(`path`,{d:`M20 12v.01`}),(0,U.jsx)(`path`,{d:`M20 16v.01`}),(0,U.jsx)(`path`,{d:`M20 20v.01`})]}),q),sw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M5 3v18`}),(0,U.jsx)(`path`,{d:`M19 21v-18`}),(0,U.jsx)(`path`,{d:`M5 7h14`}),(0,U.jsx)(`path`,{d:`M5 15h14`}),(0,U.jsx)(`path`,{d:`M8 13v4`}),(0,U.jsx)(`path`,{d:`M11 13v4`}),(0,U.jsx)(`path`,{d:`M16 13v4`}),(0,U.jsx)(`path`,{d:`M14 5v4`}),(0,U.jsx)(`path`,{d:`M11 5v4`}),(0,U.jsx)(`path`,{d:`M8 5v4`}),(0,U.jsx)(`path`,{d:`M3 21h18`})]}),q),cw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 12l18 0`}),(0,U.jsx)(`path`,{d:`M7 16l10 0l-10 5l0 -5`}),(0,U.jsx)(`path`,{d:`M7 8l10 0l-10 -5l0 5`})]}),q),lw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M12 3l0 18`}),(0,U.jsx)(`path`,{d:`M16 7l0 10l5 0l-5 -10`}),(0,U.jsx)(`path`,{d:`M8 7l0 10l-5 0l5 -10`})]}),q),uw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2`}),(0,U.jsx)(`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`})]}),q),dw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0`}),(0,U.jsx)(`path`,{d:`M22 22l-3 -3`}),(0,U.jsx)(`path`,{d:`M6 18h-1a2 2 0 0 1 -2 -2v-1`}),(0,U.jsx)(`path`,{d:`M3 11v-1`}),(0,U.jsx)(`path`,{d:`M3 6v-1a2 2 0 0 1 2 -2h1`}),(0,U.jsx)(`path`,{d:`M10 3h1`}),(0,U.jsx)(`path`,{d:`M15 3h1a2 2 0 0 1 2 2v1`})]}),q),fw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,U.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M10 15l2 6l2 -6`}),(0,U.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`})]}),q),pw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,U.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,U.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`}),(0,U.jsx)(`path`,{d:`M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6`}),(0,U.jsx)(`path`,{d:`M11 21v-6l3 6v-6`})]}),q),mw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M4 8l5 0`}),(0,U.jsx)(`path`,{d:`M15 8l4 0`})]}),q),hw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,U.jsx)(`path`,{d:`M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,U.jsx)(`path`,{d:`M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z`}),(0,U.jsx)(`path`,{d:`M16.746 16.726a3 3 0 1 0 .252 -5.555`})]}),q),gw=K((0,U.jsxs)(`g`,{stroke:`currentColor`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`})]}),{...q,strokeWidth:1.5});K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M21 12h-13l3 -3`}),(0,U.jsx)(`path`,{d:`M11 15l-3 -3`})]}),q);var _w=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M10 9l5 3l-5 3z`})]}),q),vw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 6h18`}),(0,U.jsx)(`path`,{d:`M3 12h18`}),(0,U.jsx)(`path`,{d:`M3 18h18`}),(0,U.jsx)(`path`,{d:`M6 3v18`}),(0,U.jsx)(`path`,{d:`M12 3v18`}),(0,U.jsx)(`path`,{d:`M18 3v18`})]}),q),yw=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M17 5c-6.627 0 -12 5.373 -12 12`})]}),q),bw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 18l12 -12`}),(0,U.jsx)(`path`,{d:`M18 10v-4h-4`})]}),q),xw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7`}),(0,U.jsx)(`path`,{d:`M18 4l3 3l-3 3`})]}),q),Sw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{d:`M16,12L20,9L16,6`}),(0,U.jsx)(`path`,{d:`M6 20c0 -6.075 4.925 -11 11 -11h3`})]}),q),Cw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 9l6 6l6 -6`})]}),q),ww=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),q),Tw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),q),Ew=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M8 5v10a1 1 0 0 0 1 1h10`}),(0,U.jsx)(`path`,{d:`M5 8h10a1 1 0 0 1 1 1v10`})]}),q),Dw=K((0,U.jsxs)(`g`,{children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M5 7l0 10`}),(0,U.jsx)(`path`,{d:`M7 5l10 0`}),(0,U.jsx)(`path`,{d:`M7 19l10 0`}),(0,U.jsx)(`path`,{d:`M19 7l0 10`})]}),q);K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M4 12h7a1 1 0 0 1 1 1v7`})]}),q);var Ow=K((0,U.jsxs)(`g`,{strokeWidth:1.5,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 6l8 0`}),(0,U.jsx)(`path`,{d:`M16 6l4 0`}),(0,U.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 12l2 0`}),(0,U.jsx)(`path`,{d:`M10 12l10 0`}),(0,U.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 18l11 0`}),(0,U.jsx)(`path`,{d:`M19 18l1 0`})]}),q),kw=K((0,U.jsxs)(`g`,{strokeWidth:1,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4`})]}),q),Aw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`}),(0,U.jsx)(`path`,{d:`M13.5 6.5l4 4`})]}),q);K((0,U.jsxs)(`g`,{strokeWidth:1,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M11 7l-5 5l5 5`}),(0,U.jsx)(`path`,{d:`M17 7l-5 5l5 5`})]}),q);var jw=K((0,U.jsxs)(`g`,{strokeWidth:`1.75`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`}),(0,U.jsx)(`path`,{d:`M15 4l0 16`})]}),q),Mw=K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`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`})]}),q);K((0,U.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M3 4l18 0`}),(0,U.jsx)(`path`,{d:`M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10`}),(0,U.jsx)(`path`,{d:`M12 16l0 4`}),(0,U.jsx)(`path`,{d:`M9 20l6 0`}),(0,U.jsx)(`path`,{d:`M8 12l3 -3l2 2l3 -3`})]}),q);var Nw=(0,U.jsx)(`div`,{style:{width:`1rem`,height:`1rem`}}),Pw=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`polyline`,{points:`6 9 12 15 18 9`})]}),q),Fw=K((0,U.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`polyline`,{points:`9 6 15 12 9 18`})]}),q),Iw=K((0,U.jsxs)(`g`,{strokeWidth:1.25,children:[(0,U.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,U.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 6l8 0`}),(0,U.jsx)(`path`,{d:`M16 6l4 0`}),(0,U.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 12l2 0`}),(0,U.jsx)(`path`,{d:`M10 12l10 0`}),(0,U.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,U.jsx)(`path`,{d:`M4 18l11 0`}),(0,U.jsx)(`path`,{d:`M19 18l1 0`})]}),q),Lw=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(V.useRef(Date.now()).current%1600);return(0,U.jsx)(`div`,{className:`Spinner ${r}`,children:(0,U.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,U.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},Y=V.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let a=V.useRef(null);V.useImperativeHandle(i,()=>a.current);let o=`ToolIcon_size_${e}`,[s,c]=(0,V.useState)(!1),l=(0,V.useRef)(!0),u=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(We(t))try{c(!0),await t}catch(e){if(e instanceof nc)console.warn(e);else throw e}finally{l.current&&c(!1)}};(0,V.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let d=(0,V.useRef)(null);return r.type===`button`||r.type===`icon`?(0,U.jsxs)(`button`,{className:H(`ToolIcon_type_button`,o,n,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:u,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&(0,U.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,U.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,U.jsx)(Lw,{})]}),r.showAriaLabel&&(0,U.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,s&&(0,U.jsx)(Lw,{})]}),r.children]}):(0,U.jsx)(`button`,{className:H(`ToolIcon`,`ToolIcon_type_toggle`,o,n,{"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:e=>{d.current=e.pointerType||null,r.onPointerDown?.(e)},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},onClick:()=>{r.onSelect?.({pointerType:d.current})},ref:a,children:(0,U.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,U.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})})});Y.displayName=`IconButton`;var Rw=[],X=e=>(Rw=Rw.concat(e),e),zw=(e,t,n)=>{let r=new Set(Kc(e.filter(e=>F(e)),t).map(e=>e.id)),i={},a=n.scene.getNonDeletedElementsMap(),o=new Set;for(let t of r){let n=Dn(e,t);for(let e of n)if(!o.has(e.id)){if(fn(e)){let t=xe(e,a);t&&(i[t.id]=!0)}else i[e.id]=!0;o.add(e.id)}}let s=!0,c=e.map(e=>{if(t.selectedElementIds[e.id]){let t=fn(e)?xe(e,a):null;return e.frameId&&r.has(e.frameId)?(s=!1,i[e.id]=!0,e):t?.frameId&&r.has(t?.frameId)?e:(e.boundElements&&e.boundElements.forEach(t=>{let r=n.scene.getNonDeletedElementsMap().get(t.id);r&&vn(r)&&n.scene.mutateElement(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding})}),N(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,fn(e)||(i[e.id]=!0),N(e,{frameId:null})):fn(e)&&t.selectedElementIds[e.containerId]?N(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=ul(c,t.editingGroupId).filter(e=>!e.isDeleted);if(e.length>1)e[0]&&(i[e[0].id]=!0);else{l=null,e[0]&&(i[e[0].id]=!0);let n=e[0];if(n){let e=n.groupIds.findIndex(e=>e===t.editingGroupId),r=n.groupIds[e+1];if(r){let e=ul(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...sn({selectedElementIds:i,editingGroupId:l},en(c),t,null)}}},Bw=(e,t)=>{if(e.editingGroupId){let n=ul(en(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},Vw=X({name:`deleteSelectedElements`,label:`labels.delete`,icon:Wx,trackEvent:{category:`element`,action:`delete`},perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing){let{elementId:n,selectedPointsIndices:i}=t.selectedLinearElement,a=r.scene.getNonDeletedElementsMap(),o=R.getElement(n,a);if(!o||i==null)return!1;if(i.length>=o.points.length){let n=e.map(e=>e.id===o.id?N(e,{isDeleted:!0}):e);return{elements:n,appState:{...Bw(t,n),selectedLinearElement:null},captureUpdate:I.IMMEDIATELY}}return R.deletePoints(o,r,i),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:I.IMMEDIATELY}}let{elements:i,appState:a}=zw(e,t,r);return cn(i,i.filter(e=>e.isDeleted)),a=Bw(a,i),{elements:i,appState:{...a,activeTool:ln(t,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Gt(en(e),t)?I.IMMEDIATELY:I.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===z.BACKSPACE||e.key===z.DELETE)&&!e[z.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=cW()===`mobile`;return(0,U.jsx)(Y,{type:`button`,icon:Wx,title:G(`labels.delete`),"aria-label":G(`labels.delete`),onClick:()=>n(null),disabled:!Gt(en(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?Lr:{}}})}}),Z=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,G(Jo?`keys.option`:`keys.alt`)).replace(/\bShift\b/i,G(`keys.shift`)).replace(/\b(Enter|Return)\b/i,G(`keys.enter`)).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,G(Jo?`keys.cmd`:`keys.ctrl`)).replace(/\b(Esc(?:ape)?)\b/i,G(`keys.escape`)).replace(/\b(Space(?:bar)?)\b/i,G(`keys.spacebar`)).replace(/\b(Del(?:ete)?)\b/i,G(`keys.delete`)),Hw=X({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:xS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:go(e,t,r.scene),appState:t,captureUpdate:I.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[z.CTRL_OR_CMD]&&!e.shiftKey&&e.code===d.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,U.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.sendBackward`)} \u2014 ${Z(`CtrlOrCmd+[`)}`,children:xS})}),Uw=X({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:bS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Pc(e,t,r.scene),appState:t,captureUpdate:I.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[z.CTRL_OR_CMD]&&!e.shiftKey&&e.code===d.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,U.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.bringForward`)} \u2014 ${Z(`CtrlOrCmd+]`)}`,children:bS})}),Ww=X({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:CS,trackEvent:{category:`element`},perform:(e,t)=>({elements:hl(e,t),appState:t,captureUpdate:I.IMMEDIATELY}),keyTest:e=>Jo?e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.BRACKET_LEFT:e[z.CTRL_OR_CMD]&&e.shiftKey&&e.code===d.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,U.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.sendToBack`)} \u2014 ${Z(Jo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:CS})}),Gw=X({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:SS,trackEvent:{category:`element`},perform:(e,t)=>({elements:pr(e,t),appState:t,captureUpdate:I.IMMEDIATELY}),keyTest:e=>Jo?e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.BRACKET_RIGHT:e[z.CTRL_OR_CMD]&&e.shiftKey&&e.code===d.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,U.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${G(`labels.bringToFront`)} \u2014 ${Z(Jo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:SS})}),Kw=X({name:`selectAll`,label:`labels.selectAll`,icon:ow,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing)return!1;let i=e.filter(e=>!e.isDeleted&&!(D(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...sn({editingGroupId:null,selectedElementIds:i},en(e),t,r),selectedLinearElement:Object.keys(i).length===1&&ja(e[0])?new R(e[0],y(e)):null},captureUpdate:I.IMMEDIATELY}},keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.A}),qw=X({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:Kx,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{return{elements:e,appState:R.duplicateSelectedPoints(t,r.scene),captureUpdate:I.IMMEDIATELY}}catch{return!1}let i=se({type:`in-place`,elements:e,idsOfElementsToDuplicate:y(Kc(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:e,origIdToDuplicateId:t})=>{let n=e.frameId&&t.get(e.frameId);return{x:e.x+10,y:e.y+10,frameId:n??e.frameId}}}),{duplicatedElements:a,elementsWithDuplicates:o}=i;return r.props.onDuplicate&&({elements:o,duplicatedElements:a}=r.duplicate.runOnDuplicate(i,o,e),!a.length)?!1:(r.duplicate.advanceListMarkers(a),{elements:Po(o,y(a)),appState:{...t,...fr(a,en(o),t)},captureUpdate:I.IMMEDIATELY})},keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.D,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=cW()===`mobile`;return(0,U.jsx)(Y,{type:`button`,icon:Kx,title:`${G(`labels.duplicateSelection`)} \u2014 ${Z(`CtrlOrCmd+D`)}`,"aria-label":G(`labels.duplicateSelection`),onClick:()=>n(null),disabled:!Gt(en(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?Lr:{}}})}}),Jw=new Set([`command_palette`,`export`,`ai`]),Yw=(e,t,n,r)=>{try{if(typeof window>`u`||ca.VITE_WORKER_ID||ca.VITE_APP_ENABLE_TRACKING!==`true`||!Jw.has(e)||Ae())return;ca.PROD||console.info(`trackEvent`,{category:e,action:t,label:n,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:r})}catch(e){console.error(`error during analytics`,e)}},Xw=(0,V.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,icon:o,onClick:s}=e;return(0,U.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:H(r,{active:a}),onClick:s,style:e.style,children:o},n)}),Zw=e=>(0,U.jsx)(U.Fragment,{children:e.options.map(t=>e.type===`button`?(0,U.jsx)(Xw,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:n=>e.onClick(t.value,n)},t.text):(0,U.jsxs)(`label`,{className:H({active:e.value===t.value}),title:t.text,children:[(0,U.jsx)(`input`,{type:`radio`,name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),Qw=()=>(0,U.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),$w=V.createContext(null),eT=()=>V.useContext($w),tT=e=>{let[t,n]=(0,V.useState)(null),r=sW(),{theme:i}=eT(),{container:a}=lW();return(0,V.useLayoutEffect)(()=>{t&&(t.className=``,t.classList.add(`excalidraw`,...e?.className?.split(/\s+/)||[]),t.classList.toggle(`excalidraw--mobile`,r.formFactor===`phone`),t.classList.toggle(`theme--dark`,i===M.DARK))},[t,i,r.formFactor,e?.className]),(0,V.useLayoutEffect)(()=>{let t=a?.ownerDocument,r=e?.parentSelector?a?.querySelector(e.parentSelector):t?.body;if(!r||!t)return;let i=t.createElement(`div`);r.appendChild(i);let o=e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`none`)};return e?.parentSelector||(i.addEventListener(P.DRAG_OVER,o),i.addEventListener(P.DROP,o)),n(i),()=>{i.removeEventListener(P.DRAG_OVER,o),i.removeEventListener(P.DROP,o),r.removeChild(i)}},[a,e?.parentSelector]),t};function nT(e,t,n){(0,V.useEffect)(()=>{let r=e.current?.ownerDocument;if(!r)return;let i=r;function a(r){let a=r;if(!e.current)return;let o=n?.(a,e.current);if(o!==!0){if(o===!1)return t(a);e.current.contains(a.target)||!i.documentElement.contains(a.target)||a.target.closest(`[data-radix-portal]`)||a.target===i.documentElement&&i.body.style.pointerEvents===`none`||a.target.closest(`[data-prevent-outside-click]`)||t(a)}}return i.addEventListener(P.POINTER_DOWN,a),i.addEventListener(P.TOUCH_START,a),()=>{i.removeEventListener(P.POINTER_DOWN,a),i.removeEventListener(P.TOUCH_START,a)}},[e,t,n])}var rT=e=>{let t=(0,V.useRef)(e);return Object.assign(t.current,e),t.current},iT=({cursorPosition:e,elementSize:t,containerSize:n,gap:r})=>{let i=e+r+t>n?e-r-t:e+r;return Vi(i,0,Math.max(0,n-t))},aT=({cursor:e,element:t,container:n,gap:r})=>({left:iT({cursorPosition:e.x-n.left,elementSize:t.width,containerSize:n.width,gap:r}),top:iT({cursorPosition:e.y-n.top,elementSize:t.height,containerSize:n.height,gap:r})}),oT=RC.map((e,t)=>`<path fill="${t===0?`#fff`:``}" d="${e}" />`).join(``),sT=`url(data:${A.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">${oT}</g><g stroke="#1b1b1f" stroke-width="1.25">${oT}</g></svg>`)}) 2 21, auto`,cT=Dl(null),lT=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=tT({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),a=eT(),o=uW(),s=aW(),c=s.ownerWindow,l=rT({app:s,onCancel:e,onChange:t,onSelect:n,selectedElements:Kc(o,a)}),{container:u}=lW();(0,V.useLayoutEffect)(()=>{if(i)return i.style.cursor=sT,()=>{i.style.cursor=``}},[i]),(0,V.useEffect)(()=>{let e=d.current;if(!e||!s.canvas||!i)return;let t=!1,n=s.canvas.getContext(`2d`),o=({clientX:e,clientY:t})=>{let r=n.getImageData((e-a.offsetLeft)*c.devicePixelRatio,(t-a.offsetTop)*c.devicePixelRatio,1,1).data;return Yc(r[0],r[1],r[2])},f=e=>a.theme===M.DARK?Ur(e):e,p=({clientX:n,clientY:a,altKey:s})=>{let{top:c,left:u}=aT({cursor:{x:n,y:a},element:{width:e.offsetWidth,height:e.offsetHeight},container:i.getBoundingClientRect(),gap:7});e.style.top=`${c}px`,e.style.left=`${u}px`;let d=o({clientX:n,clientY:a});t&&l.onChange(r,f(d),l.selectedElements,{altKey:s}),e.style.background=d,e.style.setProperty(`--eye-dropper-preview-border-color`,ds(d)?`#fff`:`#222`)},m=()=>{l.onCancel()},h=(e,t)=>{l.onSelect(e,t)},g=e=>{t=!0,e.stopImmediatePropagation()},_=e=>{t=!1,u?.focus(),e.stopImmediatePropagation(),e.preventDefault(),h(f(o(e)),e)},v=e=>{e.key===z.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),m())};return i.tabIndex=-1,i.focus(),p({clientX:l.app.viewport.lastPosition.x,clientY:l.app.viewport.lastPosition.y,altKey:!1}),i.addEventListener(P.KEYDOWN,v),i.addEventListener(P.POINTER_DOWN,g),i.addEventListener(P.POINTER_UP,_),c.addEventListener(`pointermove`,p,{passive:!0}),c.addEventListener(P.BLUR,m),()=>{t=!1,i.removeEventListener(P.KEYDOWN,v),i.removeEventListener(P.POINTER_DOWN,g),i.removeEventListener(P.POINTER_UP,_),c.removeEventListener(`pointermove`,p),c.removeEventListener(P.BLUR,m)}},[l,s.canvas,i,r,u,a.offsetLeft,a.offsetTop,a.theme,c]);let d=(0,V.useRef)(null);return nT(d,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,Cl.createPortal)((0,U.jsx)(`div`,{ref:d,className:`excalidraw-eye-dropper-preview`}),i):null},uT=V.forwardRef(({children:e,padding:t,className:n,style:r,"data-viewport-ui":i,"data-viewport-ui-name":a},o)=>(0,U.jsx)(`div`,{className:H(`Island`,n),style:{"--padding":t,...r},"data-viewport-ui":i,"data-viewport-ui-name":a,ref:o,children:e})),dT=V.forwardRef(({className:e,container:t,children:n,style:r,onClose:i,onKeyDown:a,onFocusOutside:o,onPointerLeave:s,onPointerDownOutside:c,preventAutoFocusOnTouch:l=!1},u)=>{let d=sW(),f=d.formFactor===`phone`&&!d.isLandscape;return(0,U.jsx)(Fy,{container:t,children:(0,U.jsxs)(Iy,{ref:u,className:H(`focus-visible-none`,e),"data-prevent-outside-click":!0,side:f?`bottom`:`right`,align:f?`center`:`start`,alignOffset:-16,sideOffset:20,collisionBoundary:t??void 0,style:{zIndex:`var(--zIndex-ui-styles-popup)`,marginLeft:d.formFactor===`phone`?`0.5rem`:void 0},onPointerLeave:s,onKeyDown:a,onFocusOutside:o,onPointerDownOutside:c,onOpenAutoFocus:e=>{l&&d.isTouchScreen&&e.preventDefault()},onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!lr(document.activeElement)&&t.focus(),i()},children:[(0,U.jsx)(uT,{padding:3,style:r,children:n}),(0,U.jsx)(Ry,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),fT=e=>e.querySelector(`.excalidraw-wysiwyg`),pT=(e=document)=>{let t=fT(e);return t?{start:t.selectionStart,end:t.selectionEnd}:null},mT=(e,t=document)=>{(t.defaultView??window).setTimeout(()=>{let n=fT(t);n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},hT=(e,t,n,r,i=document)=>{t&&r&&r();let a=t&&n?pT(i):null;e(),t&&n&&mT(a,i)},gT=(e=document)=>{let[t,n]=(0,V.useState)(null);return{saveCaretPosition:(0,V.useCallback)(()=>{let t=pT(e);n(t)},[e]),restoreCaretPosition:(0,V.useCallback)(()=>{(e.defaultView??window).setTimeout(()=>{let r=fT(e);r&&(r.focus(),t&&(r.selectionStart=t.start,r.selectionEnd=t.end,n(null)))},0)},[e,t]),clearSavedPosition:(0,V.useCallback)(()=>{n(null)},[]),hasSavedPosition:!!t}},_T=(e=document,t=100)=>{let n=fT(e);if(n){let r=n.onblur;n.onblur=null,(e.defaultView??window).setTimeout(()=>{n.onblur=r},t)}},vT=({palette:e,color:t})=>{if(!t)return null;for(let[n,r]of Object.entries(e))if(Array.isArray(r)){let e=r.indexOf(t);if(e>-1)return{colorName:n,shade:e}}else if(r===t)return{colorName:n,shade:null};return null},yT=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),bT=({color:e,palette:t})=>!Object.values(t).flat().includes(e),xT=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return!Zr(i)&&bT({color:i,palette:n})}),a=new Map;return i.forEach(e=>{let n=e[r[t]];a.has(n)?a.set(n,a.get(n)+1):a.set(n,1)}),[...a.entries()].sort((e,t)=>t[1]-e[1]).map(e=>e[0]).slice(0,5)},ST=Dl(null),CT=({color:e,onChange:t,label:n,colorPickerType:r,placeholder:i})=>{let a=sW(),[o,s]=(0,V.useState)(e),[c,l]=(0,V.useState)(null),[u,d]=Yb(ST);(0,V.useEffect)(()=>{s(e)},[e]);let f=(0,V.useCallback)(e=>{let n=e.toLowerCase().trim(),r=vr(n);r?(t(r),l(null)):n.length===0?l(null):/^#?[0-9a-f]+$/.test(n)?l(G(`colorPicker.invalidHexLength`)):l(G(`colorPicker.invalidColor`)),s(n)},[t]),p=(0,V.useRef)(null),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{p.current&&p.current.focus()},[u]);let[h,g]=Yb(cT);return(0,V.useEffect)(()=>()=>{g(null)},[g]),(0,U.jsxs)(`div`,{className:`color-picker__input-label-container`,children:[(0,U.jsxs)(`div`,{className:H(`color-picker__input-label`,{"has-error":c}),children:[(0,U.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,U.jsx)(`input`,{ref:u===`hex`?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:`color-picker-input`,"aria-label":n,"aria-invalid":!!c,onChange:e=>{f(e.target.value)},value:(o||``).replace(/^#/,``),onBlur:()=>{s(e),l(null)},tabIndex:-1,onFocus:()=>d(`hex`),onKeyDown:e=>{e.key!==z.TAB&&(e.key===z.ESCAPE&&m.current?.focus(),e.stopPropagation())},placeholder:i}),a.formFactor!==`phone`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,U.jsx)(`div`,{ref:m,className:H(`excalidraw-eye-dropper-trigger`,{selected:h}),onClick:()=>g(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${G(`labels.eyeDropper`)} \u2014 ${z.I.toLocaleUpperCase()} or ${Z(`Alt`)} `,children:zC})]})]}),c&&(0,U.jsx)(`div`,{className:`color-picker__error-message`,role:`alert`,children:c})]})},wT=({className:e,tip:t,onReset:n,resetTitle:r})=>(0,U.jsxs)(`div`,{className:H(`top-picks-dnd__tip`,e),children:[t,n&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`button`,{type:`button`,className:`top-picks-dnd__tip-reset`,title:r,onMouseDown:e=>e.preventDefault(),onClick:e=>{let t=e.currentTarget.ownerDocument.activeElement===e.currentTarget?e.currentTarget.parentElement?.closest(`[tabindex]`):null;n(),t?.focus()},onKeyDown:e=>{(e.key===z.ENTER||e.key===z.SPACE)&&e.stopPropagation()},children:G(`buttons.reset`)})]})]}),TT=({color:e,keyLabel:t,isShade:n=!1})=>(0,U.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:ds(e)?`#fff`:`#000`},children:[n&&`⇧`,t]}),ET=`excalidraw-top-picks-dnd-ghost`,DT=`excalidraw-top-picks-dnd-active`,OT=10,kT=100,AT=(e,t)=>{if(!e||e.origin.kind!==`pick`||e.overIndex===null)return 0;let n=e.origin.index,r=e.overIndex;if(n===r)return 0;let i=t;return t===n?i=r:(t>n&&--i,i>=r&&(i+=1)),(i-t)*e.slotSpan},jT=()=>(0,U.jsx)(`svg`,{className:`top-picks-dnd__outline`,"aria-hidden":`true`,children:(0,U.jsx)(`rect`,{})}),MT=({enabled:e,picks:t,onPicksChange:n,isSamePick:r=(e,t)=>e===t,createGhost:i})=>{let[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useRef)({enabled:e,picks:t,onPicksChange:n,isSamePick:r,createGhost:i});c.current={enabled:e,picks:t,onPicksChange:n,isSamePick:r,createGhost:i};let l=(0,V.useMemo)(()=>{let e=null,t=()=>{e?.activated?o({value:e.value,origin:e.origin,overIndex:e.overIndex,duplicateIndex:e.duplicateIndex,slotSpan:e.slotSpan}):o(null)},n=()=>{let t=s.current;if(!t||!e)return!1;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`)).sort((e,t)=>Number(e.dataset.topPickIndex)-Number(t.dataset.topPickIndex));if(!n.length)return!1;e.slotRects=n.map(e=>e.getBoundingClientRect());let[r,i]=e.slotRects;e.slotSpan=i?i.left-r.left:r.width+4;let a=t.getBoundingClientRect(),o=Math.max(Math.abs(e.slotSpan)/2,10);return e.hitRect={left:a.left-o,right:a.right+o,top:a.top-14,bottom:a.bottom+14},!0},r=(t,n)=>{e?.ghost&&(e.ghost.style.transform=`translate(${t-e.ghostW/2}px, ${n-e.ghostH/2}px)`)},i=(t,n,i,a)=>{e?.ghost&&(e.ghostW!==t||e.ghostH!==n)&&(e.ghostW=t,e.ghostH=n,e.ghost.style.width=`${t}px`,e.ghost.style.height=`${n}px`,r(i,a))},a=(n,i)=>{if(!e)return;let{ghostContent:a,homeRect:o}=e,s=document.createElement(`div`);s.className=ET,a.classList.add(`${ET}__content`),s.appendChild(a),document.body.appendChild(s),e.ghost=s,e.ghostW=o.width,e.ghostH=o.height,s.style.width=`${o.width}px`,s.style.height=`${o.height}px`,r(n,i),requestAnimationFrame(()=>{e?.ghost===s&&s.classList.add(`${ET}--lifted`)}),document.body.classList.add(DT),e.activated=!0,t()},l=(n,r)=>{if(!e?.hitRect)return;let{hitRect:a,slotRects:o}=e,s=null,l=null;if(n>=a.left&&n<=a.right&&r>=a.top&&r<=a.bottom){let t=0,r=1/0;if(o.forEach((e,i)=>{let a=Math.abs(n-(e.left+e.width/2));a<r&&(r=a,t=i)}),e.origin.kind===`source`){let{picks:n,isSamePick:r}=c.current,i=n.findIndex(t=>r(t,e.value));i===-1?s=t:l=i}else s=t}if(s!==e.overIndex||l!==e.duplicateIndex){e.overIndex=s,e.duplicateIndex=l;let{ghost:n}=e;n&&(n.classList.toggle(`${ET}--over`,s!==null),n.classList.toggle(`${ET}--blocked`,l!==null)),t()}if(s!==null){let t=e.slotRects[s];i(t.width,t.height,n,r)}else i(e.homeRect.width,e.homeRect.height,n,r)},u=t=>{if(!e?.ghost)return;let{ghost:n}=e;e.ghost=null,n.classList.add(`${ET}--dropping`);let r=t.rect;r&&(n.style.width=`${r.width}px`,n.style.height=`${r.height}px`,n.style.transform=`translate(${r.left}px, ${r.top}px)`),window.setTimeout(()=>{n.classList.add(`${ET}--fade`)},160),window.setTimeout(()=>{n.remove()},340)},d=()=>{let t=s.current;if(!t||!e?.activated)return;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`));for(let e of n)e.style.transition=`none`,e.style.transform=`none`;t.offsetWidth;for(let e of n)e.style.transition=``},f=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener(`click`,e,{capture:!0})},100)},p=()=>{window.removeEventListener(`pointermove`,_,!0),window.removeEventListener(`pointerup`,v,!0),window.removeEventListener(`pointercancel`,y,!0),window.removeEventListener(`keydown`,b,!0)},m=()=>{p(),document.body.classList.remove(DT),e?.activationTimer!=null&&window.clearTimeout(e.activationTimer),e=null,o(null)},h=t=>{e&&(d(),e.ghost&&(t?u({rect:e.homeRect}):(e.ghost.remove(),e.ghost=null)),m())},g=(t,r)=>{if(e&&!e.activated){if(!n()){m();return}a(t,r),l(t,r)}},_=t=>{if(e&&t.pointerId===e.pointerId){if(e.lastX=t.clientX,e.lastY=t.clientY,!e.activated){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<OT){e.activationTimer!==null&&(window.clearTimeout(e.activationTimer),e.activationTimer=null);return}let n=performance.now()-e.startTime;if(n<kT){e.activationTimer===null&&(e.activationTimer=window.setTimeout(()=>{e&&(e.activationTimer=null,Math.hypot(e.lastX-e.startX,e.lastY-e.startY)>=OT&&g(e.lastX,e.lastY))},kT-n));return}if(g(t.clientX,t.clientY),!e?.activated)return}t.preventDefault(),r(t.clientX,t.clientY),l(t.clientX,t.clientY)}},v=t=>{if(!e||t.pointerId!==e.pointerId)return;if(!e.activated){m();return}t.preventDefault(),t.stopPropagation(),f();let{overIndex:n,origin:r,value:i,slotRects:a}=e,{picks:o,onPicksChange:s,isSamePick:l}=c.current;if(d(),n!==null){if(r.kind===`source`){if(!o.some(e=>l(e,i))){let e=[...o];e[n]=i,s(e)}}else if(r.index!==n){let e=[...o],[t]=e.splice(r.index,1);e.splice(n,0,t),s(e)}u({rect:a[n]})}else u({rect:e.homeRect});m()},y=t=>{e&&t.pointerId===e.pointerId&&h(!0)},b=t=>{e?.activated&&t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),h(!0))};return{begin:(t,n,r)=>{if(!c.current.enabled||e||t.button!==0||n==null)return;let i=s.current;if(!i)return;let{content:a,rect:o}=c.current.createGhost({value:n,sourceEl:t.currentTarget,stripEl:i});e={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now(),lastX:t.clientX,lastY:t.clientY,activationTimer:null,value:n,origin:r,ghostContent:a,homeRect:o,activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener(`pointermove`,_,!0),window.addEventListener(`pointerup`,v,!0),window.addEventListener(`pointercancel`,y,!0),window.addEventListener(`keydown`,b,!0)},destroy:()=>h(!1)}},[]);return(0,V.useEffect)(()=>()=>l.destroy(),[l]),(0,V.useMemo)(()=>({dragState:a,startSourceDrag:(e,t)=>l.begin(e,t,{kind:`source`}),startPickDrag:(e,t,n)=>l.begin(e,n,{kind:`pick`,index:t}),setStripEl:e=>{s.current=e}}),[a,l])},NT=(e,t)=>{if(e.toLowerCase()===t.toLowerCase())return!0;let n=be(e);return n!==null&&n===be(t)},PT=({value:e,sourceEl:t})=>{let n=document.createElement(`div`);if(n.className=`excalidraw-color-dnd-ghost-swatch`,Zr(e))n.classList.add(`is-transparent`);else{let r=getComputedStyle(t).backgroundColor;n.style.backgroundColor=r&&r!==`rgba(0, 0, 0, 0)`?r:e}return{content:n,rect:t.getBoundingClientRect()}},FT=(0,V.createContext)(null),IT=()=>(0,V.useContext)(FT),LT=({enabled:e,picks:t,onPicksChange:n})=>MT({enabled:e,picks:t,onPicksChange:n,isSamePick:NT,createGhost:PT}),RT=({theme:e,colors:t,color:n,onChange:r,label:i})=>{let[a,o]=Yb(ST),s=IT(),c=(0,V.useRef)(null);return(0,V.useEffect)(()=>{c.current&&c.current.focus()},[n,a]),(0,U.jsx)(`div`,{className:`color-picker-content--default`,children:t.map((t,a)=>{let l=Rt(t,e===M.DARK);return(0,U.jsxs)(`button`,{ref:n===t?c:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large has-outline`,{active:n===t,"is-transparent":t===`transparent`||!t}),onClick:()=>{r(t),o(`custom`)},onPointerDown:s?e=>s.startSourceDrag(e,t):void 0,title:t,"aria-label":i,style:{"--swatch-color":l},children:[(0,U.jsx)(`div`,{className:`color-picker__button-outline`}),(0,U.jsx)(TT,{color:l,keyLabel:a+1})]},a)})})},zT=({theme:e,palette:t,color:n,onChange:r,activeShade:i,showHotKey:a=!0,excludedColors:o})=>{let s=vT({color:n,palette:t}),[c,l]=Yb(ST),u=IT(),d=(0,V.useRef)(null);return(0,V.useEffect)(()=>{d.current&&c===`baseColors`&&d.current.focus()},[s?.colorName,c]),(0,U.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(t).map(([t,n],c)=>{let f=(Array.isArray(n)?n[i]:n)||`transparent`;if(o?.includes(f))return(0,U.jsx)(`div`,{className:`color-picker__button color-picker__button--large`,style:{visibility:`hidden`},"aria-hidden":`true`},t);let p=yT[c],m=Rt(f,e===M.DARK),h=G(`colors.${t.replace(/\d+/,``)}`,null,``);return(0,U.jsxs)(`button`,{ref:s?.colorName===t?d:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large`,{"has-outline":!ds(f,255),active:s?.colorName===t,"is-transparent":f===`transparent`||!f}),onClick:()=>{r(f),l(`baseColors`)},onPointerDown:u?e=>u.startSourceDrag(e,f):void 0,title:`${h}${f.startsWith(`#`)?` ${f}`:``} \u2014 ${p}`,"aria-label":`${h} \u2014 ${p}`,style:f?{"--swatch-color":m}:void 0,"data-testid":`color-${t}`,children:[(0,U.jsx)(`div`,{className:`color-picker__button-outline`}),a&&(0,U.jsx)(TT,{color:m,keyLabel:p})]},t)})})},BT=({children:e})=>(0,U.jsx)(`div`,{className:`color-picker__heading`,children:e}),VT=({theme:e,color:t,onChange:n,palette:r,showHotKey:i})=>{let a=vT({color:t||`transparent`,palette:r}),[o,s]=Yb(ST),c=IT(),l=(0,V.useRef)(null);if((0,V.useEffect)(()=>{l.current&&o===`shades`&&l.current.focus()},[a,o]),a){let{colorName:t,shade:u}=a,d=r[t];if(Array.isArray(d))return(0,U.jsx)(`div`,{className:`color-picker-content--default shades`,children:d.map((r,a)=>{let d=Rt(r,e===M.DARK);return(0,U.jsxs)(`button`,{ref:a===u&&o===`shades`?l:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large`,{active:a===u}),"aria-label":`Shade`,title:`${t} - ${a+1}`,style:r?{"--swatch-color":d}:void 0,onClick:()=>{n(r),s(`shades`)},onPointerDown:c?e=>c.startSourceDrag(e,r):void 0,children:[(0,U.jsx)(`div`,{className:`color-picker__button-outline`}),i&&(0,U.jsx)(TT,{color:d,keyLabel:a+1,isShade:!0})]},a)})})}return(0,U.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,U.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,U.jsx)(`div`,{tabIndex:-1,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,display:`flex`,alignItems:`center`,justifyContent:`center`,textAlign:`center`,fontSize:`0.75rem`},children:G(`colorPicker.noShades`)})]})},HT=(e,t,n)=>{let r=Math.ceil(n/5);switch(t??=-1,e){case`ArrowLeft`:{let e=t-1;return e<0?n-1:e}case`ArrowRight`:return(t+1)%n;case`ArrowDown`:{let e=t+5;return e>=n?t%5:e}case`ArrowUp`:{let e=t-5,i=e<0?5*r+e:e;return i>=n?void 0:i}}},UT=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:o,excludedColors:s})=>{if(t?.shade!=null&&[`Digit1`,`Digit2`,`Digit3`,`Digit4`,`Digit5`].includes(e.code)&&e.shiftKey){let i=Number(e.code.slice(-1))-1;return n(r[t.colorName][i]),a(`shades`),!0}if([`1`,`2`,`3`,`4`,`5`].includes(e.key)&&i[Number(e.key)-1])return n(i[Number(e.key)-1]),a(`custom`),!0;if(yT.includes(e.key)){let t=yT.indexOf(e.key),i=r[Object.keys(r)[t]],c=Array.isArray(i)?i[o]:i;return c==null||s?.includes(c)||(n(c),a(`baseColors`)),!0}return!1},WT=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:a,setActiveColorPickerSection:o,updateData:s,activeShade:c,onEyeDropperToggle:l,onEscape:u,excludedColors:d})=>{if(e[z.CTRL_OR_CMD])return!1;if(e.key===z.ESCAPE)return u(e),!0;if(e.key===z.ALT)return l(!0),!0;if(e.key===z.I)return l(),!0;let f=vT({color:r,palette:n});if(e.key===z.TAB){let s={custom:!!a.length,baseColors:!0,shades:f?.shade!=null,hex:!0},c=Object.entries(s).reduce((e,[t,n])=>(n&&e.push(t),e),[]),l=c.indexOf(t),u=e.shiftKey?-1:1,d=c[l+u>c.length-1?0:l+u<0?c.length-1:l+u];return d&&o(d),d===`custom`?i(a[0]):d===`baseColors`&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(r):t===r?e:null)||i($c.black)),e.preventDefault(),e.stopPropagation(),!0}if(UT({e,colorObj:f,onChange:i,palette:n,customColors:a,setActiveColorPickerSection:o,activeShade:c,excludedColors:d}))return!0;if(t===`shades`&&f){let{shade:t}=f,r=HT(e.key,t,5);if(r!==void 0)return i(n[f.colorName][r]),!0}if(t===`baseColors`&&f){let{colorName:t}=f,r=Object.keys(n),a=r.indexOf(t),o=HT(e.key,a,r.length),s=0;for(;o!==void 0&&s++<r.length;){let t=n[r[o]],i=Array.isArray(t)?t[c]:t;if(!d?.includes(i))break;o=HT(e.key,o,r.length)}if(o!==void 0){let e=n[r[o]];return i(Array.isArray(e)?e[c]:e),!0}}if(t===`custom`){let t=r==null?0:a.indexOf(r),n=HT(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},GT=V.forwardRef(({theme:e,color:t,onChange:n,type:r,elements:i,palette:a,updateData:o,children:s,showTitle:c,onEyeDropperToggle:l,onEscape:u,showHotKey:d=!0,excludedColors:f,onResetTopPicks:p},m)=>{let h=c?r===`elementStroke`?G(`labels.stroke`):r===`elementBackground`?G(`labels.background`):null:null,[g]=V.useState(()=>r===`canvasBackground`?[]:xT(i,r,a)),[_,v]=Yb(ST),y=IT(),b=vT({color:t,palette:a});(0,V.useEffect)(()=>{if(!_){let e=!!t&&bT({color:t,palette:a}),n=e&&!g.includes(t);v(n?null:e?`custom`:b?.shade==null?`baseColors`:`shades`)}},[_,t,a,v,b,g]);let[x,S]=(0,V.useState)(b?.shade??(r===`elementBackground`?1:4));(0,V.useEffect)(()=>{b?.shade!=null&&S(b.shade);let e=e=>{e.key===z.ALT&&l(!1)};return document.addEventListener(P.KEYUP,e,{capture:!0}),()=>{document.removeEventListener(P.KEYUP,e,{capture:!0})}},[b,l]);let C=V.useRef(null);return(0,V.useImperativeHandle)(m,()=>C.current),(0,V.useEffect)(()=>{C?.current?.focus()},[]),(0,U.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":G(`labels.colorPicker`),children:(0,U.jsxs)(`div`,{ref:C,onKeyDown:e=>{WT({event:e,activeColorPickerSection:_,palette:a,color:t,onChange:n,onEyeDropperToggle:l,customColors:g,setActiveColorPickerSection:v,updateData:o,activeShade:x,onEscape:u,excludedColors:f})&&(e.preventDefault(),e.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[h&&(0,U.jsx)(`div`,{className:`color-picker__title`,children:h}),!!g.length&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(BT,{children:G(`colorPicker.mostUsedCustomColors`)}),(0,U.jsx)(RT,{theme:e,colors:g,color:t,label:G(`colorPicker.mostUsedCustomColors`),onChange:n})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(BT,{children:G(`colorPicker.colors`)}),(0,U.jsx)(zT,{theme:e,color:t,palette:a,onChange:n,activeShade:x,showHotKey:d,excludedColors:f})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(BT,{children:G(`colorPicker.shades`)}),(0,U.jsx)(VT,{theme:e,color:t,onChange:n,palette:a,showHotKey:d})]}),s,y&&(0,U.jsx)(wT,{tip:G(`colorPicker.topPicksTip`),onReset:p,resetTitle:G(`colorPicker.resetTopPicks`)})]})})}),KT=({children:e,onReset:t,isCustomized:n,resetLabel:r})=>{let{container:i}=lW();return t?(0,U.jsxs)(hv,{children:[(0,U.jsx)(gv,{asChild:!0,children:e}),(0,U.jsx)(_v,{container:i,children:(0,U.jsx)(vv,{className:`top-picks-dnd__context-menu`,style:{zIndex:`var(--zIndex-ui-styles-popup)`},children:(0,U.jsx)(yv,{className:`top-picks-dnd__context-menu-item`,disabled:!n,onSelect:t,children:r})})})]}):e},qT=({theme:e,onChange:t,type:n,activeColor:r,topPicks:i,onReset:a,isCustomized:o})=>{let s=IT(),c=s?.dragState??null,l;return n===`elementStroke`&&(l=Ms),n===`elementBackground`&&(l=zn),n===`canvasBackground`&&(l=_o),i&&(l=i),l?(0,U.jsx)(KT,{onReset:a,isCustomized:!!o,resetLabel:G(`colorPicker.resetTopPicks`),children:(0,U.jsxs)(`div`,{className:H(`color-picker__top-picks top-picks-dnd`,{"is-dnd-active":!!c}),ref:s?.setStripEl,children:[c&&(0,U.jsx)(jT,{}),l.map((n,i)=>{let a=AT(c,i),o=Rt(n,e===M.DARK);return(0,U.jsx)(`button`,{className:H(`color-picker__button top-picks-dnd__pick`,{active:n===r,"is-transparent":n===`transparent`||!n,"has-outline":!ds(n,240),"is-dnd-source":c?.origin.kind===`pick`&&c.origin.index===i,"is-dnd-target":c?.origin.kind===`source`&&c.overIndex===i,"is-dnd-duplicate":c?.duplicateIndex===i}),style:{"--swatch-color":o,transform:a?`translateX(${a}px)`:void 0},type:`button`,title:n,onClick:()=>t(n),onPointerDown:s?e=>s.startPickDrag(e,i,n):void 0,"data-testid":`color-top-pick-${n}`,"data-top-pick-index":i,children:(0,U.jsx)(`div`,{className:`color-picker__button-outline`})},n)})]})}):(console.error(`Invalid type for TopPicks`),null)},JT=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=$c,updateData:o,getOpenPopup:s,appState:c,excludedColors:l,onResetTopPicks:u})=>{let{container:d}=lW(),f=aW(),p=cW(),m=p!==`full`,h=p===`mobile`,[,g]=Yb(ST),[v,y]=Yb(cT),b=(0,U.jsxs)(`div`,{children:[(0,U.jsx)(BT,{children:G(`colorPicker.hexCode`)}),(0,U.jsx)(CT,{color:t||``,label:r,onChange:e=>{n(e)},colorPickerType:e,placeholder:G(`colorPicker.color`)})]}),x=(0,V.useRef)(null),S=()=>{x.current?.focus()};return(0,U.jsx)(dT,{container:d,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!c.editingTextElement,onFocusOutside:e=>{let t=e.target;if(t instanceof f.ownerWindow.HTMLElement&&t.closest(`.top-picks-dnd__context-menu`)){e.preventDefault();return}_(e.target)||(t instanceof f.ownerWindow.HTMLElement&&t.matches(`:active`)?f.ownerWindow.addEventListener(`pointerup`,S,{once:!0}):S()),e.preventDefault()},onPointerDownOutside:e=>{v&&e.preventDefault()},onClose:()=>{s()===e&&o({openPopup:null}),g(null),c.editingTextElement&&f.ownerWindow.setTimeout(()=>{let e=f.ownerDocument.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},children:a?(0,U.jsx)(GT,{ref:x,palette:a,excludedColors:l,onResetTopPicks:u,color:t,theme:c.theme,onChange:e=>{let t=c.editingTextElement?pT(f.ownerDocument):null;n(e),c.editingTextElement&&t&&mT(t,f.ownerDocument)},onEyeDropperToggle:t=>{y(r=>t?(r||={keepOpenOnAlt:!0,onSelect:n,colorPickerType:e},r.keepOpenOnAlt=!0,r):t===!1||r?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:e=>{v?y(null):o({openPopup:null})},type:e,elements:i,updateData:o,showTitle:m,showHotKey:!h,children:b}):b})},YT=e=>e===`elementStroke`||e===`elementBackground`||e===`canvasBackground`,XT=({label:e,color:t,type:n,theme:r,mode:i=`background`,onToggle:a,editingTextElement:o})=>{let s=aW(),c=cW(),l=c!==`full`,u=c===`mobile`,d=IT(),f=t?Rt(t,r===M.DARK):null;return(0,U.jsxs)(Py,{type:`button`,className:H(`color-picker__button active-color properties-trigger`,{"is-transparent":!t||t===`transparent`,"has-outline":!t||!ds(t,240),"compact-sizing":l,"mobile-border":u}),"aria-label":e,style:f?{"--swatch-color":f}:void 0,title:G(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),"data-openpopup":n,onClick:e=>{e.preventDefault(),e.stopPropagation(),o&&_T(s.ownerDocument),a()},onPointerDown:d?e=>d.startSourceDrag(e,t):void 0,children:[(0,U.jsx)(`div`,{className:`color-picker__button-outline`,children:!t&&uS}),l&&t&&i===`stroke`&&(0,U.jsx)(`div`,{className:`color-picker__button-background`,children:(0,U.jsx)(`span`,{style:{color:f&&ds(f,240)?`#fff`:`#111`},children:kw})})]})},ZT=(0,V.memo)(({type:e,color:t,onChange:n,label:r,elements:i,palette:a=$c,topPicks:o,updateData:s,appState:c,excludedColors:l,customizableTopPicks:u})=>{let d=(0,V.useRef)(c.openPopup);(0,V.useEffect)(()=>{d.current=c.openPopup},[c.openPopup]);let f=cW()!==`full`,p=!!u&&!f,m=p&&u?c.colorTopPicks?.[u]:null,h=m?.length?m:o??(e===`elementStroke`?Ms:zn),g=p&&u?()=>{s({colorTopPicks:{...c.colorTopPicks,[u]:null}})}:void 0,_=LT({enabled:p,picks:h,onPicksChange:e=>{u&&s({colorTopPicks:{...c.colorTopPicks,[u]:e}})}});return(0,U.jsx)(FT.Provider,{value:p?_:null,children:(0,U.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:H(`color-picker-container`,{"color-picker-container--no-top-picks":f}),children:[!f&&(0,U.jsx)(qT,{theme:c.theme,activeColor:t,onChange:t=>{n(t),YT(c.openPopup)&&c.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:m?.length?m:o,isCustomized:!!m?.length,onReset:g}),!f&&(0,U.jsx)(Qw,{}),(0,U.jsxs)(Ny,{open:c.openPopup===e,onOpenChange:t=>{t&&s({openPopup:e})},children:[(0,U.jsx)(XT,{color:t,label:r,type:e,theme:c.theme,mode:e===`elementStroke`?`stroke`:`background`,editingTextElement:!!c.editingTextElement,onToggle:()=>{c.openPopup===e?s({openPopup:null}):(c.openPopup,s({openPopup:e}))}}),c.openPopup===e&&(0,U.jsx)(JT,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,excludedColors:l,updateData:s,getOpenPopup:()=>d.current,appState:c,onResetTopPicks:m?.length?g:void 0})]})]})})},(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),QT=V.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,U.jsxs)(`div`,{className:H(`QuickSearch__wrapper`,e),children:[ew,(0,U.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),$T=({className:e,placeholder:t,children:n})=>{let r=!V.Children.count(n);return(0,U.jsx)(`div`,{className:H(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,U.jsx)(`div`,{className:`empty`,children:t}):n})},eE=({children:e,className:t=``,style:n,title:r})=>(0,U.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,U.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),tE=eE;eE.displayName=`DropdownMenuGroup`;var nE=V.createContext({}),rE=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),iE=e=>{let t=(0,V.useContext)(nE);return ys(e,e=>{t.onSelect?.(e)})},aE=({children:e,...t})=>(0,U.jsx)(`span`,{...t,style:{textOverflow:`ellipsis`,overflow:`hidden`,whiteSpace:`nowrap`,...t.style},children:e}),oE=({textStyle:e,icon:t,shortcut:n,children:r,badge:i})=>{let a=sW();return(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,U.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:(0,U.jsx)(aE,{children:r})}),i&&(0,U.jsx)(`div`,{className:`dropdown-menu-item__badge`,children:i}),n&&a.formFactor!==`phone`&&(0,U.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},sE=({icon:e,badge:t,value:n,children:r,shortcut:i,className:a,selected:o,onSelect:s,...c})=>{let l=iE(s);return(0,U.jsx)(ry,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,U.jsx)(`button`,{...c,value:n,className:rE(a,o),title:c.title??c[`aria-label`],children:(0,U.jsx)(oE,{icon:e,shortcut:i,badge:t,children:r})})})};sE.displayName=`DropdownMenuItem`;var cE={GREEN:`green`,RED:`red`,BLUE:`blue`},lE=({type:e=cE.BLUE,children:t})=>{let{theme:n}=dW(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===M.LIGHT?`1.5px solid white`:`none`};switch(e){case cE.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case cE.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case cE.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,U.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};lE.displayName=`DropdownMenuItemBadge`,sE.Badge=lE;var uE=sE,dE=({sourceEl:e,stripEl:t})=>{let n=e.dataset.topPickIndex!=null,r=(n?e:t.querySelector(`[data-top-pick-index]:not(.active)`))??t.querySelector(`[data-top-pick-index]`),i=getComputedStyle(r),a=r.getBoundingClientRect(),o=document.createElement(`div`);o.className=`excalidraw-font-dnd-ghost-tile`,o.style.backgroundColor=i.backgroundColor,o.style.color=i.color,o.style.borderStyle=`solid`,o.style.borderWidth=i.borderTopWidth,o.style.borderColor=i.borderTopColor,o.style.borderRadius=i.borderTopLeftRadius;let s=e.querySelector(`svg`);if(s){let e=r.querySelector(`svg`)?.getBoundingClientRect(),t=s.cloneNode(!0);e&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`),o.appendChild(t)}else{let t=e.querySelector(`.FontPicker__top-pick-sample`);if(t){let e=t.cloneNode(!0);e.style.fontSize=getComputedStyle(t).fontSize,e.style.lineHeight=`1`,o.appendChild(e)}}if(n)return{content:o,rect:a};let c=(s??e).getBoundingClientRect();return{content:o,rect:new DOMRect(c.left+c.width/2-a.width/2,c.top+c.height/2-a.height/2,a.width,a.height)}},fE=(0,V.createContext)(null),pE=()=>(0,V.useContext)(fE),mE=({enabled:e,picks:t,onPicksChange:n})=>MT({enabled:e,picks:t,onPicksChange:n,createGhost:dE}),hE=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===z.F)return t.current?.focus(),!0;if(e.key===z.ESCAPE)return i(),!0;if(e.key===z.ENTER)return n?.value&&a(n.value),!0;if(e.key===z.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===z.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},gE=e=>{switch(e){case Yn.Excalifont:case Yn.Virgil:return Ix;case Yn.Nunito:case Yn.Helvetica:return bC;case Yn[`Lilita One`]:return yC;case Yn[`Comic Shanns`]:case Yn.Cascadia:return SC;default:return bC}},_E=(e,t)=>Object.entries(Yn).find(([,t])=>t===e)?.[0]??t[0]?.fontFace?.family??`Unknown`,vE=V.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o,onResetTopPicks:s})=>{let{container:c}=lW(),l=aW(),{fonts:u}=l,{showDeprecatedFonts:d}=oW(),f=cW(),p=pE(),[m,h]=(0,V.useState)(``),g=(0,V.useRef)(null),_=(0,V.useMemo)(()=>Array.from(Co.registered.entries()).filter(([e,{metadata:t}])=>!t.private&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:gE(e),text:_E(e,n)};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:cE.RED,placeholder:G(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),v=(0,V.useMemo)(()=>new Set(u.getSceneFamilies()),[e]),y=(0,V.useMemo)(()=>_.filter(e=>v.has(e.value)),[_,v]),b=(0,V.useMemo)(()=>_.filter(e=>!v.has(e.value)&&(d||!e.deprecated)),[_,v,d]),x=(0,V.useMemo)(()=>Nn([...y,...b].filter(e=>e.text?.toLowerCase().includes(m))),[y,b,m]),S=(0,V.useMemo)(()=>{let n;return t?n=x.find(e=>e.value===t):e&&(n=x.find(t=>t.value===e)),!n&&m&&(x[0]?.value?r(x[0].value):i()),n},[t,e,m,x,r,i]),C=(0,V.useCallback)(e=>{let t=null;if(l.state.editingTextElement){let e=document.querySelector(`.excalidraw-wysiwyg`);e&&(t={start:e.selectionStart,end:e.selectionEnd})}n(e),l.state.editingTextElement&&t&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&t&&(e.focus(),e.selectionStart=t.start,e.selectionEnd=t.end)},0)},[n,l.state.editingTextElement]),w=(0,V.useCallback)(e=>{hE({event:e,inputRef:g,hoveredFont:S,filteredFonts:x,onSelect:C,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[S,x,C,r,o]);(0,V.useEffect)(()=>(a(),()=>{o()}),[]);let T=(0,V.useMemo)(()=>x.filter(e=>v.has(e.value)),[x,v]),E=(0,V.useMemo)(()=>x.filter(e=>!v.has(e.value)),[x,v]),D=({font:t,order:n})=>{let i=(0,V.useRef)(null),a=t.value===S?.value,o=t.value===e;return(0,V.useEffect)(()=>{a&&(n===0?i.current?.scrollIntoView?.({block:`end`}):i.current?.scrollIntoView?.({block:`nearest`}))},[a,n]),(0,U.jsx)(`button`,{ref:i,type:`button`,value:t.value,className:rE(``,o,a),title:t.text,tabIndex:o?0:-1,onClick:e=>{C(Number(e.currentTarget.value))},onMouseMove:()=>{!p?.dragState&&S?.value!==t.value&&r(t.value)},onPointerDown:p?e=>p.startSourceDrag(e,t.value):void 0,children:(0,U.jsx)(oE,{icon:t.icon,badge:t.badge&&(0,U.jsx)(lE,{type:t.badge.type,children:t.badge.placeholder}),textStyle:{fontFamily:Ot({fontFamily:t.value})},children:t.text})})},ee=[];return T.length&&ee.push((0,U.jsx)(tE,{title:G(`fontList.sceneFonts`),children:T.map((e,t)=>(0,U.jsx)(D,{font:e,order:t},e.value))},`group_1`)),E.length&&ee.push((0,U.jsx)(tE,{title:G(`fontList.availableFonts`),children:E.map((e,t)=>(0,U.jsx)(D,{font:e,order:t+T.length},e.value))},`group_2`)),(0,U.jsxs)(dT,{className:`properties-content`,container:c,style:{width:`15rem`},onClose:()=>{o(),l.state.editingTextElement&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},onPointerLeave:i,onKeyDown:w,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[f===`full`&&(0,U.jsx)(QT,{ref:g,placeholder:G(`quickSearch.placeholder`),onChange:ml(h,20)}),(0,U.jsx)($T,{className:`dropdown-menu fonts manual-hover`,placeholder:G(`fontList.empty`),children:ee.length?ee:null}),p&&(0,U.jsx)(wT,{className:`FontPicker__tip`,tip:G(`fontList.topPicksTip`),onReset:s,resetTitle:G(`fontList.resetTopPicks`)})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily&&!!e.onResetTopPicks==!!t.onResetTopPicks),yE=({selectedFontFamily:e,isOpened:t=!1,compactMode:n=!1})=>{let r=fW(),i=n?{...Lr,width:`2rem`,height:`2rem`}:{};return(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(`div`,{"data-openpopup":`fontFamily`,className:`properties-trigger`,children:(0,U.jsx)(Y,{type:`toggle`,icon:Lx,title:G(`labels.showFonts`),"aria-label":G(`labels.showFonts`),className:`standalone properties-trigger`,"data-testid":`font-family-show-fonts`,checked:t,onSelect:()=>{r(e=>({openPopup:e.openPopup===`fontFamily`?null:e.openPopup}))},style:{border:`none`,...i}})})})},bE=[{value:Yn.Excalifont,icon:Ix,text:G(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:Yn.Nunito,icon:bC,text:G(`labels.normal`),testId:`font-family-normal`},{value:Yn[`Comic Shanns`],icon:SC,text:G(`labels.code`),testId:`font-family-code`}],xE=bE.map(e=>e.value),SE=new Set(xE),CE=e=>{let t=[...new Set(e)].slice(0,3);for(let e of xE){if(t.length>=3)break;t.includes(e)||t.push(e)}return t},wE=e=>bE.find(t=>t.value===e)??{value:e,icon:gE(e),text:_E(e,Co.registered.get(e)?.fontFaces??[]),testId:`font-family-${e}`},TE=(e,t)=>{if(SE.has(e))return!1;let n=gE(e);return t.some(t=>t!==e&&wE(t).icon===n)},EE=({picks:e,selectedFontFamily:t,onSelect:n,onReset:r,isCustomized:i})=>{let a=pE(),o=a?.dragState??null;return(0,U.jsx)(KT,{onReset:r,isCustomized:i,resetLabel:G(`fontList.resetTopPicks`),children:(0,U.jsx)(`div`,{className:`buttonList FontPicker__top-picks`,children:(0,U.jsxs)(`div`,{className:H(`FontPicker__top-picks-slots top-picks-dnd`,{"is-dnd-active":!!o}),ref:a?.setStripEl,children:[o&&(0,U.jsx)(jT,{}),e.map((r,i)=>{let s=wE(r),c=AT(o,i);return(0,U.jsx)(`button`,{type:`button`,title:s.text,"data-testid":s.testId,className:H(`top-picks-dnd__pick`,{active:r===t,"is-dnd-source":o?.origin.kind===`pick`&&o.origin.index===i,"is-dnd-target":o?.origin.kind===`source`&&o.overIndex===i,"is-dnd-duplicate":o?.duplicateIndex===i}),style:c?{transform:`translateX(${c}px)`}:void 0,onClick:()=>n(r),onPointerDown:a?e=>a.startPickDrag(e,i,r):void 0,"data-top-pick-index":i,children:TE(r,e)?(0,U.jsx)(`span`,{className:`FontPicker__top-pick-sample`,style:{fontFamily:Ot({fontFamily:r})},children:`Aa`}):s.icon},r)})]})})})},DE=V.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,topPicks:r,onSelect:i,onTopPicksChange:a,onHover:o,onLeave:s,onPopupChange:c,compactMode:l=!1})=>{let u=(0,V.useCallback)(e=>{e&&i(e)},[i]),d=!l,f=!!r?.length,p=r?.length?CE(r):xE,m=()=>a(null),h=mE({enabled:d,picks:p,onPicksChange:a});return(0,U.jsx)(fE.Provider,{value:d?h:null,children:(0,U.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:H(`FontPicker__container`,{"FontPicker__container--compact":l}),children:[!l&&(0,U.jsx)(EE,{picks:p,selectedFontFamily:t,onSelect:u,isCustomized:f,onReset:d?m:void 0}),!l&&(0,U.jsx)(Qw,{}),(0,U.jsxs)(Ny,{open:e,onOpenChange:c,children:[(0,U.jsx)(yE,{selectedFontFamily:t,isOpened:e,compactMode:l}),e&&(0,U.jsx)(vE,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:u,onHover:o,onLeave:s,onOpen:()=>c(!0),onClose:()=>c(!1),onResetTopPicks:d&&f?m:void 0})]})]})})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily&&e.topPicks===t.topPicks&&e.compactMode===t.compactMode),OE=({className:e,icon:t,size:n=`1em`})=>(0,U.jsx)(`span`,{className:e,style:{width:n,height:`100%`,margin:`0 0.5ex 0 0.5ex`,display:`inline-flex`,lineHeight:0,verticalAlign:`middle`,flex:`0 0 auto`},children:t}),kE=({label:e,open:t,openTrigger:n,children:r,className:i,showCollapsedIcon:a=!0})=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,a&&(0,U.jsx)(OE,{icon:t?ww:Cw})]}),t&&(0,U.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),AE=Dl(!1),jE=4,ME=`default`,NE=e=>e.flatMap(e=>e.options),PE=(e,t)=>{for(let n of e){let e=n.options.find(t);if(e)return e}return null},FE=(e,t)=>e.some(e=>e.options.some(t)),IE=e=>e.flatMap(e=>Array.from({length:Math.ceil(e.options.length/jE)},(t,n)=>e.options.slice(n*jE,n*jE+jE)));function LE({visibleSections:e,hiddenSections:t=[],value:n,label:r,onChange:i,onClose:a}){let{container:o}=lW(),[s,c]=Yb(AE),l=NE([...e,...t]),u=IE([...e,...s?t:[]]),d=e=>{let t=l.find(t=>t.keyBinding===e.key.toLowerCase());if(!(e.metaKey||e.altKey||e.ctrlKey)&&t)i(t.value),e.preventDefault();else if(e.key===z.TAB){let t=l.findIndex(e=>e.value===n),r=e.shiftKey?(l.length+t-1)%l.length:(t+1)%l.length;i(l[r].value)}else if(Pt(e.key)){let t=lx().rtl,r=l.findIndex(e=>e.value===n);if(r!==-1){let a=l.length,o=r;switch(e.key){case t?z.ARROW_LEFT:z.ARROW_RIGHT:o=(r+1)%a;break;case t?z.ARROW_RIGHT:z.ARROW_LEFT:o=(a+r-1)%a;break;case z.ARROW_DOWN:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(t+1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}case z.ARROW_UP:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(u.length+t-1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}}i(l[o].value)}e.preventDefault()}else(e.key===z.ESCAPE||e.key===z.ENTER)&&(e.preventDefault(),a());e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()};(0,V.useEffect)(()=>{FE(t,e=>e.value===n)&&c(!0)},[n,t,c]);let f=e=>(0,U.jsx)(`div`,{className:`picker-content`,children:e.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:H(`picker-option`,{active:n===e.value}),onClick:()=>{i(e.value)},title:e.keyBinding?`${e.text} \u2014 ${e.keyBinding.toUpperCase()}`:e.text,"aria-label":e.text||`none`,"aria-keyshortcuts":e.keyBinding||void 0,ref:t=>{n===e.value&&setTimeout(()=>{t?.focus()},0)},children:[e.icon,e.keyBinding&&(0,U.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))}),p=e=>e.map((e,t)=>e.name===ME?(0,U.jsx)(V.Fragment,{children:f(e.options)},`${e.name}-${t}`):(0,U.jsxs)(`div`,{className:`picker-section`,children:[(0,U.jsx)(`div`,{className:`picker-section-label`,children:e.name}),f(e.options)]},`${e.name}-${t}`));return(0,U.jsx)(Iy,{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:d,collisionBoundary:o??void 0,children:(0,U.jsxs)(`div`,{className:`picker-sections`,children:[p(e),t.length>0&&(0,U.jsx)(kE,{label:G(`labels.more_options`),open:s,openTrigger:()=>{c(e=>!e)},className:`picker-collapsible`,children:(0,U.jsx)(`div`,{className:`picker-sections`,children:p(t)})})]})})}function RE({value:e,label:t,visibleSections:n,hiddenSections:r,onChange:i}){let[a,o]=V.useState(!1),s=(0,V.useMemo)(()=>PE(n,t=>t.value===e)??PE(r??[],t=>t.value===e),[n,r,e]);return(0,U.jsx)(`div`,{children:(0,U.jsxs)(Ny,{open:a,onOpenChange:e=>o(e),children:[(0,U.jsx)(Py,{type:`button`,"aria-label":t,onClick:()=>o(!a),className:a?`active`:``,children:s?.icon}),a&&(0,U.jsx)(LE,{visibleSections:n,hiddenSections:r,value:e,label:t,onChange:i,onClose:()=>{o(!1)}})]})})}var zE=({label:e,value:t,onChange:n,min:r=0,max:i=100,step:a=10,minLabel:o=r,hasCommonValue:s=!0,testId:c})=>{let l=(t-r)/(i-r||1);return(0,U.jsxs)(`label`,{className:`control-label`,children:[e,(0,U.jsxs)(`div`,{className:`range-wrapper`,style:{"--range-progress":l},children:[(0,U.jsx)(`input`,{style:{"--color-slider-track":s?void 0:`var(--button-bg)`},type:`range`,min:r,max:i,step:a,onChange:e=>{n(+e.target.value)},value:t,className:`range-input`,"data-testid":c}),(0,U.jsx)(`div`,{className:`value-bubble`,children:t===r?null:t}),(0,U.jsx)(`div`,{className:`zero-label`,children:o})]})]})},BE={strokeColor:{regular:`currentItemStrokeColor`,sticky:`currentItemStickynoteStrokeColor`},backgroundColor:{regular:`currentItemBackgroundColor`,sticky:`currentItemStickynoteBackgroundColor`}},VE=[$c.transparent],HE=(e,t)=>x(e)||D(e)&&mo(e,t),UE=(e,t,n)=>{let r=y(t),i=e=>n===`strokeColor`?qa(e.type):Tc(e.type),a=Kc(t,e,{includeBoundTextElement:n===`strokeColor`}).filter(i),o=e.editingTextElement&&r.get(e.editingTextElement.id),s=o&&ei(o,n,r);s&&!s.isDeleted&&i(s)&&!a.some(e=>e.id===s.id)&&a.push(s);let c;if(!a.length)c=e.activeTool.type===`stickynote`?`sticky`:`regular`;else{let e=a.filter(e=>HE(e,r)).length;c=e===0?`regular`:e===a.length?`sticky`:`mixed`}let l=BE[n],u=n===`strokeColor`;return{kind:c,property:n,appStateKeys:c===`mixed`?[l.regular,l.sticky]:[l[c]],currentValue:e[c===`sticky`?l.sticky:l.regular],palette:u?Qo:Cn,topPicks:c===`sticky`?u?Ps:qn:u?Ms:zn,customizableTopPicks:c===`sticky`?u?`stickyNoteStroke`:`stickyNoteBackground`:u?`elementStroke`:`elementBackground`,excludedColors:c===`sticky`?VE:void 0}},WE=(e,t)=>{let n={};for(let r of e.appStateKeys)n[r]=r===`currentItemStickynoteStrokeColor`?Le(t):r===`currentItemStickynoteBackgroundColor`?mr(t):t;return n},GE=.1,KE=e=>{let t=tc(e.editorInterface);return{stylesPanelMode:t,isCompact:t!==`full`,isMobile:t===`mobile`}},qE=(e,t,n,r=!1)=>{let i=y(Kc(e,t,{includeBoundTextElement:r}));return e.map(e=>{if(i.get(e.id)||e.id===t.editingTextElement?.id){Ga(e)||console.error(`[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element`);let t=n(e);return x(t)?pl(t):t}return e})},JE=function(e,t,n,r,i){let a=t.state.editingTextElement,o=en(e),s=null;if(a&&(s=n(a)),!s){if(Gt(o,t.state)){let e=t.scene.getSelectedElements(t.state),a=r===!0?e:e.filter(e=>r(e));s=da(a,n)??(typeof i==`function`?i(!0):i)}else s=typeof i==`function`?i(!1):i}return s},YE=(e,t,n)=>fn(t)||!t.autoResize?t:n.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}),XE=(e,t,n,r,i)=>{let a=new Set,o=n.scene.getNonDeletedElementsMap(),s=qE(e,t,e=>{if(D(e)){let t=r(e);a.add(t);let i=n.scene.getContainerElement(e),s=N(e,te(e,t,o));return ga(s,i,n.scene),s=YE(e,s,n.scene),s}return e},!0);return Kc(e,t,{includeBoundTextElement:!0}).forEach(e=>{D(e)&&bi(e,n.scene)}),{elements:s,appState:{...t,currentItemFontSize:a.size===1?[...a][0]:i??t.currentItemFontSize},captureUpdate:I.IMMEDIATELY}};X({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>{let{color:r,...i}=n??{};if(r===void 0)return{appState:{...t,...i},captureUpdate:I.EVENTUALLY};let a=UE(t,e,`strokeColor`),o=y(e);return{elements:rs(qE(e,t,e=>qa(e.type)?N(e,Wr(e,`strokeColor`,r,o)):e,!0),o),appState:{...t,...i,...WE(a,r)},captureUpdate:I.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=KE(r),a=UE(t,e,`strokeColor`),o=a.kind===`sticky`?G(`labels.textColor`):G(`labels.stroke`);return(0,U.jsxs)(U.Fragment,{children:[i===`full`&&(0,U.jsx)(`h3`,{"aria-hidden":`true`,children:o}),(0,U.jsx)(ZT,{topPicks:a.topPicks,palette:a.palette,customizableTopPicks:a.customizableTopPicks,excludedColors:a.excludedColors,type:`elementStroke`,label:o,color:JE(e,r,e=>e.strokeColor,!0,e=>e?null:a.currentValue),onChange:e=>n({color:e}),elements:e,appState:t,updateData:n})]})}}),X({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n,r)=>{let{color:i,...a}=n??{};if(i===void 0)return{appState:{...t,...a},captureUpdate:I.EVENTUALLY};let o=UE(t,e,`backgroundColor`),s=y(e),c,l=r.scene.getSelectedElements(t);if(!Zr(i)&&l.length>0&&l.every(e=>co(e)&&io(e.points))){let t=y(l);c=e.map(e=>t.has(e.id)&&co(e)?N(e,{backgroundColor:i,...Ze(e,!0)}):e)}else{c=qE(e,t,e=>ei(e,`backgroundColor`,s)===e?N(e,Wr(e,`backgroundColor`,i,s)):e);let n=t.editingTextElement&&s.get(t.editingTextElement.id),r=n&&ei(n,`backgroundColor`,s);r&&r!==n&&(c=c.map(e=>e.id===r.id?N(e,Wr(e,`backgroundColor`,i,s)):e))}return{elements:c,appState:{...t,...a,...WE(o,i)},captureUpdate:I.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=KE(r),a=UE(t,e,`backgroundColor`),o=r.scene.getNonDeletedElementsMap();return(0,U.jsxs)(U.Fragment,{children:[i===`full`&&(0,U.jsx)(`h3`,{"aria-hidden":`true`,children:G(`labels.background`)}),(0,U.jsx)(ZT,{topPicks:a.topPicks,palette:a.palette,customizableTopPicks:a.customizableTopPicks,excludedColors:a.excludedColors,type:`elementBackground`,label:G(`labels.background`),color:JE(e,r,e=>ei(e,`backgroundColor`,o).backgroundColor,!0,e=>e?null:a.currentValue),onChange:e=>n({color:e}),elements:e,appState:t,updateData:n})]})}});var ZE=X({name:`changeBucketFillBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:I.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=KE(r);return(0,U.jsxs)(U.Fragment,{children:[i===`full`&&(0,U.jsx)(`h3`,{"aria-hidden":`true`,children:G(`labels.background`)}),(0,U.jsx)(ZT,{topPicks:ls,palette:Cn,excludedColors:[$c.transparent],customizableTopPicks:`bucketFill`,type:`elementBackground`,label:G(`labels.background`),color:r.bucketFill.getBucketFillBackgroundColor(t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});X({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(Yw(`element`,`changeFillStyle`,`${n} (${r.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),{elements:qE(e,t,e=>ut(e.type)?N(e,{fillStyle:n}):e),appState:{...t,currentItemFillStyle:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=Kc(e,t).filter(e=>ut(e.type)),a=i.length>0&&i.every(e=>e.fillStyle===`zigzag`);return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.fill`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{type:`button`,options:[{value:`hachure`,text:`${G(a?`labels.zigzag`:`labels.hachure`)} (${Z(`Alt-Click`)})`,icon:a?LS:RS,active:a?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:G(`labels.crossHatch`),icon:zS,testId:`fill-cross-hatch`},{value:`solid`,text:G(`labels.solid`),icon:BS,testId:`fill-solid`}],value:JE(e,r,e=>e.fillStyle,e=>ut(e.type),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&e===`hachure`&&i.every(e=>e.fillStyle===`hachure`)?`zigzag`:e)}})})]})}});var QE=e=>Xe.find(t=>lo(e.type,t)===e.strokeWidth)??null,$E=(e,t)=>lo(e.type,t);X({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>(E(n,`actionChangeStrokeWidth: value must be defined`),{elements:qE(e,t,e=>N(e,{strokeWidth:$E(e,n)})),appState:{...t,currentItemStrokeWidthKey:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.strokeWidth`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`stroke-width`,options:[{value:`thin`,text:G(`labels.thin`),icon:VS,testId:`strokeWidth-thin`},{value:`medium`,text:G(`labels.medium`),icon:HS,testId:`strokeWidth-medium`},{value:`bold`,text:G(`labels.bold`),icon:US,testId:`strokeWidth-bold`}],value:JE(e,r,QE,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidthKey),onChange:e=>n(e)})})]})}),X({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:qE(e,t,e=>N(e,{seed:eo(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.sloppiness`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`sloppiness`,options:[{value:0,text:G(`labels.architect`),icon:KS},{value:1,text:G(`labels.artist`),icon:qS},{value:2,text:G(`labels.cartoonist`),icon:JS}],value:JE(e,r,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})})]})}),X({name:`changeFreedrawMode`,label:`labels.pressure`,trackEvent:!1,perform:(e,t,n)=>{let r=n||`constant`;return{elements:qE(e,t,e=>e.type===`freedraw`?N(e,{strokeOptions:{...e.strokeOptions,variability:r}}):e),appState:{...t,currentItemStrokeVariability:r},captureUpdate:I.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=JE(e,r,e=>e.strokeOptions?.variability,e=>e.type===`freedraw`,e=>e?null:t.currentItemStrokeVariability)??t.currentItemStrokeVariability;if(i?.cycle){let e=a===`variable`;return(0,U.jsx)(Y,{type:`button`,icon:e?XS:YS,title:G(`labels.pressure`),"aria-label":G(`labels.pressure`),onClick:()=>n(e?`constant`:`variable`)})}return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.pressure`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`strokeOptions.variability`,options:[{value:`constant`,text:G(`labels.pressure_constant`),icon:YS},{value:`variable`,text:G(`labels.pressure_variable`),icon:XS}],value:a,onChange:e=>n(e)})})]})}}),X({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:qE(e,t,e=>N(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.strokeStyle`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`strokeStyle`,options:[{value:`solid`,text:G(`labels.strokeStyle_solid`),icon:VS},{value:`dashed`,text:G(`labels.strokeStyle_dashed`),icon:WS},{value:`dotted`,text:G(`labels.strokeStyle_dotted`),icon:GS}],value:JE(e,r,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})})]})}),X({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:qE(e,t,e=>N(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=JE(e,n,e=>e.opacity,!0,e=>e?null:t.currentItemOpacity);return(0,U.jsx)(zE,{label:G(`labels.opacity`),value:i??t.currentItemOpacity,hasCommonValue:i!==null,onChange:r,min:0,max:100,step:10,testId:`opacity`})}}),X({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>XE(e,t,r,()=>(E(n,`actionChangeFontSize: Expected a font size value`),n),n),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=KE(r);return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.fontSize`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`font-size`,options:[{value:xs.sm,text:G(`labels.small`),icon:mC,testId:`fontSize-small`},{value:xs.md,text:G(`labels.medium`),icon:hC,testId:`fontSize-medium`},{value:xs.lg,text:G(`labels.large`),icon:gC,testId:`fontSize-large`},{value:xs.xl,text:G(`labels.veryLarge`),icon:_C,testId:`fontSize-veryLarge`}],value:JE(e,r,e=>{let t=r.scene.getNonDeletedElementsMap();if(D(e))return Zt(e,t);let n=Sn(e,t);return n?Zt(n,t):null},e=>D(e)||Sn(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>{hT(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})]})}});var eD=X({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:vC,trackEvent:!1,perform:(e,t,n,r)=>XE(e,t,r,e=>Math.round(1/(1+GE)*Zt(e,r.scene.getNonDeletedElementsMap()))),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&(e.key===z.CHEVRON_LEFT||e.key===z.COMMA)}),tD=X({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:vC,trackEvent:!1,perform:(e,t,n,r)=>XE(e,t,r,e=>Math.round(Zt(e,r.scene.getNonDeletedElementsMap())*(1+GE))),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&(e.key===z.CHEVRON_RIGHT||e.key===z.PERIOD)});X({name:`changeFontFamily`,label:`labels.fontFamily`,trackEvent:!1,perform:(e,t,n,r)=>{let{cachedElements:i,resetAll:a,resetContainers:o,...s}=n;if(a)return{elements:qE(e,t,e=>{let t=i?.get(e.id);return t?N(e,{...t}):e},!0),appState:{...t,...s},captureUpdate:I.NEVER};E(n,`actionChangeFontFamily: value must be defined`);let{currentItemFontFamily:c,currentHoveredFontFamily:l}=n,u=I.EVENTUALLY,d,f=!1;if(c)d=c,u=I.IMMEDIATELY;else if(l){d=l,u=I.EVENTUALLY;let n=Kc(e,t,{includeBoundTextElement:!0}).filter(e=>D(e));if(n.length>200)f=!0;else{let e=0,t=0;for(;e<n.length&&t<5e3;){let r=n[e];t+=r?.originalText.length||0,e++}t>5e3&&(f=!0)}}let p={appState:{...t,...s},captureUpdate:u};if(d&&!f){let n=new Map,a=new Set,s=!1,u=Array.from(Co.loadedFontsCache.values()),f=Object.entries(Yn).find(([e,t])=>t===d)?.[0];l&&f&&u.some(e=>e.startsWith(f))&&(s=!0),Object.assign(p,{elements:qE(e,t,e=>{if(D(e)&&(e.fontFamily!==d||c)){let t=N(e,{fontFamily:d,lineHeight:$n(d)}),c=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return o&&l&&c&&r.scene.mutateElement(l,{...c}),s||(a=new Set([...a,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let m=`10px ${Ot({fontFamily:d})}`,h=Array.from(a.values()).join(),g=r.props.ownerDocument??document;if(s||g.fonts.check(m,h))for(let[e,t]of n)ga(e,t,r.scene);else g.fonts.load(m,h).then(e=>{for(let[e,t]of n){let n=r.scene.getElement(e.id),i=t?r.scene.getElement(t.id):null;n&&ga(n,i,r.scene)}r.fonts.onLoaded(e)})}return p},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,V.useRef)(new Map),a=(0,V.useRef)(null),[o,s]=(0,V.useState)({}),c=(0,V.useRef)(!0),{stylesPanelMode:l,isCompact:u}=KE(n),d=(0,V.useMemo)(()=>{let r=(e,r)=>JE(e,n,e=>{if(D(e))return e.fontFamily;let t=Sn(e,r);return t?t.fontFamily:null},e=>D(e)||Sn(e,r)!==null,e=>e?null:t.currentItemFontFamily||_a);return o.openPopup===`fontFamily`&&t.openPopup===`fontFamily`?r(Array.from(i.current?.values()??[]),i.current):!o.openPopup&&t.openPopup!==`fontFamily`?r(e,n.scene.getNonDeletedElementsMap()):a.current},[o.openPopup,t,e,n]);return(0,V.useEffect)(()=>{a.current=d},[d]),(0,V.useEffect)(()=>{Object.keys(o).length&&(r(o),s({}))},[o]),(0,V.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,U.jsxs)(U.Fragment,{children:[l===`full`&&(0,U.jsx)(`legend`,{children:G(`labels.fontFamily`)}),(0,U.jsx)(DE,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:d,hoveredFontFamily:t.currentHoveredFontFamily,topPicks:t.fontTopPicks,compactMode:l!==`full`,onTopPicksChange:e=>r({fontTopPicks:e}),onSelect:e=>{hT(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},u,!!t.editingTextElement)},onHover:e=>{s({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:r=>{if(r){i.current.clear();let{editingTextElement:r}=t;if(r?.type===`text`){let e=n.scene.getElement(r.id);i.current.set(r.id,N(e||r,{},!0))}else{let n=Kc(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,N(e,{},!0))}s({...o,openPopup:`fontFamily`})}else{let e={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...e}),i.current.clear(),u&&t.editingTextElement&&mT(null,n.ownerDocument)}}})]})}}),X({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:qE(e,t,e=>{if(D(e)){let t=N(e,{textAlign:n});return ga(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=r.scene.getNonDeletedElementsMap(),{isCompact:o}=KE(r);return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.textAlign`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`text-align`,options:[{value:`left`,text:G(`labels.left`),icon:CC,testId:`align-left`},{value:`center`,text:G(`labels.center`),icon:wC,testId:`align-horizontal-center`},{value:`right`,text:G(`labels.right`),icon:TC,testId:`align-right`}],value:JE(e,r,e=>{if(D(e))return e.textAlign;let t=Sn(e,a);return t?t.textAlign:null},e=>D(e)||Sn(e,a)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>{hT(()=>n(e),o,!!t.editingTextElement,i?.onPreventClose)}})})]})}}),X({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:qE(e,t,e=>{if(D(e)){let t=N(e,{verticalAlign:n});return ga(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=KE(r);return(0,U.jsx)(`fieldset`,{children:(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`text-align`,options:[{value:Oc.TOP,text:G(`labels.alignTop`),icon:(0,U.jsx)(EC,{theme:t.theme}),testId:`align-top`},{value:Oc.MIDDLE,text:G(`labels.centerVertically`),icon:(0,U.jsx)(OC,{theme:t.theme}),testId:`align-middle`},{value:Oc.BOTTOM,text:G(`labels.alignBottom`),icon:(0,U.jsx)(DC,{theme:t.theme}),testId:`align-bottom`}],value:JE(e,r,e=>{if(D(e)&&e.containerId)return e.verticalAlign;let t=Sn(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>D(e)||Sn(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:Oc.MIDDLE),onChange:e=>{hT(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})})}}),X({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:qE(e,t,e=>vn(e)?e:N(e,{roundness:n===`round`?{type:qi(e.type)?Un.ADAPTIVE_RADIUS:Un.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>{let a=Qa(en(e),t).some(e=>e.roundness?.type===Un.LEGACY);return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.edges`)}),(0,U.jsxs)(`div`,{className:`buttonList`,children:[(0,U.jsx)(Zw,{group:`edges`,options:[{value:`sharp`,text:G(`labels.sharp`),icon:ZS},{value:`round`,text:G(`labels.round`),icon:QS}],value:JE(e,r,e=>a?null:e.roundness?`round`:`sharp`,e=>!ir(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)}),i(`togglePolygon`)]})]})}});var nD=e=>({visibleSections:[{name:`default`,options:[{value:null,text:G(`labels.arrowhead_none`),keyBinding:`q`,icon:(0,U.jsx)($S,{flip:e})},{value:`arrow`,text:G(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,U.jsx)(eC,{flip:e})},{value:`triangle`,text:G(`labels.arrowhead_triangle`),icon:(0,U.jsx)(tC,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:G(`labels.arrowhead_triangle_outline`),icon:(0,U.jsx)(nC,{flip:e}),keyBinding:`r`}]}],hiddenSections:[{name:`default`,options:[{value:`circle`,text:G(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,U.jsx)(rC,{flip:e})},{value:`circle_outline`,text:G(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,U.jsx)(iC,{flip:e})},{value:`diamond`,text:G(`labels.arrowhead_diamond`),icon:(0,U.jsx)(aC,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:G(`labels.arrowhead_diamond_outline`),icon:(0,U.jsx)(oC,{flip:e}),keyBinding:`f`},{value:`bar`,text:G(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,U.jsx)(sC,{flip:e})}]},{name:G(`labels.cardinality`),options:[{value:`cardinality_one`,text:G(`labels.arrowhead_cardinality_one`),icon:(0,U.jsx)(cC,{flip:e}),keyBinding:`x`},{value:`cardinality_many`,text:G(`labels.arrowhead_cardinality_many`),icon:(0,U.jsx)(lC,{flip:e}),keyBinding:`c`},{value:`cardinality_one_or_many`,text:G(`labels.arrowhead_cardinality_one_or_many`),icon:(0,U.jsx)(uC,{flip:e}),keyBinding:`v`},{value:`cardinality_exactly_one`,text:G(`labels.arrowhead_cardinality_exactly_one`),icon:(0,U.jsx)(dC,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_one`,text:G(`labels.arrowhead_cardinality_zero_or_one`),icon:(0,U.jsx)(fC,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_many`,text:G(`labels.arrowhead_cardinality_zero_or_many`),icon:(0,U.jsx)(pC,{flip:e}),keyBinding:null}]}]});X({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>(E(n,`actionChangeArrowhead: value must be defined`),{elements:qE(e,t,e=>{if(ja(e)){let{position:t,type:r}=n;if(t===`start`)return N(e,{startArrowhead:r});if(t===`end`)return N(e,{endArrowhead:r})}return e}),appState:{...t,[n.position===`start`?`currentItemStartArrowhead`:`currentItemEndArrowhead`]:n.type},captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=lx().rtl,a=(0,V.useMemo)(()=>nD(!i),[i]),o=(0,V.useMemo)(()=>nD(!!i),[i]);return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.arrowheads`)}),(0,U.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,U.jsx)(RE,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:`arrowhead_start`,value:JE(e,r,e=>ja(e)&&Xs(e.type)?Qc(e.startArrowhead):t.currentItemStartArrowhead,!0,e=>e?null:t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e})}),(0,U.jsx)(RE,{visibleSections:o.visibleSections,hiddenSections:o.hiddenSections,label:`arrowhead_end`,value:JE(e,r,e=>ja(e)&&Xs(e.type)?Qc(e.endArrowhead):t.currentItemEndArrowhead,!0,e=>e?null:t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e})})]})]})}}),X({name:`changeArrowProperties`,label:`Change arrow properties`,trackEvent:!1,perform:(e,t,n,r)=>!1,PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[i(`changeArrowhead`),i(`changeArrowType`)]})}),X({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=qE(e,t,e=>{if(!ir(e))return e;let i=r.scene.getNonDeletedElementsMap(),a=R.getPointAtIndexGlobalCoordinates(e,0,i),o=R.getPointAtIndexGlobalCoordinates(e,-1,i),s=N(e,{x:n===Pe.elbow?a[0]:e.x,y:n===Pe.elbow?a[1]:e.y,roundness:n===Pe.round?{type:Un.PROPORTIONAL_RADIUS}:null,elbowed:n===Pe.elbow,angle:n===Pe.elbow?0:e.angle,points:n===Pe.elbow||e.elbowed?[R.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},a,i),R.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},o,i)]:e.points});if(vn(s)){s.fixedSegments=null;let e=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let n=R.getPointAtIndexGlobalCoordinates(s,0,e),i=R.getPointAtIndexGlobalCoordinates(s,-1,e),a=s.startBinding&&e.get(s.startBinding.elementId),o=s.endBinding&&e.get(s.endBinding.elementId),c=a&&s.startBinding?{...s.startBinding,...Do(s,a,`start`,e,t.zoom,t.isBindingEnabled)}:null,l=o&&s.endBinding?{...s.endBinding,...Do(s,o,`end`,e,t.zoom,t.isBindingEnabled)}:null;s={...s,startBinding:c,endBinding:l,...ma(s,e,{points:[n,i].map(e=>L(e[0]-s.x,e[1]-s.y)),startBinding:c,endBinding:l,fixedSegments:null})}}else{let e=r.scene.getNonDeletedElementsMap();if(s.startBinding){let n=e.get(s.startBinding.elementId);n&&ks(s,n,t.bindMode===`inside`?`inside`:`orbit`,`start`,r.scene,t.zoom)}if(s.endBinding){let n=e.get(s.endBinding.elementId);n&&ks(s,n,t.bindMode===`inside`?`inside`:`orbit`,`end`,r.scene,t.zoom)}}return s}),a={...t,currentItemArrowType:n},o=t.selectedLinearElement?.elementId;if(o){let t=i.find(e=>e.id===o);t&&(a.selectedLinearElement=new R(t,y(e)))}return{elements:i,appState:a,captureUpdate:I.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.arrowtypes`)}),(0,U.jsx)(`div`,{className:`buttonList`,children:(0,U.jsx)(Zw,{group:`arrowtypes`,options:[{value:Pe.sharp,text:G(`labels.arrowtype_sharp`),icon:bw,testId:`sharp-arrow`},{value:Pe.round,text:G(`labels.arrowtype_round`),icon:Sw,testId:`round-arrow`},{value:Pe.elbow,text:G(`labels.arrowtype_elbowed`),icon:xw,testId:`elbow-arrow`}],value:JE(e,r,e=>ir(e)?e.elbowed?Pe.elbow:e.roundness?Pe.round:Pe.sharp:null,e=>ir(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})})]})});var rD=()=>{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},iD=(e,t,n=`bottom`)=>{let r=e.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=t.left+t.width/2-r.width/2;o<0?o=5:o+r.width>=i&&(o=i-r.width-5);let s;n===`bottom`?(s=t.top+t.height+5,s+r.height>=a&&(s=t.top-r.height-5)):(s=t.top-r.height-5,s<0&&(s=t.top+t.height+5)),Object.assign(e.style,{top:`${s}px`,left:`${o}px`})},aD=500,oD=300,sD=0,cD=0,lD=null,uD=()=>{clearTimeout(sD),lD?.disconnect(),lD=null;let e=document.querySelector(`.excalidraw-tooltip`);e?.classList.contains(`excalidraw-tooltip--visible`)&&(e.classList.remove(`excalidraw-tooltip--visible`),cD=Date.now())},dD=(e,t,n,r,i)=>{t.classList.add(`excalidraw-tooltip--visible`),t.style.minWidth=r?`50ch`:`10ch`,t.style.maxWidth=r?`50ch`:`15ch`,t.textContent=n,iD(t,e.getBoundingClientRect(),i),lD?.disconnect(),lD=new MutationObserver(()=>{e.isConnected||uD()}),lD.observe(document.body,{childList:!0,subtree:!0})},fD=(e,t,{long:n=!1,delay:r=!1,position:i=`bottom`}={})=>{let a=()=>{e.isConnected&&dD(e,rD(),t,n,i)};clearTimeout(sD),r&&Date.now()-cD>oD?sD=window.setTimeout(a,aD):a()},pD=({children:e,label:t,long:n=!1,style:r,className:i,disabled:a,delay:o=!1})=>a?null:(0,U.jsx)(`div`,{className:H(`excalidraw-tooltip-wrapper`,i),onPointerEnter:e=>fD(e.currentTarget,t,{long:n,delay:o}),onPointerLeave:uD,style:r,children:e}),mD=(e,t)=>typeof t==`function`?t(e):Array.isArray(t)?e:e[t],hD=(e,t,n)=>{if(e?.isDestroyed)return;let r=e?.getAppState();if(!r){if(!n)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},Se())}return mD(r,t)};function gD(e,t=!0){let n=mW(),[,r]=(0,V.useState)(0),i=(0,V.useRef)(null);return i.current||={selector:e,isInitialized:!!n,latestValue:hD(n,e,t)},i.current.selector=e,!i.current.isInitialized&&n&&!n.isDestroyed&&(i.current.isInitialized=!0,i.current.latestValue=hD(n,e,t)),(0,V.useEffect)(()=>{let e=i.current;if(n&&!n.isDestroyed&&e)return n.onStateChange(e.selector,t=>{e.latestValue=t,r(e=>e+1)})},[n]),i.current.latestValue}function _D(e,t){let n=mW(),r=(0,V.useRef)({selector:e,callback:t});r.current.selector=e,r.current.callback=t,(0,V.useEffect)(()=>{if(n&&!n.isDestroyed)return r.current.callback(hD(n,r.current.selector,!0),n.getAppState()),n.onStateChange(r.current.selector,(e,t)=>{r.current.callback(e,t)})},[n])}X({name:`changeViewBackgroundColor`,label:`labels.canvasBackground`,trackEvent:!1,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:n?.viewBackgroundColor?I.IMMEDIATELY:I.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r,data:i})=>(0,U.jsx)(ZT,{palette:null,topPicks:_o,label:G(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var vD=X({name:`clearCanvas`,label:`labels.clearCanvas`,icon:Wx,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`,perform:(e,t,n,r)=>(r.imageCache.clear(),{elements:e.map(e=>N(e,{isDeleted:!0})),appState:{...Se(),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,fontTopPicks:t.fontTopPicks,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:r.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:I.IMMEDIATELY})}),yD=X({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,navigation:!0,icon:Vx,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...ti({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Oa(t.zoom.value+Ec)},t)},captureUpdate:I.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=gD(e=>e.zoom.value);return(0,U.jsx)(pD,{label:`${G(`buttons.zoomIn`)} \u2014 ${Z(`CtrlOrCmd++`)}`,className:`zoom-in-button-wrapper`,delay:!0,children:(0,U.jsx)(Y,{type:`button`,className:`zoom-in-button zoom-button`,icon:Vx,"aria-label":G(`buttons.zoomIn`),"aria-keyshortcuts":Z(`CtrlOrCmd++`),disabled:t>=30,onClick:()=>{e(null)}})})},keyTest:e=>(e.code===d.EQUAL||e.code===d.NUM_ADD)&&(e[z.CTRL_OR_CMD]||e.shiftKey)}),bD=X({name:`zoomOut`,label:`buttons.zoomOut`,icon:Hx,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...ti({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Oa(t.zoom.value-Ec)},t)},captureUpdate:I.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=gD(e=>e.zoom.value);return(0,U.jsx)(pD,{label:`${G(`buttons.zoomOut`)} \u2014 ${Z(`CtrlOrCmd+-`)}`,className:`zoom-out-button-wrapper`,delay:!0,children:(0,U.jsx)(Y,{type:`button`,className:`zoom-out-button zoom-button`,icon:Hx,"aria-label":G(`buttons.zoomOut`),"aria-keyshortcuts":Z(`CtrlOrCmd+-`),disabled:t<=vc,onClick:()=>{e(null)}})})},keyTest:e=>(e.code===d.MINUS||e.code===d.NUM_SUBTRACT)&&(e[z.CTRL_OR_CMD]||e.shiftKey)}),xD=X({name:`resetZoom`,label:`buttons.resetZoom`,icon:Ux,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?.lockZoom?t.scrollConstraints.zoom:1;return{appState:{...t,...ti({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Oa(i)},t)},captureUpdate:I.EVENTUALLY}},PanelComponent:({updateData:e})=>{let t=gD(e=>e.zoom.value);return(0,U.jsx)(pD,{label:G(`buttons.resetZoom`),style:{height:`100%`},className:`reset-zoom-button-wrapper`,delay:!0,children:(0,U.jsxs)(Y,{type:`button`,className:`reset-zoom-button zoom-button`,"aria-label":G(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t*100).toFixed(0),`%`]})})},keyTest:e=>(e.code===d.ZERO||e.code===d.NUM_ZERO)&&(e[z.CTRL_OR_CMD]||e.shiftKey)}),SD=e=>[e.x,e.y,e.x+e.width,e.y+e.height];X({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:dw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Hc(en(i)):t.scrollConstraints?SD(t.scrollConstraints):Hc(en(e)),o=ji({bounds:a,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...qs(o.appState)}}},keyTest:e=>e.code===d.TWO&&e.shiftKey&&!e.altKey&&!e[z.CTRL_OR_CMD]}),X({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:dw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Hc(en(i)):t.scrollConstraints?SD(t.scrollConstraints):Hc(en(e)),o=ji({bounds:a,appState:t,fit:`contain`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...qs(o.appState)}}},keyTest:e=>e.code===d.THREE&&e.shiftKey&&!e.altKey&&!e[z.CTRL_OR_CMD]}),X({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:dw,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?SD(t.scrollConstraints):Hc(en(e)),a=ji({bounds:i,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...a,appState:{...a.appState,...qs(a.appState)}}},keyTest:e=>e.code===d.ONE&&e.shiftKey&&!e.altKey&&!e[z.CTRL_OR_CMD]});var CD=X({name:`toggleTheme`,label:(e,t)=>t.theme===M.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:(e,t)=>e.theme===M.LIGHT?qx:Jx,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=n||(t.theme===M.LIGHT?M.DARK:M.LIGHT);return r.props.onThemeChange?(r.props.onThemeChange(i),!1):{appState:{...t,theme:i},captureUpdate:I.EVENTUALLY}},keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===d.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),wD=({app:e,options:t,activeTool:n,defaultOption:r,"data-testid":i,onToolChange:a,displayedOption:o})=>{let[s,c]=(0,V.useState)(!1),l=n.type,u=o.type===l,{container:d}=lW();return!t.some(e=>e.type===l)&&s&&c(!1),(0,V.useEffect)(()=>{let t=e.onPointerDownEmitter.on(()=>{c(!1)});return()=>t?.()},[e]),(0,U.jsxs)(Ny,{open:s,children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(Y,{className:H({fillable:o.fillable}),type:`toggle`,icon:o.icon,checked:u,disabled:t.every(t=>AD(e,t.type)),title:vt(o.title),"aria-label":vt(o.title),"data-testid":i,onSelect:()=>{c(e=>!e),a(r)}})}),(0,U.jsx)(Iy,{className:`tool-popover-content`,sideOffset:16,collisionBoundary:d??void 0,children:t.map(({type:t,icon:n,title:r,fillable:i})=>(0,U.jsx)(Y,{className:H({fillable:i}),type:`toggle`,icon:n,checked:l===t,disabled:AD(e,t),title:vt(t),"aria-label":vt(t),"data-testid":`toolbar-${t}`,onSelect:()=>{e.state.activeTool.type!==t&&(Yw(`toolbar`,t,`ui`),e.setActiveTool({type:t}),a?.(t))}},t))})]})},TD=(e=>e)({hand:{icon:jC,letterKey:z.H,toggle:!0},selection:{icon:Ox,letterKey:z.V,numericKey:z[1],fillable:!0},rectangle:{icon:Ax,letterKey:z.R,numericKey:z[2],fillable:!0},diamond:{icon:jx,letterKey:z.D,numericKey:z[3],fillable:!0},ellipse:{icon:Mx,letterKey:z.O,numericKey:z[4],fillable:!0},arrow:{icon:Nx,letterKey:z.A,numericKey:z[5],fillable:!0},line:{icon:Px,letterKey:z.L,numericKey:z[6],fillable:!0},freedraw:{icon:Ix,letterKey:[z.P,z.X],numericKey:z[7]},text:{icon:Lx,letterKey:z.T,numericKey:z[8]},stickynote:{icon:VC,letterKey:z.N},image:{icon:zx,numericKey:z[9]},eraser:{icon:Bx,letterKey:z.E,numericKey:z[0],toggle:!0},frame:{icon:BC,letterKey:z.F},autoshape:{icon:KC,letterKey:z.X,shiftKey:!0,fillable:!1},embeddable:{icon:Gx},laser:{icon:qC,letterKey:z.K},bucketfill:{icon:lS,letterKey:z.B},lasso:{icon:kx,fillable:!1}}),ED=Object.keys(TD).filter(e=>TD[e].toggle),DD=e=>{let{letterKey:t,shiftKey:n}=TD[e];if(!t)return t;let r=vt(typeof t==`string`?t:t[0]);return n?Z(`Shift+${r}`):r},OD=e=>{let t=DD(e),{numericKey:n}=TD[e];return t&&n!=null?`${t} ${G(`helpDialog.or`)} ${n}`:`${t||n}`},kD=(e,t,n=!1)=>{let r=e.toLowerCase();for(let i of Object.keys(TD)){let{letterKey:a,numericKey:o,shiftKey:s}=TD[i];if(n===!!s&&(o!=null&&e===o||a&&(typeof a==`string`?a===r:a.includes(r))))return i===`selection`?t.state.preferredSelectionTool.type:i}return null},AD=(e,t)=>e.props.activeTool!=null&&e.props.activeTool.type!==t,jD=(e,t)=>{let n=TD[e],r=t?.shortcutType??e,i=({app:i,activeTool:a,hideKeyBinding:o,hideShortcut:s})=>{let c=vt(G(`toolBar.${e}`)),l=s?null:OD(r);return(0,U.jsx)(Y,{className:H({fillable:n.fillable}),type:`toggle`,icon:n.icon,checked:a.type===e,disabled:AD(i,e),title:l?`${c} \u2014 ${l}`:c,keyBindingLabel:o||s?void 0:DD(r)||TD[r].numericKey,"aria-label":c,"aria-keyshortcuts":l??void 0,"data-testid":`toolbar-${e}`,onPointerDown:t=>{i.toolDrag.handleButtonPointerDown(e,t.nativeEvent)},onSelect:({pointerType:n})=>{if(!i.state.penDetected&&n===`pen`&&i.togglePenMode(!0),t?.onSelect){t.onSelect(i,{pointerType:n});return}i.state.activeTool.type!==e&&(Yw(`toolbar`,e,`ui`),i.setActiveTool({type:e}))}})};return i.displayName=`${vt(e)}IconButton`,i},MD=jD(`hand`),ND=jD(`rectangle`),PD=jD(`diamond`),FD=jD(`ellipse`),ID=jD(`arrow`),LD=jD(`line`),RD=jD(`freedraw`),zD=jD(`text`),BD=jD(`stickynote`),VD=jD(`image`),HD=jD(`eraser`),UD=jD(`frame`),WD=jD(`selection`,{onSelect:(e,{pointerType:t})=>{if(e.state.activeTool.type===`selection`&&t!==null){e.setActiveTool({type:`lasso`});return}e.state.activeTool.type!==`selection`&&(Yw(`toolbar`,`selection`,`ui`),e.setActiveTool({type:`selection`}))}}),GD=jD(`lasso`,{shortcutType:`selection`}),KD=({app:e,activeTool:t,setAppState:n})=>{let r=[{type:`selection`,icon:TD.selection.icon,fillable:TD.selection.fillable,title:vt(G(`toolBar.selection`))},{type:`lasso`,icon:TD.lasso.icon,fillable:TD.lasso.fillable,title:vt(G(`toolBar.lasso`))}],i=r.find(t=>t.type===e.state.preferredSelectionTool.type)||r[0];return(0,U.jsx)(wD,{app:e,options:r,activeTool:t,defaultOption:e.state.preferredSelectionTool.type,"data-testid":`toolbar-selection`,onToolChange:t=>{(t===`selection`||t===`lasso`)&&(e.setActiveTool({type:t}),n({preferredSelectionTool:{type:t,initialized:!0}}))},displayedOption:i})},qD=({app:e,activeTool:t})=>{let n=[{type:`freedraw`,icon:TD.freedraw.icon,fillable:TD.freedraw.fillable,title:vt(G(`toolBar.freedraw`))},{type:`autoshape`,icon:TD.autoshape.icon,fillable:TD.autoshape.fillable,title:vt(G(`toolBar.autoshape`))}],[r,i]=(0,V.useState)(t.type===`autoshape`?`autoshape`:`freedraw`);(0,V.useEffect)(()=>{(t.type===`freedraw`||t.type===`autoshape`)&&i(t.type)},[t.type]);let a=n.find(e=>e.type===r)||n[0];return(0,U.jsx)(wD,{app:e,options:n,activeTool:t,defaultOption:r,"data-testid":`toolbar-freedraw`,onToolChange:t=>{(t===`freedraw`||t===`autoshape`)&&(i(t),e.setActiveTool({type:t}))},displayedOption:a})},JD=X({name:`finalize`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=!0,a=e,{focusContainer:o,scene:s}=r,c=s.getNonDeletedElementsMap(),l=t.activeTool.type===`autoshape`;if(n&&t.selectedLinearElement){let{event:i,sceneCoords:o}=n,u=R.getElement(t.selectedLinearElement.elementId,c);E(u,`Arrow element should exist if selectedLinearElement is set`),E(o,`sceneCoords should be defined if actionFinalize is called with event`);let d=R.handlePointerUp(i,t.selectedLinearElement,t,r.scene);if(bo(u)&&!t.selectedLinearElement.segmentMidPointHoveredCoords&&!n.hitBoundText){let e=!!t.newElement,n=e||!t.selectedLinearElement.selectedPointsIndices?[u.points.length-1]:t.selectedLinearElement.selectedPointsIndices,a=Fa(i),l=i[z.CTRL_OR_CMD]?null:r.getEffectiveGridSize(),f=n.reduce((e,t)=>(e.set(t,{point:a?u.points[t]:R.createPointAt(u,c,o.x-d.pointerOffset.x,o.y-d.pointerOffset.y,l)}),e),new Map)??new Map;xc(u,f,o.x,o.y,s,t,{newArrow:e,altKey:i.altKey,angleLocked:a,gridSize:r.getEffectiveGridSize()})}else co(u)&&t.selectedLinearElement?.isEditing&&!t.newElement&&!qt(u.points)&&s.mutateElement(u,{polygon:!1});if(d!==t.selectedLinearElement){u&&So(u)&&(a=a.map(e=>e.id===u.id?N(e,{isDeleted:!0}):e));let n=t.activeTool?.locked;return{elements:u.points.length<2||So(u)?e.map(e=>e.id===u.id?N(e,{isDeleted:!0}):e):a,appState:{...t,cursorButton:`up`,selectedElementIds:l?{}:t.selectedElementIds,selectedLinearElement:n||l?null:{...d,selectedPointsIndices:null,isEditing:!1,initialState:{...d.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:I.IMMEDIATELY}}}o();let u=r.drawShape.hasPendingGesture();(u||l)&&(r.drawShape.finalize(),u&&(a=r.scene.getElementsIncludingDeleted()));let d=null;if(t.multiElement)d=t.multiElement;else if(!l&&!u&&(t.newElement?.type===`freedraw`||bo(t.newElement)))d=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let e=c.get(Object.keys(t.selectedElementIds)[0]);e&&(d=e)}if(d){if(t.selectedLinearElement&&t.multiElement&&d.type!==`freedraw`&&t.lastPointerDownWith!==`touch`){let{points:e}=d,{lastCommittedPoint:n}=t.selectedLinearElement;if((!n||e[e.length-1]!==n)&&(i=!1,s.mutateElement(d,{points:d.points.slice(0,-1)}),bo(d)&&d.endBinding&&d.points.length>1)){let e=!!t.newElement,n=new Map([[d.points.length-1,{point:d.points[d.points.length-1],isDragging:!1}]]),r=R.getPointAtIndexGlobalCoordinates(d,-1,c);xc(d,n,r[0],r[1],s,t,{newArrow:e})}}if(d&&So(d)&&(a=a.map(e=>e.id===d?.id?N(e,{isDeleted:!0}):e)),ja(d)||Te(d)){if(ft(d.points,t.zoom.value)&&(co(d)||Te(d))){let e=d.points,t=e[0],n=e.map((n,r)=>r===e.length-1?L(t[0],t[1]):n);co(d)?s.mutateElement(d,{points:n,polygon:!0}):s.mutateElement(d,{points:n})}co(d)&&!qt(d.points)&&s.mutateElement(d,{polygon:!1})}}let f;f=ED.includes(t.activeTool.type)?ln(t,{...t.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveTool:null}):ln(t,{type:r.state.preferredSelectionTool.type});let p=r.isToolLocked(),m=t.activeTool.type===`autoshape`||(p||t.activeTool.type===`freedraw`)&&!!d;m||r.cursor.applyForTool(f);let h=d&&ja(d)?new R(d,y(a)):t.selectedLinearElement;return h&&={...h,isEditing:!t.newElement&&h.isEditing,initialState:{...h.initialState,lastClickedPoint:-1,origin:null}},{elements:a,appState:{...t,cursorButton:`up`,activeTool:m?t.activeTool:f,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,frameToHighlight:null,selectedElementIds:l?{}:d&&!p&&t.activeTool.type!==`freedraw`?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:l?null:h},captureUpdate:i?I.IMMEDIATELY:I.NEVER}},keyTest:(e,t)=>e.key===z.ESCAPE&&t.selectedLinearElement?.isEditing||(e.key===z.ESCAPE||e.key===z.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,U.jsx)(Y,{type:`button`,icon:pS,title:G(`buttons.done`),"aria-label":G(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),YD=(e,t)=>ED.includes(e.activeTool.type)?ln(e,{...e.activeTool.lastActiveTool||{type:t.state.preferredSelectionTool.type},lastActiveTool:null}):ln(e,{type:t.state.preferredSelectionTool.type}),XD=(e,t,n)=>{if(!e.editingGroupId)return null;let r=t.scene.getNonDeletedElements(),i=t.scene.getSelectedElements({selectedElementIds:n,elements:r}),a=i.length?i:ul(r,e.editingGroupId);for(let t of a){let n=t.groupIds.indexOf(e.editingGroupId);if(n!==-1&&t.groupIds[n+1])return t.groupIds[n+1]}return null};X({name:`deselect`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=YD(t,r);if(r.cursor.applyForTool(i),t.editingGroupId){let e=r.scene.getNonDeletedElements(),n=Object.keys(t.selectedElementIds).length>0?t.selectedElementIds:ul(e,t.editingGroupId).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...sn({editingGroupId:XD(t,r,n),selectedElementIds:n},e,t,r),activeEmbeddable:null,activeTool:i,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:I.IMMEDIATELY}}return{appState:{...t,activeEmbeddable:null,activeTool:i,editingGroupId:null,selectedElementIds:j({},t),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,frameToHighlight:null},captureUpdate:I.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key!==z.ESCAPE||_(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||Gt(r.scene.getNonDeletedElements(),t))});var ZD=({children:e,checked:t,onChange:n,className:r})=>(0,U.jsxs)(`div`,{className:H(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,U.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:rS}),(0,U.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),QD=e=>{let t=e.title||(e.value===M.DARK?G(`buttons.lightMode`):G(`buttons.darkMode`));return(0,U.jsx)(Y,{type:`icon`,icon:e.value===M.LIGHT?$D.MOON:$D.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===M.DARK?M.LIGHT:M.DARK),"data-testid":`toggle-dark-mode`})},$D={SUN:(0,U.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,U.jsx)(`path`,{fill:`currentColor`,d:`M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z`})}),MOON:(0,U.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,U.jsx)(`path`,{fill:`currentColor`,d:`M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z`})})},eO=e=>{let{id:t}=lW(),[n,r]=(0,V.useState)(e.value);return(0,U.jsxs)(`div`,{className:`ProjectName`,children:[(0,U.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,U.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||yi(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===z.ENTER){if(e.preventDefault(),e.nativeEvent.isComposing||e.keyCode===229)return;e.currentTarget.blur()}},id:`${t}-filename`,value:n,onChange:e=>r(e.target.value)})]})},tO=5e3,nO=Object.assign(({message:e,onClose:t,closable:n=!1,duration:r=tO,style:i})=>{let a=(0,V.useRef)(0),o=r!==1/0,s=(0,V.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,V.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,U.jsxs)(`div`,{className:`Toast`,role:`status`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,U.jsx)(`div`,{className:`Toast__message`,children:e}),n&&(0,U.jsx)(Y,{icon:PS,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},{ProgressBar:({progress:e})=>(0,U.jsx)(`div`,{className:`Toast__progress-bar`,children:(0,U.jsx)(`div`,{className:`Toast__progress-bar-fill`,style:{width:`${Math.min(5,Math.round(e*100))}%`}})})});`clipboard`in navigator&&`readText`in navigator.clipboard;var rO=`clipboard`in navigator&&`writeText`in navigator.clipboard,iO=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,aO=e=>!!([Nc.excalidraw,Nc.excalidrawClipboard,Nc.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),oO=({types:e,files:t})=>{!e&&!t&&console.warn(`createPasteEvent: no types or files provided`);let n=new ClipboardEvent(P.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,i]of Object.entries(e)){if(typeof i!=`string`){t||=[],t.push(i);continue}try{if(n.clipboardData?.items.add(i,r),n.clipboardData?.getData(r)!==i)throw Error(`Failed to set "${r}" as clipboardData item`)}catch(e){throw Error(e.message)}}if(t){let e=-1;for(let r of t){e++;try{if(n.clipboardData?.items.add(r),n.clipboardData?.files[e]!==r)throw Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(e){throw Error(e.message)}}}return n},sO=({elements:e,files:t})=>{let n=y(e),r=new Set(e.filter(e=>F(e))),i=!1,a=e.reduce((e,n)=>(bs(n)&&(i=!0,t&&t[n.fileId]&&(e[n.fileId]=t[n.fileId])),e),{});i&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let o={type:Nc.excalidrawClipboard,elements:e.map(e=>{if(fs(e,n)&&!r.has(fs(e,n))){let t=Yi(e);return oo(t,n,{frameId:null}),t}return e}),files:t?a:void 0};return JSON.stringify(o)},cO=async(e,t,n)=>{let r=sO({elements:e,files:t});await bO({[A.excalidrawClipboard]:r,[A.text]:r},n)};function lO(e){let t=[];for(let n of e.childNodes)if(n.nodeType===3){let e=n.textContent?.trim();e&&t.push({type:`text`,value:e})}else if(n instanceof HTMLImageElement){let e=n.getAttribute(`src`);e&&e.startsWith(`http`)&&t.push({type:`imageUrl`,value:e})}else t=t.concat(lO(n));return t}var uO=e=>{let t=e.value;try{let e=lO(new DOMParser().parseFromString(t,A.html).body);if(e.length)return{type:`mixedContent`,value:e}}catch(e){console.error(`error in parseHTMLFromPaste: ${e.message}`)}return null},dO=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let e=await navigator.clipboard?.readText();if(e)return{[A.text]:e}}}catch(t){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);else{if(t.name===`DataError`)return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${t.message}`),e;throw t}}throw t}for(let n of t)for(let t of n.types)if(na(yn,t))try{if(t===A.text||t===A.html)e[t]=await(await n.getType(t)).text();else if(ic(t)){let r=await n.getType(t);e[t]=Ea(r,t,void 0)}else throw new Gs(`Unsupported clipboard type: ${t}`)}catch(e){console.warn(e instanceof Gs?e.message:`Cannot retrieve ${t} from clipboardItem: ${e.message}`)}return Object.keys(e).length===0&&console.warn(`No clipboard data found from clipboard.read().`),e},fO=async(e,t=!1)=>{try{let n=e.findByType(A.html),r=!t&&n&&uO(n);return r?r.value.every(e=>e.type===`text`)?{type:`text`,value:e.getData(A.text)??r.value.map(e=>e.value).join(`
42
+ `).trim()}:r:{type:`text`,value:(e.getData(A.text)||``).trim()}}catch{return{type:`text`,value:``}}},pO=function(e){return this.find(t=>t.type===e)||null},mO=function(e){return this.find(t=>t.type===e)?.value??null},hO=function(){return this.filter(e=>e.kind===`file`)},gO=e=>{let t;t=SO(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=new Set;for(let e of Array.from(t||[]))n.has(e.type)||n.add(e.type);return n},_O=async e=>{let t;t=SO(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=(await Promise.all(Array.from(t||[]).map(async t=>{if(t.kind===`file`){let e=t.getAsFile();if(e){let n=await La(t);return e=await ne(e),{type:e.type,kind:`file`,file:e,fileHandle:n}}}else if(t.kind===`string`){let{type:n}=t,r;return r=`clipboardData`in e&&e.clipboardData?e.clipboardData?.getData(n):await new Promise(e=>{t.getAsString(t=>e(t))}),{type:n,kind:`string`,value:r}}return null}))).filter(e=>e!=null);return Object.assign(n,{findByType:pO,getData:mO,getFiles:hO})},vO=async(e,t=!1)=>{let n=await fO(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=JSON.parse(n.value),r=e.type===Nc.excalidrawClipboardWithAPI;if(aO(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},yO=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[A.png]:e})])}catch(t){if(We(e))await navigator.clipboard.write([new ClipboardItem({[A.png]:await e})]);else throw t}},bO=async(e,t)=>{e||=``;let n=Object.entries(typeof e==`string`?{[A.text]:e}:e);try{if(t){for(let[e,r]of n)if(t.clipboardData?.setData(e,r),t.clipboardData?.getData(e)!==r)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}let r=n.find(([e])=>e===A.text);if(rO&&r)try{await navigator.clipboard.writeText(r[1]);return}catch(e){console.error(e)}if(r&&!xO(r[1]))throw Error(`Error copying to clipboard.`)},xO=e=>{e||=` `;let t=document.documentElement.getAttribute(`dir`)===`rtl`,n=document.createElement(`textarea`);n.style.border=`0`,n.style.padding=`0`,n.style.margin=`0`,n.style.position=`absolute`,n.style[t?`right`:`left`]=`-9999px`;let r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize=`12pt`,n.setAttribute(`readonly`,``),n.value=e,document.body.appendChild(n);let i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand(`copy`)}catch(e){console.error(e)}return n.remove(),i},SO=e=>e.type===P.PASTE||e.type===P.COPY||e.type===P.CUT,CO=(e,{selectedElementIds:t},n)=>{let r=en(e),i=y(r),a=n&&Gt(r,{selectedElementIds:t}),o=null,s=a?Kc(r,{selectedElementIds:t},{includeBoundTextElement:!0}):r;if(a){let e=s[0];s.length===1&&F(e)?(o=e,s=bc(r,e,i)):s.length>1&&(s=Kc(r,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:o,exportedElements:ri(s)}},wO=async(e,t,r,i,{exportBackground:a,exportPadding:o=10,viewBackgroundColor:s,name:c=r.name||`Untitled`,fileHandle:l=null,exportingFrame:u=null})=>{if(t.length===0)throw Error(G(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let n=Cc(t,{exportBackground:a,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:s,exportPadding:o,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e===`svg`},i,{exportingFrame:u});if(e===`svg`)return Vc(n.then(e=>new Blob([Be+e.outerHTML],{type:A.svg})),{description:`Export to SVG`,name:c,extension:r.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[Fc.svg],fileHandle:l});if(e===`clipboard-svg`){let e=await n.then(e=>e.outerHTML);try{await bO(e)}catch{throw Error(G(`errors.copyToSystemClipboardFailed`))}return}}let d=sl(t,r,i,{exportBackground:a,viewBackgroundColor:s,exportPadding:o,exportingFrame:u});if(e===`png`){let e=sr(d);return r.exportEmbedScene&&(e=e.then(e=>n(async()=>{let{encodePngMetadata:e}=await import(`./image-6XY3GD3F-DCWbu6d4.js`);return{encodePngMetadata:e}},[],import.meta.url).then(({encodePngMetadata:n})=>n({blob:e,metadata:Xo(t,r,i,`local`)})))),Vc(e,{description:`Export to PNG`,name:c,extension:r.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[Fc.png],fileHandle:l})}if(e===`clipboard`)try{await yO(sr(d))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(G(`canvasError.canvasTooBig`)):Xi&&e.name===`TypeError`?Error(`${G(`alerts.couldNotCopyToClipboard`)}
43
+
44
+ ${G(`hints.firefox_clipboard_write`)}`):Error(G(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},TO=async(e,t,n)=>{let r=Hi(t);if(!di(r))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);let{elements:i,appState:a,files:o}=await e,{exportBackground:s,viewBackgroundColor:c}=a;a={...a,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:u}=CO(i,a,!1);return await wO(r,l,a,o,{exportBackground:s,viewBackgroundColor:c,name:n,fileHandle:t,exportingFrame:u}),{fileHandle:t}},EO=X({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:I.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,U.jsx)(eO,{label:G(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),DO=X({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:I.EVENTUALLY})}),OO=X({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:I.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,U.jsx)(ZD,{checked:e.exportBackground,onChange:e=>t(e),children:G(`imageExportDialog.label.withBackground`)})}),kO=X({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:I.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,U.jsxs)(ZD,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[G(`imageExportDialog.label.embedScene`),(0,U.jsx)(pD,{label:G(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,U.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:gS})})]})}),AO=!1,jO=(e,t)=>{let n=t.message??G(`progressDialog.defaultMessage`);e.setAppState({toast:{message:t.progress==null?n:(0,U.jsxs)(U.Fragment,{children:[n,(0,U.jsx)(nO.ProgressBar,{progress:t.progress})]}),duration:1/0}})};async function MO(e,t){if(t.app.state.isLoading&&(jO(t.app,{progress:null}),await t.app.onStateChange({predicate:e=>!e.isLoading})),typeof e==`object`&&e&&Symbol.asyncIterator in e){for await(let n of e){if(t.signal.aborted){e.return();return}if(n.type===`progress`)jO(t.app,{message:n.message,progress:n.progress??null});else if(n.type===`done`)return}return}e instanceof Promise&&(jO(t.app,{progress:null}),await e)}function NO(e,t,n,r){let i=new AbortController,a=i.signal;return{abortController:i,data:new Promise(async i=>{try{r.props.onExport&&await MO(r.props.onExport(`json`,{elements:e,appState:t,files:n},{signal:a}),{app:r,signal:a})}catch(e){e?.name===`AbortError`?console.warn(`onExport() aborted by host app (signal aborted: ${a.aborted})`):console.error(`Error during props.onExport() handling`,e)}i({elements:e,appState:t,files:r.files})})}}var PO=X({name:`saveToActiveFile`,label:`buttons.save`,icon:Xx,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{if(AO)return!1;AO=!0;let i=t.fileHandle,a=r.getName(),{abortController:o,data:s}=NO(e,t,r.files,r);try{let{fileHandle:e}=Gr(i)?await TO(s,i,a):await Es({data:s,filename:a,fileHandle:i});return{captureUpdate:I.NEVER,appState:{fileHandle:e,toast:{message:i&&e?.name?G(`toast.fileSavedToFilename`).replace(`{filename}`,`"${e.name}"`):G(`toast.fileSaved`),duration:1500}}}}catch(e){return o.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:I.NEVER,appState:{toast:null}}}finally{AO=!1}},keyTest:e=>e.key===z.S&&e[z.CTRL_OR_CMD]&&!e.shiftKey}),FO=X({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:Xx,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{if(AO)return!1;AO=!0;let{abortController:i,data:a}=NO(e,t,r.files,r);try{let{fileHandle:e}=await Es({data:a,filename:r.getName(),fileHandle:null});return{captureUpdate:I.NEVER,appState:{openDialog:null,fileHandle:e,toast:{message:G(`toast.fileSaved`),duration:3e3}}}}catch(e){return i.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:I.NEVER,appState:{toast:null}}}finally{AO=!1}},keyTest:e=>e.key.toLowerCase()===z.S&&e.shiftKey&&e[z.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,U.jsx)(Y,{type:`button`,icon:oS,title:G(`buttons.saveAs`),"aria-label":G(`buttons.saveAs`),showAriaLabel:sW().formFactor===`phone`,hidden:!va,onClick:()=>e(null),"data-testid":`save-as-button`})}),IO=X({name:`loadScene`,label:`buttons.load`,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{try{let{elements:n,appState:r,files:i}=await xn(t,e);return{elements:n,appState:r,files:i,captureUpdate:I.IMMEDIATELY}}catch(n){return n?.name===`AbortError`?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:I.EVENTUALLY}}},keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.O}),LO=X({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n,r)=>(r.sessionExportThemeOverride=n?M.DARK:M.LIGHT,{appState:{...t,exportWithDarkMode:n},captureUpdate:I.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,U.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,U.jsx)(QD,{value:e.exportWithDarkMode?M.DARK:M.LIGHT,onChange:e=>{t(e===M.DARK)},title:G(`imageExportDialog.label.darkMode`)})})}),RO=`{}`,zO=X({name:`copyStyles`,label:`labels.copyStyles`,icon:uw,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&ke(a)){let e=Sn(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(RO=JSON.stringify(i)),{appState:{...t,toast:{message:G(`toast.copyStyles`)}},captureUpdate:I.EVENTUALLY}},keyTest:e=>e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.C}),BO=X({name:`pasteStyles`,label:`labels.pasteStyles`,icon:uw,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(RO),a=i[0],o=i[1];if(!ci(a))return{elements:e,captureUpdate:I.EVENTUALLY};let s=Kc(e,t,{includeBoundTextElement:!0}),c=s.map(e=>e.id),l=y(e),u=y(i.filter(ci)),d=ts(rs(e.map(e=>{if(c.includes(e.id)){let t=a;if(D(e)&&e.containerId&&(t=o),!t)return e;let n=N(e,{backgroundColor:t?.backgroundColor,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,strokeStyle:t?.strokeStyle,fillStyle:t?.fillStyle,opacity:t?.opacity,roughness:t?.roughness,roundness:t.roundness?re(t.roundness.type,e)?t.roundness:za(e):null});if(D(n)){let e=t,i=(D(t)?Zt(t,u):e.fontSize)||20,a=e.fontFamily||_a,o=null,c=n.containerId;c&&(o=s.find(e=>e.id===c)||null);let d=N(n,{...te(n,i,l),fontFamily:a,textAlign:e.textAlign||`left`,lineHeight:e.lineHeight||$n(a)});n=d,mo(d,l)?n=N(d,Wr(d,`strokeColor`,d.strokeColor,l)):ga(d,o,r.scene)}return n.type===`arrow`&&ir(t)&&(n=N(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),F(e)&&(n=N(n,{roundness:null,backgroundColor:`transparent`})),x(n)&&(n=pl(n)),n}return e}),l),new Set(c),{prevElementsMap:l});for(let e of d){let t=l.get(e.id);x(e)&&Ga(e)&&t&&(t.height!==e.height||t.x!==e.x||t.y!==e.y)&&bi(e,r.scene)}return{elements:d,captureUpdate:I.IMMEDIATELY}},keyTest:e=>e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.V}),VO=X({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:Qx,viewMode:!0,trackEvent:{category:`menu`,action:`toggleHelpDialog`},perform:(e,t,n,{focusContainer:r})=>(t.openDialog?.name===`help`&&r(),{appState:{...t,openDialog:t.openDialog?.name===`help`?null:{name:`help`},openMenu:null,openPopup:null},captureUpdate:I.EVENTUALLY}),keyTest:e=>e.key===z.QUESTION_MARK}),HO=(e,t)=>{if(e.length>=2){let n=t?e[0].groupIds.indexOf(t):-1,r=n>-1?e[0].groupIds.slice(0,n):e[0].groupIds;for(let t of r)if(e.every(e=>Fe(e,t)))return!0}return!1},UO=(e,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return n.length>=2&&!HO(n,e.editingGroupId)&&!cs(n)},WO=X({name:`group`,label:`labels.group`,icon:e=>(0,U.jsx)(FS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(!UO(t,r))return!1;let i=zt(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:I.EVENTUALLY};let a=Mo(t);if(a.length===1){let n=a[0],r=new Set(ul(e,n).map(e=>e.id)),o=new Set(i.map(e=>e.id));if(new Set([...Array.from(r),...Array.from(o)]).size===r.size)return{appState:t,elements:e,captureUpdate:I.EVENTUALLY}}let o=[...e];new Set(i.map(e=>e.frameId)).size>1&&hc(i).forEach((e,t)=>{Ya(e,r.scene.getNonDeletedElementsMap())});let s=Ti(),c=y(i);o=o.map(e=>c.get(e.id)?N(e,{groupIds:Dc(e.groupIds,s,t.editingGroupId)}):e);let l=ul(o,s),u=l[l.length-1],d=o.lastIndexOf(u),f=o.slice(d+1),p=o.slice(0,d).filter(e=>!Fe(e,s)),m=Po([...p,...l,...f],y(l));return{appState:{...t,...fa(s,{...t,selectedGroupIds:{}},en(o))},elements:m,captureUpdate:I.IMMEDIATELY}},predicate:(e,t,n,r)=>UO(t,r),keyTest:e=>!e.shiftKey&&e[z.CTRL_OR_CMD]&&e.key===z.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!UO(t,r),type:`button`,icon:(0,U.jsx)(FS,{theme:t.theme}),onClick:()=>n(null),title:`${G(`labels.group`)} \u2014 ${Z(`CtrlOrCmd+G`)}`,"aria-label":G(`labels.group`),visible:Gt(en(e),t)})}),GO=X({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,U.jsx)(IS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=Mo(t),a=y(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:I.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{fn(e)&&s.push(e.id);let n=Yt(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:N(e,{groupIds:n})});let c=sn(t,en(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return b(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=Ct(o,Ra(o,e,t,a),e))}),c.selectedElementIds=Object.entries(c.selectedElementIds).reduce((e,[t,n])=>(n&&!s.includes(t)&&(e[t]=!0),e),{}),{appState:{...t,...c},elements:o,captureUpdate:I.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[z.CTRL_OR_CMD]&&e.key===z.G.toUpperCase(),predicate:(e,t)=>Mo(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,U.jsx)(Y,{type:`button`,hidden:Mo(t).length===0,icon:(0,U.jsx)(IS,{theme:t.theme}),onClick:()=>n(null),title:`${G(`labels.ungroup`)} \u2014 ${Z(`CtrlOrCmd+Shift+G`)}`,"aria-label":G(`labels.ungroup`),visible:Gt(en(e),t)})}),KO=(e,t,n,r,i,a,o)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),e.fill(),o&&(e.strokeStyle=o),e.stroke()};function qO(e){let t=0;if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r}return t}var JO=(e,t)=>`hsl(${Math.abs(qO(t?.id||e))%37*10}, 100%, 83%)`,YO=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},XO=({context:e,renderConfig:t,appState:n,normalizedWidth:r,normalizedHeight:i})=>{for(let[a,o]of t.remotePointerViewportCoords){let{x:s,y:c}=o,l=n.collaborators.get(a);s-=n.offsetLeft,c-=n.offsetTop;let u=s<0||s>r-11||c<0||c>i-14;s=Math.max(s,0),s=Math.min(s,r-11),c=Math.max(c,0),c=Math.min(c,i-14);let d=JO(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===ro.IDLE||f===ro.AWAY;p&&(e.globalAlpha=.3),t.remotePointerButton.get(a)===`down`&&(e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle=`#ffffff88`,e.stroke(),e.closePath(),e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=d,e.stroke(),e.closePath());let m=Rs,h=l?.isSpeaking;h&&(e.fillStyle=m,e.strokeStyle=m,e.lineWidth=10,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=k,e.strokeStyle=k,e.lineWidth=6,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=d,e.strokeStyle=d,e.lineWidth=2,e.lineJoin=`round`,e.beginPath(),p?(e.moveTo(s-1,c-1),e.lineTo(s-1,c+15),e.lineTo(s+5,c+10),e.lineTo(s+12,c+9),e.closePath(),e.fill()):(e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.fill(),e.stroke());let g=t.remotePointerUsernames.get(a)||``;if(!u&&g){e.font=`600 12px sans-serif`;let t=(h?s+0:s)+11/2,n=(h?c+0:c)+14+2,r=e.measureText(g),i=r.actualBoundingBoxDescent+r.actualBoundingBoxAscent,a=Math.max(i,12),o=t-1,l=n-1,u=r.width+2+10+2,f=a+2+6+2;e.roundRect?(e.beginPath(),e.roundRect(o,l,u,f,8),e.fillStyle=d,e.fill(),e.strokeStyle=`#ffffff`,e.stroke(),h&&(e.beginPath(),e.roundRect(o-2,l-2,u+4,f+4,8),e.strokeStyle=m,e.stroke())):KO(e,o,l,u,f,8,`#ffffff`),e.fillStyle=`#1e1e1e`,e.fillText(g,t+5+1,n+3+r.actualBoundingBoxAscent+Math.floor((a-i)/2)+2),h&&(e.fillStyle=m,e.fillRect(o+u+8,l+(f/2-4),2,8),e.fillRect(o+u+8+5,l+(f/2-8),2,16),e.fillRect(o+u+8+10,l+(f/2-4),2,8))}e.restore(),e.closePath()}},ZO=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=YO(n),[o,s]=(0,V.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,U.jsx)(`div`,{className:H(`Avatar`,i),style:l,onClick:t,children:c?(0,U.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};X({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n,r)=>(E(n,`actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called`),!n.socketId||r.props.userToFollow?.socketId===n.socketId||n.isCurrentUser?(r.requestUnfollow(),{appState:t,captureUpdate:I.EVENTUALLY}):(r.emitUserFollowIntent({userToFollow:{socketId:n.socketId,username:n.username||``},action:`FOLLOW`}),{appState:{...t,openMenu:t.openMenu===`canvas`?null:t.openMenu},captureUpdate:I.EVENTUALLY})),PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:r,collaborator:i,withName:a,isBeingFollowed:o}=t,s=JO(r,i),c=H({"is-followed":o,"is-current-user":i.isCurrentUser===!0,"is-speaking":i.isSpeaking,"is-in-call":i.isInCall,"is-muted":i.isMuted}),l=i.isInCall?i.isSpeaking?(0,U.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:G(`userList.hint.isSpeaking`),children:[(0,U.jsx)(`div`,{}),(0,U.jsx)(`div`,{}),(0,U.jsx)(`div`,{})]}):i.isMuted?(0,U.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:G(`userList.hint.micMuted`),children:iw}):(0,U.jsx)(`div`,{title:G(`userList.hint.inCall`),children:rw}):null;return a?(0,U.jsxs)(`div`,{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${c}`,style:{"--avatar-size":`1.5rem`},onClick:i.isCurrentUser?void 0:()=>e(i),children:[(0,U.jsx)(ZO,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,U.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,U.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,U.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:G(`userList.hint.followStatus`),children:XC}),i.isCurrentUser&&` (${G(`labels.you`)})`,l]})]}):(0,U.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,U.jsx)(ZO,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,U.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var QO=X({name:`addToLibrary`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let e of p)if(i.some(t=>t.type===e))return{captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:G(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Ti(),status:`unpublished`,elements:i.map(Yi),created:Date.now()},...e])).then(()=>({captureUpdate:I.EVENTUALLY,appState:{...t,toast:{message:G(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),$O=(e,t)=>{let n=t.scene.getSelectedElements(e);return gi(n,t.scene.getNonDeletedElementsMap(),e).length>1&&!n.some(e=>F(e))},ek=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=Na(i,r,n.scene,t),o=y(a);return c(e.map(e=>o.get(e.id)||e),t,n)};X({name:`alignTop`,label:`labels.alignTop`,icon:wS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`start`,axis:`y`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key===z.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:wS,onClick:()=>n(null),title:`${G(`labels.alignTop`)} \u2014 ${Z(`CtrlOrCmd+Shift+Up`)}`,"aria-label":G(`labels.alignTop`),visible:Gt(en(e),t)})}),X({name:`alignBottom`,label:`labels.alignBottom`,icon:TS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`end`,axis:`y`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key===z.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:TS,onClick:()=>n(null),title:`${G(`labels.alignBottom`)} \u2014 ${Z(`CtrlOrCmd+Shift+Down`)}`,"aria-label":G(`labels.alignBottom`),visible:Gt(en(e),t)})}),X({name:`alignLeft`,label:`labels.alignLeft`,icon:ES,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`start`,axis:`x`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key===z.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:ES,onClick:()=>n(null),title:`${G(`labels.alignLeft`)} \u2014 ${Z(`CtrlOrCmd+Shift+Left`)}`,"aria-label":G(`labels.alignLeft`),visible:Gt(en(e),t)})}),X({name:`alignRight`,label:`labels.alignRight`,icon:DS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`end`,axis:`x`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key===z.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:DS,onClick:()=>n(null),title:`${G(`labels.alignRight`)} \u2014 ${Z(`CtrlOrCmd+Shift+Right`)}`,"aria-label":G(`labels.alignRight`),visible:Gt(en(e),t)})}),X({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:AS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`center`,axis:`y`}),captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:AS,onClick:()=>n(null),title:G(`labels.centerVertically`),"aria-label":G(`labels.centerVertically`),visible:Gt(en(e),t)})}),X({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:jS,trackEvent:{category:`element`},predicate:(e,t,n,r)=>$O(t,r),perform:(e,t,n,r)=>({appState:t,elements:ek(e,t,r,{position:`center`,axis:`x`}),captureUpdate:I.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!$O(t,r),type:`button`,icon:jS,onClick:()=>n(null),title:G(`labels.centerHorizontally`),"aria-label":G(`labels.centerHorizontally`),visible:Gt(en(e),t)})});var tk=(e,t)=>{let n=t.scene.getSelectedElements(e);return gi(n,t.scene.getNonDeletedElementsMap(),e).length>2&&!n.some(e=>F(e))},nk=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=wn(i,n.scene.getNonDeletedElementsMap(),r,t,n.scene),o=y(a);return c(e.map(e=>o.get(e.id)||e),t,n)};X({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:nk(e,t,r,{space:`between`,axis:`x`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!tk(t,r),type:`button`,icon:OS,onClick:()=>n(null),title:`${G(`labels.distributeHorizontally`)} \u2014 ${Z(`Alt+H`)}`,"aria-label":G(`labels.distributeHorizontally`),visible:Gt(en(e),t)})}),X({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:nk(e,t,r,{space:`between`,axis:`y`}),captureUpdate:I.IMMEDIATELY}),keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,U.jsx)(Y,{hidden:!tk(t,r),type:`button`,icon:kS,onClick:()=>n(null),title:`${G(`labels.distributeVertically`)} \u2014 ${Z(`Alt+V`)}`,"aria-label":G(`labels.distributeVertically`),visible:Gt(en(e),t)})});var rk=X({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:lw,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:c(ak(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:I.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===d.H}),ik=X({name:`flipVertical`,label:`labels.flipVertical`,icon:cw,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:c(ak(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:I.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===d.V&&!e[z.CTRL_OR_CMD]}),ak=(e,t,n,r,i)=>{let a=ok(Kc(en(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,r,i),o=y(a);return e.map(e=>o.get(e.id)||e)},ok=(e,t,n,r)=>{if(e.every(e=>ir(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return N(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:i,midY:a}=g(e);T(e,t,`nw`,r.scene,new Map(Array.from(t.values()).map(e=>[e.id,Yi(e)])),{flipByX:n===`horizontal`,flipByY:n===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),lc(e.filter(ir),r.scene,r.state);let{elbowArrows:o,otherElements:s}=e.reduce((e,t)=>vn(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:l}=g(e),[u,d]=[i-c,a-l];return s.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),o.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),e},sk=X({name:`copy`,label:`labels.copy`,icon:Kx,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await cO(i,r.files,n)}catch(e){return{captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:I.EVENTUALLY}},keyTest:void 0}),ck=X({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await dO()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),Xi?{captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:G(`hints.firefox_clipboard_write`)}}:{captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:G(`errors.asyncPasteFailedOnRead`)}})}try{r.clipboard.pasteFromClipboard(oO({types:i}))}catch(e){return console.error(e),{captureUpdate:I.EVENTUALLY,appState:{...t,errorMessage:G(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:I.EVENTUALLY}},keyTest:void 0}),lk=X({name:`cut`,label:`labels.cut`,icon:PC,trackEvent:{category:`element`},perform:(e,t,n,r)=>(sk.perform(e,t,n,r),Vw.perform(e,t,null,r)),keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.X}),uk=X({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:fw,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:I.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=CO(e,t,!0);try{return await wO(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:G(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?G(`toast.selection`):G(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?G(`buttons.darkMode`):G(`buttons.lightMode`)})}},captureUpdate:I.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:I.EVENTUALLY}}},predicate:e=>rO&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),dk=X({name:`copyAsPng`,label:`labels.copyAsPng`,icon:pw,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:I.EVENTUALLY};let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:o}=CO(e,t,!0);try{return await wO(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:G(`toast.copyToClipboardAsPng`,{exportSelection:i.length?G(`toast.selection`):G(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?G(`buttons.darkMode`):G(`buttons.lightMode`)})}},captureUpdate:I.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:I.EVENTUALLY}}},predicate:e=>iO&&e.length>0,keyTest:e=>e.code===d.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),fk=X({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{bO(Io(i))}catch{throw Error(G(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:I.EVENTUALLY}},predicate:(e,t,n,r)=>rO&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(D),keywords:[`text`,`clipboard`,`copy`]}),pk=X({name:`gridMode`,icon:vw,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:I.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[z.CTRL_OR_CMD]&&e.code===d.QUOTE}),mk=X({name:`zenMode`,label:`buttons.zenMode`,icon:hw,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:I.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n,r)=>r.editorInterface.formFactor!==`phone`&&typeof n.zenModeEnabled>`u`,keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.Z}),hk=X({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:mw,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:I.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>`u`,keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.S}),gk=X({name:`arrowBinding`,label:`labels.arrowBinding`,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>e.bindingPreference===`disabled`},perform(e,t){let n=t.bindingPreference===`enabled`?`disabled`:`enabled`;return{appState:{...t,bindingPreference:n,isBindingEnabled:n===`enabled`},captureUpdate:I.NEVER}},checked:e=>e.bindingPreference===`enabled`}),_k=X({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:I.NEVER}},checked:e=>e.isMidpointSnappingEnabled}),vk=X({name:`showHints`,label:`labels.showHints`,icon:Mw,keywords:[`hint`,`hints`,`tip`,`tips`],viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.showHints},perform(e,t){return{appState:{...t,showHints:!this.checked(t)},captureUpdate:I.NEVER}},checked:e=>e.showHints}),yk=X({name:`stats`,label:`stats.fullTitle`,icon:sw,viewMode:!0,trackEvent:{category:`menu`},keywords:[`edit`,`attributes`,`customize`],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:I.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.SLASH}),bk=X({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>ke(e)),perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=r.scene.getNonDeletedElementsMap();return i.forEach(e=>{let t=Sn(e,a);if(t){let{width:n,height:i}=Oi(t.originalText,Or(t),t.lineHeight),o=kr(e.id);oi(e.id);let{x:s,y:c}=Wn(e,t,a);r.scene.mutateElement(t,{containerId:null,width:n,height:i,text:t.originalText,baseFontSize:null,x:s,y:c,labelPosition:null}),r.scene.mutateElement(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id)}),x(e)?Xc(e,r.scene):r.scene.mutateElement(e,{height:o||e.height})}}),{elements:e,appState:t,captureUpdate:I.IMMEDIATELY}}}),xk=X({name:`bindText`,label:`labels.bindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);if(i.length===2){let e=D(i[0])||D(i[1]),t;if(ve(i[0])?t=i[0]:ve(i[1])&&(t=i[1]),e&&t&&Sn(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a,o;D(i[0])&&ve(i[1])?(a=i[0],o=i[1]):(a=i[1],o=i[0]);let s=x(o)?Zr(a.strokeColor)?o.strokeColor:a.strokeColor:null;r.scene.mutateElement(a,{containerId:o.id,verticalAlign:Oc.MIDDLE,textAlign:Ta.CENTER,autoResize:!0,angle:ir(o)?0:o?.angle??0,labelPosition:ir(o)?Ha:null,...s?{baseFontSize:Mc(a.baseFontSize??a.fontSize),strokeColor:s}:null}),r.scene.mutateElement(o,{boundElements:(o.boundElements||[]).concat({type:`text`,id:a.id}),...s?{strokeColor:s}:null});let c=o.height;return ga(a,o,r.scene),rr(o.id,c),{elements:Sk(e,o,a),appState:{...t,selectedElementIds:{[o.id]:!0}},captureUpdate:I.IMMEDIATELY}}}),Sk=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===n.id);r.splice(i,1);let a=r.findIndex(e=>e.id===t.id);return r.splice(a+1,0,n),Po(r,y([t,n])),r},Ck=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===t.id);r.splice(i,1);let a=r.findIndex(e=>e.id===n.id);return r.splice(a,0,t),Po(r,y([t,n])),r},wk=X({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=i.some(e=>D(e)&&!fn(e));return i.length>0&&a},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=e.slice(),o={};for(let e of i)if(D(e)&&!fn(e)){let n=jr({type:`rectangle`,backgroundColor:t.currentItemBackgroundColor,boundElements:[...e.boundElements||[],{id:e.id,type:`text`}],angle:e.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:lo(`rectangle`,t.currentItemStrokeWidthKey),strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:qi(`rectangle`)?Un.ADAPTIVE_RADIUS:Un.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:Fs(e.width,`rectangle`),height:Fs(e.height,`rectangle`),groupIds:e.groupIds,frameId:e.frameId});if(e.boundElements?.length){let t=e.boundElements.filter(e=>e.type===`arrow`).map(e=>e.id);a.filter(e=>t.includes(e.id)).forEach(t=>{let i=t.startBinding,a=t.endBinding;i?.elementId===e.id&&(i={...i,elementId:n.id}),a?.elementId===e.id&&(a={...a,elementId:n.id}),(i||a)&&r.scene.mutateElement(t,{startBinding:i,endBinding:a})})}r.scene.mutateElement(e,{containerId:n.id,verticalAlign:Oc.MIDDLE,boundElements:null,textAlign:Ta.CENTER,autoResize:!0}),ga(e,n,r.scene),a=Ck([...a,n],n,e),o[n.id]=!0}return{elements:a,appState:{...t,selectedElementIds:o},captureUpdate:I.IMMEDIATELY}}}),Tk=380,Ek=42,Dk=5,Ok=85,kk=500,Ak=!1,jk=new Map,Mk=({element:e,scene:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=t.getNonDeletedElementsMap(),s=dW(),c=oW(),l=sW(),u=e.link||``,[d,f]=(0,V.useState)(u),p=(0,V.useRef)(null),m=s.showHyperlinkPopup===`editor`,h=(0,V.useCallback)(()=>{if(!p.current)return;let r=Ee(p.current.value)||null;if(!e.link&&r&&Yw(`hyperlink`,`create`),Si(e)){if(s.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!r){t.mutateElement(e,{link:null}),a(e,!1);return}if(!Qt(r,c.validateEmbeddable))r&&i({message:G(`toast.unableToEmbed`),closable:!0}),e.link&&jk.set(e.id,e.link),t.mutateElement(e,{link:r}),a(e,!1);else{let{width:n,height:o}=e,s=il(r);s?.error instanceof URIError&&i({message:G(`toast.unrecognizedLinkFormat`),closable:!0});let c=s?s.intrinsicSize.w/s.intrinsicSize.h:1,l=jk.get(e.id)!==e.link;t.mutateElement(e,{...l?{width:s?.type===`video`?n>o?n:o*c:n,height:s?.type===`video`&&n>o?n/c:o}:{},link:r}),a(e,!0),jk.has(e.id)&&jk.delete(e.id)}}else t.mutateElement(e,{link:r})},[e,t,i,c.validateEmbeddable,s.activeEmbeddable,n,a]);(0,V.useLayoutEffect)(()=>()=>{h()},[h]),(0,V.useEffect)(()=>{m&&p?.current&&!(l.formFactor===`phone`||l.isTouchScreen)&&p.current.select()},[m,l.formFactor,l.isTouchScreen]),(0,V.useEffect)(()=>{let t=null,r=r=>{m||(t&&clearTimeout(t),zk(e,o,s,L(r.clientX,r.clientY))&&(t=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},kk)))};return window.addEventListener(P.POINTER_MOVE,r,!1),()=>{window.removeEventListener(P.POINTER_MOVE,r,!1),t&&clearTimeout(t)}},[s,e,m,n,o]);let g=(0,V.useCallback)(()=>{Yw(`hyperlink`,`delete`),t.mutateElement(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e,t]),_=()=>{Yw(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:v,y}=Nk(e,s,o);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:(0,U.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${y}px`,left:`${v}px`,width:Tk,padding:Dk},children:[m?(0,U.jsx)(`input`,{className:H(`excalidraw-hyperlinkContainer-input`),placeholder:G(`labels.link.hint`),ref:p,value:d,onChange:e=>f(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[z.CTRL_OR_CMD]&&e.key===z.K&&e.preventDefault(),(e.key===z.ENTER||e.key===z.ESCAPE)&&(h(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,U.jsx)(`a`,{href:Ee(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:wr(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=ie(P.EXCALIDRAW_LINK,t.nativeEvent);r({...e,link:Ee(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,U.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:G(`labels.link.empty`)}),(0,U.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!m&&(0,U.jsx)(Y,{type:`button`,title:G(`buttons.edit`),"aria-label":G(`buttons.edit`),label:G(`buttons.edit`),onClick:_,className:`excalidraw-hyperlinkContainer--edit`,icon:Ix}),(0,U.jsx)(Y,{type:`button`,title:G(`labels.linkToElement`),"aria-label":G(`labels.linkToElement`),label:G(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:Dw}),u&&!Si(e)&&(0,U.jsx)(Y,{type:`button`,title:G(`buttons.remove`),"aria-label":G(`buttons.remove`),label:G(`buttons.remove`),onClick:g,className:`excalidraw-hyperlinkContainer--remove`,icon:Wx})]})]})},Nk=(e,t,n)=>{let[r,i]=In(e,n),{x:a,y:o}=hs({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-Tk/2,y:o-t.offsetTop-Ok}},Pk=(e,t)=>{let n=Kc(e,t);return Si(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},Fk=null,Ik=(e,t,n)=>{Fk&&clearTimeout(Fk),Fk=window.setTimeout(()=>Lk(e,t,n),300)},Lk=(e,t,n)=>{if(!e.link)return;let r=rD();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=Vt(e.link)?G(`labels.link.goToElement`):e.link;let[i,a,o,s]=In(e,n),[c,l,u,d]=jn([i,a,o,s],e.angle,t),f=hs({sceneX:c,sceneY:l},t);iD(r,{left:f.x,top:f.y,width:u,height:d},`top`),Yw(`hyperlink`,`tooltip`,`link-icon`),Ak=!0},Rk=()=>{Fk&&clearTimeout(Fk),Ak&&(Ak=!1,rD().classList.remove(`excalidraw-tooltip--visible`))},zk=(e,t,n,[r,i])=>{let{x:a,y:o}=ws({clientX:r,clientY:i},n),s=15/n.zoom.value;if(Js(L(a,o),e,t))return!1;let[c,l,u]=In(e,t);if(a>=c&&a<=u&&o>=l-Ok&&o<=l)return!1;let{x:d,y:f}=Nk(e,n,t);return!(r>=d-s&&r<=d+Tk+Dk*2+s&&i>=f-s&&i<=f+s+Dk*2+Ek)},Bk=X({name:`hyperlink`,label:(e,t)=>Pk(en(e),t),icon:iS,perform:(e,t)=>t.showHyperlinkPopup!==`editor`&&{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:I.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.K,predicate:(e,t)=>Kc(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=Kc(e,t);return(0,U.jsx)(Y,{type:`toggle`,icon:iS,"aria-label":G(Pk(en(e),t)),title:`${Si(e[0])?G(`labels.link.labelEmbed`):G(`labels.link.label`)} - ${Z(`CtrlOrCmd+K`)}`,onSelect:()=>n(null),checked:r.length===1&&!!r[0].link})}}),Vk=e=>e.every(e=>!e.locked),Hk=X({name:`toggleElementLock`,label:(e,t,n)=>Vk(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}))?`labels.elementLock.lock`:`labels.elementLock.unlock`,icon:(e,t)=>Vk(Kc(t,e))?Cx:Sx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return i.length>0&&!i.some(e=>e.locked&&e.frameId)},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!i.length)return!1;let a=Vk(i),o=y(i),s=i.length>1&&Ua(i),c=i.length===1||s?null:Ti(),l={...t.lockedMultiSelections};if(a)l={...t.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let e=i[0].groupIds.at(-1);delete l[e]}let u=e.map(e=>{if(!o.has(e.id))return e;let n=e.groupIds;return a?c&&(n=[...n,c]):n=n.filter(e=>!t.lockedMultiSelections[e]),N(e,{locked:a,groupIds:n.length===e.groupIds.length?e.groupIds:n})}),d=y(u),f=a?{}:Object.fromEntries(i.map(e=>[e.id,!0])),p=i.map(e=>d.get(e.id)||e),m=a?{}:Nr(en(p),t),h=a?c||(s?i[0].groupIds.at(-1):i[0].id):null;return{elements:u,appState:{...t,selectedElementIds:f,selectedGroupIds:m,selectedLinearElement:a?null:t.selectedLinearElement,lockedMultiSelections:l,activeLockedId:h},captureUpdate:I.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===z.L&&e[z.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),Uk=X({name:`unlockAllElements`,trackEvent:{category:`canvas`},viewMode:!1,icon:Sx,predicate:(e,t)=>Kc(e,t).length===0&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked),r=e.map(e=>{if(e.locked){let n=e.groupIds.filter(e=>!t.lockedMultiSelections[e]);return N(e,{locked:!1,groupIds:e.groupIds.length===n.length?e.groupIds:n})}return e}),i=y(r),a=n.map(e=>i.get(e.id)||e),o=en(a);return{elements:r,appState:{...t,selectedElementIds:Object.fromEntries(o.map(e=>[e.id,!0])),selectedGroupIds:Nr(o,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:I.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),Wk=8,Gk=10,Kk=[`rectangle`,`diamond`,`ellipse`],qk=[`line`,`sharpArrow`,`curvedArrow`,`elbowArrow`],Jk=new Set(Kk),Yk=new Set(qk),Xk=e=>Jk.has(e),Zk=e=>e===`arrow`||Yk.has(e),Qk=Dl(null),$k=new Map,eA=new Map,tA=({app:e})=>{let t=e.scene.getSelectedElements(e.state),n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(t.length===0){e.updateEditorAtom(Qk,null);return}let r=aA(t);r&&!n.current?n.current=r:(n.current&&!r||n.current&&r!==n.current)&&(e.updateEditorAtom(Qk,null),n.current=null)},[t,e]),(0,V.useEffect)(()=>()=>{$k.clear(),eA.clear()},[]),(0,U.jsx)(nA,{app:e,elements:t})},nA=({app:e,elements:t})=>{let n=aA(t),r=(0,V.useMemo)(()=>n===`generic`?cA(t):[],[n,t]),i=(0,V.useMemo)(()=>n===`linear`?lA(t):[],[n,t]),a=n===`generic`?r.every(e=>e.type===r[0].type):n===`linear`&&i.every(e=>v(e)===v(i[0])),[o,s]=(0,V.useState)({x:0,y:0}),c=(0,V.useRef)(``),l=(0,V.useRef)(null);(0,V.useEffect)(()=>{let t=[...r,...i].sort((e,t)=>e.id.localeCompare(t.id)),n=`
45
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${t.map(e=>e.id).join(`,`)}`;if(n===c.current)return;c.current=n;let a;if(t.length===1){let[n,,,r,i,o]=In(t[0],e.scene.getNonDeletedElementsMap());a=As(L(n,r),L(i,o),t[0].angle)}else{let{minX:e,maxY:n}=g(t);a=L(e,n)}let{x:o,y:l}=hs({sceneX:a[0],sceneY:a[1]},e.state);s({x:o,y:l})},[r,i,e.scene,e.state]),(0,V.useEffect)(()=>{for(let e of i){let t=sA(e.id,vA(e));eA.has(t)||eA.set(t,e)}},[i]),(0,V.useEffect)(()=>{for(let t of r)if(!$k.has(t.id)){let n=Sn(t,e.scene.getNonDeletedElementsMap());n&&$k.set(t.id,{fontSize:n.fontSize})}},[r,e.scene]);let u=n===`linear`?[[`line`,Px],[`sharpArrow`,bw],[`curvedArrow`,Sw],[`elbowArrow`,xw]]:n===`generic`?[[`rectangle`,Ax],[`diamond`,jx],[`ellipse`,Mx]]:[];return(0,U.jsx)(`div`,{ref:l,tabIndex:-1,style:{position:`absolute`,top:`${o.y+(Gk+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${o.x-e.state.offsetLeft-Wk}px`,zIndex:2},className:hn.CONVERT_ELEMENT_TYPE_POPUP,children:u.map(([o,s])=>{let c=a&&(n===`generic`&&r[0].type===o||n===`linear`&&v(i[0])===o);return(0,U.jsx)(Y,{type:`toggle`,icon:s,checked:c,title:o,"aria-label":o,"data-testid":`toolbar-${o}`,onSelect:()=>{c||(e.state.activeTool.type!==o&&Yw(`convertElementType`,o,`ui`),iA(e,{conversionType:n,nextType:o}),l.current?.focus())}},`${t[0].id}${t[0].version}_${o}`)})})},rA=(e,t,n)=>{let r=Jr(e,t),i=uc(e,t),a=ec(t.text,Or(t),r),o=Oi(a,Or(t),t.lineHeight),s=t.fontSize;for(;(o.width>r||o.height>i)&&s>0;){--s;let e={...t,fontSize:s};o=Oi(t.text,Or(e),t.lineHeight)}oo(t,n.getNonDeletedElementsMap(),{fontSize:s,width:o.width,height:o.height}),ga(t,e,n)},iA=(e,{conversionType:t,nextType:n,direction:r=`right`})=>{if(!t)return!1;let i=e.scene.getSelectedElements(e.state),a=i.reduce((e,t)=>({...e,[t.id]:!0}),{}),o=r===`right`?1:-1;if(t===`generic`){let t=cA(i),r=t.every(e=>e.type===t[0].type)?Kk.indexOf(t[0].type):-1;if(n??=Kk[(r+Kk.length+o)%Kk.length],n&&Xk(n)){let r={};for(let i of t){let t=gA(i,n,e);r[t.id]=t}let i=[];for(let t of e.scene.getElementsIncludingDeleted())r[t.id]?i.push(r[t.id]):i.push(t);e.scene.replaceAllElements(i);for(let t of Object.values(r)){Xr(t)&&($a(t,e.scene,e.state.zoom),le(t,e.scene,e.state));let n=Sn(t,e.scene.getNonDeletedElementsMap());n&&($k.get(t.id)&&oo(n,e.scene.getNonDeletedElementsMap(),{fontSize:$k.get(t.id)?.fontSize??n.fontSize}),rA(t,n,e.scene))}e.setState(e=>({selectedElementIds:a,activeTool:ln(e,{type:`selection`})}))}}if(t===`linear`){let t=lA(i);if(!n){let e=da(t,v);n=qk[((e?qk.indexOf(e):-1)+qk.length+o)%qk.length]}if(Zk(n)){let r=[],i=e.scene.getElementsMapIncludingDeleted();for(let a of t){let t=eA.get(sA(a.id,n));if(t&&v(t)===n)i.set(t.id,t),r.push(t);else{let t=gA(a,n,e);i.set(t.id,t),r.push(t)}}e.scene.replaceAllElements(i);for(let t of r)if(ja(t)){if(vn(t)){let n=mA(t);if(n.length<2)continue;let r=[];for(let e=1;e<n.length-2;e++)r.push({start:n[e],end:n[e+1],index:e+1});let i=ma(t,e.scene.getNonDeletedElementsMap(),{points:n,fixedSegments:r});oo(t,e.scene.getNonDeletedElementsMap(),{...i,endArrowhead:`arrow`})}else{let n=at([`line`,`sharpArrow`,`curvedArrow`],e=>eA.get(sA(t.id,e)));if(n){let r=n.points;e.scene.mutateElement(t,{points:r})}}}}let r=lA(e.scene.getSelectedElements(e.state));e.setState(t=>({selectedElementIds:a,selectedLinearElement:r.length===1?new R(r[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ln(t,{type:`selection`})}))}return!0},aA=e=>{if(e.length===0)return null;let t=!1;for(let n of e){if(Xk(n.type))return`generic`;oA(n)&&(t=!0)}return t?`linear`:null},oA=e=>ja(e)&&(!ir(e)||!Ls(e)&&!ke(e)),sA=(e,t)=>`${e}:${t}`,cA=e=>e.filter(e=>Xk(e.type)),lA=e=>e.filter(e=>oA(e)),uA=20,dA=(e,t)=>e[0]===t[0],fA=(e,t)=>e[1]===t[1],pA=(e,t)=>dA(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),mA=e=>{let t=[e.points[0]],n=hA(e.points);for(let e=1;e<n.length;++e){let r=t[t.length-1],i=[...n[e]];Math.abs(i[0]-r[0])<uA?i[0]=r[0]:Math.abs(i[1]-r[1])<uA&&(i[1]=r[1]),dA(r,i)||fA(r,i)||t.push(L(r[0],i[1])),t.push(i)}let r=[t[0]];for(let e=1;e<t.length-1;++e)dA(t[e-1],t[e])&&dA(t[e],t[e+1])||fA(t[e-1],t[e])&&fA(t[e],t[e+1])||r.push(t[e]);r.push(t[t.length-1]);let i=[r[0]];for(let e=1;e<r.length-1;++e){let t=i[i.length-1],n=r[e],a=r[e+1],o=dA(t,n),s=dA(n,a);if(o!==s){let e=pA(t,n),r=pA(n,a);if(e<uA||r<uA){if(r<e)o?a[0]=t[0]:a[1]=t[1];else if(s)for(let e=i.length-1;e>=0&&i[e][0]===t[0];--e)i[e][0]=n[0];else for(let e=i.length-1;e>=0&&i[e][1]===t[1];--e)i[e][1]=n[1];continue}}i.push(n)}return i.push(r[r.length-1]),i},hA=e=>{if(e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++){let[r,i]=t[t.length-1],[a,o]=e[n];(r!==a||i!==o)&&t.push(e[n])}return t},gA=(e,t,n)=>{if(!_A(e.type,t)){if(!zo())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(wa.delete(e),Xk(t))return gn(jr({...e,type:t,roundness:e.roundness?{type:qi(t)?Un.ADAPTIVE_RADIUS:Un.PROPORTIONAL_RADIUS}:e.roundness}));if(Zk(t))switch(t){case`line`:return gn(jc({...e,type:`line`}));case`sharpArrow`:return gn(w({...e,type:`arrow`,elbowed:!1,roundness:null,startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`curvedArrow`:return gn(w({...e,type:`arrow`,elbowed:!1,roundness:{type:Un.PROPORTIONAL_RADIUS},startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`elbowArrow`:return gn(w({...e,type:`arrow`,elbowed:!0,fixedSegments:null,roundness:null}))}return Jt(t,`unhandled conversion type: ${t}`),e},_A=(e,t)=>!!(Xk(e)&&Xk(t)||Zk(e)&&Zk(t)),vA=e=>ja(e)?v(e):e.type,yA=tA,bA=X({name:`toggleShapeSwitch`,label:`labels.shapeSwitch`,icon:()=>null,viewMode:!0,trackEvent:{category:`shape_switch`,action:`toggle`},keywords:[`change`,`switch`,`swap`],perform(e,t,n,r){return ex.set(Qk,{type:`panel`}),{captureUpdate:I.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>aA(e)!==null}),xA=X({name:`copyElementLink`,label:`labels.copyElementLink`,icon:NC,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=Kc(e,t);try{if(window.location){let n=Ve(i,t);return n?(await bO(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):mi(n.id,n.type)),{appState:{toast:{message:G(`toast.elementLinkCopied`),closable:!0}},captureUpdate:I.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:I.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:r,captureUpdate:I.EVENTUALLY}},predicate:(e,t)=>Kr(Kc(e,t))}),SA=X({name:`linkToElement`,label:`labels.linkToElement`,icon:Dw,perform:(e,t,n,r)=>{let i=Kc(e,t);return i.length!==1||!Kr(i)?{elements:e,appState:t,app:r,captureUpdate:I.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:Kc(e,t)[0].id}},captureUpdate:I.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=Kc(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&&Kr(i)},trackEvent:!1}),CA={toggleTheme:[Z(`Shift+Alt+D`)],saveScene:[Z(`CtrlOrCmd+S`)],loadScene:[Z(`CtrlOrCmd+O`)],clearCanvas:[Z(`CtrlOrCmd+Delete`)],imageExport:[Z(`CtrlOrCmd+Shift+E`)],commandPalette:[Z(`CtrlOrCmd+/`),Z(`CtrlOrCmd+Shift+P`)],cut:[Z(`CtrlOrCmd+X`)],copy:[Z(`CtrlOrCmd+C`)],paste:[Z(`CtrlOrCmd+V`)],copyStyles:[Z(`CtrlOrCmd+Alt+C`)],pasteStyles:[Z(`CtrlOrCmd+Alt+V`)],selectAll:[Z(`CtrlOrCmd+A`)],deleteSelectedElements:[Z(`Delete`)],duplicateSelection:[Z(`CtrlOrCmd+D`),Z(`Alt+${G(`helpDialog.drag`)}`)],sendBackward:[Z(`CtrlOrCmd+[`)],bringForward:[Z(`CtrlOrCmd+]`)],sendToBack:[Z(Jo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[Z(Jo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[Z(`Shift+Alt+C`)],group:[Z(`CtrlOrCmd+G`)],ungroup:[Z(`CtrlOrCmd+Shift+G`)],gridMode:[Z(`CtrlOrCmd+'`)],zenMode:[Z(`Alt+Z`)],objectsSnapMode:[Z(`Alt+S`)],stats:[Z(`Alt+/`)],addToLibrary:[],flipHorizontal:[Z(`Shift+H`)],flipVertical:[Z(`Shift+V`)],viewMode:[Z(`Alt+R`)],hyperlink:[Z(`CtrlOrCmd+K`)],toggleElementLock:[Z(`CtrlOrCmd+Shift+L`)],resetZoom:[Z(`CtrlOrCmd+0`)],zoomOut:[Z(`CtrlOrCmd+-`)],zoomIn:[Z(`CtrlOrCmd++`)],zoomToFitSelection:[Z(`Shift+3`)],zoomToFit:[Z(`Shift+1`)],zoomToFitSelectionInViewport:[Z(`Shift+2`)],saveFileToDisk:[Z(`CtrlOrCmd+S`)],saveToActiveFile:[Z(`CtrlOrCmd+S`)],toggleShortcuts:[Z(`?`)],searchMenu:[Z(`CtrlOrCmd+F`)],wrapSelectionInFrame:[],toolLock:[Z(`Q`)]},wA=(e,t=0)=>{let n=CA[e];return n&&n.length>0?n[t]||n[0]:``},TA=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),EA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,DA={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`E`,æ:`e`,Þ:`T`,þ:`t`,ß:`s`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`I`,ij:`i`,Œ:`E`,œ:`e`,ʼn:`n`,ſ:`s`},OA=e=>e.replace(EA,e=>DA[e]||e).replace(TA,``),kA=()=>{let[e,t]=(0,V.useState)(null);return[e,(0,V.useCallback)(e=>t(e),[])]},AA=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let s=en(Vn(e,null,{deleteInvisibleElements:!0})),c=fc(t,null),{exportBackground:l,viewBackgroundColor:u}=c;return sl(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},jA=async e=>{let{mimeType:t=A.png,quality:n}=e;t===A.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${A.png}" mimeType`),t===`image/jpg`&&(t=A.jpg),t===A.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${A.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await AA(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===A.png&&e.appState?.exportEmbedScene&&(n=await ss({blob:n,metadata:Xo(Vn(e.elements,null),e.appState,e.files||{},`local`)})),i(n)},t,n)})},MA=async({elements:e,appState:t=Se(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let c=en(Vn(e,null,{deleteInvisibleElements:!0})),l={...fc(t,null),exportPadding:r};return Cc(c,l,n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},NA=async e=>{if(e.type===`svg`)await bO((await MA(e)).outerHTML);else if(e.type===`png`)await yO(jA(e));else if(e.type===`json`)await cO(en(Vn(e.elements,null)),e.files);else throw Error(`Invalid export type`)},PA=Dl(new Map),FA=async e=>await MA({elements:e,appState:{exportBackground:!1,viewBackgroundColor:$c.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),IA=(e,t,n,r)=>{let[i,a]=(0,V.useState)();return(0,V.useEffect)(()=>{if(t){if(e){let r=n.get(e);r?a(r):(async()=>{let r=await FA(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),a(r))})()}else(async()=>{let e=await FA(t);a(e)})()}},[e,t,n,a]),(0,V.useEffect)(()=>{let e=r.current;if(e)return i&&(e.innerHTML=i.outerHTML),()=>{e.innerHTML=``}},[i,r]),i},LA=()=>{let[e]=Yb(PA);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},RA=[`excalidraw.com`,`raw.githubusercontent.com/excalidraw/excalidraw-libraries`],zA=new rt,BA=Dl({status:`loaded`,isInitialized:!1,libraryItems:[]}),VA=e=>ri(e),HA=(e,t)=>!e.find(e=>e.elements.length===t.elements.length&&e.elements.every((e,n)=>e.id===t.elements[n].id&&e.versionNonce===t.elements[n].versionNonce)),UA=(e,t)=>{let n=[];for(let r of t)HA(e,r)&&n.push(r);return[...n,...e]},WA=(e,t)=>{let n=y(t),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let t of e)n.has(t.id)||r.deletedItems.set(t.id,t);let i=y(e);for(let e of t){let t=i.get(e.id);t?$A(t)!==$A(e)&&r.updatedItems.set(e.id,e):r.addedItems.set(e.id,e)}return r},GA=class{constructor(e){B(this,`currLibraryItems`,[]),B(this,`prevLibraryItems`,VA(this.currLibraryItems)),B(this,`app`),B(this,`updateQueue`,[]),B(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),B(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)ex.set(BA,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{ex.set(BA,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=VA(this.currLibraryItems);let t=VA(this.currLibraryItems);this.app.props.onLibraryChange?.(t),zA.trigger(WA(e,t),t)}catch(e){console.error(e)}}}),B(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],ex.set(PA,new Map)}),B(this,`resetLibrary`,()=>this.setLibrary([])),B(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(VA(t))}catch{return e(this.currLibraryItems)}})),B(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:Vr.name,tab:`library`}}),this.setLibrary(()=>new Promise(async(r,a)=>{try{let o=await(typeof e==`function`&&!(e instanceof Blob)?e(this.currLibraryItems):e),s;s=o instanceof Blob?await mc(o,i):po(o,i),!t||window.confirm(G(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?UA(this.currLibraryItems,s):s)):a(new nc)}catch(e){a(e)}})))),B(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=VA(await e),t(this.currLibraryItems)}catch(e){n(e)}}).catch(e=>{if(e.name===`AbortError`)return console.warn(`Library update aborted by user`),this.currLibraryItems;throw e}).finally(()=>{this.updateQueue=this.updateQueue.filter(e=>e!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t}),this.app=e}},KA=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=n=>e.slice(n*t,n*t+t).reduce((e,t)=>{let{height:n}=g(t.elements);return Math.max(e,n)},0),i=n=>{let r=0,i=0,a=0;for(let o of e){if(r%t===0&&(i=0),i===n){let{width:e}=g(o.elements);a=Math.max(a,e)}r++,i++}return a},a=0,o=0,s=0,c=0,l=0,u=0,d=0;for(let f of e){l&&l%t===0&&(o+=s+50,a=0,u=0,d++),u===0&&(s=r(d)),c=i(u);let{minX:e,minY:p,width:m,height:h}=g(f.elements),_=(c-m)/2,v=(s-h)/2;n.push(...f.elements.map(t=>({...t,x:t.x+a+_-e,y:t.y+o+v-p}))),a+=c+50,l++,u++}return n},qA=(e,t=RA)=>{if(typeof t==`function`?t(e):t.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,``)}`),{hostname:r,pathname:i}=new URL(e);return RegExp(`(^|\\.)${n.hostname}$`).test(r)&&RegExp(`^${n.pathname.replace(/\/+$/,``)}(/+|$)`).test(i)}))return!0;throw Error(`Invalid or disallowed library URL: "${e}"`)},JA=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ja.addLibrary)||new URLSearchParams(window.location.search).get(Pr.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get(`token`):null;return e?{libraryUrl:e,idToken:t}:null},YA=class e{constructor(e){B(this,`adapter`),this.adapter=e}static async getLibraryItems(t,n,r=!0){let i=()=>new Promise(async(e,r)=>{try{let r=await t.load({source:n});e(po(r?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};B(YA,`queue`,new kn),B(YA,`run`,async(e,t)=>{let n=new YA(e);return YA.queue.push(()=>t(n))});var XA=YA,ZA=0,QA=0,$A=e=>`${e.id}:${e.name||``}:${ac(e.elements)}`,ej=e=>_c(e.map(e=>$A(e)).sort().join()),tj=async(e,t)=>{try{return QA++,await XA.run(e,async n=>{let r=y(await n.getLibraryItems(`save`));for(let[e]of t.deletedItems)r.delete(e);let i=[];for(let[e,n]of t.addedItems)r.has(e)?r.set(e,n):i.push(n);if(t.updatedItems)for(let[e,n]of t.updatedItems)r.set(e,n);let a=i.concat(Array.from(r.values())),o=ej(a);return o!==ZA&&await e.save({libraryItems:a}),ZA=o,a})}finally{QA--}},nj=e=>{let{excalidrawAPI:t}=e,n=(0,V.useRef)(e);n.current=e;let r=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(!t)return;r.current=!1;let e=async({libraryUrl:e,idToken:r})=>{let i=new Promise(async(t,r)=>{try{e=decodeURIComponent(e),e=Ws(e),qA(e,n.current.validateLibraryUrl),t(await(await fetch(e)).blob())}catch(e){r(e)}}),a=r!==t.id;await(a&&document.hidden?new Promise(e=>{window.addEventListener(`focus`,()=>e(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:i,prompt:a,merge:!0,defaultStatus:`published`,openLibraryMenu:!0})}catch(e){throw t.updateScene({appState:{errorMessage:e.message}}),e}finally{if(window.location.hash.includes(Ja.addLibrary)){let e=new URLSearchParams(window.location.hash.slice(1));e.delete(Ja.addLibrary),window.history.replaceState({},rn,`#${e.toString()}`)}else if(window.location.search.includes(Pr.addLibrary)){let e=new URLSearchParams(window.location.search);e.delete(Pr.addLibrary),window.history.replaceState({},rn,`?${e.toString()}`)}}},i=t=>{t.preventDefault();let n=JA();n&&(t.stopImmediatePropagation(),window.history.replaceState({},``,t.oldURL),e(n))},a=JA();if(a&&e(a),`getInitialLibraryItems`in n.current&&n.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(n.current.getInitialLibraryItems()).then(e=>{t.updateLibrary({libraryItems:e,merge:!0})}).catch(e=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${e?.message}`)})),`adapter`in n.current&&n.current.adapter){let e=n.current.adapter,i=n.current.migrationAdapter,a=al();i?a.resolve(ko(i.load).then(async t=>{let n=null;try{if(!t)return XA.getLibraryItems(e,`load`);n=po(t.libraryItems||[],`published`);let r=await tj(e,WA([],n));try{await i.clear()}catch(e){console.error(`couldn't delete legacy library data: ${e.message}`)}return r}catch(e){return console.error(`couldn't migrate legacy library data: ${e.message}`),n}}).catch(t=>(console.error(`error during library migration: ${t.message}`),XA.getLibraryItems(e,`load`)))):a.resolve(ko(XA.getLibraryItems,e,`load`)),t.updateLibrary({libraryItems:a.then(e=>{let t=e||[];return ZA=ej(t),t}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(P.HASHCHANGE,i),()=>{window.removeEventListener(P.HASHCHANGE,i)}},[t]),(0,V.useEffect)(()=>{let e=zA.on(async(e,t)=>{let i=r.current,a=`adapter`in n.current&&n.current.adapter||null;try{a&&ZA!==ej(t)&&await tj(a,e)}catch(t){console.error(`couldn't persist library update: ${t.message}`,e),i&&n.current.excalidrawAPI&&n.current.excalidrawAPI.updateScene({appState:{errorMessage:G(`errors.saveLibraryError`)}})}}),t=e=>{QA&&Ni(e)};return window.addEventListener(P.BEFORE_UNLOAD,t),()=>{window.removeEventListener(P.BEFORE_UNLOAD,t),e(),ZA=0,QA=0}},[])},rj=({theme:e,id:t,libraryReturnUrl:n})=>{let r=n||window.location.origin+window.location.pathname;return(0,U.jsx)(`a`,{className:`library-menu-browse-button`,href:`${ca.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${C.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:G(`labels.libraries`)})},ij=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,U.jsxs)(`div`,{className:H(`library-menu-control-buttons`,a),style:r,children:[(0,U.jsx)(rj,{id:n,libraryReturnUrl:e,theme:t}),i]}),aj=Dl(0),oj=e=>{let[t,n]=Yb(aj);return(0,V.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,Tl.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},sj=({label:e,onClick:t,className:n,children:r,actionType:i,type:a=`button`,isLoading:o,...s})=>{let c=i?`Dialog__action-button--${i}`:``;return(0,U.jsxs)(`button`,{className:H(`Dialog__action-button`,c,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,U.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,U.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,U.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,U.jsx)(Lw,{})})]})},cj=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=G(`buttons.confirm`),cancelText:a=G(`buttons.cancel`),className:o=``,...s}=e,c=fW(),l=Xb(iM),{container:u}=lW();return(0,U.jsxs)(fM,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,U.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,U.jsx)(sj,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,Cl.flushSync)(()=>{n()}),u?.focus()}}),(0,U.jsx)(sj,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,Cl.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},lj=class{static has(e){try{return!!window.localStorage.getItem(e)}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),!1}}static get(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),null}}};B(lj,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),B(lj,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var uj=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,dj=/{{([\w-]+)}}/,fj=/<([\w-]+)>/,pj=/<\/([\w-]+)>/,mj=(e,t)=>{let n=[{name:``,children:[]}];return e.split(uj).filter(Boolean).forEach(r=>{let i=r.match(fj),a=r.match(pj),o=r.match(dj);if(i!==null){let r=i[1];t.hasOwnProperty(r)?n.push({name:r,children:[]}):console.warn(`Trans: missed to pass in prop ${r} for interpolating ${e}`)}else if(a!==null){if(a[1]===n[n.length-1].name){let e=n.pop(),r=V.createElement(V.Fragment,{},...e.children),i=t[e.name];typeof i==`function`&&n[n.length-1].children.push(i(r))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`)}else if(o!==null){let r=o[1];t.hasOwnProperty(r)?n[n.length-1].children.push(t[r]):console.warn(`Trans: key ${r} not in props for interpolating ${e}`)}else n[n.length-1].children.push(r)}),n.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),n[0].children},hj=({i18nKey:e,children:t,...n})=>{let{t:r}=fx();return V.createElement(V.Fragment,{},...mj(r(e),n))},gj=async e=>{let t=gc(e,6),n=document.createElement(`canvas`);n.width=t[0].length*128+(t[0].length+1)*16-16,n.height=t.length*128+(t.length+1)*16-16;let r=n.getContext(`2d`);r.fillStyle=`#fff`,r.fillRect(0,0,n.width,n.height);for(let[t,n]of e.entries()){let e=await AA({elements:n.elements,files:null,maxWidthOrHeight:128}),{width:i,height:a}=e,o=Math.floor(t/6)*144,s=t%6*144;r.drawImage(e,s+(128-i)/2+8,o+(128-a)/2+8),r.lineWidth=2,r.strokeStyle=`#ced4da`,r.strokeRect(s+4,o+4,136,136)}return await st(new File([await sr(n)],`preview`,{type:A.png}),{outputType:A.jpg,maxWidthOrHeight:5e3})},_j=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,V.useRef)(null),o=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let n=a.current;n&&(async()=>{let r=await MA({elements:e.elements,appState:{...t,viewBackgroundColor:`#fff`,exportBackground:!0},files:null,skipInliningFonts:!0});n.innerHTML=r.outerHTML})()},[e.elements,t]),(0,U.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,U.jsx)(`span`,{className:`single-library-item-status`,children:G(`labels.statusPublished`)}),(0,U.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,U.jsx)(Y,{"aria-label":G(`buttons.remove`),type:`button`,icon:PS,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:G(`buttons.remove`)}),(0,U.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,U.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,U.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,U.jsx)(`span`,{style:{fontWeight:500,color:`#868e96`},children:G(`publishDialog.itemName`)}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,U.jsx)(`input`,{type:`text`,ref:o,style:{width:`80%`,padding:`0.2rem`},defaultValue:e.name,placeholder:`Item name`,onChange:e=>{r(e.target.value,n)}})]}),(0,U.jsx)(`span`,{className:`error`,children:e.error})]})]})},vj=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:a,onRemove:o})=>{let[s,c]=(0,V.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=lj.get(wt.PUBLISH_LIBRARY);e&&c(e)},[]);let[d,f]=(0,V.useState)(t.slice());(0,V.useEffect)(()=>{f(t.slice())},[t]);let p=e=>{c({...s,[e.target.name]:e.target.value})},m=async e=>{e.preventDefault(),u(!0);let t=[],n=!1;if(d.forEach(e=>{let r=``;e.name||(r=G(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){f(t),u(!1);return}let a=await gj(d),o={type:Nc.excalidrawLibrary,version:C.excalidrawLibrary,source:Fi(),libraryItems:d},c=JSON.stringify(o,null,2),l=new Blob([c],{type:`application/json`}),p=new FormData;p.append(`excalidrawLib`,l),p.append(`previewImage`,a),p.append(`previewImageType`,a.type),p.append(`title`,s.name),p.append(`authorName`,s.authorName),p.append(`githubHandle`,s.githubHandle),p.append(`name`,s.name),p.append(`description`,s.description),p.append(`twitterHandle`,s.twitterHandle),p.append(`website`,s.website),fetch(`${ca.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:p}).then(e=>e.ok?e.json().then(({url:e})=>{lj.delete(wt.PUBLISH_LIBRARY),r({url:e,authorName:s.authorName,items:d})}):e.json().catch(()=>{throw Error(e.statusText||`something went wrong`)}).then(t=>{throw Error(t.message||e.statusText||`something went wrong`)}),e=>{console.error(e),i(e),u(!1)}).catch(e=>{console.error(e),i(e),u(!1)})},h=()=>{let e=[];return d.forEach((t,r)=>{e.push((0,U.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,U.jsx)(_j,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=d.slice();n[t].name=e,f(n)},onRemove:o})},r))}),(0,U.jsx)(`div`,{className:`selected-library-items`,children:e})},g=(0,V.useCallback)(()=>{a(d),lj.set(wt.PUBLISH_LIBRARY,s),e()},[d,e,a,s]),_=!!t.length,v=t.some(e=>e.status===`published`);return(0,U.jsx)(fM,{onCloseRequest:g,title:G(`publishDialog.title`),className:`publish-library`,children:_?(0,U.jsxs)(`form`,{onSubmit:m,children:[(0,U.jsx)(`div`,{className:`publish-library-note`,children:(0,U.jsx)(hj,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,U.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener`,children:e})})}),(0,U.jsx)(`span`,{className:`publish-library-note`,children:(0,U.jsx)(hj,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,U.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,U.jsx)(`div`,{className:`publish-library-note`,children:G(`publishDialog.noteItems`)}),v&&(0,U.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:G(`publishDialog.republishWarning`)}),h(),(0,U.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.libraryName`)}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,U.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:s.name,onChange:p,placeholder:G(`publishDialog.placeholder.libraryName`)})]}),(0,U.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.libraryDesc`)}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,U.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:s.description,onChange:p,placeholder:G(`publishDialog.placeholder.libraryDesc`)})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.authorName`)}),(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,U.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:s.authorName,onChange:p,placeholder:G(`publishDialog.placeholder.authorName`)})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.githubUsername`)}),(0,U.jsx)(`input`,{type:`text`,name:`githubHandle`,value:s.githubHandle,onChange:p,placeholder:G(`publishDialog.placeholder.githubHandle`)})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.twitterUsername`)}),(0,U.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:s.twitterHandle,onChange:p,placeholder:G(`publishDialog.placeholder.twitterHandle`)})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:G(`publishDialog.website`)}),(0,U.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:G(`publishDialog.errors.website`),value:s.website,onChange:p,placeholder:G(`publishDialog.placeholder.website`)})]}),(0,U.jsx)(`span`,{className:`publish-library-note`,children:(0,U.jsx)(hj,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,U.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,U.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,U.jsx)(sj,{label:G(`buttons.saveLibNames`),onClick:g,"data-testid":`cancel-clear-canvas-button`}),(0,U.jsx)(sj,{type:`submit`,label:G(`buttons.submit`),actionType:`primary`,isLoading:l})]})]}):(0,U.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:G(`publishDialog.atleastOneLibItem`)})})},yj={Row:(0,V.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,U.jsx)(`div`,{className:H(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,V.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,U.jsx)(`div`,{className:H(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},bj=({children:e,onClickOutside:t,className:n=``,onSelect:r,open:i=!0,align:a=`end`,style:o})=>{let s=sW(),[c,l]=kA(),u=(0,V.useMemo)(()=>({current:c}),[c]),d=rT({onClickOutside:t});nT(u,(0,V.useCallback)(e=>{u.current?.closest(`.${hn.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(e.target)||d.onClickOutside?.()},[d,u])),(0,V.useEffect)(()=>{if(!i||!c)return;let e=e=>{e.key===z.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),d.onClickOutside?.())},t={capture:!0},n=c.ownerDocument;return n.addEventListener(P.KEYDOWN,e,t),()=>{n.removeEventListener(P.KEYDOWN,e,t)}},[d,i,c]);let f=H(`dropdown-menu ${n}`,{"dropdown-menu--mobile":s.formFactor===`phone`}).trim();return(0,U.jsx)(nE.Provider,{value:{onSelect:r},children:(0,U.jsx)(ny,{ref:l,className:f,style:o,"data-testid":`dropdown-menu`,align:a,sideOffset:8,onCloseAutoFocus:e=>e.preventDefault(),children:s.formFactor===`phone`?(0,U.jsx)(yj.Col,{className:`dropdown-menu-container`,children:e}):(0,U.jsx)(uT,{className:`dropdown-menu-container`,padding:2,children:e})})})};bj.displayName=`DropdownMenuContent`;var xj=bj,Sj=({children:e,className:t=``,selected:n,...r})=>(0,U.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),Cj=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noopener`,...c})=>{let l=iE(i);return(0,U.jsx)(ry,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,U.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noopener ${s}`,className:rE(a,o),title:c.title??c[`aria-label`],children:(0,U.jsx)(oE,{icon:e,shortcut:t,children:r})})})},wj=Cj;Cj.displayName=`DropdownMenuItemLink`;var Tj=()=>(0,U.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`6px 0`,flex:`0 0 auto`}}),Ej=Tj;Tj.displayName=`DropdownMenuSeparator`;var Dj=-4,Oj=4,kj=({children:e,className:t})=>{let n=sW(),r=H(`dropdown-menu dropdown-submenu ${t}`,{"dropdown-menu--mobile":n.formFactor===`phone`}).trim(),i=(0,V.useCallback)(e=>{if(e){let t=e.closest(`.dropdown-menu-container`)?.getBoundingClientRect();if(t){let n=e.getBoundingClientRect().width,r=window.innerWidth-t.right;r<n+20&&(o(r-n+Dj),c(Dj+8))}}},[]),[a,o]=(0,V.useState)(Oj),[s,c]=(0,V.useState)(Dj);return(0,U.jsx)(oy,{className:r,sideOffset:a,alignOffset:s,collisionPadding:8,ref:i,children:n.formFactor===`phone`?(0,U.jsx)(yj.Col,{className:`dropdown-menu-container`,children:e}):(0,U.jsx)(uT,{className:`dropdown-menu-container`,padding:2,style:{zIndex:1},children:e})})},Aj=kj;kj.displayName=`DropdownMenuSubContent`;var jj=({children:e,icon:t,shortcut:n,className:r})=>(0,U.jsxs)(ay,{className:`${rE(r)} dropdown-menu__submenu-trigger`,children:[(0,U.jsx)(oE,{icon:t,shortcut:n,children:e}),(0,U.jsx)(`div`,{className:`dropdown-menu__submenu-trigger-icon`,children:Fw})]}),Mj=jj;jj.displayName=`DropdownMenuSubTrigger`;var Nj=e=>t=>V.Children.toArray(t).find(t=>V.isValidElement(t)&&typeof t.type!=`string`&&t?.type.displayName&&t.type.displayName===e)||null,Pj=Nj(`DropdownMenuTrigger`),Fj=Nj(`DropdownMenuContent`),Ij=Nj(`DropdownMenuSubTrigger`),Lj=Nj(`DropdownMenuSubContent`),Rj=({children:e})=>{let t=Ij(e),n=Lj(e);return(0,U.jsxs)(iy,{children:[t,n]})};Rj.Trigger=Mj,Rj.Content=Aj,Rj.displayName=`DropdownMenuSub`;var zj=Rj,Bj=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=sW(),o=H(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.formFactor===`phone`}).trim();return(0,U.jsx)(ty,{className:o,onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},Vj=Bj;Bj.displayName=`DropdownMenuTrigger`;var Hj=e=>(0,U.jsx)(uE,{...e,icon:e.checked?rS:Nw}),Uj=({children:e,open:t})=>{let n=Pj(e),r=Fj(e),i=r&&V.isValidElement(r)?V.cloneElement(r,{open:t}):r;return(0,U.jsx)(ey,{open:t,modal:!1,children:(0,U.jsxs)(`div`,{className:hn.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:`contents`},children:[n,i]})})};Uj.Trigger=Vj,Uj.Content=xj,Uj.Item=uE,Uj.ItemCheckbox=Hj,Uj.ItemLink=wj,Uj.ItemCustom=Sj,Uj.Group=tE,Uj.Separator=Ej,Uj.Sub=zj;var Q=Uj;Uj.displayName=`DropdownMenu`;var Wj=(e,t)=>e.filter(e=>t.includes(e.id)),Gj=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=Yb(BA),[l,u]=Yb(iM),d=()=>{let e=t.length?G(`alerts.removeItemsFromsLibrary`,{count:t.length}):G(`alerts.resetLibrary`),n=t.length?G(`confirmDialog.removeItemsFromLib`):G(`confirmDialog.resetLibrary`);return(0,U.jsx)(cj,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:n,children:(0,U.jsx)(`p`,{children:e})})},[f,p]=(0,V.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=G(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),x=(0,V.useCallback)(()=>(0,U.jsxs)(fM,{onCloseRequest:()=>b(null),title:G(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,U.jsx)(`p`,{children:(0,U.jsx)(hj,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,U.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,U.jsx)(Y,{type:`button`,title:G(`buttons.close`),"aria-label":G(`buttons.close`),label:G(`buttons.close`),onClick:()=>b(null),"data-testid":`publish-library-success-close`,className:`publish-library-success-close`})]}),[b,y]),S=(e,r)=>{v(!1),b({url:e.url,authorName:e.authorName});let i=r.slice();i.forEach(e=>{t.includes(e.id)&&(e.status=`published`)}),n.setLibrary(i)};return(0,U.jsxs)(`div`,{className:H(`library-menu-dropdown-container`,s),children:[(0,U.jsxs)(Q,{open:l,children:[(0,U.jsx)(Q.Trigger,{onToggle:()=>u(!l),children:vx}),(0,U.jsxs)(Q.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,U.jsx)(Q.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:xi({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:G(`errors.importLibraryError`)})}},icon:sS,"data-testid":`lib-dropdown--load`,children:G(`buttons.load`)}),!!h.length&&(0,U.jsx)(Q.Item,{onSelect:async()=>{let t=m?h:await n.getLatestLibrary();It(t).catch(ue).catch(t=>{e({errorMessage:t.message})})},icon:Xx,"data-testid":`lib-dropdown--export`,children:G(`buttons.export`)}),m&&(0,U.jsx)(Q.Item,{icon:AC,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:G(`buttons.publishLibrary`)}),!!h.length&&(0,U.jsx)(Q.Item,{onSelect:()=>p(!0),icon:Wx,children:g})]})]}),t.length>0&&(0,U.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,U.jsx)(vj,{onClose:()=>v(!1),libraryItems:Wj(c.libraryItems,t),appState:o,onSuccess:e=>S(e,c.libraryItems),onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(c.libraryItems),onRemove:e=>a(t.filter(t=>t!==e))}),y&&x()]})},Kj=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=aW(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=LA(),o=eT(),s=fW(),[c]=Yb(BA),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:G(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,U.jsx)(Gj,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})};function qj(){return[!1,(0,V.useCallback)(e=>e(),[])]}var Jj=V.useTransition||qj,Yj=(0,V.memo)(({id:e,name:t,showName:n,elements:r,isPending:i,onClick:a,selected:o,onToggle:s,onDrag:c,svgCache:l})=>{let u=(0,V.useRef)(null),d=IA(e,r,l,u),[f,p]=(0,V.useState)(!1),m=sW().formFactor===`phone`,h=!!t?.trim(),g=i&&(0,U.jsx)(`div`,{className:`library-unit__adder`,children:_x});return(0,U.jsxs)(`div`,{className:H(`library-unit`,{"library-unit__active":r,"library-unit--hover":r&&f,"library-unit--selected":o,"library-unit--skeleton":!d,"library-unit--named":n}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onPointerEnter:h?e=>{let r=n?e.currentTarget.querySelector(`.library-unit__name`):null;r&&r.scrollWidth<=r.clientWidth||fD(e.currentTarget,t,{delay:!0,position:`top`})}:void 0,onPointerLeave:h?uD:void 0,onPointerDown:h?uD:void 0,children:[(0,U.jsx)(`div`,{className:H(`library-unit__dragger`,{"library-unit__pulse":!!i}),ref:n?void 0:u,draggable:!!r,onClick:r||i?t=>{e&&t.shiftKey?s(e,t):a(e)}:void 0,onDragStart:t=>{if(!e){t.preventDefault();return}p(!1),c(e,t)},children:n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`library-unit__preview`,ref:u}),(0,U.jsx)(`div`,{className:`library-unit__name`,children:t})]})}),g,e&&r&&(f||m||o)&&(0,U.jsx)(ZD,{checked:o,onChange:(t,n)=>s(e,n),className:`library-unit__checkbox`})]})}),Xj=({showName:e})=>(0,U.jsx)(`div`,{className:H(`library-unit library-unit--skeleton`,{"library-unit--named":e})}),Zj=({children:e,showNames:t})=>(0,U.jsx)(`div`,{className:H(`library-menu-items-container__grid`,{"library-menu-items-container__grid--named":t}),children:e}),Qj=(0,V.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o,showNames:s})=>{let[,c]=Jj(),[l,u]=(0,V.useState)(0);return(0,V.useEffect)(()=>{l<e.length&&c(()=>{u(l+o)})},[l,e.length,c,o]),(0,U.jsx)(U.Fragment,{children:e.map((e,o)=>o<l?(0,U.jsx)(Yj,{elements:e?.elements,isPending:!e?.id&&!!e?.elements,onClick:i,svgCache:a,id:e?.id,name:`name`in e?e.name:void 0,showName:s,selected:r(e.id),onToggle:t,onDrag:n},e?.id??o):(0,U.jsx)(Xj,{showName:s},o))})}),$j=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,U.jsx)(`button`,{onClick:ys(a.onClick,e=>{t()}),type:e,className:H(`excalidraw-button`,i,{selected:n}),...a,children:r}),eM=(0,V.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:a,onKeyDown:o,isRedacted:s=!1,icon:c,className:l,type:u,...d},f)=>{let p=(0,V.useRef)(null);(0,V.useImperativeHandle)(f,()=>p.current),(0,V.useLayoutEffect)(()=>{a&&(p.current?.focus(),p.current?.select())},[a]);let[m,h]=(0,V.useState)(!1);return(0,U.jsxs)(`div`,{className:H(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{p.current?.focus()},children:[c,t&&(0,U.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,U.jsxs)(`div`,{className:H(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,U.jsx)(`input`,{className:H({"is-redacted":`value`in d&&d.value&&s&&!m}),readOnly:i,value:`value`in d?d.value:void 0,defaultValue:`defaultValue`in d?d.defaultValue:void 0,placeholder:r,ref:p,onChange:t=>e?.(t.target.value),onKeyDown:o,type:u}),s&&(0,U.jsx)($j,{onSelect:()=>h(!m),style:{border:0,userSelect:`none`},children:m?ZC:XC})]})]})}),tM=17,nM=64;function rM({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=sW(),d=(0,V.useRef)(null),f=oj(d);(0,V.useEffect)(()=>{f>0&&d.current?.scrollTo(0,f)},[]);let{svgCache:p}=LA(),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(``),v=!t.length&&!i.length,b=!v&&!!g.trim(),x=(0,V.useMemo)(()=>{let e=OA(g.trim().toLowerCase());return e?t.filter(t=>{let n=t.name||``;return n.trim()&&OA(n.toLowerCase()).includes(e)}):[]},[t,g]),S=(0,V.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),C=(0,V.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),w=(0,V.useCallback)((e,t)=>{let n=!l.includes(e),r=[...S,...C];if(n){if(t.shiftKey&&m){let t=r.findIndex(e=>e.id===m),n=r.findIndex(t=>t.id===e);if(t===-1||n===-1){c([...l,e]);return}let i=y(l),a=Math.min(t,n),o=Math.max(t,n);c(r.reduce((e,t,n)=>((n>=a&&n<=o||i.has(t.id))&&e.push(t.id),e),[]))}else c([...l,e]);h(e)}else h(null),c(l.filter(t=>t!==e))},[m,c,C,l,S]);(0,V.useEffect)(()=>{l.length||h(null)},[l]);let T=(0,V.useCallback)(e=>{let n;return n=l.includes(e)?t.filter(e=>l.includes(e.id)):t.filter(t=>t.id===e),n.map(e=>({...e,elements:se({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[t,l]),E=(0,V.useCallback)((e,t)=>{let n={itemIds:l.includes(e)?l:[e]};t.dataTransfer.setData(A.excalidrawlibIds,JSON.stringify(n))},[l]),D=(0,V.useCallback)(e=>e?l.includes(e):!1,[l]),ee=(0,V.useCallback)(()=>{n(i)},[i,n]),O=(0,V.useCallback)(e=>{e&&r(T(e))},[T,r]),k=p.size>=(x.length?x:t).length?nM:tM,te=(0,V.useRef)(null);(0,V.useEffect)(()=>{si(()=>{te.current?.focus()})},[]);let j=!b&&(0,U.jsxs)(U.Fragment,{children:[!v&&(0,U.jsx)(`div`,{className:`library-menu-items-container__header`,children:G(`labels.personalLib`)}),!i.length&&!S.length?(0,U.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[!C.length&&(0,U.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:G(`library.noItems`)}),(0,U.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:C.length>0?G(`library.hint_emptyPrivateLibrary`):G(`library.hint_emptyLibrary`)})]}):(0,U.jsxs)(Zj,{children:[i.length>0&&(0,U.jsx)(Qj,{itemsRenderedPerBatch:k,items:[{id:null,elements:i}],onItemSelectToggle:w,onItemDrag:E,onClick:ee,isItemSelected:D,svgCache:p}),(0,U.jsx)(Qj,{itemsRenderedPerBatch:k,items:S,onItemSelectToggle:w,onItemDrag:E,onClick:O,isItemSelected:D,svgCache:p})]}),C.length>0&&(0,U.jsx)(`div`,{className:`library-menu-items-container__header`,style:{marginTop:`0.75rem`},children:G(`labels.excalidrawLib`)}),C.length>0&&(0,U.jsx)(Zj,{children:(0,U.jsx)(Qj,{itemsRenderedPerBatch:k,items:C,onItemSelectToggle:w,onItemDrag:E,onClick:O,isItemSelected:D,svgCache:p})})]}),ne=b&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`library-menu-items-container__header`,children:[G(`library.search.heading`),!e&&(0,U.jsxs)(`div`,{className:`library-menu-items-container__header__hint`,style:{cursor:`pointer`},onPointerDown:e=>e.preventDefault(),onClick:e=>{_(``)},children:[(0,U.jsx)(`kbd`,{children:`esc`}),` to clear`]})]}),x.length>0?(0,U.jsx)(Zj,{showNames:!0,children:(0,U.jsx)(Qj,{itemsRenderedPerBatch:k,items:x,onItemSelectToggle:w,onItemDrag:E,onClick:O,isItemSelected:D,svgCache:p,showNames:!0})}):(0,U.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,U.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:G(`library.search.noResults`)}),(0,U.jsx)($j,{onPointerDown:e=>e.preventDefault(),onSelect:()=>{_(``)},style:{width:`auto`,marginTop:`1rem`},children:G(`library.search.clearSearch`)})]})]});return(0,U.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||S.length||C.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[(0,U.jsxs)(`div`,{className:`library-menu-items-header`,children:[!v&&(0,U.jsx)(eM,{ref:te,type:`search`,className:H(`library-menu-items-container__search`,{hideCancelButton:u.formFactor!==`phone`}),placeholder:G(`library.search.inputPlaceholder`),value:g,onChange:e=>_(e),onKeyDown:e=>{e.key===z.ESCAPE&&g&&(e.preventDefault(),e.stopPropagation(),_(``))}}),(0,U.jsx)(Kj,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`})]}),(0,U.jsxs)(yj.Col,{className:`library-menu-items-container__items`,align:`start`,gap:1,style:{flex:C.length>0?1:`0 1 auto`,margin:v?`auto`:0},ref:d,children:[e&&(0,U.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,U.jsx)(Lw,{})}),j,ne,v&&(0,U.jsx)(ij,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a})]})]})}var iM=Dl(!1),aM=({children:e})=>(0,U.jsx)(`div`,{className:`layer-ui__library`,children:e}),oM=(0,V.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=Yb(BA),d=(0,V.useCallback)(e=>{(async(e,t)=>{Yw(`element`,`addToLibrary`,`ui`);for(let t of p)if(e.some(e=>e.type===t))return r({errorMessage:G(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Ti(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:G(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,V.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,U.jsx)(aM,{children:(0,U.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Lw,{size:`2em`}),(0,U.jsx)(`span`,{children:G(`labels.libraryLoadingMessage`)})]})})});let m=u.libraryItems.length>0||t.length>0;return(0,U.jsxs)(aM,{children:[(0,U.jsx)(rM,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),m&&(0,U.jsx)(ij,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),sM=(e,t)=>({elements:e,pending:Kc(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),cM=(e,t)=>{let n=uW(),[r,i]=(0,V.useState)(()=>sM(n,e.selectedElementIds)),a=(0,V.useRef)(new Map);return(0,V.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,V.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!qr(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),sM(n,e.selectedElementIds);let i=t.scene.getNonDeletedElementsMap();for(let t of Object.keys(e.selectedElementIds)){let r=i.get(t)?.version;if(r&&r!==a.current.get(t))return sM(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},lM=(0,V.memo)(()=>{let e=aW(),{onInsertElements:t}=e,n=oW(),r=eT(),i=fW(),[a,o]=(0,V.useState)([]),s=(0,V.useMemo)(()=>e.library,[e.library]),c=cM(r,e);(0,V.useEffect)(()=>{let t=e.ownerDocument,n=e.ownerWindow;return we(t,P.KEYDOWN,r=>{if(r.key===z.ESCAPE&&r.target instanceof n.HTMLElement){let s=r.target;if(s.closest(`.${hn.SIDEBAR}`))a.length>0?(r.stopPropagation(),o([])):s instanceof n.HTMLInputElement&&_(s)&&!s.value&&(r.stopPropagation(),i({openSidebar:null}),e.focusContainer());else if(a.length>0){let{x:n,y:i}=e.viewport.lastPosition;t.elementFromPoint(n,i)?.closest(`.${hn.SIDEBAR}`)&&(r.stopPropagation(),o([]))}}},{capture:!0})},[a,i,e]);let l=(0,V.useCallback)(n=>{t(KA(n)),e.focusContainer()},[t,e]),u=(0,V.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return(0,U.jsx)(oM,{pendingElements:c,onInsertLibraryItems:l,onAddToLibrary:u,setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})}),uM=e=>{let{closeOnClickOutside:t=!0}=e,n=tT({className:`excalidraw-modal-container`}),r=(0,V.useMemo)(()=>n?.ownerDocument.body.classList.contains(`excalidraw-animations-disabled`)??!1,[n]);return n?(0,Cl.createPortal)((0,U.jsxs)(`div`,{className:H(`Modal`,e.className,{"animations-disabled":r}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===z.ESCAPE&&(t.preventDefault(),t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,children:[(0,U.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,U.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null};function dM(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var fM=e=>{let[t,n]=kA(),[r]=(0,V.useState)(document.activeElement),{id:i}=lW(),a=sW().formFactor===`phone`;(0,V.useEffect)(()=>{if(!t)return;let n=Bs(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===z.TAB){let n=Bs(t),{activeElement:r}=document,i=n.findIndex(e=>e===r);i===0&&e.shiftKey?(n[n.length-1].focus(),e.preventDefault()):i===n.length-1&&!e.shiftKey&&(n[0].focus(),e.preventDefault())}};return t.addEventListener(`keydown`,r),()=>t.removeEventListener(`keydown`,r)},[t,e.autofocus]);let o=fW(),s=Xb(iM),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,U.jsx)(uM,{className:H(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:dM(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,U.jsxs)(uT,{ref:n,children:[e.title&&(0,U.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,U.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,U.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:G(`buttons.close`),"aria-label":G(`buttons.close`),type:`button`,children:PS}),(0,U.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},pM=X({name:`viewMode`,label:`labels.viewMode`,icon:XC,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:I.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n,r)=>typeof n.viewModeEnabled>`u`&&r.isInteractionEnabled(),keyTest:e=>!e[z.CTRL_OR_CMD]&&e.altKey&&e.code===d.R}),mM=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return qa(e.activeTool.type)&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>qa(e.type))},hM=(e,t,n)=>Tc(e.activeTool.type)||t.some(e=>Tc(ei(e,`backgroundColor`,n).type)),gM=(e,t,n,r)=>{let i=e.activeTool.type,a=e=>e(i)||t.some(t=>e(t.type)),o=t.length===1,s=t.length===2&&(ke(t[0])||ke(t[1])),c=!!(e.editingTextElement||e.newElement),l=t.length>0;return{hasSelection:l,showExtraActions:l&&!c,strokeColor:mM(e,t),backgroundColor:hM(e,t,n),fill:i===`bucketfill`||ut(i)&&!Zr(e.currentItemBackgroundColor)||t.some(e=>ut(e.type)&&!Zr(e.backgroundColor)),strokeWidth:a(Qe),freedrawMode:a(Ns),strokeStyle:a(ua),sloppiness:a(Mn),roundness:a(yr),arrowType:a(Pn),arrowheads:a(Xs),text:i===`text`||t.some(D),textAlign:i===`text`||xt(t,n),verticalAlign:Ji(t,n),opacity:i!==`autoshape`||l,layers:i!==`freedraw`&&i!==`autoshape`&&!t.some(e=>e.type===`freedraw`)||Kc(n,e).some(e=>e.type===`freedraw`),align:!s&&$O(e,r),distribute:t.length>2,link:o||s,linkSingleOnly:o,cropEditor:!e.croppingElementId&&o&&O(t[0]),lineEditor:!e.selectedLinearElement?.isEditing&&o&&ja(t[0])&&!vn(t[0])}},_M=H([hn.SHAPE_ACTIONS_THEME_SCOPE,`properties-content`]),vM=({renderAction:e})=>(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.layers`)}),(0,U.jsxs)(`div`,{className:`buttonList`,children:[e(`sendToBack`),e(`sendBackward`),e(`bringForward`),e(`bringToFront`)]})]}),yM=({renderAction:e,showDistribute:t})=>{let n=document.documentElement.getAttribute(`dir`)===`rtl`;return(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.align`)}),(0,U.jsxs)(`div`,{className:`buttonList align-buttons`,children:[(0,U.jsxs)(`div`,{className:`align-buttons__row`,children:[n?(0,U.jsxs)(U.Fragment,{children:[e(`alignRight`),e(`alignHorizontallyCentered`),e(`alignLeft`)]}):(0,U.jsxs)(U.Fragment,{children:[e(`alignLeft`),e(`alignHorizontallyCentered`),e(`alignRight`)]}),t&&e(`distributeHorizontally`)]}),(0,U.jsxs)(`div`,{className:`align-buttons__row`,children:[e(`alignTop`),e(`alignVerticallyCentered`),e(`alignBottom`),t&&e(`distributeVertically`)]})]})]})},bM=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=gM(e,Qa(t,e),t,r);return e.activeTool.type===`bucketfill`?(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,U.jsx)(`div`,{children:n(`changeBucketFillBackgroundColor`)}),n(`changeFillStyle`),n(`changeOpacity`)]}):(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,U.jsx)(`div`,{children:i.strokeColor&&n(`changeStrokeColor`)}),i.backgroundColor&&(0,U.jsx)(`div`,{children:n(`changeBackgroundColor`)}),i.fill&&n(`changeFillStyle`),i.strokeWidth&&n(`changeStrokeWidth`),i.strokeStyle&&(0,U.jsx)(U.Fragment,{children:n(`changeStrokeStyle`)}),i.freedrawMode&&n(`changeFreedrawMode`),i.sloppiness&&(0,U.jsx)(U.Fragment,{children:n(`changeSloppiness`)}),i.roundness&&(0,U.jsx)(U.Fragment,{children:n(`changeRoundness`)}),i.arrowType&&(0,U.jsx)(U.Fragment,{children:n(`changeArrowType`)}),i.text&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`fieldset`,{children:n(`changeFontFamily`)}),n(`changeFontSize`),i.textAlign&&n(`changeTextAlign`)]}),i.verticalAlign&&n(`changeVerticalAlign`),i.arrowheads&&(0,U.jsx)(U.Fragment,{children:n(`changeArrowhead`)}),i.opacity&&n(`changeOpacity`),i.layers&&(0,U.jsx)(vM,{renderAction:n}),i.align&&(0,U.jsx)(yM,{renderAction:n,showDistribute:i.distribute}),i.showExtraActions&&(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.actions`)}),(0,U.jsxs)(`div`,{className:`buttonList`,children:[n(`duplicateSelection`),n(`deleteSelectedElements`),n(`group`),n(`ungroup`),i.link&&n(`hyperlink`),i.cropEditor&&n(`cropEditor`),i.lineEditor&&n(`toggleLinearEditor`)]})]})]})},xM=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let a=r.hasSelection||e.activeTool.type!==`selection`&&e.activeTool.type!==`eraser`&&e.activeTool.type!==`hand`&&e.activeTool.type!==`laser`&&e.activeTool.type!==`lasso`,o=e.openPopup===`compactStrokeStyles`;return a?(0,U.jsx)(`div`,{className:`compact-action-item`,children:(0,U.jsxs)(Ny,{open:o,onOpenChange:e=>{n(e?{openPopup:`compactStrokeStyles`}:{openPopup:null})},children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:o}),title:G(`labels.stroke`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:o?null:`compactStrokeStyles`})},children:Ow})}),o&&(0,U.jsx)(dT,{className:_M,container:i,style:{maxWidth:`13rem`},onClose:()=>{},children:(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.fill&&t(`changeFillStyle`),r.strokeWidth&&t(`changeStrokeWidth`),r.freedrawMode&&t(`changeFreedrawMode`),r.strokeStyle&&(0,U.jsx)(U.Fragment,{children:t(`changeStrokeStyle`)}),r.sloppiness&&(0,U.jsx)(U.Fragment,{children:t(`changeSloppiness`)}),r.roundness&&t(`changeRoundness`),r.opacity&&t(`changeOpacity`)]})})]})}):null},SM=({appState:e,renderAction:t,setAppState:n,targetElements:r,predicates:i,container:a,app:o})=>{if(!i.arrowType)return null;let s=e.openPopup===`compactArrowProperties`;return(0,U.jsx)(`div`,{className:`compact-action-item`,children:(0,U.jsxs)(Ny,{open:s,onOpenChange:e=>{n(e?{openPopup:`compactArrowProperties`}:{openPopup:null})},children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.arrowtypes`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:s?null:`compactArrowProperties`})},children:(()=>{let t=JE(r,o,e=>ir(e)?e.elbowed?`elbow`:e.roundness?`round`:`sharp`:null,e=>ir(e),t=>t?null:e.currentItemArrowType);return t===`elbow`?xw:t===`round`?Sw:bw})()})}),s&&(0,U.jsx)(dT,{container:a,className:`properties-content`,style:{maxWidth:`13rem`},onClose:()=>{},children:t(`changeArrowProperties`)})]})})},CM=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let{saveCaretPosition:a,restoreCaretPosition:o}=gT(i?.ownerDocument),s=e.openPopup===`compactTextProperties`;return(0,U.jsx)(`div`,{className:`compact-action-item`,children:(0,U.jsxs)(Ny,{open:s,onOpenChange:t=>{t?(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`})):(n({openPopup:null}),e.editingTextElement&&o())},children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.textAlign`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?n({openPopup:null}):(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`}))},children:Rx})}),e.openPopup===`compactTextProperties`&&(0,U.jsx)(dT,{className:_M,container:i,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&o()},children:(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.text&&t(`changeFontSize`),r.textAlign&&t(`changeTextAlign`),r.verticalAlign&&t(`changeVerticalAlign`)]})})]})})},wM=({appState:e,renderAction:t,predicates:n,setAppState:r,container:i,showDuplicate:a,showDelete:o})=>{let s=e.openPopup===`compactOtherProperties`;return n.showExtraActions?(0,U.jsx)(`div`,{className:`compact-action-item`,children:(0,U.jsxs)(Ny,{open:s,onOpenChange:e=>{r(e?{openPopup:`compactOtherProperties`}:{openPopup:null})},children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.actions`),onClick:e=>{e.preventDefault(),e.stopPropagation(),r({openPopup:s?null:`compactOtherProperties`})},children:yx})}),s&&(0,U.jsx)(dT,{className:_M,container:i,style:{maxWidth:`12rem`,justifyContent:`center`,alignItems:`center`},onClose:()=>{},children:(0,U.jsxs)(`div`,{className:`selected-shape-actions`,children:[n.layers&&(0,U.jsx)(vM,{renderAction:t}),n.align&&(0,U.jsx)(yM,{renderAction:t,showDistribute:n.distribute}),(0,U.jsxs)(`fieldset`,{children:[(0,U.jsx)(`legend`,{children:G(`labels.actions`)}),(0,U.jsxs)(`div`,{className:`buttonList`,children:[t(`group`),t(`ungroup`),n.linkSingleOnly&&t(`hyperlink`),n.cropEditor&&t(`cropEditor`),a&&t(`duplicateSelection`),o&&t(`deleteSelectedElements`)]})]})]})})]})}):null},TM=({renderAction:e,predicates:t})=>t.lineEditor?(0,U.jsx)(`div`,{className:`compact-action-item`,children:e(`toggleLinearEditor`)}):null,EM=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=Qa(t,e),o=gM(e,a,t,r),{container:s}=lW();return(0,U.jsxs)(`div`,{className:`compact-shape-actions`,children:[o.strokeColor&&(0,U.jsx)(`div`,{className:H(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),o.freedrawMode&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFreedrawMode`,{cycle:!0})}),(0,U.jsx)(xM,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,U.jsx)(SM,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),o.lineEditor&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`toggleLinearEditor`)}),o.text&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,U.jsx)(CM,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),o.showExtraActions&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),o.showExtraActions&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)}),(0,U.jsx)(wM,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s})]})},DM=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=Qa(t,e),o=gM(e,a,t,r),{container:s}=lW(),c=(0,V.useRef)(null),l=c.current?.getBoundingClientRect()?.width??0,u=l>=374,d=l>=412;return(0,U.jsxs)(uT,{className:`compact-shape-actions mobile-shape-actions`,style:{flexDirection:`row`,boxShadow:`none`,padding:0,zIndex:2,backgroundColor:`transparent`,height:43.2,marginBottom:4,alignItems:`center`,gap:6,pointerEvents:`none`},ref:c,children:[(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6,flex:1},children:[o.strokeColor&&(0,U.jsx)(`div`,{className:H(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),(0,U.jsx)(xM,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,U.jsx)(SM,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),(0,U.jsx)(TM,{renderAction:n,predicates:o}),o.text&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,U.jsx)(CM,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),(0,U.jsx)(wM,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s,showDuplicate:!d,showDelete:!u})]}),(0,U.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6},children:[(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`undo`)}),(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`redo`)}),d&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),u&&(0,U.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)})]})]})},OM=({renderAction:e})=>(0,U.jsx)(yj.Col,{gap:1,className:hn.ZOOM_ACTIONS,children:(0,U.jsxs)(yj.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),kM=({renderAction:e,className:t})=>(0,U.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,U.jsx)(`div`,{className:`undo-button-container`,children:(0,U.jsx)(pD,{label:G(`buttons.undo`),delay:!0,children:e(`undo`)})}),(0,U.jsx)(`div`,{className:`redo-button-container`,children:(0,U.jsx)(pD,{label:G(`buttons.redo`),delay:!0,children:e(`redo`)})})]}),AM=({actionManager:e,showExitZenModeBtn:t})=>(0,U.jsx)(`button`,{type:`button`,className:H(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(mk),children:G(`buttons.exitZenMode`)}),jM=({actionManager:e})=>(0,U.jsx)(`button`,{type:`button`,className:`disable-view-mode`,onClick:()=>e.executeAction(pM),children:Aw}),MM=e=>{let t=(0,V.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},NM=Dl(null),PM=()=>{let[e,t]=Yb(NM),n=pW();return e&&e===`clearCanvas`?(0,U.jsx)(cj,{onConfirm:()=>{n.executeAction(vD),t(null)},onCancel:()=>t(null),title:G(`clearCanvasDialog.title`),children:(0,U.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,G(`alerts.clearReset`)]})}):null},FM={},IM=Dl(null),LM={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`,library:`Library`},RM=e=>{switch(e){case LM.app:return 1;case LM.export:return 2;case LM.editor:return 3;case LM.tools:return 4;case LM.elements:return 5;case LM.links:return 6;default:return 10}},zM=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,U.jsxs)(`div`,{className:H(`shortcut`,t),children:[r.map((e,t)=>(0,U.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,U.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,U.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},BM=e=>!e.altKey&&e[z.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===z.P||e.key===z.SLASH),VM=Object.assign(e=>{let t=eT(),n=fW();return(0,V.useEffect)(()=>{let e=e=>{BM(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&Yw(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(P.KEYDOWN,e,{capture:!0}),()=>window.removeEventListener(P.KEYDOWN,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,U.jsx)(HM,{...e}):null},{defaultItems:FM});function HM({customCommandPaletteItems:e}){let t=aW(),n=eT(),r=fW(),i=oW(),a=pW(),[o,s]=Yb(IM),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(null),d=rT({uiAppState:n,customCommandPaletteItems:e,appProps:i}),[f]=Yb(BA),p=(0,V.useMemo)(()=>f.libraryItems?.filter(e=>!!e.name).map(e=>({label:e.name,icon:(0,U.jsx)(UM,{id:e.id,elements:e.elements}),category:`Library`,order:RM(`Library`),haystack:OA(e.name),perform:()=>{t.onInsertElements(KA([e]))}}))||[],[t,f.libraryItems]);(0,V.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=d,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?G(n.label(t.scene.getNonDeletedElements(),e,t)):G(n.label)),r},u=n=>typeof n.icon==`function`?n.icon(e,t.scene.getNonDeletedElements()):n.icon,f=[],m=(e,t,n)=>{let r={label:c(e),icon:u(e),category:t,shortcut:wA(e.name),keywords:e.keywords,predicate:e.predicate,viewMode:e.viewMode,perform:()=>{a.executeAction(e,`commandPalette`)}};return n?n(r,e):r};if(e&&t.scene&&a){let d=[a.actions.group,a.actions.ungroup,a.actions.cut,a.actions.copy,a.actions.deleteSelectedElements,a.actions.wrapSelectionInFrame,a.actions.copyStyles,a.actions.pasteStyles,a.actions.bringToFront,a.actions.bringForward,a.actions.sendBackward,a.actions.sendToBack,a.actions.alignTop,a.actions.alignBottom,a.actions.alignLeft,a.actions.alignRight,a.actions.alignVerticallyCentered,a.actions.alignHorizontallyCentered,a.actions.duplicateSelection,a.actions.flipHorizontal,a.actions.flipVertical,a.actions.zoomToFitSelection,a.actions.zoomToFitSelectionInViewport,a.actions.increaseFontSize,a.actions.decreaseFontSize,a.actions.toggleLinearEditor,a.actions.cropEditor,a.actions.togglePolygon,Bk,xA,SA].map(e=>m(e,LM.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>Kc(e,t).length>0}))),h=[a.actions.undo,a.actions.redo,a.actions.zoomIn,a.actions.zoomOut,a.actions.resetZoom,a.actions.zoomToFit,a.actions.zenMode,a.actions.viewMode,a.actions.gridMode,a.actions.objectsSnapMode,a.actions.toggleShortcuts,a.actions.selectAll,a.actions.toggleElementLock,a.actions.unlockAllElements,a.actions.stats].map(e=>m(e,LM.editor)),g=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>m(e,LM.export));f=[...d,...h,{label:c(vD),icon:u(vD),shortcut:wA(vD.name),category:LM.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{ex.set(NM,`clearCanvas`)}},{label:G(`buttons.exportImage`),category:LM.export,icon:dS,shortcut:wA(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},...g];let _=[m(CD,LM.app),{label:G(`toolBar.library`),category:LM.app,icon:gx,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Vr.name,tab:Vr.defaultTab}})}},{label:G(`search.title`),category:LM.app,icon:ew,viewMode:!0,perform:()=>{a.executeAction(vP)}},{label:G(`labels.shapeSwitch`),category:LM.elements,icon:aw,perform:()=>{a.executeAction(bA)}},{label:G(`labels.changeStroke`),keywords:[`color`,`outline`],category:LM.elements,icon:lS,viewMode:!1,predicate:(e,t)=>{let n=Kc(e,t);return n.length>0&&mM(t,n)},perform:()=>{r(e=>({openPopup:`elementStroke`}))}},{label:G(`labels.changeBackground`),keywords:[`color`,`fill`],icon:lS,category:LM.elements,viewMode:!1,predicate:(e,t)=>{let n=Kc(e,t);return n.length>0&&hM(t,n,y(e))},perform:()=>{r(e=>({openPopup:`elementBackground`}))}},{label:G(`labels.canvasBackground`),keywords:[`color`],icon:lS,category:LM.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...Object.keys(TD).reduce((e,n)=>{let r=TD[n];if(i.UIOptions.tools?.[n]===!1)return e;let a=DD(n)||r.numericKey,o={label:G(`toolBar.${n}`),category:LM.tools,shortcut:a,icon:r.icon,keywords:[`toolbar`],viewMode:!1,perform:()=>{t.setActiveTool({type:n},{toggle:!1})}};return e.push(o),e},[]),{label:G(`toolBar.lock`),category:LM.tools,icon:e.activeTool.locked?Cx:Sx,shortcut:z.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${G(`labels.textToDiagram`)}...`,category:LM.tools,icon:$C,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${G(`toolBar.mermaidToExcalidraw`)}...`,category:LM.tools,icon:HC,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],v=[...f,..._,...n||[]].map(e=>({...e,icon:e.icon||aw,order:e.order??RM(e.category),haystack:`${OA(e.label.toLocaleLowerCase())} ${e.keywords?.join(` `)||``}`}));l(v),s([...v,...p].find(e=>e.label===o?.label)??null)}},[d,t,a,l,o?.label,s,r,p]);let[m,h]=(0,V.useState)(``),[g,v]=(0,V.useState)(null),[b,x]=(0,V.useState)({}),S=e=>{r({openDialog:null},e),h(``)},C=(e,t)=>{n.openDialog?.name===`commandPalette`&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add(`excalidraw-animations-disabled`),S(()=>{e.perform({actionManager:a,event:t}),s(e),requestAnimationFrame(()=>{document.body.classList.remove(`excalidraw-animations-disabled`)})}))},w=MM(e=>e.viewMode===!1&&n.viewModeEnabled?!1:typeof e.predicate==`function`?e.predicate(t.scene.getNonDeletedElements(),n,i,t):e.predicate===void 0||e.predicate),T=MM(e=>{let t=_(e.target)||BM(e)||e.key===z.ESCAPE;if(t&&e.key!==z.ARROW_UP&&e.key!==z.ARROW_DOWN&&e.key!==z.ENTER)return;let n=Object.values(b).flat(),r=o&&!m&&w(o);if(e.key===z.ARROW_UP){e.preventDefault();let t=n.findIndex(e=>e.label===g?.label);if(r){if(t===0){v(o);return}if(g===o){let e=n[n.length-1];e&&v(e);return}}let i;i=t===-1||t===0?n.length-1:(t-1)%n.length;let a=n[i];a&&v(a);return}if(e.key===z.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===g?.label);if(r){if(!g||t===n.length-1){v(o);return}if(g===o){let e=n[0];e&&v(e);return}}let i=n[(t+1)%n.length];i&&v(i);return}if(e.key===z.ENTER&&g&&setTimeout(()=>{C(g,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key)){u?.current?.focus();return}e.preventDefault()}});return(0,V.useEffect)(()=>(window.addEventListener(P.KEYDOWN,T,{capture:!0}),()=>window.removeEventListener(P.KEYDOWN,T,{capture:!0})),[T]),(0,V.useEffect)(()=>{if(!c)return;let e=e=>{let t={};for(let n of e)t[n.category]?t[n.category].push(n):t[n.category]=[n];return t},t=m?.length>1?[...c.filter(w).sort((e,t)=>e.order-t.order),...p]:c.filter(w).sort((e,t)=>e.order-t.order),n=!m&&o&&w(o);if(!m){x(e(n?t.filter(e=>e.label!==o?.label):t)),v(n?o:t[0]||null);return}let r=OA(m.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=ib.default.filter(r,t,{extract:e=>e.haystack??``}).sort((e,t)=>t.score-e.score).map(e=>e.original),x(e(t)),v(t[0]??null)},[m,c,w,o,p]),(0,U.jsxs)(fM,{onCloseRequest:()=>S(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,U.jsx)(eM,{value:m,placeholder:G(`commandPalette.search.placeholder`),onChange:e=>{h(e)},selectOnRender:!0,ref:u}),t.editorInterface.formFactor!==`phone`&&(0,U.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,U.jsx)(zM,{shortcut:`↑↓`,children:G(`commandPalette.shortcuts.select`)}),(0,U.jsx)(zM,{shortcut:`↵`,children:G(`commandPalette.shortcuts.confirm`)}),(0,U.jsx)(zM,{shortcut:Z(`Esc`),children:G(`commandPalette.shortcuts.close`)})]}),(0,U.jsxs)(`div`,{className:`commands`,children:[o&&!m&&(0,U.jsxs)(`div`,{className:`command-category`,children:[(0,U.jsxs)(`div`,{className:`command-category-title`,children:[G(`commandPalette.recents`),(0,U.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:tw})]}),(0,U.jsx)(WM,{command:o,isSelected:o.label===g?.label,onClick:e=>C(o,e),disabled:!w(o),onMouseMove:()=>v(o),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n})]}),Object.keys(b).length>0?Object.keys(b).map((e,r)=>(0,U.jsxs)(`div`,{className:`command-category`,children:[(0,U.jsx)(`div`,{className:`command-category-title`,children:e}),b[e].map(r=>(0,U.jsx)(WM,{command:r,isSelected:r.label===g?.label,onClick:e=>C(r,e),onMouseMove:()=>v(r),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n,size:e===`Library`?`large`:`small`},r.label))]},e)):c?(0,U.jsxs)(`div`,{className:`no-match`,children:[(0,U.jsx)(`div`,{className:`icon`,children:ew}),` `,G(`commandPalette.search.noMatch`)]}):null]})]})}var UM=({id:e,elements:t})=>{let n=(0,V.useRef)(null),{svgCache:r}=LA();return IA(e,t,r,n),(0,U.jsx)(`div`,{className:`library-item-icon`,ref:n})},WM=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o,size:s=`small`})=>{let c=()=>{};return(0,U.jsxs)(`div`,{className:H(`command-item`,{"item-selected":t,"item-disabled":n,"command-item-large":s===`large`}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:`nearest`})},onClick:n?c:i,onMouseMove:n?c:r,title:n?G(`commandPalette.itemNotAvailable`):``,children:[(0,U.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,U.jsx)(OE,{className:`icon`,size:`var(--icon-size, 1rem)`,icon:typeof e.icon==`function`?e.icon(o,[]):e.icon}),(0,U.jsx)(aE,{children:e.label})]}),a&&e.shortcut&&(0,U.jsx)(zM,{shortcut:e.shortcut})]})};function GM([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function KM([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function qM([e,t,n],r){return[e*r,t*r,n*r]}function JM([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function YM([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function XM(e,t,n){return GM(e,qM(KM(t,e),n))}function ZM(e,t,n){return Math.atan2(n[1]-e[1],n[0]-e[0])-Math.atan2(t[1]-e[1],t[0]-e[0])}function QM(e){return Math.atan2(Math.sin(e),Math.cos(e))}function $M([e,t]){return Math.sqrt(e**2+t**2)}function eN([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function tN(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=eN(e[n-1],e[n]);return t+=eN(e[e.length-2],e[e.length-1]),t}var nN=(e,t,n)=>Math.max(t,Math.min(n,e));function rN(e,t,n){let r=eN(t,n);if(r===0)return eN(e,t);let i=nN(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return eN([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function iN(e,t){if(t===0||e.length<=2)return e;let n=e[0],r=e[e.length-1],[i,a]=e.reduce(([e,t],i,a)=>{let o=rN(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...iN([n,...e.slice(1,a),i],t).slice(0,-1),i,...iN([i,...e.slice(a,-1),r],t).slice(1)]}return[n,r]}var aN=class e{constructor(t){B(this,`options`),B(this,`originalPoints`,[]),B(this,`stablePoints`,[]),B(this,`tailPoints`,[]),B(this,`isFresh`,!0),this.options=Object.assign({},e.defaults,t)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(t){let n=this.originalPoints[this.originalPoints.length-1];if(!(n&&n[0]===t[0]&&n[1]===t[1])){if(this.originalPoints.push(t),this.isFresh){this.isFresh=!1,this.stablePoints.push(t);return}this.options.streamline>0&&(t=XM(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),tN(this.tailPoints)>e.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase===`tail`)throw Error(`Not implemented yet`);this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(e,t,n,r,i){return(e??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:n,totalLength:r})}getStrokeOutline(t){if(this.isFresh)return[];let n=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase===`input`&&(n=iN(n,this.options.simplify));let r=n.length;if(r===0)return[];if(r===1){let e=n[0],i=this.getSize(t,e[2],0,r,0);if(i<.5)return[];let a=[];for(let t=0;t<=Math.PI*2;t+=Math.PI/16)a.push(GM(e,qM(YM([1,0,0],t),i)));return a.push(GM(e,qM([1,0,0],this.getSize(t,e[2],0,r,0)))),a}if(r===2){let e=n[0],i=n[1],a=this.getSize(t,e[2],0,r,0),o=this.getSize(t,i[2],0,r,0);if(a<.5||o<.5)return[];let s=[],c=ZM(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(GM(e,qM(YM([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(GM(i,qM(YM([1,0,0],e),o)));return s.push(s[0]),s}let i=[],a=[],o=0,s=0,c=0,l=0;for(let u=1;u<r-1;u++){let d=n[u-1],f=n[u],p=n[u+1],m=f[2],h=eN(d,f);l+=h,o=s+(h-s)*.2;let g=this.getSize(t,m,u,r,l);if(g===0){c=u+1;continue}let _=JM(KM(d,f)),v=JM(KM(p,f)),y=YM(_,Math.PI/2),b=YM(_,-Math.PI/2),x=YM(v,Math.PI/2),S=YM(v,-Math.PI/2),C=GM(f,qM(y,g)),w=GM(f,qM(b,g)),T=GM(f,qM(x,g)),E=GM(f,qM(S,g)),D=GM(y,S),ee=GM(b,x),O=GM(f,qM($M(D)===0?_:JM(D),g)),k=GM(f,qM($M(ee)===0?v:JM(ee),g)),te=QM(ZM(f,d,p)),A=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(te)<A){let e=Math.abs(QM(Math.PI-te));if(e===0)continue;if(te<0){a.push(w,k);for(let t=0;t<=e;t+=e/4)i.push(GM(f,YM(qM(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(GM(f,YM(qM(y,g),t)));a.push(k,T)}else{i.push(C,O);for(let t=0;t<=e;t+=e/4)a.push(GM(f,YM(qM(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(GM(f,YM(qM(y,-g),-t)));i.push(O,E)}}else i.push(O),a.push(k);s=o}if(c>=r-2){if(this.options.keepHead){let e=n[r-1],t=[];for(let n=0;n<=Math.PI*2;n+=Math.PI/16)t.push(GM(e,qM(YM([1,0,0],n),this.options.size)));return t.push(GM(e,qM([1,0,0],this.options.size))),t}return[]}let u=n[c],d=n[c+1],f=n[r-2],p=n[r-1],m=JM(KM(d,u)),h=JM(KM(f,p)),g=YM(m,-Math.PI/2),_=YM(h,Math.PI/2),v=this.getSize(t,u[2],0,r,0),y=[],b=this.options.keepHead?this.options.size:this.getSize(t,f[2],r-2,r,l),x=[];if(v>.1){for(let e=0;e<=Math.PI;e+=Math.PI/16)y.unshift(GM(u,YM(qM(g,v),-e)));y.unshift(GM(u,qM(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(GM(p,YM(qM(_,-b),-e)));let S=[...y,...i,...x.reverse(),...a.reverse()];return y.length>0&&S.push(y[0]),this.options.simplify>0&&this.options.simplifyPhase===`output`?iN(S,this.options.simplify):S}};B(aN,`defaults`,{size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}),B(aN,`constants`,{cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50});var oN=aN,sN=e=>{if(!e)return[];for(let t of e.sets)if(t.type===`path`)return t.ops;return e.sets[0].ops},cN=e=>!!e&&e.type===`embeddable`,lN=e=>!!e&&e.type===`iframe`,uN=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),dN=e=>e!=null&&e.type===`text`,fN=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),pN=e=>e!=null&&gN(e.type),mN=e=>e!=null&&e.type===`arrow`,hN=e=>mN(e)&&e.elbowed,gN=e=>e===`arrow`||e===`line`,_N=e=>e!==null&&`containerId`in e&&e.containerId!==null&&dN(e);`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase();var vN=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n};(function(){let e=null,t=null,n=null,r=(r,i)=>(n!=null&&r===e&&i.selectedElementIds===t||(n=r.some(e=>i.selectedElementIds[e.id]),e=r,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r})();var yN=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){NN(a)?(i.push(a),r.add(a.id)):console.error(`[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection`);continue}if(n?.includeBoundTextElement&&_N(a)&&NN(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{fN(n)&&vN(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},bN=(e,t)=>qr(t.selectedElementIds,e)?t.selectedElementIds:e;(function(){let e=null,t=null,n=null,r=(r,i,a,o)=>{if(n!==void 0&&i===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let s={};for(let e of r){let t=e.groupIds;if(a.editingGroupId){let e=t.indexOf(a.editingGroupId);e>-1&&(t=t.slice(0,e))}if(t.length>0){let e=t[t.length-1];s[e]=!0}}let c={},l=i.reduce((e,t)=>{if(t.isDeleted)return e;let n=t.groupIds.find(e=>s[e]);return n&&(e[t.id]=!0,Array.isArray(c[n])?c[n].push(t.id):c[n]=[t.id]),e},{});for(let e of Object.keys(c))c[e].length<2&&s[e]&&(s[e]=!1);return t=i,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:s,selectedElementIds:bN({...a.selectedElementIds,...l},o)},n},i=(e,t,n,i)=>{let a=i?i.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,elements:t}):yN(t,e);return a.length?r(a,t,e,n):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:bN(e.selectedElementIds,n)}};return i.clearCache=()=>{t=null,e=null,n=null},i})();var xN=[1,0],SN=[0,1],CN=[-1,0],wN=[0,-1],TN=e=>{let[t,n]=e,r=Math.abs(t),i=Math.abs(n);return t>i?xN:t<=-i?CN:n>r?SN:wN},EN=(e,t)=>TN(br(e,t)),DN=(e,t)=>kN(EN(e,t)),ON=(e,t)=>e[0]===t[0]&&e[1]===t[1],kN=e=>ON(e,xN)||ON(e,CN),AN=e=>e===`rectangle`||e===`iframe`||e===`embeddable`||e===`line`||e===`diamond`||e===`stickynote`||e===`image`;(0,Tl.default)(e=>{(Ae()||pi()||window?.DEBUG_FRACTIONAL_INDICES)&&Ce(e,{shouldThrow:Ae()||pi(),includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1});var jN={decimal:42,alpha:9,roman:99},MN=e=>[``,`x`,`xx`,`xxx`,`xl`,`l`,`lx`,`lxx`,`lxxx`,`xc`][Math.floor(e/10)]+[``,`i`,`ii`,`iii`,`iv`,`v`,`vi`,`vii`,`viii`,`ix`][e%10];new Map(Array.from({length:jN.roman},(e,t)=>[MN(t+1),t+1]));var NN=e=>!e.isDeleted,PN=(e,t=1)=>{if(e.length>=3){let[n,r]=[e[0],e[e.length-1]];return Ke(n,r)<=8/t}return!1},FN=(e,t)=>{if(t.roundness?.type===Un.PROPORTIONAL_RADIUS||t.roundness?.type===Un.LEGACY)return e*zc;if(t.roundness?.type===Un.ADAPTIVE_RADIUS){let n=t.roundness?.value??32;return e<=n/.25?e*zc:n}return 0},IN=e=>{let t=Math.floor(e.width/2)+1,n=e.width,r=Math.floor(e.height/2)+1;return[t,0,n,r,t,e.height,0,r]},LN=20,RN=15,zN=e=>{switch(e){case`arrow`:return 25;case`diamond`:case`diamond_outline`:return 12;case`cardinality_many`:case`cardinality_one_or_many`:case`cardinality_zero_or_many`:return RN;case`cardinality_one`:case`cardinality_exactly_one`:case`cardinality_zero_or_one`:return LN;default:return 15}},BN=e=>{switch(e){case`bar`:return 90;case`arrow`:return 20;default:return 25}},VN=(e,t,n,r,i=0)=>{if(r===null||t.length<1)return null;let a=sN(t[0]);if(a.length<1)return null;let o=n===`start`?1:a.length-1,s=a[o].data;E(s.length===6,`Op data length is not 6`);let c=L(s[4],s[5]),u=L(s[2],s[3]),d=L(s[0],s[1]),f=a[o-1],p=L(0,0);if(f.op===`move`){let e=tt(f.data);E(e!=null,`Op data is not a point`),p=e}else f.op===`bcurveTo`&&(p=L(f.data[4],f.data[5]));let m=(e,t)=>(1-e)**3*c[t]+3*e*(1-e)**2*u[t]+3*e**2*(1-e)*d[t]+p[t]*e**3,[h,g]=n===`start`?p:c,[_,v]=[m(.3,0),m(.3,1)],y=Math.hypot(h-_,g-v),b=(h-_)/y,x=(g-v)/y,S=zN(r),C=0;{let[t,r]=n===`end`?e.points[e.points.length-1]:e.points[0],[i,a]=e.points.length>1?n===`end`?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(t-i,r-a)}let w=Math.min(S,C*(r===`diamond`||r===`diamond_outline`?.25:.5)),T=h-b*w*i,D=g-x*w*i,ee=T-b*w,O=D-x*w;if(r===`circle`||r===`circle_outline`)return[T,D,Math.hypot(O-D,ee-T)+e.strokeWidth-2];let k=BN(r);if(r===`cardinality_many`||r===`cardinality_one_or_many`){let[e,t]=As(L(T,D),L(ee,O),l(-k)),[n,r]=As(L(T,D),L(ee,O),l(k));return[ee,O,e,t,n,r]}let[te,A]=As(L(ee,O),L(T,D),-k*Math.PI/180),[j,ne]=As(L(ee,O),L(T,D),l(k));if(r===`diamond`||r===`diamond_outline`){let t,r;if(n===`start`){let[n,i]=e.points.length>1?e.points[1]:[0,0];[t,r]=As(L(T+w*2,D),L(T,D),Math.atan2(i-D,n-T))}else{let[n,i]=e.points.length>1?e.points[e.points.length-2]:[0,0];[t,r]=As(L(T-w*2,D),L(T,D),Math.atan2(D-i,T-n))}return[T,D,te,A,t,r,j,ne]}return[T,D,te,A,j,ne]},HN=typeof document<`u`?document.createElement(`img`):{src:``};HN.src=`data:${A.svg},%3Csvg%20aria-hidden%3D%22true%22%20focusable%3D%22false%22%20data-prefix%3D%22fas%22%20data-icon%3D%22image%22%20class%3D%22svg-inline--fa%20fa-image%20fa-w-16%22%20role%3D%22img%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%3Cpath%20fill%3D%22%23888%22%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048zM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56zM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E`;var UN=typeof document<`u`?document.createElement(`img`):{src:``};UN.src=`data:${A.svg},%3Csvg%20viewBox%3D%220%200%20668%20668%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xml%3Aspace%3D%22preserve%22%20style%3D%22fill-rule%3Aevenodd%3Bclip-rule%3Aevenodd%3Bstroke-linejoin%3Around%3Bstroke-miterlimit%3A2%22%3E%3Cpath%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048ZM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56ZM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.81709%200%200%20.81709%20124.825%20145.825)%22%2F%3E%3Cpath%20d%3D%22M256%208C119.034%208%208%20119.033%208%20256c0%20136.967%20111.034%20248%20248%20248s248-111.034%20248-248S392.967%208%20256%208Zm130.108%20117.892c65.448%2065.448%2070%20165.481%2020.677%20235.637L150.47%20105.216c70.204-49.356%20170.226-44.735%20235.638%2020.676ZM125.892%20386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53%20406.784c-70.203%2049.356-170.226%2044.736-235.638-20.676Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.30366%200%200%20.30366%20506.822%2060.065)%22%2F%3E%3C%2Fsvg%3E`;var WN=new WeakMap,GN=class{};B(GN,`rg`,new Ts),B(GN,`cache`,new WeakMap),B(GN,`get`,(e,t)=>{let n=GN.cache.get(e);if(n&&(t===null||n.theme===t))return n.shape}),B(GN,`delete`,e=>{GN.cache.delete(e),WN.delete(e)}),B(GN,`destroy`,()=>{GN.cache=new WeakMap}),B(GN,`generateElementShape`,(e,t)=>{let n=t?.isExporting?void 0:GN.get(e,t?t.theme:null);if(n!==void 0)return n;WN.delete(e);let r=rP(e,GN.rg,t||{isExporting:!1,canvasBackgroundColor:$c.white,embedsValidationStatus:null,theme:M.LIGHT});return t?.isExporting||GN.cache.set(e,{shape:r,theme:t?.theme||M.LIGHT}),r});var KN=e=>[8,8+e],qN=e=>[1.5,6+e];function JN(e){let t=e.roughness,n=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&n>=50||r>=15&&e.roundness&&AN(e.type)||pN(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var YN=(e,t=!1,n=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle===`dashed`?KN(e.strokeWidth):e.strokeStyle===`dotted`?qN(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!==`solid`,strokeWidth:e.strokeStyle===`solid`?e.strokeWidth:e.strokeWidth+.5,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:JN(e),stroke:Rt(e.strokeColor,n),preserveVertices:t||e.roughness<ea.cartoonist};switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:case`diamond`:case`ellipse`:return r.fillStyle=e.fillStyle,r.fill=Zr(e.backgroundColor)?void 0:Rt(e.backgroundColor,n),e.type===`ellipse`&&(r.curveFitting=1),r;case`line`:case`freedraw`:return PN(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor===`transparent`?void 0:Rt(e.backgroundColor,n)),r;case`arrow`:return r;default:throw Error(`Unimplemented type ${e.type}`)}},XN=(e,t,n)=>uN(e)&&(t||cN(e)&&n?.get(e.id)!==!0)&&Zr(e.backgroundColor)&&Zr(e.strokeColor)?{...e,roughness:0,backgroundColor:`#d3d3d3`,fillStyle:`solid`}:lN(e)?{...e,strokeColor:Zr(e.strokeColor)?`#000000`:e.strokeColor,backgroundColor:Zr(e.backgroundColor)?`#f4f4f6`:e.backgroundColor}:e,ZN=(e,t,n)=>{if(t===null)return[];let[,,r,i,a,o]=t;return[e.line(r,i,a,o,n)]},QN=(e,t,n)=>{if(t===null)return[];let[r,i,a,o,s,c]=t;return[e.line(a,o,r,i,n),e.line(s,c,r,i,n)]},$N=(e,t)=>{let n={...t};if(e.strokeStyle===`dotted`){let t=qN(e.strokeWidth-1);n.strokeLineDash=[t[0],t[1]-1]}else delete n.strokeLineDash;return n.roughness=Math.min(1,n.roughness||0),n},eP=(e,t,n,r,i,a=1)=>{if(r===null)return[];let[o,s,c]=r,l={...t,fill:i,fillStyle:`solid`,stroke:n,roughness:Math.min(.5,t.roughness||0)};return delete l.strokeLineDash,[e.circle(o,s,c*a,l)]},tP=(e,t,n,r,i,a,o,s)=>{if(r===null)return[];let c=Rt(e.strokeColor,s),l=Rt(o,s),u=.8;switch(r){case`circle`:case`circle_outline`:return eP(i,a,c,VN(e,t,n,r),r===`circle_outline`?l:c);case`triangle`:case`triangle_outline`:{let o=VN(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m]=o,h={...a,fill:r===`triangle_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete h.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[s,u]],h)]}case`diamond`:case`diamond_outline`:{let o=VN(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m,h,g]=o,_={...a,fill:r===`diamond_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete _.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[h,g],[s,u]],_)]}case`cardinality_one`:return ZN(i,VN(e,t,n,r),$N(e,a));case`cardinality_many`:return QN(i,VN(e,t,n,r),$N(e,a));case`cardinality_one_or_many`:{let r=$N(e,a);return[...QN(i,VN(e,t,n,`cardinality_many`),r),...ZN(i,VN(e,t,n,`cardinality_one`,-.25),r)]}case`cardinality_exactly_one`:{let r=$N(e,a);return[...ZN(i,VN(e,t,n,`cardinality_one`,-.5),r),...ZN(i,VN(e,t,n,`cardinality_one`),r)]}case`cardinality_zero_or_one`:{let r=$N(e,a);return[...eP(i,a,c,VN(e,t,n,`circle_outline`,1.5),l,u),...ZN(i,VN(e,t,n,`cardinality_one`,-.5),r)]}case`cardinality_zero_or_many`:{let r=$N(e,a);return[...QN(i,VN(e,t,n,`cardinality_many`),r),...eP(i,a,c,VN(e,t,n,`circle_outline`,1.5),l,u)]}default:return QN(i,VN(e,t,n,r),$N(e,a))}},nP=e=>cb(e.points,.75),rP=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:i,theme:a})=>{let o=a===M.DARK;switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:{let r;if(e.roundness){let a=e.width,s=e.height,c=FN(Math.min(a,s),e);r=t.path(`M ${c} 0 L ${a-c} 0 Q ${a} 0, ${a} ${c} L ${a} ${s-c} Q ${a} ${s}, ${a-c} ${s} L ${c} ${s} Q 0 ${s}, 0 ${s-c} L 0 ${c} Q 0 0, ${c} 0`,YN(XN(e,n,i),!0,o))}else r=t.rectangle(0,0,e.width,e.height,YN(XN(e,n,i),!1,o));return r}case`diamond`:{let n,[r,i,a,s,c,l,u,d]=IN(e);if(e.roundness){let f=FN(Math.abs(r-u),e),p=FN(Math.abs(s-i),e);n=t.path(`M ${r+f} ${i+p} L ${a-f} ${s-p}
46
+ C ${a} ${s}, ${a} ${s}, ${a-f} ${s+p}
47
+ L ${c+f} ${l-p}
48
+ C ${c} ${l}, ${c} ${l}, ${c-f} ${l-p}
49
+ L ${u+f} ${d+p}
50
+ C ${u} ${d}, ${u} ${d}, ${u+f} ${d-p}
51
+ L ${r-f} ${i+p}
52
+ C ${r} ${i}, ${r} ${i}, ${r+f} ${i+p}`,YN(e,!0,o))}else n=t.polygon([[r,i],[a,s],[c,l],[u,d]],YN(e,!1,o));return n}case`ellipse`:return t.ellipse(e.width/2,e.height/2,e.width,e.height,YN(e,!1,o));case`line`:case`arrow`:{let n,i=YN(e,!1,o),a=e.points.length?e.points:[L(0,0)];if(hN(e)?a.every(e=>Math.abs(e[0])<=1e6&&Math.abs(e[1])<=1e6)?n=[t.path(iP(a,16),YN(e,!0,o))]:(console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`,e.id,JSON.stringify(a)),n=[]):n=e.roundness?[t.curve(a,i)]:i.fill?[t.polygon(a,i)]:[t.linearPath(a,i)],e.type===`arrow`){let{startArrowhead:a=null,endArrowhead:s=`arrow`}=e;if(a!==null){let s=tP(e,n,`start`,a,t,i,r,o);n.push(...s)}if(s!==null){let a=tP(e,n,`end`,s,t,i,r,o);n.push(...a)}}return n}case`freedraw`:{let n=[];return PN(e.points)&&n.push(t.curve(nP(e),{...YN(e,!1,o),stroke:`none`})),n.push(aP(e)),n}case`stickynote`:case`frame`:case`magicframe`:case`text`:case`image`:return null;default:return Jt(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},iP=(e,t)=>{let n=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],o=e[r],s=DN(o,i),c=DN(a,o),l=Math.min(t,Ke(e[r],a)/2,Ke(e[r],i)/2);s?i[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):i[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l]),n.push(e[r]),c?a[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):a[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let e=0;e<n.length;e+=3)r.push(`L ${n[e][0]} ${n[e][1]}`),r.push(`Q ${n[e+1][0]} ${n[e+1][1]}, ${n[e+2][0]} ${n[e+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(` `)},aP=e=>hP(fP(e)),oP={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},sP={SIZE_FACTOR:1.4,COLLISION_SIMPLIFY_TOLERANCE:.2},cP=e=>e.strokeOptions?.streamline??.5,lP=e=>Nb(e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]],{simulatePressure:e.simulatePressure,size:e.strokeWidth*oP.SIZE_FACTOR,thinning:oP.THINNING,smoothing:oP.SMOOTHING,streamline:cP(e),easing:e=>Math.sin(e*Math.PI/2),last:!0}),uP=e=>new oN({size:e.strokeWidth*sP.SIZE_FACTOR,streamline:cP(e),simplify:0,sizeMapping:e=>Math.max(.1,e.pressure)}),dP=e=>{let t=uP(e);return e.points.map(([e,n])=>t.addPoint([e,n,1])),t.getStrokeOutline().map(([e,t])=>[e,t])},fP=e=>e.strokeOptions?.variability===`constant`?dP(e):lP(e),pP=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],mP=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,hP=e=>{if(!e.length)return``;let t=e.length-1;return e.reduce((e,n,r,i)=>(r===t?e.push(n,pP(n,i[0]),`L`,i[0],`Z`):e.push(n,pP(n,i[r+1])),e),[`M`,e[0],`Q`]).join(` `).replace(mP,`$1`)},gP=(e,t,n=!1)=>{let r=!1;for(let n in t){let i=t[n];if(typeof i<`u`){if(e[n]===i&&(typeof i!=`object`||!i))continue;r=!0}}return!r&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??eo(),updated:Ht()}},_P=X({name:`toggleLinearEditor`,category:LM.elements,label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`,keywords:[`line`],trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!(t.selectedLinearElement?.isEditing||i.length!==1||!ja(i[0])||vn(i[0]))},perform(e,t,n,r){E(t.selectedLinearElement,`No selected linear element found`);let i=r.scene.getElement(t.selectedLinearElement.elementId);E(i,`No selected element found`);let a={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:a},captureUpdate:I.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let i=G(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,U.jsx)(Y,{type:`button`,icon:yw,title:i,"aria-label":i,onClick:()=>t(null)})}});X({name:`togglePolygon`,category:LM.elements,icon:xx,keywords:[`loop`],label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(e=>!co(e)||!e.polygon)?`labels.polygon.convertToPolygon`:`labels.polygon.breakPolygon`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return i.length>0&&i.every(e=>co(e)&&e.points.length>=4)},perform(e,t,n,r){let i=r.scene.getSelectedElements(t);if(i.some(e=>!co(e)))return!1;let a=i,o=a.some(e=>!e.polygon),s=y(a);return{elements:e.map(e=>!s.has(e.id)||!co(e)?e:gP(e,{backgroundColor:o?e.backgroundColor:`transparent`,...Ze(e,o)})),appState:t,captureUpdate:I.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(e=>!co(e)||!e.polygon||e.points.length<3))return null;let i=r.every(e=>co(e)&&e.polygon),a=G(i?`labels.polygon.breakPolygon`:`labels.polygon.convertToPolygon`);return(0,U.jsx)(Y,{type:`toggle`,icon:xx,title:a,"aria-label":a,checked:i,onSelect:()=>t(null),style:{marginLeft:`auto`}})}});var vP=X({name:`searchMenu`,icon:ew,keywords:[`search`,`find`],label:`search.title`,viewMode:!0,trackEvent:{category:`search_menu`,action:`toggle`,predicate:e=>e.gridModeEnabled},perform(e,t,n,r){if(t.openDialog)return!1;if(t.openSidebar?.name===Vr.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${hn.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.focus(),e?.select(),!1}return{appState:{...t,openSidebar:{name:Vr.name,tab:Sc},openDialog:null},captureUpdate:I.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[z.CTRL_OR_CMD]&&e.key===z.F}),yP=X({name:`cropEditor`,label:`helpDialog.cropStart`,icon:Ew,viewMode:!0,trackEvent:{category:`menu`},keywords:[`image`,`crop`],perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:i.id},captureUpdate:I.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!(t.croppingElementId||i.length!==1||!O(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=G(`helpDialog.cropStart`);return(0,U.jsx)(Y,{type:`button`,icon:Ew,title:r,"aria-label":r,onClick:()=>t(null)})}}),bP=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&F(n[0])},xP=X({name:`selectAllElementsInFrame`,label:`labels.selectAllElementsInFrame`,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;if(F(i)){let n=Dn(en(e),i.id).filter(e=>!(e.type===`text`&&e.containerId));return{elements:e,appState:{...t,selectedElementIds:n.reduce((e,t)=>(e[t.id]=!0,e),{})},captureUpdate:I.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:I.EVENTUALLY}},predicate:(e,t,n,r)=>bP(t,r)}),SP=X({name:`removeAllElementsFromFrame`,label:`labels.removeAllElementsFromFrame`,trackEvent:{category:`history`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;return F(i)?{elements:rl(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:I.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:I.EVENTUALLY}},predicate:(e,t,n,r)=>bP(t,r)});X({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:I.EVENTUALLY}),checked:e=>e.frameRendering.enabled});var CP=X({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=Kc(e,t);return i.length>0&&!i.some(e=>F(e))},perform:(e,t,n,r)=>{let i=Kc(e,t),a=r.scene.getNonDeletedElementsMap(),[o,s,c,l]=Hc(i,a),u=Tt({x:o-16,y:s-16,width:c-o+32,height:l-s+32});if(t.editingGroupId){let e=ul(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);oo(n,a,{groupIds:n.groupIds.slice(0,e)})}}return{elements:_n([...r.scene.getElementsIncludingDeleted(),u],i,u),appState:{selectedElementIds:{[u.id]:!0}},captureUpdate:I.IMMEDIATELY}}}),wP=class extends Lt{applyTo(e,t,n){let[r,i]=this.elements.applyTo(e,n.elements,{excludedProperties:new Set([`version`,`versionNonce`])}),[a,o]=this.appState.applyTo(t,r);return[r,a,i||o]}static calculate(e,t){return super.calculate(e,t)}static inverse(e){return super.inverse(e)}static applyLatestChanges(e,t,n,r){return super.applyLatestChanges(e,t,n,r)}},TP=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},EP=class e{constructor(e){this.store=e,B(this,`onHistoryChangedEmitter`,new rt),B(this,`undoStack`,[]),B(this,`redoStack`,[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(e){if(e.isEmpty()||e instanceof wP)return;let t=wP.inverse(e);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new TP(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,n){return this.perform(t,n,()=>e.pop(this.undoStack),t=>e.push(this.redoStack,t))}redo(t,n){return this.perform(t,n,()=>e.pop(this.redoStack),t=>e.push(this.undoStack,t))}perform(e,t,n,r){try{let i=n();if(i===null)return;let a=I.IMMEDIATELY,o=this.store.snapshot,s=e,c=t,l=!1;for(;i;){try{[s,c,l]=i.applyTo(s,c,o);let e=o.elements,t=o.maybeClone(a,s,c),n=Cs.create(o,t),r=wP.applyLatestChanges(i,e,s);r.isEmpty()||(this.store.scheduleMicroAction({action:a,change:n,delta:r}),i=r),o=t}finally{r(i)}if(l)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new TP(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(e){if(!e.length)return null;let t=e.pop();return t===void 0?null:t}static push(e,t){let n=wP.inverse(t);return e.push(n)}},DP=(e,t)=>{let[n,r]=(0,V.useState)(t);return(0,V.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},OP=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let e=n();if(!e)return{captureUpdate:I.EVENTUALLY};let[t,r]=e;return{appState:r,elements:kc(Array.from(t.values())),captureUpdate:I.NEVER}}return{captureUpdate:I.EVENTUALLY}},kP=e=>({name:`undo`,label:`buttons.undo`,icon:mS,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>OP(i,n,()=>e.undo(y(t),n)),keyTest:e=>e[z.CTRL_OR_CMD]&&ll(e,z.Z)&&!e.shiftKey,PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isUndoStackEmpty:a}=DP(e.onHistoryChangedEmitter,new TP(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=cW()===`mobile`;return(0,U.jsx)(Y,{type:`button`,icon:mS,"aria-label":G(`buttons.undo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-undo`,style:{...o?Lr:{}}})}}),AP=e=>({name:`redo`,label:`buttons.redo`,icon:hS,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>OP(i,n,()=>e.redo(y(t),n)),keyTest:e=>e[z.CTRL_OR_CMD]&&e.shiftKey&&ll(e,z.Z)||e[z.CTRL_OR_CMD]&&!e.shiftKey&&ll(e,z.Y),PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isRedoStackEmpty:a}=DP(e.onHistoryChangedEmitter,new TP(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=cW()===`mobile`;return(0,U.jsx)(Y,{type:`button`,icon:hS,"aria-label":G(`buttons.redo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-redo`,style:{...o?Lr:{}}})}}),jP=X({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n)=>{let r=Kc(e,t);return r.length===1&&D(r[0])&&!r[0].autoResize},perform:(e,t,n,r)=>{let i=Kc(e,t),a=ci(n)&&D(n)?n:i[0],o=e.find(e=>e.id===a?.id);if(!o||!D(o))return!1;let s=Oi(o.originalText,Or(o),o.lineHeight),c=Vs(o),l=N(o,{autoResize:!0,width:s.width,height:s.height,x:o.x+(o.width-s.width)*c.x,y:o.y+(o.height-s.height)*c.y,text:o.originalText});return Ga(l)&&bi(l,r.scene,{changedElements:new Map([[l.id,l]])}),{appState:t,elements:e.map(e=>e.id===l.id?l:e),captureUpdate:I.IMMEDIATELY}}}),MP=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&Yw(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},NP=class{constructor(e,t,n,r){B(this,`actions`,{}),B(this,`updater`),B(this,`getAppState`),B(this,`getElementsIncludingDeleted`),B(this,`app`),B(this,`isActionBlockedByViewportTransition`,e=>e.navigation===!0&&this.app.viewport.isLockedTransitionPending),B(this,`renderAction`,(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&`PanelComponent`in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],r=n.PanelComponent;return r.displayName=`PanelComponent`,(0,U.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{this.isActionBlockedByViewportTransition(n)||(MP(n,`ui`,this.getAppState(),this.getElementsIncludingDeleted(),this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app)))},appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null}),B(this,`isActionEnabled`,e=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!e.predicate||e.predicate(t,n,this.app.props,this.app)}),this.updater=t=>{if(We(t))t.then(t=>e(t));else return e(t)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(e){this.actions[e.name]=e}registerAll(e){e.forEach(e=>this.registerAction(e))}handleKeyDown(e){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((e,t)=>(t.keyPriority||0)-(e.keyPriority||0)).filter(n=>(n.name in t?t[n.name]:!0)&&n.keyTest&&n.keyTest(e,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn(`Canceling as multiple actions match this shortcut`,n),!1;let r=n[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return e.preventDefault(),e.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return MP(r,`keyboard`,a,i,this.app,null),e.preventDefault(),e.stopPropagation(),this.updater(n[0].perform(i,a,null,this.app)),!0}executeAction(e,t=`api`,n=null){if(t!==`api`&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&e.navigation===!0)||this.isActionBlockedByViewportTransition(e))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();MP(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},PP=e=>{let t=Array.from(e.values());return{x:IP(t,e=>e.x)/t.length,y:IP(t,e=>e.y)/t.length}},FP=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),IP=(e,t)=>e.reduce((e,n)=>e+t(n),0),LP=e=>{let t=new Map;for(let[n,r]of e??[]){let{opacity:e,offset:i}=r;if(e!==void 0&&!Number.isFinite(e)||i!==void 0&&(i===null||!Number.isFinite(i.x)||!Number.isFinite(i.y)))throw TypeError(`Render overrides for ${n} must be finite numbers`);e===void 0&&i===void 0||t.set(n,{...e===void 0?{}:{opacity:Vi(e,0,100)},...i?{offset:{x:i.x,y:i.y}}:{}})}return t},RP=(e,t)=>{let n=0,r=!1;for(let[i,{offset:a}]of e){if(!a)continue;n++;let e=t.get(i);if(!e||e.x!==a.x||e.y!==a.y){r=!0;break}}if(!r&&n===t.size)return t;let i=new Map;for(let[t,{offset:n}]of e)n&&i.set(t,n);return i},zP=8,BP=99999,VP=e=>zP/e,HP=class{};B(HP,`referenceSnapPoints`,null),B(HP,`visibleGaps`,null),B(HP,`setReferenceSnapPoints`,e=>{HP.referenceSnapPoints=e}),B(HP,`getReferenceSnapPoints`,()=>HP.referenceSnapPoints),B(HP,`setVisibleGaps`,e=>{HP.visibleGaps=e}),B(HP,`getVisibleGaps`,()=>HP.visibleGaps),B(HP,`destroy`,()=>{HP.referenceSnapPoints=null,HP.visibleGaps=null});var UP=HP,WP=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,GP=({event:e,app:t,selectedElements:n})=>{if(e){let n=t.state.activeTool.type===`lasso`&&t.state.selectedElementsAreBeingDragged;return(t.state.activeTool.type!==`lasso`||n)&&(t.state.objectsSnapModeEnabled&&!e[z.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[z.CTRL_OR_CMD]&&!WP(t))}return n.length===1&&n[0].type===`arrow`?!1:t.state.objectsSnapModeEnabled},KP=(e,t,n=.01)=>Math.abs(e-t)<=n,qP=(e,t,{omitCenter:n,boundingBoxCorners:r,dragOffset:i}={omitCenter:!1,boundingBoxCorners:!1})=>{let a=[];if(e.length===1){let o=e[0],[s,c,l,u,d,f]=In(o,t);i&&(s+=i.x,l+=i.x,d+=i.x,c+=i.y,u+=i.y,f+=i.y);let p=(l-s)/2,m=(u-c)/2;if((o.type===`diamond`||o.type===`ellipse`)&&!r){let e=As(L(s,c+m),L(d,f),o.angle),t=As(L(s+p,c),L(d,f),o.angle),r=As(L(l,c+m),L(d,f),o.angle),i=As(L(s+p,u),L(d,f),o.angle),h=L(d,f);a=n?[e,t,r,i]:[e,t,r,i,h]}else{let e=As(L(s,c),L(d,f),o.angle),t=As(L(l,c),L(d,f),o.angle),r=As(L(s,u),L(d,f),o.angle),i=As(L(l,u),L(d,f),o.angle),p=L(d,f);a=n?[e,t,r,i]:[e,t,r,i,p]}}else if(e.length>1){let[t,r,o,s]=no(e,i??{x:0,y:0}),c=o-t,l=s-r,u=L(t,r),d=L(o,r),f=L(t,s),p=L(o,s),m=L(t+c/2,r+l/2);a=n?[u,d,f,p]:[u,d,f,p,m]}return a.map(e=>L(eF(e[0]),eF(e[1])))},JP=(e,t,n,r)=>Zi(e,t,n,r),YP=(e,t,n,r)=>{let i=JP(e,t,n,r),a=ur(i,r).filter(e=>!(e.length===1&&fn(e[0]))).map(e=>Hc(e).map(e=>eF(e))),o=a.sort((e,t)=>e[0]-t[0]),s=[],c=0;e:for(let e=0;e<o.length;e++){let t=o[e];for(let n=e+1;n<o.length;n++){if(++c>BP)break e;let e=o[n],[,r,i,a]=t,[l,u,,d]=e;i<l&&pc(dt(r,a),dt(u,d))&&s.push({startBounds:t,endBounds:e,startSide:[L(i,r),L(i,a)],endSide:[L(l,u),L(l,d)],length:l-i,overlap:os(dt(r,a),dt(u,d))})}}let l=a.sort((e,t)=>e[1]-t[1]),u=[];c=0;e:for(let e=0;e<l.length;e++){let t=l[e];for(let n=e+1;n<l.length;n++){if(++c>BP)break e;let e=l[n],[r,,i,a]=t,[o,s,d]=e;a<s&&pc(dt(r,i),dt(o,d))&&u.push({startBounds:t,endBounds:e,startSide:[L(r,a),L(i,a)],endSide:[L(o,s),L(d,s)],length:s-a,overlap:os(dt(r,i),dt(o,d))})}}return{horizontalGaps:s,verticalGaps:u}},XP=(e,t,n,r,i,a,o)=>{if(!GP({app:n,event:r,selectedElements:e})||e.length===0)return[];let s=UP.getVisibleGaps();if(s){let{horizontalGaps:n,verticalGaps:r}=s,[c,l,u,d]=no(e,t).map(e=>eF(e)),f=(c+u)/2,p=(l+d)/2;for(let e of n){if(!pc(dt(l,d),e.overlap))continue;let t=eF(e.startSide[0][0]+e.length/2-f);if(e.length>u-c&&Math.abs(t)<=o.x){Math.abs(t)<o.x&&(i.length=0),o.x=Math.abs(t);let n={type:`gap`,direction:`center_horizontal`,gap:e,offset:t};i.push(n);continue}let[,,n]=e.endBounds,r=c-n,a=eF(e.length-r);if(Math.abs(a)<=o.x){Math.abs(a)<o.x&&(i.length=0),o.x=Math.abs(a);let t={type:`gap`,direction:`side_right`,gap:e,offset:a};i.push(t);continue}let[s,,,]=e.startBounds,p=eF(s-u-e.length);if(Math.abs(p)<=o.x){Math.abs(p)<o.x&&(i.length=0),o.x=Math.abs(p);let t={type:`gap`,direction:`side_left`,gap:e,offset:p};i.push(t);continue}}for(let e of r){if(!pc(dt(c,u),e.overlap))continue;let t=eF(e.startSide[0][1]+e.length/2-p);if(e.length>d-l&&Math.abs(t)<=o.y){Math.abs(t)<o.y&&(a.length=0),o.y=Math.abs(t);let n={type:`gap`,direction:`center_vertical`,gap:e,offset:t};a.push(n);continue}let[,n,,]=e.startBounds,r=eF(n-d-e.length);if(Math.abs(r)<=o.y){Math.abs(r)<o.y&&(a.length=0),o.y=Math.abs(r);let t={type:`gap`,direction:`side_top`,gap:e,offset:r};a.push(t);continue}let[,,,i]=e.endBounds,s=eF(l-i),f=e.length-s;if(Math.abs(f)<=o.y){Math.abs(f)<o.y&&(a.length=0),o.y=Math.abs(f);let t={type:`gap`,direction:`side_bottom`,gap:e,offset:f};a.push(t);continue}}}},ZP=(e,t,n,r)=>{let i=JP(e,t,n,r);return ur(i,r).filter(e=>!(e.length===1&&fn(e[0]))).flatMap(e=>qP(e,r))},QP=(e,t,n,r,i,a,o)=>{if(!GP({app:n,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let s=UP.getReferenceSnapPoints();if(s)for(let e of t)for(let t of s){let n=t[0]-e[0],r=t[1]-e[1];Math.abs(n)<=o.x&&(Math.abs(n)<o.x&&(i.length=0),i.push({type:`point`,points:[e,t],offset:n}),o.x=Math.abs(n)),Math.abs(r)<=o.y&&(Math.abs(r)<o.y&&(a.length=0),a.push({type:`point`,points:[e,t],offset:r}),o.y=Math.abs(r))}},$P=(e,t,n,r,i)=>{let a=n.state,o=Kc(e,a);if(!GP({app:n,event:r,selectedElements:o})||o.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=eF(t.x),t.y=eF(t.y);let s=[],c=[],l=VP(a.zoom.value),u={x:l,y:l};QP(o,qP(o,i,{dragOffset:t}),n,r,s,c,u),XP(o,t,n,r,s,c,u);let d={x:s[0]?.offset??0,y:c[0]?.offset??0};u.x=0,u.y=0,s.length=0,c.length=0;let f={x:eF(t.x+d.x),y:eF(t.y+d.y)};QP(o,qP(o,i,{dragOffset:f}),n,r,s,c,u),XP(o,f,n,r,s,c,u);let p=nF(s,c),m=iF(o,f,[...s,...c].filter(e=>e.type===`gap`));return{snapOffset:d,snapLines:[...p,...m]}},eF=e=>Math.round(e*10**6)/10**6,tF=e=>{let t=new Map;for(let n of e){let e=n.join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},nF=(e,t)=>{let n={},r={};if(e.length>0){for(let t of e)if(t.type===`point`){let e=eF(t.points[0][0]);n[e]||(n[e]=[]),n[e].push(...t.points.map(e=>L(eF(e[0]),eF(e[1]))))}}if(t.length>0){for(let e of t)if(e.type===`point`){let t=eF(e.points[0][1]);r[t]||(r[t]=[]),r[t].push(...e.points.map(e=>L(eF(e[0]),eF(e[1]))))}}return Object.entries(n).map(([e,t])=>({type:`points`,points:tF(t.map(t=>L(Number(e),t[1])).sort((e,t)=>e[1]-t[1]))})).concat(Object.entries(r).map(([e,t])=>({type:`points`,points:tF(t.map(t=>L(t[0],Number(e))).sort((e,t)=>e[0]-t[0]))})))},rF=e=>{let t=new Map;for(let n of e){let e=n.points.flat().map(e=>[eF(e)]).join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},iF=(e,t,n)=>{let[r,i,a,o]=no(e,t),s=[];for(let e of n){let[t,n,c,l]=e.gap.startBounds,[u,d,f,p]=e.gap.endBounds,m=os(dt(i,o),e.gap.overlap),h=os(dt(r,a),e.gap.overlap);switch(e.direction){case`center_horizontal`:if(m){let t=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[L(e.gap.startSide[0][0],t),L(r,t)]},{type:`gap`,direction:`horizontal`,points:[L(a,t),L(e.gap.endSide[0][0],t)]})}break;case`center_vertical`:if(h){let t=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[L(t,e.gap.startSide[0][1]),L(t,i)]},{type:`gap`,direction:`vertical`,points:[L(t,o),L(t,e.gap.endSide[0][1])]})}break;case`side_right`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[L(c,e),L(u,e)]},{type:`gap`,direction:`horizontal`,points:[L(f,e),L(r,e)]})}break;case`side_left`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[L(a,e),L(t,e)]},{type:`gap`,direction:`horizontal`,points:[L(c,e),L(u,e)]})}break;case`side_top`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[L(e,o),L(e,n)]},{type:`gap`,direction:`vertical`,points:[L(e,l),L(e,d)]})}break;case`side_bottom`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[L(e,l),L(e,d)]},{type:`gap`,direction:`vertical`,points:[L(e,p),L(e,i)]})}}}return rF(s.map(e=>({...e,points:e.points.map(e=>L(eF(e[0]),eF(e[1])))})))},aF=(e,t,n,r,i,a)=>{if(!GP({event:r,selectedElements:e,app:n})||e.length===0||e.length===1&&!KP(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[o,s,c,l]=Hc(t);a&&(a.includes(`e`)?c+=i.x:a.includes(`w`)&&(o+=i.x),a.includes(`n`)?s+=i.y:a.includes(`s`)&&(l+=i.y));let u=[];if(a)switch(a){case`e`:u.push(L(c,s),L(c,l));break;case`w`:u.push(L(o,s),L(o,l));break;case`n`:u.push(L(o,s),L(c,s));break;case`s`:u.push(L(o,l),L(c,l));break;case`ne`:u.push(L(c,s));break;case`nw`:u.push(L(o,s));break;case`se`:u.push(L(c,l));break;case`sw`:u.push(L(o,l))}let d=VP(n.state.zoom.value),f={x:d,y:d},p=[],m=[];QP(t,u,n,r,p,m,f);let h={x:p[0]?.offset??0,y:m[0]?.offset??0};f.x=0,f.y=0,p.length=0,m.length=0;let[g,_,v,y]=Hc(e).map(e=>eF(e));return QP(e,[L(g,_),L(g,y),L(v,_),L(v,y)],n,r,p,m,f),{snapOffset:h,snapLines:nF(p,m)}},oF=(e,t,n,r,i,a)=>{if(!GP({event:n,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let o=[L(r.x+i.x,r.y+i.y)],s=VP(t.state.zoom.value),c={x:s,y:s},l=[],u=[];QP([e],o,t,n,l,u,c);let d={x:l[0]?.offset??0,y:u[0]?.offset??0};c.x=0,c.y=0,l.length=0,u.length=0;let f=qP([e],a,{boundingBoxCorners:!0,omitCenter:!0});return QP([e],f,t,n,l,u,c),{snapOffset:d,snapLines:nF(l,u)}},sF=(e,t,n,r,i)=>{if(!GP({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let a=Zi(e,[],t.state,i),o=VP(t.state.zoom.value),s={x:o,y:o},c=[],l=[];for(let e of a){let t=qP([e],i);for(let e of t){let t=e[0]-n.x;Math.abs(t)<=Math.abs(s.x)&&(Math.abs(t)<Math.abs(s.x)&&(l.length=0),l.push({type:`pointer`,points:[e,L(e[0],n.y)],direction:`vertical`}),s.x=t);let r=e[1]-n.y;Math.abs(r)<=Math.abs(s.y)&&(Math.abs(r)<Math.abs(s.y)&&(c.length=0),c.push({type:`pointer`,points:[e,L(n.x,e[1])],direction:`horizontal`}),s.y=r)}}return{originOffset:{x:l.length>0?l[0].points[0][0]-n.x:0,y:c.length>0?c[0].points[0][1]-n.y:0},snapLines:[...l,...c]}},cF=e=>e===Ys.rectangle||e===Ys.ellipse||e===Ys.diamond||e===Ys.frame||e===Ys.magicframe||e===Ys.image||e===Ys.text,lF=class{constructor(e){B(this,`scene`),B(this,`_getVisibleElementsWithRenderOffsets`,Ci(({visibleElements:e,elementsMap:t,offsets:n,selectedElements:r,frameToHighlight:i,...a})=>{let o=(e,n)=>et(e,a.width,a.height,{...a,scrollX:a.scrollX+n.x,scrollY:a.scrollY+n.y},t),s=this.getVisibleSet(e),c=new Set,l=new Set,u=(e,t)=>{s.has(e)!==t&&(t?c:l).add(e)};for(let[e,r]of n){let n=t.get(e);!n||D(n)&&xe(n,t)||u(n,o(n,r))}if(!c.size&&!l.size)return e;let d=i&&Lc(r)!==i.id;if(!c.size&&!d)return e.filter(e=>!l.has(e));let f=[];for(let e of t.values())(c.has(e)||s.has(e)&&!l.has(e))&&f.push(e);return d?this.sortSelectedElementsIntoHighlightedFrame({visibleElements:f,selectedElements:r,frameToHighlight:i}):f})),B(this,`visibleSets`,new WeakMap),B(this,`_getRenderableElements`,Ci(({canvasNonce:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s,editingTextElement:c,newElement:l})=>{let u=this.scene.getNonDeletedElements(),{elementsMap:d,newElementCanvasElement:f}=this.getRenderableElementsMap({elements:u,editingTextElement:c,newElement:l});return{elementsMap:d,visibleElements:this.getVisibleCanvasElements({elementsMap:d,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}),newElementCanvasElement:f,canvasNonce:e}})),B(this,`getRenderableElements`,e=>{let{newElement:t}=e,n=`${this.scene.getSceneNonce()}${t?.frameId||D(t)?`:${t.versionNonce}`:``}`,r=this._getRenderableElements({canvasNonce:n,zoom:e.zoom,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,scrollX:e.scrollX,scrollY:e.scrollY,height:e.height,width:e.width,editingTextElement:e.editingTextElement,newElement:e.newElement});if(e.frameToHighlight&&e.selectedElementsAreBeingDragged&&Lc(e.selectedElements)!==e.frameToHighlight.id){let t=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:e.selectedElements,frameToHighlight:e.frameToHighlight});return{...r,visibleElements:t}}return r}),this.scene=e}getVisibleElementsWithRenderOffsets(e,t,n,r){return this._getVisibleElementsWithRenderOffsets({visibleElements:e,elementsMap:t,offsets:r,zoom:n.zoom,scrollX:n.scrollX,scrollY:n.scrollY,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,width:n.width,height:n.height,selectedElements:this.scene.getSelectedElements(n),frameToHighlight:n.selectedElementsAreBeingDragged?n.frameToHighlight:null})}getVisibleSet(e){let t=this.visibleSets.get(e);return t||(t=new Set(e),this.visibleSets.set(e,t)),t}getVisibleCanvasElements({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}){let c=[];for(let l of e.values())et(l,s,o,{zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a},e)&&c.push(l);return c}getRenderableElementsMap({elements:e,editingTextElement:t,newElement:n}){let r=_i(new Map),i=n?.frameId?null:n;for(let n of e)i?.id!==n.id&&(!t||t.type!==`text`||n.id!==t.id)&&r.set(n.id,n);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:e,selectedElements:t,frameToHighlight:n}){if(!t.length)return e;let r=y(t),i=e.filter(e=>!r.has(e.id)),a=Rn(i,n.id);return a===null?e:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){_s.cancel(),this._getRenderableElements.clear(),this._getVisibleElementsWithRenderOffsets.clear()}},uF=5,dF=(e,t,n)=>{let[r,i]=In(e,n),{x:a,y:o}=hs({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},fF=({children:e,element:t,elementsMap:n})=>{let r=dW();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=dF(t,r,n);return(0,U.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:uF},children:e})},pF=e=>t=>{(0,Cl.unstable_batchedUpdates)(e,t)},mF=e=>Ho(t=>{(0,Cl.unstable_batchedUpdates)(e,t)}),hF=(()=>{let e;try{let t=V.version.split(`.`);e=Number(t[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn(`Excalidraw: render throttling is disabled on React versions < 18.`)),!1):!1})(),gF=class e{static start(t,n){if(e.animations.has(t))return;let r={animation:n,lastTime:0,state:void 0};e.animations.set(t,r);let i;try{i=n({deltaTime:0,state:void 0})}catch(n){throw e.animations.get(t)===r&&(e.animations.delete(t),e.cancelScheduledFrameIfIdle()),n}if(e.animations.get(t)===r){if(!i){e.animations.delete(t),e.cancelScheduledFrameIfIdle();return}r.state=i,e.scheduleNextFrame()}}static scheduleNextFrame(){e.scheduledFrame||(hF()?e.scheduledFrame={id:requestAnimationFrame(e.tick),type:`raf`}:e.scheduledFrame={id:setTimeout(e.tick,0),type:`timeout`})}static cancelScheduledFrame(){e.scheduledFrame&&=(e.scheduledFrame.type===`raf`?cancelAnimationFrame(e.scheduledFrame.id):clearTimeout(e.scheduledFrame.id),null)}static cancelScheduledFrameIfIdle(){return e.animations.size>0?!1:(e.cancelScheduledFrame(),!0)}static tick(){if(e.scheduledFrame=null,e.animations.size>0){let t=[...e.animations];for(let[n,r]of t){if(e.animations.get(n)!==r)continue;let t=performance.now(),i=r.lastTime===0?0:t-r.lastTime,a=r.animation({deltaTime:i,state:r.state});if(e.animations.get(n)===r){if(a)r.lastTime=t,r.state=a;else if(e.animations.delete(n),e.cancelScheduledFrameIfIdle())return}}if(e.cancelScheduledFrameIfIdle())return;e.scheduleNextFrame()}}static running(t){return e.animations.has(t)}static cancel(t){e.animations.delete(t),e.cancelScheduledFrameIfIdle()}static reset(){e.animations.clear(),e.cancelScheduledFrame()}};B(gF,`scheduledFrame`,null),B(gF,`animations`,new Map);var _F=gF,vF=class e{constructor(t,n){this.app=t,this.options=n,B(this,`currentTrail`),B(this,`pastTrails`,[]),B(this,`container`),B(this,`trailElement`),B(this,`trailAnimation`),B(this,`key`),this.key=`animated-trail-${e.counter++}`,this.trailElement=document.createElementNS(Ma,`path`),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(`http://www.w3.org/2000/svg`,`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(e,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===e&&this.currentTrail.originalPoints[n-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(e){e&&(this.container=e),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),_F.running(this.key)||_F.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){_F.cancel(this.key),this.cleanup()}startPath(e,t){this.currentTrail=new oN(this.options),this.currentTrail.addPoint([e,t,performance.now()]),this.update()}addPointToPath(e,t){this.currentTrail&&(this.currentTrail.addPoint([e,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}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 e=[];for(let t of this.pastTrails)e.push(this.drawTrail(t,this.app.state));if(this.currentTrail){let t=this.drawTrail(this.currentTrail,this.app.state);e.push(t)}if(this.pastTrails=this.pastTrails.filter(e=>e.getStrokeOutline(e.options.size/this.app.state.zoom.value).length!==0),e.length===0)return this.trailElement.setAttribute(`d`,``),!1;let t=e.join(` `).trim();return 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)),!0}drawTrail(e,t){let n=e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let r=hs({sceneX:e,sceneY:n},t);return[r.x,r.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return ho(r,!0)}};B(vF,`counter`,0);var yF=vF,bF=class{constructor(e){this.app=e,B(this,`localTrail`),B(this,`collabTrails`,new Map),B(this,`container`),this.localTrail=new yF(e,{...this.getTrailOptions(),fill:()=>`red`})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/1e3),n=(50-Math.min(50,e.totalLength-e.currentIndex))/50;return Math.min(me(n),me(t))}}}startPath(e,t){this.localTrail.startPath(e,t)}addPointToPath(e,t){this.localTrail.addPointToPath(e,t)}endPath(){this.localTrail.endPath()}start(e){this.container=e,this.localTrail.start(e)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(e){for(let[t,n]of this.collabTrails)e?.get(t)||(n.stop(),this.collabTrails.delete(t))}updateCollabTrails(e){if(this.stopCollabTrails(e),this.container&&e.size!==0)for(let[t,n]of e.entries()){if(n.isCurrentUser)continue;let e=this.collabTrails.get(t);if(e||(e=new yF(this.app,{...this.getTrailOptions(),fill:()=>n.pointer?.laserColor||JO(t,n)}),e.start(this.container),this.collabTrails.set(t,e)),n.pointer&&n.pointer.tool===`laser`){let t=n.button===`down`,r=n.button===`up`,i=e.hasCurrentTrail;t&&!i&&e.startPath(n.pointer.x,n.pointer.y);let a=!e.hasLastPoint(n.pointer.x,n.pointer.y);t&&a&&e.addPointToPath(n.pointer.x,n.pointer.y),r&&i&&(e.addPointToPath(n.pointer.x,n.pointer.y),e.endPath())}}}},xF=4,SF=6,CF=`rgba(0,0,0,0.3)`,wF=(e,t,n,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[i,a,o,s]=Hc(e),c=t/r.zoom.value,l=n/r.zoom.value,u={top:parseInt(Xa(`sat`))||0,bottom:parseInt(Xa(`sab`))||0,left:parseInt(Xa(`sal`))||0,right:parseInt(Xa(`sar`))||0},d=lx().rtl,f=-r.scrollX+u.left,p=-r.scrollY+u.top,m=f+c-u.right,h=p+l-u.bottom,g=Math.min(i,f),_=Math.min(a,p),v=Math.max(o,m),y=Math.max(s,h),b=o-i,x=s-a,S=v-g,C=y-_,w=Math.max(xF*2,u.left+u.right)+SF*2,T=c/S*t-w,E=Math.max(xF*2,u.top+u.bottom)+SF*2,D=l/C*n-E,ee=S>b?S*r.zoom.value/(T+w):t/(T+w),O=C>x?C*r.zoom.value/(D+E):n/(D+E);return{horizontal:f===g&&m===v?null:{x:Math.max(u.left,xF)+SF+(f-g)/S*t,y:n-SF-Math.max(xF,u.bottom),width:T,height:SF,deltaMultiplier:ee},vertical:p===_&&h===y?null:{x:d?Math.max(u.left,xF):t-SF-Math.max(u.right,xF),y:Math.max(u.top,xF)+SF+(p-_)/C*n,width:SF,height:D,deltaMultiplier:O}}},TF=(e,t,n)=>{let[r,i]=[e.horizontal,e.vertical].map(e=>e!=null&&e.x<=t&&t<=e.x+e.width&&e.y<=n&&n<=e.y+e.height);return{isOverEither:r||i,isOverHorizontal:r,isOverVertical:i}},EF=e=>{let{lassoPath:t,elements:n,elementsMap:r,elementsSegments:i,intersectedElements:a,enclosedElements:o,simplifyDistance:s,mode:c=`contain`}=e,l=t;s&&(l=cb(t,s));let u=n.filter(e=>!e.locked&&!fn(e));o.clear(),a.clear();let d=t.reduce((e,t)=>[Math.min(e[0],t[0]),Math.min(e[1],t[1]),Math.max(e[2],t[0]),Math.max(e[3],t[1])],[1/0,1/0,-1/0,-1/0]),f=hi(l),p=[d[0]-Da,d[1]-Da,d[2]+Da,d[3]+Da];for(let e of u){let t=Qr(e,r),n=DF(e,t,r),s=OF(t,n);if(yo(d,s)&&!a.has(e.id)&&!o.has(e.id)){if(c===`contain`&&!aa(p,s))continue;let t=MF(f,kF(e,r,i,n),s,c);c===`contain`?t&&!FF(l,e,r,n)&&o.add(e.id):t?o.add(e.id):FF(l,e,r,n)&&a.add(e.id)}}return{selectedElementIds:c===`contain`?jF([...o],r):[...a,...o]}},DF=(e,t,n)=>{let r=fs(e,n);if(!r)return null;let i=Qr(r,n);return aa(i,t)?null:Hr(e,r,n)?i:null},OF=(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,kF=(e,t,n,r)=>{let i=n.get(e.id)??[],a=Sn(e,t),o=a?n.get(a.id):null,s=o?.length?[...i,...o]:i;return r?AF(s,r):s},AF=(e,t)=>{let[n,r,i,a]=t,o=[];for(let[[t,s],[c,l]]of e){let e=c-t,u=l-s,d=0,f=1,p=!0;for(let[o,c]of[[-e,t-n],[e,i-t],[-u,s-r],[u,a-s]]){if(o===0){if(c<0){p=!1;break}continue}let e=c/o;if(o<0){if(e>f){p=!1;break}d=Math.max(d,e)}else{if(e<d){p=!1;break}f=Math.min(f,e)}}p&&o.push(Bt(L(t+d*e,s+d*u),L(t+f*e,s+f*u)))}return o},jF=(e,t)=>{if(!e.some(e=>t.get(e)?.groupIds.length))return e;let n=new Map;for(let e of t.values()){let t=e.groupIds.at(-1);if(!t||e.locked||fn(e))continue;let r=n.get(t);r?r.push(e.id):n.set(t,[e.id])}if(!n.size)return e;let r=new Set(e);return e.filter(e=>{let i=t.get(e)?.groupIds.at(-1),a=i?n.get(i):null;return!a||a.every(e=>r.has(e))})},MF=(e,t,n,r)=>{let i=r===`contain`?`every`:`some`,a=t=>bt(t,e)||r===`contain`&&PF(t,e);return t.length===0?NF(n)[i](a):t[i](e=>e[i](a))},NF=([e,t,n,r])=>[L(e,t),L(n,t),L(n,r),L(e,r)],PF=(e,t)=>t.some((n,r)=>r>0&&fo(e,Bt(t[r-1],n))),FF=(e,t,n,r)=>{let i=e.slice(1).map((t,n)=>Bt(e[n],t)).concat([Bt(e[e.length-1],e[0])]),a=Sn(t,n),o=(e,t)=>{let i=nn(e,n,t,0,!r);return r?i.some(e=>ot(e,r)):i.length>0};return i.some(e=>o(t,e)||!!a&&o({...a,...Wn(t,a,n)},e))},IF=class extends yF{constructor(e){super(e,{animateTrail:!0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/(1/0)),n=(5e3-Math.min(5e3,e.totalLength-e.currentIndex))/5e3;return Math.min(me(n),me(t))},fill:()=>No(as(e.interactiveCanvas),.05),stroke:()=>as(e.interactiveCanvas)}),B(this,`intersectedElements`,new Set),B(this,`enclosedElements`,new Set),B(this,`elementsSegments`,null),B(this,`canvasTranslate`,null),B(this,`keepPreviousSelection`,!1),B(this,`selectElementsFromIds`,e=>{this.app.setState(t=>{let n=e.reduce((e,t)=>(e[t]=!0,e),{});if(this.keepPreviousSelection)for(let e of Object.keys(t.selectedElementIds))n[e]=!0;for(let[e]of Object.entries(n)){let t=this.app.scene.getNonDeletedElement(e);if(t&&F(t)){let e=Dn(this.app.scene.getNonDeletedElementsMap(),t.id);for(let t of e)delete n[t.id]}}let r=sn({editingGroupId:t.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),t,this.app),i=[...Object.keys(r.selectedElementIds)],a=[...Object.keys(r.selectedGroupIds)];return{selectedElementIds:r.selectedElementIds,selectedGroupIds:r.selectedGroupIds,selectedLinearElement:i.length===1&&!a.length&&ja(this.app.scene.getNonDeletedElement(i[0]))?new R(this.app.scene.getNonDeletedElement(i[0]),this.app.scene.getNonDeletedElementsMap()):null}})}),B(this,`addPointToPath`,(e,t,n=!1)=>{super.addPointToPath(e,t),this.keepPreviousSelection=n,this.updateSelection()}),B(this,`updateSelection`,()=>{let e=super.getCurrentTrail()?.originalPoints?.map(e=>L(e[0],e[1])),t={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!qr(t,this.canvasTranslate??{})){this.canvasTranslate=t,this.elementsSegments=new Map;let e=y(this.app.visibleElements);for(let t of this.app.visibleElements){let n=bn(t,e);this.elementsSegments.set(t.id,n)}}if(e){let{selectedElementIds:t}=EF({lassoPath:e,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(t)}})}startPath(e,t,n=!1){this.endPath(),super.startPath(e,t),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}},LF=class extends yF{constructor(e){super(e,{streamline:.2,size:5,keepHead:!0,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/200),n=(10-Math.min(10,e.totalLength-e.currentIndex))/10;return Math.min(me(n),me(t))},fill:()=>e.state.theme===M.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`}),B(this,`elementsToErase`,new Set),B(this,`groupsToErase`,new Set)}startPath(e,t){this.endPath(),super.startPath(e,t),this.elementsToErase.clear()}addPointToPath(e,t,n=!1){return super.addPointToPath(e,t),this.updateElementsToBeErased(n)}updateElementsToBeErased(e){let t=super.getCurrentTrail()?.originalPoints?.map(e=>L(e[0],e[1]))||[];if(t.length<2)return[];let n=Bt(t[t.length-1],t[t.length-2]),r=this.app.visibleElements.filter(e=>!e.locked),i=y(r);for(let t of r)if(e&&this.elementsToErase.has(t.id)){if(RF(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(this.groupsToErase.has(e)){let t=ul(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.delete(e.id);this.groupsToErase.delete(e)}if(fn(t)&&this.elementsToErase.delete(t.containerId),ke(t)){let e=An(t);e&&this.elementsToErase.delete(e)}this.elementsToErase.delete(t.id)}}else if(!e&&!this.elementsToErase.has(t.id)&&RF(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(!this.groupsToErase.has(e)){let t=ul(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.add(e.id);this.groupsToErase.add(e)}if(ke(t)){let e=An(t);e&&this.elementsToErase.add(e)}fn(t)&&this.elementsToErase.add(t.containerId),this.elementsToErase.add(t.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},RF=(e,t,n,r)=>{let i=e[1],a=Te(t)?15:t.strokeWidth/2,o=[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],s=Qr(t,n),c=[s[0]-a,s[1]-a,s[2]+a,s[3]+a];if(!yo(o,c))return!1;if(mn(t)&&Va(i,t,n))return!0;if(Te(t)){let i=ce(t),a=yt(t,i,n),o=Math.max(2.25,5/r);for(let t of a)if(rc(t,e)<=o)return!0;let s=ai(...i.map(([e,n])=>L(t.x+e,t.y+n)));return!!bt(e[0],s)}let l=Sn(t,n);if(ir(t)||co(t)&&!t.polygon){let i=Math.max(t.strokeWidth,t.strokeWidth*2/r),a=bn(t,n);for(let t of a)if(rc(t,e)<=i)return!0;return!1}return nn(t,n,e,0,!0).length>0||!!l&&nn({...l,...Wn(t,l,n)},n,e,0,!0).length>0},zF=class{constructor(e){this.app=e}getBindableEndpointAtPosition(e,t){if(!ol(this.app.state))return null;let n=mt(L(e,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!n)return null;let r=this.app.getElementAtPosition(e,t,{includeLockedElements:!0});return r&&r.id!==n.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(n.arrow.id)?null:n}getTextBinding({arrow:e,startOrEnd:t},n){return ct(e,t,this.app.scene.getNonDeletedElementsMap(),n)}bindText({arrow:e,startOrEnd:t},n,r){Yo(e,n,t,r,this.app.scene)}maybeDragNewText(e,t){return!D(e)||!u(e,this.app.scene.getNonDeletedElementsMap())?!1:(Qn({newElement:e,...Go(e),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}isBoundTextGrabbable(e,t,n){if(!ir(e)||!wo(L(t,n),e,this.app.scene.getNonDeletedElementsMap()))return!1;let r=this.app.getElementsAtPosition(t,n),i=r.findIndex(t=>t.id===e.id);return i!==-1&&!r.slice(i+1).some(e=>this.app.hitElement(t,n,e,!1))}maybeDragLabel(e,t,n){if(!t.hit.arrowLabel)return!1;if(this.app.cursor.set(To.GRABBING),e.isDragging||Ke(L(t.origin.x,t.origin.y),L(n.x,n.y))>=10/this.app.state.zoom.value){let r=R.handleBoundTextDragging(e,this.app.scene,n.x,n.y);r&&(t.drag.hasOccurred=!0,this.app.setState({selectedLinearElement:r}))}return!0}},BF=44,VF=22,HF=66,UF=48,WF=14,GF=304,KF=320,qF=5.87,JF=28,YF=4,XF=2,ZF=10,QF=10,$F=8,eI=12,tI=256,nI=10,rI=4,iI=eI*2,aI=eI*2,oI=100,sI=140,cI=.35,lI=eI/2,uI=20,dI=eI*2,fI=eI,pI={fillStyle:`hachure`,fontFamily:_a,fontSize:20,opacity:100,roughness:1,strokeColor:$c.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:Oc.MIDDLE,locked:!1},mI=s(4),hI=e=>e.labels?.length??e.series[0]?.values.length??0,gI=(e,t)=>{if(!e)return!1;let n=hI(e);return n<2?!1:t!==`radar`||n>=3},_I=(e,t)=>e+(t<=1?0:Math.min(HF,(t-1)*VF)),vI=(e,t)=>{if(e===`line`){let e=_I(UF,t);return{slotWidth:e,gap:WF,chartHeight:KF,xLabelMaxWidth:e+WF*3+ZF}}let n=_I(BF,t);return{slotWidth:n,gap:WF,chartHeight:GF,xLabelMaxWidth:n+WF*3+ZF}},yI=(e,t)=>({chartWidth:(t.slotWidth+t.gap)*e.series[0].values.length+t.gap,chartHeight:t.chartHeight+t.gap*2}),bI=()=>({chartWidth:tI+aI*2,chartHeight:tI+aI*2}),xI=(e,t,n)=>{let r=Math.abs(e-t);return Math.min(r,n-r)},SI=(e,t)=>{if(e<=0||mI.length===0)return[];let n=mI.length,r=(t%n+n)%n,i=[r],a=Math.min(e,n),o=new Set(Array.from({length:n},(e,t)=>t).filter(e=>e!==r));for(;i.length<a;){let e=-1,t=-1,r=-1;for(let a of o){let o=i.map(e=>xI(a,e,n)),s=Math.min(...o),c=o.reduce((e,t)=>e+t,0)/o.length;(s>t||s===t&&c>r)&&(e=a,t=s,r=c)}i.push(e),o.delete(e)}return Array.from({length:e},(e,t)=>mI[i[t%i.length]])},CI=e=>{if(mI.length===0)return 0;if(typeof e!=`number`||!Number.isFinite(e))return Math.floor(Math.random()*mI.length);let t=e.toString(),n=0;for(let e=0;e<t.length;e++)n=n*31+t.charCodeAt(e)|0;return Math.abs(n)%mI.length},wI=e=>mI[e],TI=(e,t)=>{let n=e.flatMap(e=>e.values.map(e=>Math.max(0,e))),r=n.filter(e=>e>0),i=Math.max(1,...n),a=r.length>0?Math.min(...r):1,o=e.length===1&&a>0&&i/a>=oI;return{renderSteps:!1,normalize:(e,t)=>{let n=Math.max(0,e);return o?Math.log10(n+1)/Math.log10(i+1):n/i}}},EI=e=>/\s/.test(e.trim()),DI=(e,t,n)=>EI(e)?ec(e,t,n):e,OI=(e,t,n,r,i,a)=>{let o=Yn.Excalifont,s=xs.sm,c=$n(o),l=Or({fontFamily:o,fontSize:s}),u=Math.min(sI,i*(e.length>8?.56:.72)),d=yc(l,c),f=e.map((e,f)=>{let p=t[f],m=Math.max(0,...e.trim().split(/\s+/).filter(Boolean).map(e=>Oi(e,l,c).width)),h=DI(e,l,Math.max(d,u,m)),g=Oi(h,l,c),_=Math.cos(p),v=Math.sin(p),y=_>cI?`left`:_<-cI?`right`:`center`,b=y===`center`?g.width/2:0,x=iI+(Math.abs(_)*b+Math.abs(v)*(g.height/2))+lI,S=n+_*(i+x),C=r+v*(i+x),w=v>cI?eI/3:v<-cI?-eI/3:0;return el({backgroundColor:a,...pI,text:h,originalText:e,x:S,y:C+w,fontFamily:o,fontSize:s,lineHeight:c,textAlign:y,verticalAlign:`middle`})});return{axisLabels:f,axisLabelTopY:Math.min(...f.map(e=>e.y)),axisLabelBottomY:Math.max(...f.map(e=>e.y+e.height))}},kI=(e,t,n,r,i,a)=>{if(e.length<=1)return[];let o=Yn[`Lilita One`],s=xs.lg,c=$n(o),l=Or({fontFamily:o,fontSize:s}),u=e.map((e,n)=>{let r=e.title?.trim()||`Series ${n+1}`,i=DI(r,l,tI),a=Oi(i,l,c),o=uI+fI+a.width;return{label:r,displayLabel:i,color:t[n],width:o,height:a.height}}),d=Math.max(uI/2,...u.map(e=>e.height/2)),f=Math.max(i,r+d+iI),p=dI,m=uI*.6,h=u.reduce((e,t)=>e+t.width,0)+dI*Math.max(0,u.length-1),g=h+p*2,_=d*2+m*2,v=[];v.push(jr({...pI,backgroundColor:`transparent`,type:`rectangle`,fillStyle:`solid`,strokeColor:$c.black,x:n-g/2,y:f-_/2,width:g,height:_,roughness:ea.architect,roundness:{type:Un.PROPORTIONAL_RADIUS}}));let y=n-h/2;return u.forEach(e=>{v.push(jr({...pI,backgroundColor:e.color,type:`rectangle`,x:y,y:f-uI/2,width:uI,height:uI,fillStyle:`solid`,strokeColor:e.color,roughness:ea.architect,roundness:{type:Un.PROPORTIONAL_RADIUS}})),v.push(el({...pI,text:e.displayLabel,originalText:e.label,autoResize:!1,x:y+uI+fI,y:f,fontFamily:o,fontSize:s,lineHeight:c,textAlign:`left`,verticalAlign:`middle`})),y+=e.width+dI}),v},AI=(e,t,n,r)=>{if(Oi(e,n,r).width<=t)return e;let i=e.length;for(;i>1;){let a=`${e.slice(0,i)}...`;if(Oi(a,n,r).width<=t)return a;i--}return e[0]?`${e[0]}...`:e},jI=(e,t,n,r)=>{if(Oi(e,n,r).width<=t)return{wrapped:!1,text:e};let i=e.trim().split(/\s+/).filter(Boolean);return i.length>1&&!i.some(e=>Oi(e,n,r).width>t)&&t>=yc(n,r)?{wrapped:!0,text:ec(e,n,t)}:{wrapped:!1,text:AI(e,t,n,r)}},MI=(e,t,n)=>{let r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n));return{width:e*r+t*i,height:e*i+t*r}},NI=e=>e.includes(`...`),PI=(e,t,n,r,i)=>{let a=Math.max(JF,Math.ceil(yc(r,i))),o=Math.max(a,Math.floor(t)),s=[];for(let e=o;e>=a;e-=4)s.push(e);s[s.length-1]!==a&&s.push(a);let c=e=>({ellipsified:NI(e.text),visibleChars:e.text.replace(/\.\.\./g,``).replace(/\n/g,``).length,lineCount:e.text.split(`
53
+ `).length}),l=(e,t)=>{let n=c(e),r=c(t);return n.ellipsified===r.ellipsified?n.visibleChars===r.visibleChars?n.lineCount===r.lineCount?e.rotatedHeight<t.rotatedHeight:n.lineCount<r.lineCount:n.visibleChars>r.visibleChars:!n.ellipsified},u=null,d=null,f=null;for(let t of s){let{wrapped:a,text:o}=jI(e,t,r,i),s=Oi(o,r,i),c=MI(s.width,s.height,qF),p={originalText:e,text:o,metrics:s,rotatedWidth:c.width,rotatedHeight:c.height,wrapped:a},m=c.width-n;if(m<=0){(!u||l(p,u))&&(u=p);continue}(!d||m<d.overflow||m===d.overflow&&l(p,d.spec))&&(d={overflow:m,spec:p}),!NI(p.text)&&(!f||m<f.overflow||m===f.overflow&&l(p,f.spec))&&(f={overflow:m,spec:p})}return u||(f&&d&&f.overflow<=d.overflow+$F?f.spec:d.spec)},FI=e=>{if(e.type!==`text`)return e.y+e.height;let t=MI(e.width,e.height,e.angle);return e.y+e.height/2+t.height/2},II=(e,t,n,r,i)=>{let a=pI.fontFamily,o=xs.sm,s=$n(a),c=Or({fontFamily:a,fontSize:o}),l=Math.max(1,i.slotWidth+i.gap-YF*2+QF),u=n;return e.labels?.map((e,n)=>{let a=PI(e,i.xLabelMaxWidth,l,c,s),d=t+n*(i.slotWidth+i.gap)+i.gap+i.slotWidth/2,f=u+XF+(a.rotatedHeight-a.metrics.height)/2;return el({backgroundColor:r,...pI,text:a.text,originalText:a.wrapped?e:a.text,autoResize:!a.wrapped,x:d,y:f,angle:qF,fontSize:o,lineHeight:s,textAlign:`center`,verticalAlign:`top`})})||[]},LI=(e,t,n,r,i,a=Math.max(...e.series[0].values))=>{let o=el({backgroundColor:r,...pI,x:t-i.gap,y:n-i.gap,text:`0`,textAlign:`right`});return[o,el({backgroundColor:r,...pI,x:t-i.gap,y:n-i.chartHeight-o.height/2,text:a.toLocaleString(),textAlign:`right`})]},RI=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=yI(e,i);return[jc({backgroundColor:r,...pI,type:`line`,x:t,y:n,width:a,points:[L(0,0),L(a,0)]}),jc({backgroundColor:r,...pI,type:`line`,x:t,y:n,height:o,points:[L(0,0),L(0,-o)]}),jc({backgroundColor:r,...pI,type:`line`,x:t,y:n-i.chartHeight-i.gap,strokeStyle:`dotted`,width:a,opacity:nI,points:[L(0,0),L(a,0)]})]},zI=(e,t,n,r,i,a=Math.max(...e.series[0].values),o)=>{let{chartWidth:s,chartHeight:c}=yI(e,i),l=e.title?el({backgroundColor:r,...pI,text:e.title,x:t+s/2,y:n-i.chartHeight-i.gap*2-20,roundness:null,textAlign:`center`,fontSize:xs.xl,fontFamily:Yn[`Lilita One`]}):null,u=o?jr({backgroundColor:r,...pI,type:`rectangle`,x:t,y:n-c,width:s,height:c,strokeColor:$c.black,fillStyle:`solid`,opacity:6}):null;return[...u?[u]:[],...l?[l]:[],...II(e,t,n,r,i),...LI(e,t,n,r,i,a),...RI(e,t,n,r,i)]},BI=(e,t,n,r)=>{let i=e.series,a=vI(`bar`,i.length),o=Math.max(1,...i.flatMap(e=>e.values.map(e=>Math.max(0,e)))),s=CI(r),c=wI(s),l=SI(i.length,s),u=i.length>1?Math.max(1,Math.floor(a.gap/(i.length+1))):0,d=i.length>1?Math.max(2,(a.slotWidth-u*(i.length-1))/i.length):a.slotWidth,f=i.length*d+u*(i.length-1),p=(a.slotWidth-f)/2,m=i[0].values.flatMap((e,r)=>i.map((e,s)=>{let f=Math.max(0,e.values[r]??0)/o*a.chartHeight,m=i.length>1?l[s]:c;return jr({backgroundColor:m,...pI,type:`rectangle`,fillStyle:i.length>1?`solid`:pI.fillStyle,strokeColor:i.length>1?m:pI.strokeColor,x:t+r*(a.slotWidth+a.gap)+a.gap+p+s*(d+u),y:n-f-a.gap,width:d,height:f})})),h=zI(e,t,n,c,a,o,Ae()),g=II(e,t,n,c,a),_=Math.max(n+a.gap/2,...g.map(e=>FI(e))),{chartWidth:v}=yI(e,a),y=kI(i,l,t+v/2,_,n+a.gap*5,c);return[...h,...m,...y]},VI=(e,t,n,r)=>{let i=e.series,a=vI(`line`,i.length),o=Math.max(1,...i.flatMap(e=>e.values)),s=CI(r),c=wI(s),l=SI(i.length,s),u=i.map((e,r)=>{let i=e.values.map((e,t)=>L(t*(a.slotWidth+a.gap),-(e/o)*a.chartHeight)),s=Math.max(...i.map(e=>e[0])),c=Math.max(...i.map(e=>e[1])),u=Math.min(...i.map(e=>e[0])),d=Math.min(...i.map(e=>e[1]));return jc({backgroundColor:`transparent`,...pI,type:`line`,x:t+a.gap+a.slotWidth/2,y:n-a.gap,height:c-d,width:s-u,strokeColor:l[r],strokeWidth:2,points:i})}),d=i.flatMap((e,r)=>e.values.map((e,i)=>{let s=i*(a.slotWidth+a.gap)+a.gap/2,c=-(e/o)*a.chartHeight+a.gap/2;return jr({backgroundColor:l[r],...pI,fillStyle:`solid`,strokeColor:l[r],strokeWidth:2,type:`ellipse`,x:t+s+a.slotWidth/2,y:n+c-a.gap*2,width:a.gap,height:a.gap})})),f=i[0].values.map((e,t)=>Math.max(0,...i.map(e=>e.values[t]??0))).map((e,r)=>{let i=r*(a.slotWidth+a.gap)+a.gap/2,s=e/o*a.chartHeight+a.gap/2+a.gap;return jc({backgroundColor:c,...pI,type:`line`,x:t+i+a.slotWidth/2+a.gap/2,y:n-s,height:s,strokeStyle:`dotted`,opacity:nI,points:[L(0,0),L(0,s)]})}),p=zI(e,t,n,c,a,o,Ae()),m=II(e,t,n,c,a),h=Math.max(n+a.gap/2,...m.map(e=>FI(e))),{chartWidth:g}=yI(e,a),_=kI(i,l,t+g/2,h,n+a.gap*5,c);return[...p,...u,...f,...d,..._]},HI=e=>{let t=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,``)):null},UI=(e,t)=>e.slice(1).every(e=>HI(e[t])!==null),WI=e=>{let t=e[0].length;if(t>2){let n=e[0].every(e=>HI(e)===null),r=n?e.slice(1):e;if(r.length<1)return{ok:!1,reason:`No data rows`};if(r.some(e=>e.slice(1).some(e=>HI(e)===null)))return{ok:!1,reason:`Value is not numeric`};if(t-1>r.length){let t=n?e[0].slice(1).map(e=>e.trim()):null,i=r.map(e=>({title:e[0]?.trim()||null,values:e.slice(1).map(e=>HI(e))}));return{ok:!0,data:{title:i.length===1?i[0].title:n&&e[0][0].trim()||null,labels:t,series:i}}}let i=e[0].slice(1).map((e,t)=>{let i=t+1,a=`Series ${i}`;return{title:n&&e.trim()||a,values:r.map(e=>HI(e[i]))}});return{ok:!0,data:{title:n&&e[0][0].trim()||null,labels:r.map(e=>e[0]),series:i}}}if(t===1){if(!UI(e,0))return{ok:!1,reason:`Value is not numeric`};let t=HI(e[0][0])===null,n=t?e[0][0]:null,r=(t?e.slice(1):e).map(e=>HI(e[0]));return r.length<2?{ok:!1,reason:`Less than two rows`}:{ok:!0,data:{title:n,labels:null,series:[{title:n,values:r}]}}}let n=HI(e[0][1])===null,r=n?e.slice(1):e;if(r.length<2)return{ok:!1,reason:`Less than 2 rows`};if(r.some(e=>HI(e[1])===null))return{ok:!1,reason:`Value is not numeric`};let i=n?e[0][1]:null;return{ok:!0,data:{title:i,labels:r.map(e=>e[0]),series:[{title:i,values:r.map(e=>HI(e[1]))}]}}},GI=e=>{let t=t=>e.replace(/\r\n?/g,`
54
+ `).split(`
55
+ `).filter(e=>e.trim().length>0).map(e=>e.split(t).map(e=>e.trim())),n=[` `,`,`,`;`].map(e=>{let n=t(e),r=n[0]?.length??0;return{delimiter:e,parsed:n,numCols:r,isConsistent:n.length>0&&n.every(e=>e.length===r)}}),r=(n.find(e=>e.isConsistent&&e.numCols>1)??n.find(e=>e.isConsistent)??n[0]).parsed;if(r.length===0)return{ok:!1,reason:`No values`};let i=r[0].length;return r.every(e=>e.length===i)?WI(r):{ok:!1,reason:`All rows don't have same number of columns`}},KI=(e,t,n,r)=>{if(!gI(e,`radar`))return null;let i=e.labels??e.series[0].values.map((e,t)=>`Value ${t+1}`),a=e.series,{normalize:o,renderSteps:s}=TI(a,i.length),c=CI(r),l=wI(c),u=SI(a.length,c),{chartWidth:d,chartHeight:f}=bI(),p=t+d/2,m=n-f/2,h=tI/2,g=i.map((e,t)=>-Math.PI/2+Math.PI*2*t/i.length),{axisLabels:_,axisLabelTopY:v,axisLabelBottomY:y}=OI(i,g,p,m,h,l),b=Yn[`Lilita One`],x=xs.xl,S=$n(b),C=Or({fontFamily:b,fontSize:x}),w=e.title?DI(e.title,C,d+iI*2):null,T=w?Oi(w,C,S):null,E=w?el({backgroundColor:l,...pI,text:w,originalText:e.title??w,x:t+d/2,y:v-iI-T.height/2,fontFamily:b,fontSize:x,lineHeight:S,textAlign:`center`}):null,D=s?Array.from({length:rI},(e,t)=>{let n=(t+1)/rI,r=h*n,i=g.map(e=>L(Math.cos(e)*r,Math.sin(e)*r));return i.push(L(i[0][0],i[0][1])),jc({backgroundColor:`transparent`,...pI,type:`line`,x:p,y:m,width:r*2,height:r*2,strokeStyle:`solid`,roughness:ea.architect,opacity:nI,polygon:!0,points:i})}):[],ee=g.map(e=>{let t=Math.cos(e)*h,n=Math.sin(e)*h;return jc({backgroundColor:`transparent`,...pI,type:`line`,x:p,y:m,width:Math.abs(t),height:Math.abs(n),strokeStyle:`solid`,roughness:ea.architect,opacity:nI,points:[L(0,0),L(t,n)]})}),O=a.map((e,t)=>{let n=g.map((t,n)=>{let r=e.values[n]??0,i=o(r,n)*h;return L(Math.cos(t)*i,Math.sin(t)*i)});return n.push(L(n[0][0],n[0][1])),jc({backgroundColor:`transparent`,...pI,type:`line`,x:p,y:m,width:h*2,height:h*2,strokeColor:u[t],strokeWidth:2,polygon:!0,points:n})}),k=kI(a,u,p,y,n+eI*5,l);return[...E?[E]:[],..._,...D,...ee,...O,...k]},qI=(e,t,n,r,i)=>e===`line`?VI(t,n,r,i):e===`radar`?KI(t,n,r,i):BI(t,n,r,i),JI=e=>RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${[`flowchart`,`graph`,`sequenceDiagram`,`classDiagram`,`stateDiagram`,`stateDiagram-v2`,`erDiagram`,`journey`,`gantt`,`pie`,`quadrantChart`,`requirementDiagram`,`gitGraph`,`C4Context`,`mindmap`,`timeline`,`zenuml`,`sankey`,`xychart`,`block`].map(e=>`\\s*${e}(-beta)?`).join(`|`)})\\b`).test(e.trim()),YI=!1,XI=0,ZI=!1,QI=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`onCut`,pF(e=>{!this.app.isInteractionEnabled()||!this.dependencies.getContainer()?.contains(this.app.ownerDocument.activeElement)||_(e.target)||(this.app.actionManager.executeAction(lk,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),B(this,`onCopy`,pF(e=>{!this.app.isInteractionEnabled()||!this.dependencies.getContainer()?.contains(this.app.ownerDocument.activeElement)||_(e.target)||(this.app.actionManager.executeAction(sk,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),B(this,`onPasteShortcut`,e=>{YI=e.shiftKey,clearTimeout(XI),XI=this.app.ownerWindow.setTimeout(()=>{YI=!1},100)}),B(this,`clearPlainPaste`,()=>{clearTimeout(XI),XI=0,YI=!1}),B(this,`pasteFromClipboard`,pF(async e=>{if(!this.app.isInteractionEnabled())return;let t=!!YI,n=this.app.ownerDocument.activeElement,r=this.dependencies.getContainer()?.contains(n);if(e&&!r)return;let i=this.app.ownerDocument.elementFromPoint(this.app.viewport.lastPosition.x,this.app.viewport.lastPosition.y);if(e&&(!(i instanceof this.app.ownerWindow.HTMLCanvasElement)||_(n)))return;let a=await _O(e),o=a.getFiles(),s=await vO(a,t);if(this.app.props.onPaste)try{if(await this.app.props.onPaste(s,e)===!1)return}catch(e){console.error(e)}await this.insertClipboardContent(s,o,t),this.app.setActiveTool({type:this.app.state.preferredSelectionTool.type},{keepSelection:!0}),e?.preventDefault()}))}async insertClipboardContent(e,t,r){let{x:i,y:a}=ws({clientX:this.app.viewport.lastPosition.x,clientY:this.app.viewport.lastPosition.y},this.app.state);if(e.errorMessage){this.app.setState({errorMessage:e.errorMessage});return}if(t.length===0&&!r&&e.mixedContent){await this.addElementsFromMixedContentPaste(e.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&e.text){let t=GI(e.text);if(t.ok){this.app.setState({openDialog:{name:`charts`,data:t.data,rawText:e.text}});return}}let o=t.map(e=>e.file);if(o.length===0&&e.text&&!r){let t=e.text.trim();t.startsWith(`<svg`)&&t.endsWith(`</svg>`)&&o.push(Zn(t))}if(o.length>0){this.app.isToolSupported(`image`)?await this.app.insertImages(o,i,a):this.app.setState({errorMessage:G(`errors.imageToolNotSupported`)});return}if(e.elements){let t=e.programmaticAPI?Ut(e.elements):e.elements;this.app.addElementsFromPasteOrLibrary({elements:t,files:e.files||null,position:this.app.editorInterface.formFactor===`desktop`?`cursor`:`center`,retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!e.text)return;if(!r&&JI(e.text)){let t=await n(()=>import(`./dist-DPJj-Y3l.js`),[],import.meta.url);try{let{elements:n,files:r={}}=await t.parseMermaidToExcalidraw(e.text),i=Ut(n,{regenerateIds:!0});this.app.addElementsFromPasteOrLibrary({elements:i,files:r,position:this.app.editorInterface.formFactor===`desktop`?`cursor`:`center`});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let s=$e(e.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),c=s.map(e=>ze(e)).filter(e=>Qt(e,this.app.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||il(e)?.type===`video`));if(!r&&c.length>0&&c.length===s.length){let e=[];for(let t of c){let n=e[e.length-1],r=this.app.insertEmbeddableElement({sceneX:n?n.x+n.width+20:i,sceneY:a,link:Ee(t)});r&&e.push(r)}e.length&&(this.app.store.scheduleCapture(),this.app.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))}));return}this.addTextFromPaste(e.text,r)}async addElementsFromMixedContentPaste(e,{isPlainPaste:t,sceneX:n,sceneY:r}){if(!t&&e.some(e=>e.type===`imageUrl`)&&this.app.isToolSupported(`image`)){let t=e.filter(e=>e.type===`imageUrl`).map(e=>e.value),i=await Promise.all(t.map(async e=>{try{return{file:await Qi(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=G(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=G(`errors.unsupportedFileType`)),{errorMessage:t}}})),a=i.filter(e=>!!e.file).map(e=>e.file);await this.app.insertImages(a,n,r);let o=i.find(e=>!!e.errorMessage);o&&o.errorMessage&&this.app.setState({errorMessage:o.errorMessage})}else{let n=e.filter(e=>e.type===`text`);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
56
+
57
+ `),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=ws({clientX:this.app.viewport.lastPosition.x,clientY:this.app.viewport.lastPosition.y},this.app.state),i={x:n,y:r,strokeColor:this.app.state.currentItemStrokeColor,backgroundColor:this.app.state.currentItemBackgroundColor,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:this.app.getCurrentItemStrokeWidth(`text`),strokeStyle:this.app.state.currentItemStrokeStyle,roundness:null,roughness:this.app.state.currentItemRoughness,opacity:this.app.state.currentItemOpacity,text:e,fontSize:this.app.state.currentItemFontSize,fontFamily:this.app.state.currentItemFontFamily,textAlign:ba,verticalAlign:`top`,locked:!1},a=Or({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=$n(i.fontFamily),s=t?[e]:e.split(`
58
+ `),c=e=>{let t=r;return s.reduce((r,c,l)=>{let u=ni(c).trim();if(u.length){let s=this.app.getTopLayerFrameAtSceneCoords({x:n,y:t}),c=Oi(u,a,o),l=c.width>e,d=l?ec(u,a,e):u;c=l?Oi(d,a,o):c;let f=n-c.width/2,p=t-c.height/2,m=el({...i,x:f,y:p,text:d,originalText:u,lineHeight:o,autoResize:!l,frameId:s?s.id:null});r.push(m),t+=m.height+10}else s[l-1]?.trim()&&(t+=Zo(i.fontSize,o)+10);return r},[])},l=e=>{let t=c(this.app.text.getMaxTextWidth(e)),n=t.length&&t.some(e=>!e.autoResize)?sa({bounds:Hc(t),appState:this.app.state,offsets:e}):null;if(!n)return t;let r=n.scrollX-this.app.state.scrollX,i=n.scrollY-this.app.state.scrollY;return t.map(e=>{let t=e.x+r,n=e.y+i,a=this.app.getTopLayerFrameAtSceneCoords({x:t+e.width/2,y:n+e.height/2});return N(e,{x:t,y:n,frameId:a?a.id:null})})},u=this.app.text.getTextViewportOffsets(),d=l(u);if(d.length===0)return;let f=()=>j(Object.fromEntries(d.map(e=>[e.id,!0])),this.app.state);if(this.app.viewport.getSideUIRect(`stats`)){(0,Cl.flushSync)(()=>{this.app.insertNewElements(d),this.app.setState({selectedElementIds:f()})});let e=this.app.text.getTextViewportOffsets(Hc(d));if(e.left!==u.left||e.right!==u.right){let t=l(e),n=new Set(d.map(e=>e.id));d=d.map((e,n)=>{let{x:r,y:i,width:a,height:o,text:s,autoResize:c,frameId:l}=t[n];return N(e,{x:r,y:i,width:a,height:o,text:s,autoResize:c,frameId:l})}),this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().filter(e=>!n.has(e.id))),this.app.insertNewElements(d)}}else this.app.insertNewElements(d);this.app.store.scheduleCapture(),this.app.setState({selectedElementIds:f()}),!t&&d.length>1&&ZI===!1&&this.app.editorInterface.formFactor!==`phone`&&(this.app.setToast({message:G(`toast.pasteAsSingleElement`,{shortcut:Z(`CtrlOrCmd+Shift+V`)}),duration:5e3}),ZI=!0)}},$I=12,eL=16,tL=10,nL=eL+2,rL=.8,iL=e=>4/e,aL=(e,t,n)=>{let r=iL(t);if(n!==`desktop`||eL>(e.height+r*2)*t*rL)return null;let i=$I/t,a=eL/t,o=L(e.x+e.width/2,e.y+e.height/2),s=As(L(o[0]+e.width/2+r+i,o[1]),o,e.angle);return{center:s,start:As(L(s[0],s[1]-a/2),s,e.angle),end:As(L(s[0],s[1]+a/2),s,e.angle),hitboxWidth:tL/t,hitboxHeight:nL/t}},oL=(e,t,n,r)=>{let i=aL(t,n,r);if(!i)return!1;let a=As(L(e.x,e.y),i.center,-t.angle);return Math.abs(a[0]-i.center[0])<=i.hitboxWidth/2&&Math.abs(a[1]-i.center[1])<=i.hitboxHeight/2},sL=5,cL=(e,t,n,r)=>{let{zoom:i}=r,a=180*n/Math.PI;return`translate(${e*(i.value-1)/2}px, ${t*(i.value-1)/2}px) scale(${i.value}) rotate(${a}deg)`},lL=(e,t)=>{let n=e.lastIndexOf(`
59
+ `,Math.max(0,t-1))+1,r=e.indexOf(`
60
+ `,t),i=e.slice(n,r===-1?e.length:r);return Ln(i)?`rtl`:`ltr`},uL=e=>{let t=[0],n=0;for(let r of Array.from(e))n+=r.length,t.push(n);return t},dL=({text:e,font:t,lineHeightPx:n,direction:r,ownerDocument:i,offsets:a})=>{if(!e||!i.body||typeof i.createRange!=`function`)return null;let o=i.createElement(`div`),s=i.createTextNode(e),c=i.createRange(),l=[];o.dir=r,Object.assign(o.style,{position:`fixed`,top:`0`,left:`0`,margin:0,padding:0,border:0,opacity:`0`,pointerEvents:`none`,whiteSpace:`pre`,font:t,lineHeight:`${n}px`}),o.append(s),i.body.append(o);try{c.selectNodeContents(s);let{left:e}=c.getBoundingClientRect();for(let e of a){c.setStart(s,e),c.setEnd(s,e);let t=c.getBoundingClientRect();if(!Number.isFinite(t.left))return null;l.push(t.left)}return{left:e,positions:l}}catch{return null}finally{o.remove()}},fL=({targetX:e,...t})=>{let n=uL(t.text),r=dL({...t,offsets:n})?.positions;if(!r)return null;let i=Math.min(...r),a=n[0],o=1/0;for(let t=0;t<n.length;t++){let s=Math.abs(r[t]-i-e);s<o&&(o=s,a=n[t])}return a},pL=({offset:e,...t})=>{let n=dL({...t,offsets:[e]});return n?n.positions[0]-n.left:null},mL=({onChange:e,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:o,autoSelect:s=!0,initialCaretSceneCoords:c=null,initialSelection:l=null})=>{let u=a?.ownerDocument??document,p=u.defaultView??window,m=a?.querySelector(`.excalidraw-textEditorContainer`)??null,h=()=>{if(!m)return 0;let{left:e,right:t}=o.viewport.getSidebarInsets();return m.style.left=`${e}px`,m.style.right=`${t}px`,e},g=null,v=(e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,``);return Ot({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},y=o.state.theme,b=()=>{y=o.state.theme;let e=o.state,t=o.scene.getElement(r.id);if(!t)return;let{textAlign:i,verticalAlign:a}=t,s=o.scene.getNonDeletedElementsMap();if(t&&D(t)){let r=t.x,c=t.y,l=xe(t,o.scene.getNonDeletedElementsMap()),u=t.width,d=t.height,p=t.height;if(l&&t.containerId){if(ir(l)){let e=R.getBoundTextElementPosition(l,t,s);r=e.x,c=e.y}if(p=uc(l,t),x(l)){let{x:e,y:n}=Wn(l,t,s);r=e,c=n}else{let e=v(t,S),n;if(e?n=rr(l.id,l.height):(n=Ui[l.id],n||=rr(l.id,l.height)),!ir(l)&&d>p){let e=Fs(d,l.type);o.scene.mutateElement(l,{height:e}),bi(l,o.scene);return}if(!ir(l)&&l.height>n.height&&d<p){let e=Fs(d,l.type);o.scene.mutateElement(l,{height:e}),bi(l,o.scene)}else{let{x:e,y:n}=Wn(l,t,s);r=e,c=n}}}let[m,_]=n(r,c),y=f(t,l);l&&(u+=.5),d*=1.05;let b=Or(t),C=h();!t.autoResize&&S.style.whiteSpace!==`pre-wrap`&&(S.style.whiteSpace=`pre-wrap`,S.style.wordBreak=`break-word`),Object.assign(S.style,{font:b,lineHeight:t.lineHeight,width:`${u}px`,height:`${d}px`,left:`${m-C}px`,top:`${_}px`,transformOrigin:`${t.width/2}px ${t.height/2}px`,transform:cL(t.width,t.height,y,e),textAlign:i,verticalAlign:a,color:Rt(t.strokeColor,e.theme===M.DARK),opacity:t.opacity/100}),g={angle:y,font:b,height:t.height,lineHeightPx:Zo(t.fontSize,t.lineHeight),textAlign:i,width:t.width,x:r,y:c},S.scrollTop=0,pi()&&(S.style.fontFamily=Ot(t)),o.scene.mutateElement(t,{x:r,y:c})}},S=u.createElement(`textarea`);S.dir=`auto`,S.tabIndex=0,S.dataset.type=`wysiwyg`,S.wrap=`off`,S.classList.add(`excalidraw-wysiwyg`);let C=`pre`,w=`normal`;(fn(r)||!r.autoResize)&&(C=`pre-wrap`,w=`break-word`),Object.assign(S.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:w,whiteSpace:C,overflowWrap:`break-word`,boxSizing:`content-box`}),S.value=r.originalText,b();let T=()=>{if(!c||!g)return null;let e=g,t=L(e.x+e.width/2,e.y+e.height/2),[n,r]=As(L(c.x,c.y),t,-e.angle),i=n-e.x,a=r-e.y,o=ha(S.value,e.font,C===`pre-wrap`?e.width:1/0),s=o[Math.max(0,Math.min(o.length-1,Math.floor(a/e.lineHeightPx)))],l=lL(S.value,s.start),d=Ao(s.text,e.font),f=i-(e.textAlign===`center`?(e.width-d)/2:e.textAlign===`right`?e.width-d:0);if(!s.text)return s.start;let p=fL({text:s.text,font:e.font,lineHeightPx:e.lineHeightPx,direction:l,targetX:f,ownerDocument:u});return s.start+(p||0)},E=()=>{let e=g;if(!e)return null;let{value:t}=S,r=S.selectionDirection===`backward`?S.selectionStart:S.selectionEnd,i=ha(t,e.font,S.style.whiteSpace===`pre-wrap`?e.width:1/0),a=Math.max(0,i.findLastIndex(e=>e.start<=r)),o=i[a],s=Ao(o.text,e.font),c=e.textAlign===`center`?(e.width-s)/2:e.textAlign===`right`?e.width-s:0,l=t.slice(o.start,o.end),d=Math.min(r,o.end)-o.start,f=Ao(l.slice(0,d),e.font),p=lL(t,o.start),m=c+((Je(l)?pL({text:l,font:e.font,lineHeightPx:e.lineHeightPx,direction:p,ownerDocument:u,offset:d}):null)??(p===`rtl`?s-f:f)),h=L(e.x+e.width/2,e.y+e.height/2),[[_,v],[y,b]]=[a,a+1].map(t=>{let[r,i]=As(L(e.x+m,e.y+t*e.lineHeightPx),h,e.angle);return n(r,i)});return{left:Math.min(_,y),right:Math.max(_,y),top:Math.min(v,b),bottom:Math.max(v,b)}},ee=()=>{let e=!he&&E();if(e)for(let t of o.text.getTextSidePanels()){let n=o.viewport.getSideUIRect(t);if(n&&e.right>=n.left&&e.left<=n.right&&e.bottom>n.top&&e.top<n.bottom){let t=n.left+n.right<o.state.width?n.right+sL-e.left:n.left-sL-e.right;o.viewport.translate(e=>({scrollX:e.scrollX+t/e.zoom.value}));return}}},O=l??(()=>{let e=T();return e===null?null:{start:e,end:e}})();e&&(S.onpaste=async e=>{let t=gO(e),n=null;if(t.has(A.excalidrawClipboard)||t.has(A.excalidraw)){e.preventDefault(),n=await _O(e);try{let e=await vO(n);if(e.elements){let t=Io(e.elements);if(t){let{selectionStart:e,selectionEnd:n,value:r}=S;S.value=r.slice(0,e)+t+r.slice(n);let i=e+t.length;S.selectionStart=S.selectionEnd=i,S.dispatchEvent(new Event(`input`))}}return}catch{console.warn(`failed to parse excalidraw clipboard data`)}}n||=await _O(e);let i=n.findByType(A.text);if(!i)return;let a=ni(i.value);if(!a)return;let s=xe(r,o.scene.getNonDeletedElementsMap());if(s){let e=Sn(s,o.scene.getNonDeletedElementsMap()),t=Or({fontSize:x(s)&&e?e.fontSize:o.state.currentItemFontSize,fontFamily:x(s)&&e?e.fontFamily:o.state.currentItemFontFamily}),n=Jr(s,e),{selectionStart:r,selectionEnd:i,value:c}=S,l=c.slice(0,r)+a+c.slice(i),u=ec(l,t,n),d=Math.min(Ro(u,t),n);S.style.width=`${d}px`}},S.oninput=()=>{let t=ni(S.value);if(S.value!==t){let e=S.selectionStart;S.value=t,S.selectionStart=e,S.selectionEnd=e}e(S.value),queueMicrotask(ee)}),S.onkeydown=e=>{if(!e.shiftKey&&yD.keyTest(e))e.preventDefault(),o.actionManager.executeAction(yD),b();else if(!e.shiftKey&&bD.keyTest(e))e.preventDefault(),o.actionManager.executeAction(bD),b();else if(!e.shiftKey&&xD.keyTest(e))e.preventDefault(),o.actionManager.executeAction(xD),b();else if(eD.keyTest(e))o.actionManager.executeAction(eD);else if(tD.keyTest(e))o.actionManager.executeAction(tD);else if(e.key===z.ESCAPE)e.preventDefault(),ae=!0,oe();else if(PO.keyTest(e))e.preventDefault(),oe(),o.actionManager.executeAction(PO,`keyboard`);else if(FO.keyTest(e))e.preventDefault(),oe(),o.actionManager.executeAction(FO,`keyboard`);else if(e.key===z.ENTER&&e[z.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;ae=!0,oe()}else if(e.key===z.TAB||e[z.CTRL_OR_CMD]&&(e.code===d.BRACKET_LEFT||e.code===d.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===d.BRACKET_LEFT?ne():j(),S.dispatchEvent(new Event(`input`))}};let k=` `.repeat(4),te=RegExp(`^ {1,4}`),j=()=>{let{selectionStart:e,selectionEnd:t}=S,n=re(),r=S.value;n.forEach(e=>{let t=r.slice(0,e),n=r.slice(e);r=`${t}${k}${n}`}),S.value=r,S.selectionStart=e+4,S.selectionEnd=t+4*n.length},ne=()=>{let{selectionStart:e,selectionEnd:t}=S,n=re(),r=[],i=S.value;n.forEach(e=>{let t=i.slice(e,e+4).match(te);t&&(i=`${i.slice(0,e)}${i.slice(e+t[0].length)}`,r.push(e))}),S.value=i,r.length&&(e>r[r.length-1]?S.selectionStart=Math.max(e-4,r[r.length-1]):S.selectionStart=e,S.selectionEnd=Math.max(S.selectionStart,t-4*r.length))},re=()=>{let{selectionStart:e,selectionEnd:t,value:n}=S,r=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=r,n.slice(e,t).split(`
61
+ `).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},ie=e=>{e.target instanceof p.HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},ae=!1,oe=()=>{if(he)return;he=!0,se();let e=o.scene.getElement(r.id);if(!e)return;let n=xe(e,o.scene.getNonDeletedElementsMap());if(n){if(S.value.trim()){let e=An(n);!e||e!==r.id?o.scene.mutateElement(n,{boundElements:(n.boundElements||[]).concat({type:`text`,id:r.id})}):ir(n)&&gn(n)}else o.scene.mutateElement(n,{boundElements:n.boundElements?.filter(e=>!D(e))});ga(e,n,o.scene)}t({viaKeyboard:ae,nextOriginalText:S.value})},se=()=>{S.onblur=null,S.oninput=null,S.onkeydown=null,ge&&ge.disconnect(),p.removeEventListener(`resize`,b),p.removeEventListener(`wheel`,ie,!0),p.removeEventListener(`pointerdown`,ue),p.removeEventListener(`pointerup`,ce),p.removeEventListener(`blur`,oe),p.removeEventListener(`beforeunload`,oe),fe(),de(),pe(),m?.removeEventListener(`scroll`,me),m?.style.removeProperty(`left`),m?.style.removeProperty(`right`),S.remove()},ce=e=>{p.removeEventListener(`pointerup`,ce);let t=e?.target,n=t instanceof p.HTMLElement&&t.classList.contains(`properties-trigger`),r=(t instanceof p.HTMLElement||t instanceof p.SVGElement)&&!!t.closest(`.properties-content`),i=(t instanceof p.HTMLElement||t instanceof p.SVGElement)&&(!!t.closest(`.${hn.SHAPE_ACTIONS_MENU}`)||!!t.closest(`.compact-shape-actions-island`));p.setTimeout(()=>{i||n||r||(S.onblur=oe,S.focus({preventScroll:!0}),O&&=(S.setSelectionRange(O.start,O.end),null))})},le=()=>{S.onblur=null,p.addEventListener(`pointerup`,ce),p.addEventListener(`blur`,oe)},ue=e=>{let t=e?.target;if(e.button===Aa.WHEEL){t instanceof p.HTMLTextAreaElement&&(e.preventDefault(),o.pan.start(e)),le();return}if(e.altKey&&!e[z.CTRL_OR_CMD]&&e.button===Aa.MAIN&&t===S&&(o.state.activeTool.type===`selection`||o.state.activeTool.type===`lasso`)){e.preventDefault(),e.stopPropagation(),ae=!0,oe(),o.duplicate.handOverTextEditorPress(e,r.id);return}let n=t instanceof p.HTMLElement&&t.classList.contains(`properties-trigger`),i=(t instanceof p.HTMLElement||t instanceof p.SVGElement)&&!!t.closest(`.properties-content`);(e.target instanceof p.HTMLElement||e.target instanceof p.SVGElement)&&(e.target.closest(`.${hn.SHAPE_ACTIONS_MENU}, .${hn.ZOOM_ACTIONS}`)||e.target.closest(`.compact-shape-actions-island`))&&!_(e.target)||n||i?le():e.target instanceof p.HTMLCanvasElement&&!pi()&&p.requestAnimationFrame(()=>{oe()})},de=o.onChangeEmitter.on(e=>{o.state.theme!==y&&b()}),fe=o.scene.onUpdate(()=>{b(),u.activeElement?.closest(`.properties-content`)||S.focus({preventScroll:!0})}),pe=o.onScrollChangeEmitter.on(()=>{b()}),me=()=>{if(!m)return;let{scrollLeft:e,scrollTop:t}=m;if(!e&&!t)return;m.scrollLeft=0,m.scrollTop=0;let n=e&&e+sL,r=t&&t+sL;o.viewport.translate(e=>({scrollX:e.scrollX-n/e.zoom.value,scrollY:e.scrollY-r/e.zoom.value}))};m?.addEventListener(`scroll`,me);let he=!1;s&&!O&&S.select(),ce();let ge=null;return i&&`ResizeObserver`in p?(ge=new p.ResizeObserver(()=>{b()}),ge.observe(i)):p.addEventListener(`resize`,b),S.onpointerdown=e=>e.stopPropagation(),p.requestAnimationFrame(()=>{p.addEventListener(`pointerdown`,ue,{capture:!0})}),p.addEventListener(`beforeunload`,oe),m.appendChild(S),oe},hL=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`textWysiwygSubmitHandler`,null),B(this,`getTextCreationGridPoint`,(e,t)=>{let n=this.app.getEffectiveGridSize();if(n===null)return null;let r=e=>Math.floor(e/n)*n;return{x:r(e),y:r(t)}}),B(this,`getTextSidePanels`,()=>this.dependencies.getStylesPanelMode()===`full`&&this.app.isDefaultUIEnabled()&&!this.app.state.zenModeEnabled?[`stats`,`stylesPanel`]:[`stats`]),B(this,`getTextViewportOffsets`,e=>{let t=e&&this.app.viewport.getSideUIRect(`stats`),{scrollY:n,zoom:r}=this.app.state,i=!!t&&!!e&&(e[1]+n)*r.value<t.bottom+20&&(e[3]+n)*r.value>t.top-20,{left:a,right:o}=this.app.viewport.getSideInsets([`sidebar`,...this.getTextSidePanels().filter(e=>e!==`stats`||i)],{reserve:{stylesPanel:!0}});return{top:20,right:o+20,bottom:20,left:a+20}}),B(this,`getMaxTextWidth`,e=>{let{left:t,right:n}=e,r=this.app.state.width-t-n;return Math.min(r>0?r/this.app.state.zoom.value:1/0,800)}),B(this,`isHittingTextAutoResizeHandle`,(e,t)=>{let n=hr(e,this.app.state);return!(!n||n.isDeleted||n.autoResize||!oL(t,n,this.app.state.zoom.value,this.app.editorInterface.formFactor))}),B(this,`handleTextAutoResizeHandlePointerDown`,(e,t)=>{let n=hr(e,this.app.state);return!n||!this.isHittingTextAutoResizeHandle(e,t)?!1:(this.app.actionManager.executeAction(jP,`ui`,n),this.app.cursor.reset(),!0)}),B(this,`startTextEditing`,({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:r,autoEdit:i=!0,initialCaretSceneCoords:a,initialSelection:o,arrowEndpoint:s,textElement:c})=>{let l=!1,u=s&&this.app.arrowText.getTextBinding(s,this.app.getCurrentItemStrokeWidth(`text`));u&&(r=null,n=!1,e=u.anchor[0],t=u.anchor[1]);let d=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.app.state,r);r&&d&&(Sn(r,this.app.scene.getNonDeletedElementsMap())||(l=!0));let f=u?null:c===void 0?this.getSelectedTextElement(r)||(r&&ir(r)?Sn(r,this.app.scene.getNonDeletedElementsMap()):null)||this.getTextElementAtPosition(e,t):c,p=f?.fontFamily||this.app.state.currentItemFontFamily,m=f?.lineHeight||$n(p),h=this.app.state.currentItemFontSize;if(!f&&l&&r&&!ir(r)&&!x(r)){let n=yc(Or({fontSize:h,fontFamily:p}),m),i=vo(h,m),a=Math.max(r.height,i),o=Math.max(r.width,n);this.app.scene.mutateElement(r,{height:a,width:o}),e=r.x+o/2,t=r.y+a/2,d&&=this.getTextWysiwygSnappedToCenterPosition(e,t,this.app.state,r)}let g=this.getTextCreationGridPoint(e,t),_=u?{x:e,y:t}:d?{x:d.elementCenterX,y:d.elementCenterY}:f?{x:e,y:t}:{x:g?.x??e,y:g===null?t-Zo(h,m)/2:g.y},v=this.app.getTopLayerFrameAtSceneCoords({x:_.x,y:_.y}),y=v&&(!l||!r||r.frameId===v.id)?v.id:null,b=f||el({x:_.x,y:_.y,strokeColor:l&&x(r)?r.strokeColor:this.app.state.currentItemStrokeColor,backgroundColor:this.app.state.currentItemBackgroundColor,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:this.app.getCurrentItemStrokeWidth(`text`),strokeStyle:this.app.state.currentItemStrokeStyle,roughness:this.app.state.currentItemRoughness,opacity:this.app.state.currentItemOpacity,text:``,fontSize:h,baseFontSize:l&&x(r)?h:null,fontFamily:p,textAlign:u?.textAlign??(d?`center`:this.app.state.currentItemTextAlign),verticalAlign:u?.verticalAlign??(d?Oc.MIDDLE:`top`),containerId:l?r?.id:void 0,labelPosition:l&&r&&ir(r)?.5:null,groupIds:l?r?.groupIds??[]:[],lineHeight:m,angle:l&&r&&!ir(r)?r.angle:0,frameId:y});if(!f&&l&&r&&this.app.scene.mutateElement(r,{boundElements:(r.boundElements||[]).concat({type:`text`,id:b.id})}),this.app.setState({editingTextElement:b}),!f){if(r&&l){let e=this.app.scene.getElementIndex(r.id);this.app.scene.insertElementsAtIndex([b],e+1)}else this.app.insertNewElement(b)}s&&u&&this.app.arrowText.bindText(s,b,u.fixedPoint),i||f||l?this.handleTextWysiwyg(b,{isExistingElement:!!f,initialCaretSceneCoords:f?a:null,initialSelection:f?o:null}):this.app.setState({newElement:b,multiElement:null})})}handleTextWysiwyg(e,{isExistingElement:t=!1,initialCaretSceneCoords:n=null,initialSelection:r=null}){let i=this.app.scene.getElementsMapIncludingDeleted(),a=(t,n)=>{let r=this.app.scene.getElement(e.id);if(!r||!D(r))return;let a=xe(r,i),o=a&&x(a)?a:null,s=o?Us(o,r,{originalText:t}):null,c=this.getTextViewportOffsets(Qr(r,i)),l=this.getMaxTextWidth(c);this.app.scene.replaceAllElements([...this.app.scene.getElementsIncludingDeleted().map(e=>s&&e.id===o?.id&&x(e)?N(e,s.container):e.id===r.id&&D(e)?N(e,{originalText:t,isDeleted:n??e.isDeleted,...s?.text??Nt(e,xe(e,i),i,t,l)}):e)]);let u=this.app.scene.getNonDeletedElement(r.id);if(r.autoResize&&u&&D(u)&&!u.autoResize){let e=sa({bounds:Qr(u,this.app.scene.getNonDeletedElementsMap()),appState:this.app.state,offsets:c,tooLarge:`leave`});e&&this.app.viewport.translate(e)}if(o){let e=this.app.scene.getNonDeletedElement(o.id);e&&bi(e,this.app.scene)}};this.textWysiwygSubmitHandler=mL({canvas:this.app.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=hs({sceneX:e,sceneY:t},this.app.state);return[n-this.app.state.offsetLeft,r-this.app.state.offsetTop]},onChange:pF(t=>{a(t,!1),Ga(e)&&bi(e,this.app.scene)}),onSubmit:pF(({viaKeyboard:n,nextOriginalText:r})=>{this.textWysiwygSubmitHandler=null;let i=!r.trim();a(r,i);let o=n&&!this.app.isToolLocked()&&this.app.state.activeTool.type!==`autoshape`?e.containerId||(i?null:e.id):null;o&&(0,Cl.flushSync)(()=>{this.app.setState(e=>({selectedElementIds:j({...e.selectedElementIds,[o]:!0},e)}))}),i&&cn(this.app.scene.getNonDeletedElements(),[e]),(!i||t)&&this.app.store.scheduleCapture(),(0,Cl.flushSync)(()=>{this.app.setState({newElement:null,editingTextElement:null})}),(this.app.isToolLocked()||this.app.state.activeTool.type===`autoshape`)&&this.app.cursor.applyForTool(),this.app.focusContainer()}),element:e,excalidrawContainer:this.dependencies.getContainer(),app:this.app,initialCaretSceneCoords:n,initialSelection:r,autoSelect:!this.app.editorInterface.isTouchScreen}),this.app.deselectElements(),this.app.state.selectedLinearElement&&this.app.setState({selectedLinearElement:{...this.app.state.selectedLinearElement,hoverPointIndex:-1,segmentMidPointHoveredCoords:null,hoveredFocusPointBinding:null}}),a(e.originalText,!1)}getSelectedTextElement(e){let t=this.app.scene.getSelectedElements(this.app.state);if(t.length!==1)return null;let n=t[0];return D(n)?n:e?Sn(n,this.app.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(e,t){let n=this.app.scene.getSelectedElements(this.app.state);if(n.length!==1||!e||e.id!==n[0].id)return null;let r=n[0];if(D(r))return null;if(!ms(r))return;let i=this.getSelectedTextElement(r),a=this.getTextElementAtPosition(t.x,t.y);if(i&&a?.id===i.id)return r}getTextElementAtPosition(e,t){let n=this.app.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&D(n)&&!n.isDeleted?n:null}getTextBindableContainerAtPosition(e,t){let n=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=[];for(let a=n.length-1;a>=0;--a){let o=n[a];if(F(o)||this.app.isClippedByFrameAt(e,t,o))continue;let[s,c,l,u]=In(o,r),d=ir(o);if(!(d?!xr({point:L(e,t),element:o,elementsMap:r,threshold:this.app.getElementHitThreshold(o)}):!(s<e&&e<l&&c<t&&t<u))&&(ve(o,!1)&&i.push({container:o,area:d?0:(l-s)*(u-c)}),d||Hn(o)))break}return(i.filter(({container:n})=>this.getTextWysiwygSnappedToCenterPosition(e,t,this.app.state,n)).reduce((e,t)=>!e||t.area<e.area?t:e,null)??i[0])?.container??null}isEditingTextContent(){return!!this.app.state.editingTextElement||D(this.app.state.newElement)}getTextWysiwygSnappedToCenterPosition(e,t,n,r){if(r){let i=r.x+r.width/2,a=r.y+r.height/2,o=Oe(r,this.app.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=hs({sceneX:i,sceneY:a},n);return{viewportX:e,viewportY:t,elementCenterX:i,elementCenterY:a}}}}},gL=e=>{switch(e.type){case`endpoint`:return{type:`arrow`,elementId:e.endpoint.arrow.id,anchor:e.endpoint.startOrEnd};case`text`:return{type:`text`,elementId:e.element.id};case`container`:return ir(e.element)?{type:`arrow`,elementId:e.element.id,anchor:`label`}:{type:`container`,elementId:e.element.id};case`free`:return null}},_L=(e,t)=>e===t?!0:!e||!t||e.type!==t.type||e.elementId!==t.elementId?!1:e.type!==`arrow`||t.type!==`arrow`||e.anchor===t.anchor,vL=class{constructor(e){this.app=e,B(this,`pending`,null),B(this,`lastModifiers`,{ctrlKey:!1,metaKey:!1}),B(this,`getTargetAt`,(e,t)=>{let{x:n,y:r}=e,i=this.app.arrowText.getBindableEndpointAtPosition(n,r);if(i)return{type:`endpoint`,endpoint:i};let a=this.app.text.getTextElementAtPosition(n,r);if(a)return{type:`text`,element:a};if(!t[z.CTRL_OR_CMD]){let e=this.app.text.getTextBindableContainerAtPosition(n,r);if(e&&!ke(e)&&this.app.text.getTextWysiwygSnappedToCenterPosition(n,r,this.app.state,e))return{type:`container`,element:e}}return{type:`free`}}),B(this,`updateHover`,(e,t,n=!1)=>{let{state:r}=this.app;if(r.activeTool.type!==`text`||this.pending)return null;this.lastModifiers={ctrlKey:t.ctrlKey,metaKey:t.metaKey};let i=r.editingTextElement||r.newElement||r.multiElement||r.selectionElement||r.selectedElementsAreBeingDragged||n?null:this.getTargetAt(e,t);return this.setHover(i&&gL(i)),i}),B(this,`refresh`,(e=this.lastModifiers)=>{let t=this.app.lastPointerMoveEvent;if(this.app.state.activeTool.type!==`text`||!t||t.pointerType===`touch`)return;let n=this.updateHover(ws(t,this.app.state),e);this.app.pan.isNavigating()||this.app.cursor.set(this.cursorFor(n))}),B(this,`cancel`,()=>{this.pending&&(this.pending=null,this.clearHover())}),B(this,`clearHover`,()=>{this.app.state.textToolHover&&this.app.setState({textToolHover:null})}),B(this,`setHover`,e=>{_L(this.app.state.textToolHover,e)||this.app.setState({textToolHover:e})}),B(this,`cursorFor`,e=>e?.type===`endpoint`||e?.type===`container`&&ir(e.element)?To.POINTER:e?.type===`text`?To.TEXT:To.CROSSHAIR),B(this,`handlePointerDown`,(e,t)=>{if(this.app.state.editingTextElement)return;let n=t.origin.x,r=t.origin.y,i=this.getTargetAt({x:n,y:r},e);switch(i.type){case`endpoint`:this.app.text.startTextEditing({sceneX:n,sceneY:r,autoEdit:!1,arrowEndpoint:i.endpoint,textElement:null});break;case`text`:this.app.text.startTextEditing({sceneX:n,sceneY:r,textElement:i.element,autoEdit:!1,initialCaretSceneCoords:{x:n,y:r}});break;case`container`:this.pending={containerId:i.element.id,origin:{x:n,y:r}},this.setHover(gL(i));return;case`free`:this.app.text.startTextEditing({sceneX:n,sceneY:r,container:null,textElement:null,insertAtParentCenter:!1,autoEdit:!1})}this.finish()}),B(this,`handlePointerMove`,(e,t)=>{if(!this.pending)return!1;if(this.app.state.activeTool.type!==`text`)return this.cancel(),!0;let n=ws(e,this.app.state);return this.isDrag(n)&&this.resolvePending(!0,n,t,e),!0}),B(this,`handlePointerUp`,(e,t)=>{if(!this.pending)return;if(e.type!==P.POINTER_UP||this.app.state.activeTool.type!==`text`){this.cancel();return}let n=ws(e,this.app.state);this.resolvePending(this.isDrag(n),n,t,e)}),B(this,`isDrag`,e=>Math.abs(e.x-this.pending.origin.x)*this.app.state.zoom.value>36),B(this,`resolvePending`,(e,t,n,r)=>{let{containerId:i,origin:a}=this.pending;this.pending=null;let o=this.app.scene.getNonDeletedElement(i),s=ve(o,!1);(0,Cl.flushSync)(()=>{s&&this.app.text.startTextEditing({sceneX:a.x,sceneY:a.y,container:e?null:o,textElement:null,insertAtParentCenter:!e,autoEdit:!e}),this.finish()}),s&&e&&(n.lastCoords.x=t.x,n.lastCoords.y=t.y,this.app.maybeDragNewGenericElement(n,r))}),B(this,`finish`,()=>{this.clearHover(),this.app.isToolLocked()?this.app.cursor.reset():this.app.setState({activeTool:ln(this.app.state,{type:this.app.state.preferredSelectionTool.type})},()=>this.app.cursor.reset())})}},yL=ls.filter(e=>e!==$c.white),bL=class{constructor(e){this.app=e,B(this,`temporaryEyeDropper`,null),B(this,`pending`,null),B(this,`handlePointerDown`,e=>{this.pending=e}),B(this,`handlePointerUp`,()=>{let e=this.pending;this.pending=null,e&&this.fill(e)}),B(this,`cancel`,()=>{this.pending=null}),B(this,`cycleBackgroundColor`,()=>{let e=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=yL[(yL.indexOf(e)+1)%yL.length];this.app.actionManager.executeAction(ZE,`keyboard`,{currentItemBackgroundColor:t})}),B(this,`openTemporaryEyeDropper`,()=>{if(ex.get(cT))return;let e={colorPickerType:`elementBackground`,keepOpenOnAlt:!0,onSelect:e=>{this.app.actionManager.executeAction(ZE,`ui`,{currentItemBackgroundColor:e})}};this.temporaryEyeDropper=e,this.app.updateEditorAtom(cT,e)}),B(this,`closeTemporaryEyeDropper`,()=>{let e=this.temporaryEyeDropper;this.temporaryEyeDropper=null,e&&ex.get(cT)===e&&this.app.updateEditorAtom(cT,null)}),B(this,`restyle`,e=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);e.backgroundColor===t&&e.fillStyle===this.app.state.currentItemFillStyle&&e.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(e,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),wa.delete(e),this.app.scheduleCapture())}),B(this,`fill`,e=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),n=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=L(e.x,e.y),a=this.app.getElementAtPosition(i[0],i[1]),o=cr({point:i,elements:n,elementsMap:r});if(!o.ok){if(a&&Uo(a)){this.restyle(a);return}o.reason===`too_complex`?this.app.setToast({message:G(`bucketfill.tooComplex`),duration:3e3}):(o.reason===`open_region`||o.reason===`too_small`||o.reason===`invalid_polygon`)&&this.app.setToast({message:G(`bucketfill.noRegion`),duration:3e3});return}if(a&&wi({hitElement:a,scenePoints:o.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:c}=$r(o.scenePoints),[l,u]=o.scenePoints[0],d=o.scenePoints.map(e=>L(e[0]-l,e[1]-u)),f=o.ownerId?r.get(o.ownerId):null,p=f?F(f)?f.id:f.frameId:this.app.getTopLayerFrameAtSceneCoords(e)?.id??null,m=f?f.groupIds:o.boundaryElementIds.map(e=>r.get(e)?.groupIds).filter(e=>!!e).reduce((e,t)=>e===null?t:e.filter(e=>t.includes(e)),null)??[],h=jc({type:`line`,x:l,y:u,width:s,height:c,points:d,polygon:!0,strokeColor:`transparent`,backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:`solid`,roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:p,groupIds:m}),g=this.app.scene.getElementsIncludingDeleted().findIndex(e=>e.id===o.insertion.elementId);this.app.scene.insertElementsAtIndex([h],g<0?null:o.insertion.placement===`above`?g+1:g),this.app.scheduleCapture()}),B(this,`getBucketFillBackgroundColor`,(e,t)=>Zr(e)?$c.green[1]:Rt(e,t===M.DARK))}},xL=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),SL={stickynote:{createElement:(e,t)=>{let{state:n}=e;return _e({type:`stickynote`,...xL(t,250,250),baseHeight:250,strokeColor:n.currentItemStickynoteStrokeColor,backgroundColor:n.currentItemStickynoteBackgroundColor,fillStyle:n.currentItemFillStyle,strokeWidth:e.getCurrentItemStrokeWidth(`stickynote`),strokeStyle:n.currentItemStrokeStyle,roughness:n.currentItemRoughness,opacity:n.currentItemOpacity,roundness:e.getCurrentItemRoundness(`stickynote`),locked:!1,frameId:e.getTopLayerFrameAtSceneCoords(t)?.id??null})},onDrop:(e,t)=>{x(t)&&e.text.startTextEditing({sceneX:t.x+t.width/2,sceneY:t.y+t.height/2,container:t})}}},CL=.5,wL=class{constructor(e){this.app=e,B(this,`preview`,null),B(this,`armed`,null),B(this,`tool`,null),B(this,`type`,null),B(this,`isDragging`,()=>this.preview!==null),B(this,`handleButtonPointerDown`,(e,t)=>{let n=SL[e];return!n||t.button!==0||!this.app.isInteractionEnabled()?!1:(this.cancel(),this.armed={type:e,pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY},this.tool=n,this.type=e,this.addListeners(),!0)}),B(this,`onPointerMove`,e=>{if(!this.armed||e.pointerId!==this.armed.pointerId)return;if(!this.preview){if(Math.hypot(e.clientX-this.armed.clientX,e.clientY-this.armed.clientY)<10)return;Yw(`toolbar`,this.armed.type,`drag`)}let t=this.tool.createElement(this.app,ws(e,this.app.state)),[n,r]=Tn(t.x,t.y,e[z.CTRL_OR_CMD]?null:this.app.getEffectiveGridSize());this.preview={...t,x:n,y:r},this.app.triggerRender()}),B(this,`onPointerUp`,e=>{if(!this.armed||e.pointerId!==this.armed.pointerId)return;let{preview:t,tool:n,type:r}=this;if(!t){this.cancel();return}if(this.cancel(),!this.isOverCanvas(e))return;let{app:i}=this;i.insertNewElement(t),i.store.scheduleCapture(),i.setState({selectedElementIds:{[t.id]:!0},selectedGroupIds:{}}),i.setActiveTool({type:i.state.preferredSelectionTool.type},{keepSelection:!0}),Yw(`toolbar`,r,`drop`),n.onDrop?.(i,t)}),B(this,`onKeyDown`,e=>{e.key===z.ESCAPE&&(e.stopPropagation(),this.cancel())}),B(this,`cancel`,()=>{let e=this.preview!==null;this.armed=null,this.tool=null,this.type=null,this.preview=null,this.removeListeners(),e&&this.app.triggerRender()}),B(this,`isOverCanvas`,e=>!!(this.app.ownerDocument.elementFromPoint?.(e.clientX,e.clientY)??e.target)?.closest?.(`.excalidraw__canvas`)),B(this,`addListeners`,()=>{let{ownerWindow:e}=this.app;e.addEventListener(P.POINTER_MOVE,this.onPointerMove),e.addEventListener(P.POINTER_UP,this.onPointerUp),e.addEventListener(P.POINTER_CANCEL,this.cancel),e.addEventListener(P.BLUR,this.cancel),e.addEventListener(P.KEYDOWN,this.onKeyDown,!0)}),B(this,`removeListeners`,()=>{let{ownerWindow:e}=this.app;e.removeEventListener(P.POINTER_MOVE,this.onPointerMove),e.removeEventListener(P.POINTER_UP,this.onPointerUp),e.removeEventListener(P.POINTER_CANCEL,this.cancel),e.removeEventListener(P.BLUR,this.cancel),e.removeEventListener(P.KEYDOWN,this.onKeyDown,!0)})}};B(wL,`isDraggable`,e=>e in SL);var TL=`<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">`,EL=`<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"/>`,DL=`<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"/>`,OL=`data:${A.svg},${encodeURIComponent(`${TL}${DL}</svg>`)}`,kL=`data:${A.svg},${encodeURIComponent(`${TL}${EL}${DL}</svg>`)}`,AL=e=>{let t=cS.map((t,n)=>`<path d="${t}" ${n<2?`fill="${e}"`:``} />`).join(``);return`data:${A.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>`)}`},jL=class{constructor(e){this.app=e,B(this,`toolCursorMemo`,null),B(this,`eraserCanvasCache`,null),B(this,`eraserPreviewDataURL`,null),B(this,`set`,e=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=e)}),B(this,`reset`,()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(To.GRAB):this.clear():this.applyForTool()}),B(this,`applyForTool`,(e=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let n=e.type===`eraser`||e.type===`laser`||e.type===`bucketfill`?this.app.state.theme:void 0,r=e.type===`bucketfill`?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,n):void 0,i=this.toolCursorMemo;if(i?.canvas!==t||i.type!==e.type||i.bucketFillColor!==r||i.theme!==n){if(e.type===`selection`)this.clear();else if(a({activeTool:e}))this.set(To.GRAB);else if(wc({activeTool:e}))this.applyEraser();else if(e.type===`autoshape`)this.set(To.CROSSHAIR);else if(e.type===`bucketfill`)this.set(`url(${AL(r)}) 5 18, auto`);else if(e.type===`laser`){let e=this.app.state.theme===M.LIGHT?OL:kL;this.set(`url(${e}), auto`)}else[`image`,`custom`].includes(e.type)?e.type!==`image`&&this.set(To.AUTO):this.set(To.CROSSHAIR);this.toolCursorMemo={canvas:t,type:e.type,bucketFillColor:r,theme:n}}}),B(this,`refreshHover`,()=>{let e=this.app.lastPointerMoveEvent??this.app.lastPointerUpEvent;if(!e||!this.canvas)return;let t=e.pointerType;if(t&&t!==`mouse`)return;let n=typeof PointerEvent<`u`?PointerEvent:MouseEvent;this.canvas.dispatchEvent(new n(`pointermove`,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}))}),B(this,`clear`,()=>{this.set(``)}),B(this,`applyEraser`,()=>{let e=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==e){let t=e===M.DARK;this.eraserCanvasCache=document.createElement(`canvas`),this.eraserCanvasCache.theme=e,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=t?`#000`:`#fff`,n.fill(),n.strokeStyle=t?`#fff`:`#000`,n.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(A.svg)}this.set(`url(${this.eraserPreviewDataURL}) 10 10, auto`)})}get canvas(){return this.app.interactiveCanvas}},ML=class{constructor(e){this.app=e,B(this,`trail`),this.trail=new yF(this.app,{...this.getTrailOptions(),fill:()=>e.state.theme===M.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>Vi(lo(`line`,this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(e,t){this.trail.startPath(e,t)}addPointToPath(e,t){this.trail.addPointToPath(e,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let e=this.trail.getCurrentTrail();return e?e.originalPoints.map(([e,t])=>L(e,t)):[]}start(e){this.trail.start(e)}stop(){this.trail.stop()}},NL=class{constructor(e){this.app=e,B(this,`trail`),B(this,`gestureInProgress`,!1),B(this,`stop`,()=>{this.trail.stop()}),B(this,`hasPendingGesture`,()=>this.gestureInProgress),B(this,`handlePointerDown`,e=>{this.gestureInProgress&&this.app.actionManager.executeAction(JD),this.gestureInProgress=!0,this.trail.startPath(e.lastCoords.x,e.lastCoords.y)}),B(this,`handlePointerMove`,e=>Gi(this.app,e)),B(this,`bindRecognizedArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=[`start`,`end`].map(i=>{let a=R.getPointAtIndexGlobalCoordinates(e,i===`start`?0:-1,n);return{startOrEnd:i,globalPoint:a,target:_t(a,r,n,t.state.zoom)}}),a=!!i[0].target&&i[0].target===i[1].target,o=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:n,globalPoint:r,target:s}of i)s&&ks(e,s,a?`inside`:`orbit`,n,t.scene,t.state.zoom,r,t.state.isBindingEnabled,o);if(a)return;let s=new Map;for(let{startOrEnd:t,target:r}of i){if(!r)continue;let i=Bn(e,t===`start`?`startBinding`:`endBinding`,t===`start`?e.startBinding:e.endBinding,r,n);i&&s.set(t===`start`?0:e.points.length-1,{point:i})}s.size&&R.movePoints(e,t.scene,s)}),B(this,`maybeUpgradeLineToArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),[i,a]=[0,-1].map(i=>_t(R.getPointAtIndexGlobalCoordinates(e,i,n),r,n,t.state.zoom));return!i&&!a||i===a?null:w({type:`arrow`,x:e.x,y:e.y,width:e.width,height:e.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:e.points,groupIds:e.groupIds,frameId:e.frameId,locked:!1,angle:e.angle,strokeColor:e.strokeColor,backgroundColor:e.backgroundColor,fillStyle:e.fillStyle,roughness:e.roughness,opacity:e.opacity,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth})}),B(this,`finalize`,()=>{let{app:e}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let n=e.state.newElement||cl(t,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(n){let t={...n,seed:eo(),opacity:e.state.currentItemOpacity};e.state.isBindingEnabled&&co(t)&&(t=this.maybeUpgradeLineToArrow(t)??t),e.insertNewElement(t),e.state.isBindingEnabled&&bo(t)&&this.bindRecognizedArrow(t)}}this.trail.clearTrails()}),this.trail=new ML(e)}},PL=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`runOnDuplicate`,(e,t,n)=>Bc(this.app.props.onDuplicate?.(t,n,{duplicateElements:e.duplicateElementsMap,originalElements:e.origElementsMap,origIdToDuplicateId:e.origIdToDuplicateId,duplicateIdToOrigId:e.duplicateIdToOrigId}),t,e.duplicatedElements)),B(this,`advanceListMarkers`,e=>{this.afterCommit(()=>{let t=e.flatMap(e=>this.app.scene.getNonDeletedElement(e.id)??[]);return On(t,this.app.scene).length>0})}),B(this,`handedOverTextId`,null),B(this,`handOverTextEditorPress`,(e,t)=>{this.handedOverTextId=t;try{this.app.interactiveCanvas?.dispatchEvent(new this.app.ownerWindow.PointerEvent(e.type,e))}finally{this.handedOverTextId=null}}),B(this,`hitEditedElement`,e=>{let{editedTextId:t}=e.hit,n=this.app.scene.getNonDeletedElementsMap(),r=t&&this.app.scene.getElement(t),i=r&&D(r)?n.get(r.containerId??r.id):null;return i?(e.hit.element=i,e.hit.allHitElements=[i],this.app.state.selectedLinearElement&&this.app.setState({selectedLinearElement:ja(i)?new R(i,n):null}),!0):!1}),B(this,`commitDraggedDuplicates`,({hit:e},{editText:t})=>{let n=e.advancedListMarkers,[r]=n,i=n.length===1&&r.contentStart<r.nextOriginalText.length?r:null,a=t?i?i.elementId:e.editedTextId:null,o=()=>{a&&this.afterCommit(()=>(this.editDuplicatedText(a,i),!1))};if(!n.length){o();return}Oo(n,`prev`,this.app.scene),this.afterCommit(()=>(Oo(n,`next`,this.app.scene),o(),!0))}),B(this,`duplicateAtSceneCoords`,(e,{x:t,y:n},r)=>{let[i,a,s,c]=Hc(e),l=oe(i,s)/2,u=oe(a,c)/2,d=t-l,f=n-u,[p,m]=Tn(d,f,this.app.getEffectiveGridSize()),h=se({type:`everything`,elements:e.map(e=>N(e,{x:e.x+p-i,y:e.y+m-a})),randomizeSeed:!r?.retainSeed,preserveFrameChildrenOrder:r?.preserveFrameChildrenOrder}),{duplicatedElements:g}=h,_=this.app.scene.getElementsIncludingDeleted(),v=[..._,...g];Po(v,y(g));let b=this.app.getTopLayerFrameAtSceneCoords({x:t,y:n});if(b){let e=o(g,b);v=_n(v,e,b)}if(this.app.props.onDuplicate){if({elements:v,duplicatedElements:g}=this.runOnDuplicate(h,v,_),!g.length)return null;Po(v,y(g))}return{nextElements:v,duplicatedElements:g}}),B(this,`duplicateDraggedSelection`,(e,t)=>{e.hit.hasBeenDuplicated=!0;let n=this.app.scene.getElementsIncludingDeleted(),r=e.hit.element,i=this.app.scene.getSelectedElements({selectedElementIds:this.app.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});r&&e.hit.wasAddedToSelection&&!i.find(e=>e.id===r.id)&&i.push(r);let a=new Map(i.map(e=>[e.id,e])),o=se({type:`in-place`,elements:n,appState:this.app.state,randomizeSeed:!0,idsOfElementsToDuplicate:a,overrides:({duplicateElement:e,origElement:t})=>({frameId:e.frameId??t.frameId,seed:eo()})}),{origElementsMap:s,origIdToDuplicateId:c}=o,l=o.elementsWithDuplicates.map(t=>{if(a.has(t.id)){let n=e.originalElements.get(t.id);if(n){let e=N(t,{x:n.x,y:n.y});return s.has(t.id)&&s.set(t.id,e),e}}return t}),{elements:u,duplicatedElements:d}=this.runOnDuplicate(o,l,n);if(!d.length){e.hit.editedTextId=null;return}let f=y(d),p=Po(u,f);(0,Cl.flushSync)(()=>{if(e.hit.element){let t=c.get(e.hit.element.id),n=t&&f.get(t);e.hit.element=n||null}if(e.hit.editedTextId){let t=c.get(e.hit.editedTextId);e.hit.editedTextId=t&&f.get(t)?.id||null}e.hit.allHitElements=e.hit.allHitElements.reduce((e,t)=>{let n=c.get(t.id),r=n&&f.get(n);return r&&e.push(r),e},[]),e.drag.origin=ws(t,this.app.state),this.app.setState(e=>({...fr(d,this.app.scene.getNonDeletedElements(),e)})),this.app.scene.replaceAllElements(p),e.hit.advancedListMarkers=On(d,this.app.scene),d.forEach(t=>{e.originalElements.set(t.id,Yi(t))}),i.forEach(e=>{Xr(e)&&e.boundElements?.some(e=>e.type===`arrow`)&&bi(e,this.app.scene)}),this.app.maybeCacheVisibleGaps(t,i,!0),this.app.maybeCacheReferenceSnapPoints(t,i,!0)})})}afterCommit(e){this.app.setState({},()=>{e()&&this.app.store.scheduleCapture()})}editDuplicatedText(e,t){let n=this.app.scene.getNonDeletedElement(e);!n||!D(n)||t&&n.originalText!==t.nextOriginalText||this.dependencies.getPointerCount()>0||this.app.text.startTextEditing({sceneX:n.x,sceneY:n.y,insertAtParentCenter:!1,textElement:n,initialSelection:{start:t?.contentStart??0,end:n.originalText.length}})}},FL=class e{constructor(e){this.app=e,B(this,`creator`,new un),B(this,`navigator`,new ii),B(this,`clear`,()=>{this.creator.clear(),this.navigator.clear()}),B(this,`handleKeyEvent`,e=>{let t=this.resolveKeyboardEventToOperation(e);switch(t.type){case`none`:return!1;case`canceled`:return this.app.triggerRender(!0),!0;case`creating`:return e.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case`navigating`:{e.preventDefault();let n=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return n&&this.selectAndReveal(n),!0}case`committed`:{t.nodes.length&&this.app.insertNewElements(t.nodes);let e=t.nodes[0];return e&&this.selectAndReveal(e),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:n,navigator:r,app:i}=this;if(t.type===`keydown`){if(t.key===z.ESCAPE&&n.isCreatingChart)return n.clear(),{type:`canceled`};if(!Pt(t.key))return{type:`none`};if(t[z.CTRL_OR_CMD]&&!t.shiftKey){let r=Kc(i.scene.getNonDeletedElementsMap(),i.state);return r.length===1&&ya(r[0])&&n.createNodes(r[0],i.state,e.getLinkDirectionFromKey(t.key),i.scene),{type:`creating`,pending:n.pendingNodes??[]}}if(t.altKey){let n=i.scene.getNonDeletedElementsMap(),a=Kc(n,i.state);if(a.length===1)return{type:`navigating`,nodeId:r.exploreByDirection(a[0],n,e.getLinkDirectionFromKey(t.key))}}return{type:`none`}}let a=!t.altKey&&r.isExploring;if(a&&r.clear(),!t[z.CTRL_OR_CMD]&&n.isCreatingChart){let e=n.pendingNodes??[];return n.clear(),{type:`committed`,nodes:e}}return a?{type:`navigationEnded`}:{type:`none`}}selectAndReveal(e){this.app.setState(t=>({selectedElementIds:j({[e.id]:!0},t)})),this.app.revealIfHidden([e])}captureUpdate(){this.app.syncActionResult({captureUpdate:I.IMMEDIATELY})}static getLinkDirectionFromKey(e){switch(e){case z.ARROW_UP:return`up`;case z.ARROW_DOWN:return`down`;case z.ARROW_RIGHT:return`right`;case z.ARROW_LEFT:return`left`;default:return`right`}}},IL=5,LL=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`spaceHeld`,!1),B(this,`active`,!1),B(this,`secondary`,null),B(this,`suppressNextContextMenu`,!1),B(this,`pendingMoveFlush`,null),B(this,`teardown`,null),B(this,`isActive`,()=>this.active),B(this,`isSpaceHeld`,()=>this.spaceHeld),B(this,`setSpaceHeld`,e=>{this.spaceHeld=e}),B(this,`isNavigating`,()=>this.spaceHeld||this.active||this.dependencies.isDraggingScrollBar()||a(this.app.state)),B(this,`flushMove`,()=>{this.pendingMoveFlush?.()}),B(this,`end`,()=>{this.teardown?.()}),B(this,`consumesContextMenuEvent`,()=>this.secondary?(this.secondary.nativeMenuSeen=!0,!0):this.suppressNextContextMenu?(this.suppressNextContextMenu=!1,!0):!1),B(this,`start`,e=>{let{app:t}=this;this.suppressNextContextMenu=!1;let n=e.button===Aa.SECONDARY;if(!(this.dependencies.getPointerCount()<=1&&((e.button===Aa.WHEEL||n||e.button===Aa.MAIN&&this.spaceHeld||a(t.state))&&(t.isInteractionEnabled()||t.isNavigationEnabled())||t.state.viewModeEnabled&&!t.isActiveToolPointerCapturing())))return!1;this.active=!0,this.secondary=n?{engaged:!1,nativeMenuSeen:!1}:null,t.focusContainer(),t.state.editingTextElement||e.preventDefault();let r=!1,i=/Linux/.test(t.ownerWindow.navigator.platform);this.secondary||t.cursor.set(To.GRABBING);let{clientX:o,clientY:s}=e,{clientX:c,clientY:l}=e,u=mF(e=>{if(this.secondary&&!this.secondary.engaged){if(Math.hypot(e.clientX-o,e.clientY-s)<=IL)return;this.secondary.engaged=!0,t.cursor.set(To.GRABBING),c=e.clientX,l=e.clientY;return}let n=c-e.clientX,a=l-e.clientY;if(c=e.clientX,l=e.clientY,i&&!r&&(Math.abs(n)>1||Math.abs(a)>1)){r=!0;let e=n=>{t.ownerDocument.body.removeEventListener(P.PASTE,e),n.stopPropagation()},n=()=>{setTimeout(()=>{t.ownerDocument.body.removeEventListener(P.PASTE,e),t.ownerWindow.removeEventListener(P.POINTER_UP,n)},100)};t.ownerDocument.body.addEventListener(P.PASTE,e),t.ownerWindow.addEventListener(P.POINTER_UP,n)}t.viewport.translate(e=>({scrollX:e.scrollX-n/e.zoom.value,scrollY:e.scrollY-a/e.zoom.value}))});this.pendingMoveFlush=u.flush;let d=pF(e=>{let{secondary:n}=this;this.teardown=null,this.pendingMoveFlush=null,this.active=!1,this.secondary=null,n?.engaged&&!n.nativeMenuSeen&&(this.suppressNextContextMenu=!0),this.spaceHeld||t.cursor.reset(),t.setState({cursorButton:`up`},()=>{if(t.state.cursorButton===`up`){let n=e&&`clientX`in e?e:{clientX:c,clientY:l};t.savePointer(n.clientX,n.clientY,`up`)}t.viewport.releaseOverscroll()}),t.ownerWindow.removeEventListener(P.POINTER_MOVE,u),t.ownerWindow.removeEventListener(P.POINTER_UP,d),t.ownerWindow.removeEventListener(P.BLUR,d),u.flush(),n&&!n.engaged&&n.nativeMenuSeen&&e&&`clientX`in e&&t.openContextMenu({clientX:e.clientX,clientY:e.clientY,button:e.button,pointerType:e.pointerType})});return this.teardown=d,t.ownerWindow.addEventListener(P.BLUR,d),t.ownerWindow.addEventListener(P.POINTER_MOVE,u,{passive:!0}),t.ownerWindow.addEventListener(P.POINTER_UP,d),!0})}},RL=`animateScrollToContent`,zL=`animateScrollConstraintsSnapBack`,BL=500,VL=250,HL=200,UL=302,WL={full:216,compact:64},GL=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`)},KL=(e,t)=>{let n=t.get(e);return n?[n]:ul(t,e)},qL=(e,t,n)=>{if(typeof e==`string`){let n=Vt(e),r=n?`link`:`element`,i=n?qe(e):e,a=i?KL(i,t):[];return a.length?{bounds:Hc(a,t),type:r}:{bounds:null,type:r}}if(Wa(e))return{bounds:e,type:`area`};if(GL(e)&&!ci(e)){let t=e.width??n.width,r=e.height??n.height;return{bounds:[e.x,e.y,e.x+t,e.y+r],type:`area`}}let r=Array.isArray(e)?e:[e],i=r.reduce((e,n)=>{if(n&&!n.isDeleted){let r=t.get(n.id);r&&e.push(r)}return e},[]),a=!i.length;return(i.length!==r.length||a)&&console.warn(`supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out`),a?{bounds:null,type:`element`}:{bounds:Hc(i,t),type:`element`}},JL=e=>e===!1?0:e===!0||e==null?150:Math.max(e,0),YL=(e,t,n=`scale-down`,r)=>{let{appState:i}=ji({bounds:t,appState:e,fit:n,canvasOffsets:r,steppedZoom:!1});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},XL=(e,t,{fit:n,offsets:r,lock:i})=>{let a=YL(e,t,n,r);if(!i?.scroll&&!i?.zoom)return{...a,scrollConstraints:null};let[o,s,c,l]=t,u={x:o,y:s,width:c-o,height:l-s,lockScroll:!!i.scroll,lockZoom:!!i.zoom,zoom:a.zoom.value,overscroll:JL(i.overscroll),offsets:r};return{...qs({...e,...a,scrollConstraints:u}),scrollConstraints:u}},ZL=({from:e,target:t,factor:n})=>{if(n>=1)return{...t};let r=e.zoom.value*(t.zoom.value/e.zoom.value)**+n,i=t.zoom.value===e.zoom.value?n:(r-e.zoom.value)/(t.zoom.value-e.zoom.value);return{scrollX:((1-i)*e.scrollX*e.zoom.value+i*t.scrollX*t.zoom.value)/r,scrollY:((1-i)*e.scrollY*e.zoom.value+i*t.scrollY*t.zoom.value)/r,zoom:{value:r}}},QL=e=>e===!1?null:e===!0||e==null?BL:e.duration??BL,$L=(e,t,n,r,i)=>{_F.start(RL,({deltaTime:a,state:o})=>{let s=(o?.elapsed??0)+a,c=Math.min(s/n,1),l=me(Vi(c,0,1));return c<1?(r({...ZL({from:e,target:t,factor:l}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(i(),null)})},eR=(e,t,n=VL)=>{let r=qs(e);if(r.scrollX===e.scrollX&&r.scrollY===e.scrollY&&r.zoom.value===e.zoom.value||_F.running(RL))return;let i=(e.scrollX-r.scrollX)*e.zoom.value,a=(e.scrollY-r.scrollY)*e.zoom.value;_F.start(zL,({deltaTime:e,state:r})=>{let o=(r?.elapsed??0)+e,s=Math.min(o/n,1),c=1-me(Vi(s,0,1));return t(e=>{if(!e.scrollConstraints)return null;let t=qs(e),n=t.zoom.value;return{scrollX:t.scrollX+i*c/n,scrollY:t.scrollY+a*c/n,zoom:t.zoom}}),s<1?{elapsed:o}:null})},tR=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`lastPosition`,{x:0,y:0}),B(this,`activeTransition`,null),B(this,`uiLastMeasured`,new Map),B(this,`invalidateUIOffset`,e=>{this.uiLastMeasured.delete(e)}),B(this,`measureSide`,(e,t)=>{let n=e.getBoundingClientRect(),r=n.left-t.left,i=n.right-t.left;return r+n.width/2<this.app.state.width/2?{side:`left`,offset:i}:{side:`right`,offset:this.app.state.width-r}}),B(this,`getReservedSide`,e=>{let t=lx().rtl;return this.uiLastMeasured.get(e)??(e===`stylesPanel`?{side:t?`right`:`left`,offset:this.dependencies.getStylesPanelMode()===`compact`?WL.compact:WL.full}:{side:t?`left`:`right`,offset:UL})}),B(this,`querySideUI`,(e,t)=>e.querySelector(`[data-viewport-ui="side"][data-viewport-ui-name="${t}"]`)),B(this,`getSideUIRect`,e=>{let t=this.dependencies.getContainer(),n=t&&this.querySideUI(t,e);if(!t||!n)return null;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect();return{left:i.left-r.left,right:i.right-r.left,top:i.top-r.top,bottom:i.bottom-r.top}}),B(this,`getSideInsets`,(e,t)=>{let n={left:0,right:0},r=this.dependencies.getContainer();if(!r)return n;let i=r.getBoundingClientRect();for(let a of e){let e=this.querySideUI(r,a),o=null;e?(o=this.measureSide(e,i),o.offset>0&&this.uiLastMeasured.set(a,o)):a!==`stats`&&t?.reserve?.[a]&&this.app.editorInterface.formFactor!==`phone`&&(o=this.getReservedSide(a)),o&&(n[o.side]=Math.max(n[o.side],o.offset))}return n}),B(this,`getSidebarInsets`,()=>this.getSideInsets([`sidebar`])),B(this,`resolveOffsets`,e=>{if(!e)return e;let{ui:t,...n}=e;if(!t)return n;let r=this.getOffsets(t===!0?void 0:t);return{top:n.top??r.top,right:n.right??r.right,bottom:n.bottom??r.bottom,left:n.left??r.left}}),B(this,`getOffsets`,e=>{let t=this.dependencies.getContainer(),n=t?.getBoundingClientRect(),r=lx().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&n)for(let e of t.querySelectorAll(`[data-viewport-ui]`)){let t=e.getBoundingClientRect(),r={top:t.top-n.top,right:t.right-n.left,bottom:t.bottom-n.top,left:t.left-n.left,width:t.width};switch(e.dataset.viewportUi){case`top`:i.top=Math.max(i.top,r.bottom);break;case`bottom`:i.bottom=Math.max(i.bottom,this.app.state.height-r.top);break;case`side`:{let{side:t,offset:r}=this.measureSide(e,n);i[t]=Math.max(i[t],r);let o=e.dataset.viewportUiName;o&&(a.add(o),r>0&&this.uiLastMeasured.set(o,{side:t,offset:r}));break}}}if(e?.reserve&&this.app.editorInterface.formFactor!==`phone`){for(let t of[`stylesPanel`,`sidebar`])if(e.reserve[t]&&!a.has(t)){let{side:e,offset:n}=this.getReservedSide(t);i[e]=Math.max(i[e],n)}}let o=e?.padding??24,s=e?.paddingTop??o,c=(r?e?.paddingLeft:e?.paddingRight)??o,l=e?.paddingBottom??o,u=(r?e?.paddingRight:e?.paddingLeft)??o,d={top:i.top+s,right:i.right+c,bottom:i.bottom+l,left:i.left+u};return{top:e?.top??d.top,right:(r?e?.left:e?.right)??d.right,bottom:e?.bottom??d.bottom,left:(r?e?.right:e?.left)??d.left}}),B(this,`resolveInitialViewport`,(e,t,n)=>{let{bounds:r}=qL(e.target,t,n);return r?XL(n,r,{...e,offsets:this.resolveOffsets(e.offsets)}):null}),B(this,`setViewport`,e=>{if(e===null){this.cancelTransition(),_F.cancel(zL),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:n,lock:r,animation:i}=e,a=this.resolveOffsets(e.offsets),{bounds:o,type:s}=qL(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!o){s===`link`&&this.app.setState({toast:{message:G(`elementLink.notFound`),duration:3e3,closable:!0}});return}this.app.requestUnfollow();let c=XL(this.app.state,o,{fit:n,offsets:a,lock:r}),l=QL(i),u={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),_F.cancel(zL),this.snapBackDebounced.cancel(),l===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let d={target:c};this.activeTransition=d,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),$L(u,c,l,e=>{this.activeTransition===d&&this.app.setState(e)},()=>{this.activeTransition===d&&(this.activeTransition=null,this.app.setState({...d.target,shouldCacheIgnoreZoom:!1}))})}),B(this,`translate`,(e,t)=>!this.isLockedTransitionPending&&(this.activeTransition&&this.app.setState({shouldCacheIgnoreZoom:!1}),this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||_F.cancel(zL),this.app.requestUnfollow(),this.app.setState((n,r)=>{let i=typeof e==`function`?e(n,r):e;if(!i)return null;let a={...n,...i};if(!a.scrollConstraints)return i;let o=!t?.zoomPreConstrained&&a.zoom.value!==n.zoom.value?0:a.scrollConstraints.overscroll;return o>0&&this.snapBackDebounced(),{...a,...qs(a,o)}}),!0)),B(this,`constrain`,(e=0)=>{this.app.setState(t=>t.scrollConstraints?qs(t,e):null)}),B(this,`releaseOverscroll`,()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())}),B(this,`snapBack`,()=>{this.app.unmounted||this.dependencies.isGestureActive()||eR(this.app.state,e=>this.app.setState(t=>e(t)))}),B(this,`snapBackDebounced`,ml(this.snapBack,HL)),B(this,`cancelTransition`,()=>{this.activeTransition=null,_F.cancel(RL)}),B(this,`destroy`,()=>{this.cancelTransition(),_F.cancel(zL),this.snapBackDebounced.cancel()})}get isAnimating(){return _F.running(RL)||_F.running(zL)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}},nR=4,rR=class{constructor(e){this.app=e,B(this,`isOverEditorSurface`,e=>{let{ownerWindow:t}=this.app;return e.target instanceof t.HTMLCanvasElement||e.target instanceof t.HTMLTextAreaElement||e.target instanceof t.HTMLIFrameElement||e.target instanceof t.HTMLElement&&e.target.classList.contains(hn.FRAME_NAME)}),B(this,`handle`,pF(e=>{if(!this.app.isNavigationEnabled())return;if(!this.isOverEditorSurface(e)){e[z.CTRL_OR_CMD]&&e.preventDefault();return}e.preventDefault();let t=!!(e.buttons&nR);if(this.app.pan.isActive()){if(!t)return;this.app.pan.flushMove()}let{deltaX:n,deltaY:r}=e;if(!n&&!r)return;let i=e.metaKey||e.ctrlKey;if(r!==0&&(t||!e.shiftKey&&(i||fe(this.app.state.inputDevice)===`mouse`))){this.zoomBy(r);return}if(e.shiftKey){let e=r||n;this.app.viewport.translate(({zoom:t,scrollX:n,scrollY:r})=>({scrollX:i?n:n-e/t.value,scrollY:i?r-e/t.value:r}));return}this.app.viewport.translate(({zoom:e,scrollX:t,scrollY:i})=>({scrollX:t-n/e.value,scrollY:i-r/e.value}))})),B(this,`preventBrowserZoom`,e=>{e[z.CTRL_OR_CMD]&&e.preventDefault()}),B(this,`zoomBy`,e=>{let{viewport:t}=this.app,n=Math.sign(e),r=Ec*100,i=Math.abs(e),a=e;i>r&&(a=r*n);let{x:o,y:s}=t.lastPosition;t.translate(e=>{let t=e.zoom.value-a/100;t+=Math.log10(Math.max(1,e.zoom.value))*-n*Math.min(1,i/20);let r=e.scrollConstraints?.lockZoom?e.scrollConstraints.zoom:.1,c=Oa(Math.max(t,r));return c===e.zoom.value?null:{...ti({viewportX:o,viewportY:s,nextZoom:c},e),shouldCacheIgnoreZoom:!0}},{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.app.resetShouldCacheIgnoreZoomDebounced()})}},iR=()=>(0,U.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,U.jsx)(`p`,{children:(0,U.jsx)(hj,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,U.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,U.jsx)(`p`,{children:(0,U.jsx)(hj,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,U.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,U.jsx)(`p`,{children:(0,U.jsx)(hj,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,U.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,U.jsx)(`p`,{children:(0,U.jsx)(hj,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,U.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,U.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),aR=10,oR=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,viewportWidth:a=window.innerWidth,viewportHeight:o=window.innerHeight,className:s})=>{let c=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=c.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===z.TAB){let n=Bs(e),{activeElement:r}=document,i=n.findIndex(e=>e===r);r===e?(t.shiftKey?n[n.length-1]?.focus():n[0].focus(),t.preventDefault(),t.stopImmediatePropagation()):i===0&&t.shiftKey?(n[n.length-1]?.focus(),t.preventDefault(),t.stopImmediatePropagation()):i===n.length-1&&!t.shiftKey&&(n[0]?.focus(),t.preventDefault(),t.stopImmediatePropagation())}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let l=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{if(i&&c.current&&n!=null&&t!=null){let e=c.current,{width:r,height:i}=e.getBoundingClientRect();if(l.current?.top===n&&l.current?.left===t)return;l.current={top:n,left:t};let s=Math.max(0,a-aR*2);r>=s?(e.style.width=`${s}px`,e.style.left=`${aR}px`,e.style.overflowX=`scroll`):e.style.left=`${Vi(t,aR,a-aR-r)}px`;let u=Math.max(0,o-aR*2);i>=u?(e.style.height=`${u}px`,e.style.top=`${aR}px`,e.style.overflowY=`scroll`):e.style.top=`${Vi(n,aR,o-aR-i)}px`}},[n,t,i,a,o]),(0,V.useEffect)(()=>{if(r){let e=e=>{c.current?.contains(e.target)||(0,Cl.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,U.jsx)(`div`,{className:H(`popover`,s),ref:c,tabIndex:-1,children:e})},sR=`separator`,cR=V.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=dW(),o=uW(),s=t.reduce((t,n)=>(n&&(n===sR||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,U.jsx)(oR,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,viewportWidth:a.width,viewportHeight:a.height,className:`context-menu-popover`,children:(0,U.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===sR)return!s[n-1]||s[n-1]===sR?null:(0,U.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?G(t.label(o,a,e.app)):G(t.label)),(0,U.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,U.jsxs)(`button`,{type:`button`,className:H(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,U.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,U.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?wA(r):``})]})},n)})})})}),lR=()=>{let e=aW(),{container:t}=lW(),{t:n}=fx(),[r,i]=(0,V.useState)(null);if((0,V.useEffect)(()=>{if(!t)return;let n=0,r=()=>{n=0,i(null)},a=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),o=e=>{let t=Array.from(e.dataTransfer?.items??[]).filter(e=>e.kind===`file`);if(t.some(e=>e.type.startsWith(`image/`))){i(null);return}let n=t[0]?.type,r=n===A.excalidrawlib?`library`:n?`scene`:`unknown`;i(t=>t?.shiftKey===e.shiftKey&&t.kind===r?t:{shiftKey:e.shiftKey,kind:r})},s=e=>{a(e)&&(n++,o(e))},c=e=>{a(e)&&(e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n=Math.max(1,n),o(e))},l=()=>{n=Math.max(0,n-1),n||r()},u=e=>{e.key===z.ESCAPE?r():e.key===`Shift`&&i(t=>t&&{...t,shiftKey:e.shiftKey})};return t.addEventListener(`dragenter`,s),t.addEventListener(`dragover`,c),t.addEventListener(`dragleave`,l),e.ownerDocument.addEventListener(`drop`,r,!0),e.ownerDocument.addEventListener(`dragend`,r,!0),e.ownerDocument.addEventListener(`keydown`,u,!0),e.ownerDocument.addEventListener(`keyup`,u,!0),e.ownerWindow.addEventListener(`blur`,r),()=>{t.removeEventListener(`dragenter`,s),t.removeEventListener(`dragover`,c),t.removeEventListener(`dragleave`,l),e.ownerDocument.removeEventListener(`drop`,r,!0),e.ownerDocument.removeEventListener(`dragend`,r,!0),e.ownerDocument.removeEventListener(`keydown`,u,!0),e.ownerDocument.removeEventListener(`keyup`,u,!0),e.ownerWindow.removeEventListener(`blur`,r)}},[e,t]),!r)return null;let a=r.shiftKey||r.kind===`library`;return(0,U.jsx)(`div`,{className:H(`file-drop-overlay`,{"file-drop-overlay--keep":a}),children:(0,U.jsxs)(`div`,{className:`file-drop-overlay__card`,children:[(0,U.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[(0,U.jsx)(`div`,{className:`file-drop-overlay__title`,children:n(r.kind===`library`?`fileDrop.importLibrary`:r.shiftKey?`fileDrop.add`:`fileDrop.replace`)}),(0,U.jsx)(`div`,{className:`file-drop-overlay__hint`,children:a?n(`fileDrop.keepHint`):(0,U.jsx)(hj,{i18nKey:`fileDrop.replaceHint`,shift:e=>(0,U.jsx)(`kbd`,{children:e})})}),r.kind===`unknown`&&(0,U.jsxs)(`div`,{className:`file-drop-overlay__hint file-drop-overlay__hint--secondary`,children:[`(`,n(`fileDrop.libraryHint`),`)`]})]}),(0,U.jsx)(`div`,{className:`file-drop-overlay__illustration`,"aria-hidden":`true`,children:[`back`,`front`].map(e=>(0,U.jsxs)(`svg`,{className:`file-drop-overlay__file file-drop-overlay__file--${e}`,viewBox:`0 0 100 128`,fill:`none`,children:[(0,U.jsx)(`path`,{className:`file-drop-overlay__paper`,d:`M16 3h43l28 28v81c0 7-4 12-12 12H16c-8 0-12-5-12-12V15C4 7 8 3 16 3Z`}),(0,U.jsx)(`path`,{d:`M59 3v20c0 6 3 8 9 8h19`}),(0,U.jsx)(`path`,{className:`file-drop-overlay__lines`,d:`M24 61h43M24 77h43M24 93h26`}),e===`back`&&(0,U.jsx)(`path`,{className:`file-drop-overlay__cross`,d:`M18 44l24 24M42 44L18 68`})]},e))})]})})},uR=({border:e,style:t})=>(0,U.jsx)(`div`,{className:`viewport-status-frame__border`,style:{borderColor:e,...t}}),dR=({label:e,border:t})=>{let n=(0,V.useId)(),r=(0,U.jsxs)(U.Fragment,{children:[e.icon&&(0,U.jsx)(`span`,{className:`viewport-status-frame__badge-icon`,children:e.icon}),e.label]});return(0,U.jsxs)(`div`,{className:H(`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&&(0,U.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-action`,"aria-labelledby":n,onClick:e.onClick}),(0,U.jsx)(`div`,{className:`viewport-status-frame__badge-label`,id:e.onClick?n:void 0,children:r}),e.onClose&&(0,U.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-close`,"aria-label":G(`buttons.close`),onClick:e.onClose,children:PS})]})},fR=V.createContext(null),pR=()=>V.useContext(fR),mR=fu(),hR=()=>V.useMemo(()=>({MainMenuTunnel:Kb(),WelcomeScreenMenuHintTunnel:Kb(),WelcomeScreenToolbarHintTunnel:Kb(),WelcomeScreenHelpHintTunnel:Kb(),WelcomeScreenCenterTunnel:Kb(),FooterCenterTunnel:Kb(),DefaultSidebarTriggerTunnel:Kb(),DefaultSidebarTabTriggersTunnel:Kb(),OverwriteConfirmDialogTunnel:Kb(),TTDDialogTriggerTunnel:Kb(),tunnelsJotai:mR}),[]),gR=({delay:e,theme:t})=>{let[n,r]=(0,V.useState)(!!e);return(0,V.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,U.jsxs)(`div`,{className:H(`LoadingMessage`,{"LoadingMessage--dark":t===M.DARK}),children:[(0,U.jsx)(`div`,{children:(0,U.jsx)(Lw,{})}),(0,U.jsx)(`div`,{className:`LoadingMessage-text`,children:G(`labels.loadingScene`)})]})},_R=({app:e,setAppState:t})=>{let n=e.state.activeTool,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(`rectangle`),[s,c]=(0,V.useState)(`arrow`);(0,V.useEffect)(()=>{(n.type===`rectangle`||n.type===`diamond`||n.type===`ellipse`)&&o(n.type)},[n.type]),(0,V.useEffect)(()=>{(n.type===`arrow`||n.type===`line`)&&c(n.type)},[n.type]);let l=n.type===`frame`,u=n.type===`autoshape`,d=n.type===`laser`,f=n.type===`embeddable`,p=n.type===`bucketfill`,m=n.type===`stickynote`,{TTDDialogTriggerTunnel:h}=pR(),g=[`rectangle`,`diamond`,`ellipse`].map(e=>({type:e,icon:TD[e].icon,title:vt(G(`toolBar.${e}`)),fillable:TD[e].fillable})),_=[`arrow`,`line`].map(e=>({type:e,icon:TD[e].icon,title:vt(G(`toolBar.${e}`)),fillable:TD[e].fillable})),[v,y]=(0,V.useState)(0),b=v>=316,x=v>=356,S=v>=396,C=[`text`,`stickynote`,`frame`,`embeddable`,`laser`,`bucketfill`,`magicframe`].filter(e=>!(b&&e===`text`||S&&e===`frame`)).includes(n.type),w=C?n.type===`text`?Lx:n.type===`image`?zx:n.type===`frame`?BC:n.type===`stickynote`?VC:n.type===`embeddable`?Gx:n.type===`laser`?qC:n.type===`bucketfill`?lS:n.type===`magicframe`?JC:vx:vx,T={app:e,activeTool:n};return(0,U.jsxs)(`div`,{className:`mobile-toolbar`,ref:e=>{e&&y(e.getBoundingClientRect().width)},children:[(0,U.jsx)(MD,{...T,hideKeyBinding:!0}),(0,U.jsx)(KD,{...T,setAppState:t}),(0,U.jsx)(qD,{...T}),(0,U.jsx)(HD,{...T,hideShortcut:!0}),(0,U.jsx)(wD,{app:e,options:g,activeTool:n,defaultOption:a,"data-testid":`toolbar-rectangle`,onToolChange:t=>{(t===`rectangle`||t===`diamond`||t===`ellipse`)&&(o(t),e.setActiveTool({type:t}))},displayedOption:g.find(e=>e.type===a)||g[0]}),(0,U.jsx)(wD,{app:e,options:_,activeTool:n,defaultOption:s,"data-testid":`toolbar-arrow`,onToolChange:t=>{(t===`arrow`||t===`line`)&&(c(t),e.setActiveTool({type:t}))},displayedOption:_.find(e=>e.type===s)||_[0]}),b&&(0,U.jsx)(zD,{...T,hideShortcut:!0}),x&&(0,U.jsx)(VD,{...T,hideShortcut:!0}),S&&(0,U.jsx)(UD,{...T,hideShortcut:!0}),(0,U.jsxs)(Q,{open:r,children:[(0,U.jsx)(Q.Trigger,{className:H(`App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile`,{"App-toolbar__extra-tools-trigger--selected":C||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:G(`toolBar.extraTools`),style:{width:36,height:36,display:`flex`,alignItems:`center`,justifyContent:`center`},children:w}),(0,U.jsxs)(Q.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,align:`start`,children:[!b&&(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`text`}),icon:Lx,shortcut:z.T.toLocaleUpperCase(),"data-testid":`toolbar-text`,selected:n.type===`text`,disabled:AD(e,`text`),children:G(`toolBar.text`)}),!x&&(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:zx,"data-testid":`toolbar-image`,selected:n.type===`image`,disabled:AD(e,`image`),children:G(`toolBar.image`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`stickynote`}),icon:VC,shortcut:z.N.toLocaleUpperCase(),"data-testid":`toolbar-stickynote`,selected:m,disabled:AD(e,`stickynote`),children:G(`toolBar.stickynote`)}),!S&&(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:BC,shortcut:z.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:AD(e,`frame`),children:G(`toolBar.frame`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:Gx,"data-testid":`toolbar-embeddable`,selected:f,disabled:AD(e,`embeddable`),children:G(`toolBar.embeddable`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:KC,shortcut:OD(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:AD(e,`autoshape`),children:G(`toolBar.autoshape`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:qC,"data-testid":`toolbar-laser`,selected:d,shortcut:z.K.toLocaleUpperCase(),disabled:AD(e,`laser`),children:G(`toolBar.laser`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:lS,"data-testid":`toolbar-bucketfill`,selected:p,shortcut:z.B.toLocaleUpperCase(),disabled:AD(e,`bucketfill`),children:G(`toolBar.bucketfill`)}),(0,U.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,U.jsx)(h.Out,{}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:HC,"data-testid":`toolbar-embeddable`,children:G(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:JC,"data-testid":`toolbar-magicframe`,badge:(0,U.jsx)(Q.Item.Badge,{children:`AI`}),disabled:AD(e,`magicframe`),children:G(`toolBar.magicframe`)})})]})]})]})},vR=({children:e,side:t,className:n})=>(0,U.jsx)(`div`,{className:H(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),yR=e=>e.penDetected?(0,U.jsx)(Y,{className:H(`ToolIcon__penMode`,{"is-mobile":e.isMobile}),type:`toggle`,icon:Fx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null,bR=({appState:e,elements:t,actionManager:n,setAppState:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:o,renderWelcomeScreen:s,defaultUIEnabled:c,scrollBackToContentUIEnabled:l,app:u,onPenModeToggle:d})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:m}=pR(),h=()=>{if(e.openDialog?.name===`elementLinkSelector`)return null;let t=(0,U.jsxs)(`div`,{className:`excalidraw-ui-top-right`,children:[a?.(!0,e)??(!e.viewModeEnabled&&(0,U.jsxs)(U.Fragment,{children:[c&&(0,U.jsx)(yR,{checked:e.penMode,onChange:()=>d(null),title:G(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,U.jsx)(m.Out,{})]})),c&&e.viewModeEnabled&&u.isInteractionEnabled()&&(0,U.jsx)(jM,{actionManager:n})]}),r=(0,U.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[i?.(!0,e),(0,U.jsx)(p.Out,{})]});return(0,U.jsxs)(`div`,{className:`App-toolbar-content`,style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`},children:[r,t]})},g=()=>(0,U.jsx)(_R,{app:u,setAppState:r}),_=l&&e.scrolledOutside,v=c&&!e.viewModeEnabled,y=_&&!e.openMenu&&!e.openSidebar?(0,U.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Ka(t,e)}))},children:G(`buttons.scrollBackToContent`)}):null,b=u.props.viewportStatusFrame?.label,x=b?(0,U.jsx)(dR,{label:b,border:u.props.viewportStatusFrame?.border}):null;return(0,U.jsxs)(U.Fragment,{children:[o(),(0,U.jsx)(`div`,{className:`App-welcome-screen`,children:s&&(0,U.jsx)(f.Out,{})}),v&&(0,U.jsxs)(`div`,{className:`App-bottom-bar`,style:{marginBottom:SF+xF},"data-viewport-ui":`bottom`,children:[y&&(0,U.jsx)(`div`,{className:`floating-status-stack`,children:y}),(0,U.jsx)(DM,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:u,setAppState:r}),(0,U.jsx)(uT,{className:`App-toolbar`,children:e.openDialog?.name!==`elementLinkSelector`&&g()})]}),!v&&y&&(0,U.jsx)(`div`,{className:`floating-status-stack`,children:y}),x&&(0,U.jsx)(`div`,{className:`viewport-status-frame__badge-row`,children:x}),(0,U.jsx)(vR,{side:`top`,className:`App-top-bar`,children:h()})]})},xR=e=>{switch(e){case`bar`:return G(`labels.chartType_bar`);case`line`:return G(`labels.chartType_line`);case`radar`:return G(`labels.chartType_radar`);default:return e}},SR=e=>{let t=(0,V.useRef)(null),[n,r]=(0,V.useState)(null),{theme:i}=eT();(0,V.useLayoutEffect)(()=>{if(!e.spreadsheet){r(null);return}let n=qI(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!n){r(null),t.current?.replaceChildren();return}r(n);let a,o=t.current;return(async()=>(a=await Cc(n,{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:i===`dark`},null,{skipInliningFonts:!0}),a.querySelector(`.style-fonts`)?.remove(),o.replaceChildren(),o.appendChild(a)))(),()=>{o.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,i]);let a=xR(e.chartType);return(0,U.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":a,onClick:()=>{n&&e.onClick(e.chartType,n)},children:[(0,U.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,U.jsx)(`div`,{className:`ChartPreview__label`,children:a})]})},CR=e=>{let t=(0,V.useRef)(null),{theme:n}=eT();return(0,V.useLayoutEffect)(()=>{if(!e.rawText)return;let r=el({text:e.rawText,x:0,y:0}),i=t.current;return(async()=>{let e=await Cc([r],{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:n===`dark`},null,{skipInliningFonts:!0});e.querySelector(`.style-fonts`)?.remove(),i.replaceChildren(),i.appendChild(e)})(),()=>{i.replaceChildren()}},[e.rawText,n]),(0,U.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":G(`labels.chartType_plaintext`),onClick:()=>{e.onClick(e.rawText)},children:[(0,U.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,U.jsx)(`div`,{className:`ChartPreview__label`,children:G(`labels.chartType_plaintext`)})]})},wR=({data:e,rawText:t,onClose:n})=>{let{onInsertElements:r,focusContainer:i}=aW(),[a,o]=(0,V.useState)(Math.random()),s=V.useCallback(()=>{o(Math.random())},[]),c=V.useCallback(()=>{n&&n()},[n]),l=(e,t)=>{r(t),Yw(`paste`,`chart`,e),n(),i()};return(0,U.jsx)(fM,{size:`regular`,onCloseRequest:c,title:(0,U.jsxs)(`div`,{className:`PasteChartDialog__title`,children:[(0,U.jsx)(`div`,{className:`PasteChartDialog__titleText`,children:G(`labels.pasteCharts`)}),(0,U.jsx)(`div`,{className:`PasteChartDialog__reshuffleBtn`,onClick:s,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},children:lS})]}),className:`PasteChartDialog`,autofocus:!1,children:(0,U.jsxs)(`div`,{className:`container`,children:[[`bar`,`line`,`radar`].map(t=>gI(e,t)?(0,U.jsx)(SR,{chartType:t,spreadsheet:e,colorSeed:a,onClick:l},t):null),t&&(0,U.jsx)(CR,{rawText:t,onClick:e=>{let t=el({text:e,x:0,y:0});r([t]),Yw(`paste`,`chart`,`plaintext`),n(),i()}})]})})},TR=({heading:e,children:t,...n})=>{let{id:r}=lW(),i=(0,U.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:G(`headings.${e}`)});return(0,U.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,U.jsxs)(U.Fragment,{children:[i,t]})})},ER=4,DR=8,OR=38,kR=21,AR=({shouldWrap:e,children:t,username:n})=>e?(0,U.jsx)(pD,{label:n||`Unknown user`,children:t}):(0,U.jsx)(U.Fragment,{children:t}),jR=({actionManager:e,collaborator:t,socketId:n,withName:r=!1,shouldWrapWithTooltip:i=!1,isBeingFollowed:a})=>{let o={socketId:n,collaborator:t,withName:r,isBeingFollowed:a},s=e.renderAction(`goToCollaborator`,o);return(0,U.jsx)(AR,{username:t.username,shouldWrap:i,children:s},n)},MR=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`,`isCurrentUser`],NR=V.memo(({className:e,mobile:t,collaborators:n,userToFollow:r,currentUserControls:i})=>{let a=pW(),o=typeof i==`function`?i(!!t):i,s=Array.from(n,([e,t])=>({...t,socketId:e})).filter(e=>e.username?.trim()),c=s.find(e=>e.isCurrentUser),l=s.filter(e=>!e.isCurrentUser),[u,d]=V.useState(``),f=s.filter(e=>e.username?.toLowerCase().includes(u)),p=V.useRef(null);(0,V.useLayoutEffect)(()=>{if(p.current){let e=p.current.ownerDocument.defaultView,t=e=>{h(e)};if(t(p.current.clientWidth),!e||typeof e.ResizeObserver!=`function`)return;let n=new e.ResizeObserver(e=>{for(let n of e){let{width:e}=n.contentRect;t(e)}});return n.observe(p.current),()=>{n.disconnect()}}},[]);let[m,h]=V.useState(ER*OR),g=c?m-kR:m,_=Math.max(1,Math.min(8,Math.floor(g/OR))),v=c?Math.max(0,_-1):_,y=l.slice(0,v),b=c?[...y,c]:y,x=b.map(e=>{let t=jR({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r});return e.isCurrentUser?(0,U.jsxs)(Ny,{children:[(0,U.jsx)(Py,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`UserList__pill`,children:[t,(0,U.jsx)(`div`,{className:`UserList__pill-chevron`,children:Pw})]})}),(0,U.jsx)(Iy,{className:`focus-visible-none`,style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,U.jsxs)(uT,{padding:2,children:[s.length>=DR&&(0,U.jsx)(QT,{placeholder:G(`quickSearch.placeholder`),onChange:d}),(0,U.jsx)($T,{className:`dropdown-menu UserList__collaborators`,placeholder:G(`userList.empty`),children:f.length>0?[(0,U.jsx)(`div`,{className:`hint`,children:G(`userList.hint.text`)},`hint`),f.map(e=>jR({actionManager:a,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`UserList__menu-divider`}),(0,U.jsx)(Ly,{asChild:!0,children:(0,U.jsx)(`div`,{className:`dropdown-menu`,children:o})})]}),(0,U.jsx)(Ry,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})]},e.socketId):t});return t?(0,U.jsxs)(`div`,{className:H(`UserList UserList_mobile`,e),children:[(0,U.jsx)(`div`,{className:`UserList_mobile__avatars`,children:s.map(e=>jR({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`UserList__menu-divider`}),o]})]}):(0,U.jsx)(`div`,{className:`UserList__wrapper`,ref:p,children:(0,U.jsx)(`div`,{className:H(`UserList`,e),style:{"--max-avatars":b.length+(c?kR/OR:0)},children:x})})},(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 n=t.collaborators.keys();for(let[r,i]of e.collaborators){let e=t.collaborators.get(r);if(!e||r!==n.next().value||!qr(i,e,MR))return!1}return!0}),PR=e=>(0,U.jsx)(pD,{label:`${G(`helpDialog.title`)} \u2014 ?`,delay:!0,children:(0,U.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,"aria-label":G(`helpDialog.title`),children:Zx})}),FR=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r,defaultUIEnabled:i,zoomUIEnabled:a})=>{let{FooterCenterTunnel:o,WelcomeScreenHelpHintTunnel:s}=pR(),c=aW();return(0,U.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(i||a&&c.isNavigationEnabled())&&(0,U.jsx)(`div`,{className:`layer-ui__wrapper__footer-left zen-mode-transition`,children:(0,U.jsx)(yj.Col,{gap:2,children:(0,U.jsxs)(TR,{heading:`canvasActions`,children:[a&&c.isNavigationEnabled()&&(0,U.jsx)(OM,{renderAction:t.renderAction}),i&&!e.viewModeEnabled&&(0,U.jsx)(kM,{renderAction:t.renderAction,className:H(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),(0,U.jsx)(o.Out,{}),(i||r)&&(0,U.jsx)(`div`,{className:H(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,U.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,U.jsx)(s.Out,{}),i&&(0,U.jsx)(PR,{onClick:()=>t.executeAction(VO)})]})}),i&&(0,U.jsx)(AM,{actionManager:t,showExitZenModeBtn:n})]})},IR=FR;FR.displayName=`Footer`;var LR=V.createContext({}),RR=({children:e,className:t})=>{let n=sW(),r=(0,V.useContext)(LR),i=!!(n.canFitSidebar&&r.shouldRenderDockButton);return(0,U.jsxs)(`div`,{className:H(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,U.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,U.jsx)(pD,{label:G(`labels.sidebarLock`),children:(0,U.jsx)($j,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":G(`labels.sidebarLock`),children:bx})}),(0,U.jsx)($j,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":G(`buttons.close`),children:PS})]})]})};RR.displayName=`SidebarHeader`;var zR=({children:e,tab:t,onSelect:n,...r})=>(0,U.jsx)(nb,{value:t,asChild:!0,onSelect:n,children:(0,U.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});zR.displayName=`SidebarTabTrigger`;var BR=({children:e,...t})=>(0,U.jsx)(tb,{className:`sidebar-triggers`,...t,children:e});BR.displayName=`SidebarTabTriggers`;var VR=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=fW(),l=eT().openSidebar?.name===e;return(0,U.jsx)(`button`,{type:`button`,title:r,className:`sidebar-trigger__label-element`,"aria-label":r,"aria-keyshortcuts":`0`,"aria-pressed":l,onClick:()=>{document.querySelector(`.layer-ui__wrapper`)?.classList.remove(`animate`);let n=!l;c({openSidebar:n?{name:e,tab:t}:null,openMenu:null,openPopup:null}),a?.(n)},children:(0,U.jsxs)(`div`,{className:H(`sidebar-trigger`,o),style:s,children:[n&&(0,U.jsx)(`div`,{children:n}),i&&(0,U.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})})};VR.displayName=`SidebarTrigger`;var HR=({children:e,...t})=>{let n=eT(),r=fW();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,U.jsx)(eb,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};HR.displayName=`SidebarTabs`;var UR=({tab:e,children:t,...n})=>(0,U.jsx)(rb,{...n,value:e,"data-testid":e,children:t});UR.displayName=`SidebarTab`;var WR=Dl(!1),GR=(0,V.forwardRef)(({name:e,children:t,onDock:n,docked:r,className:i,...a},o)=>{Ae()&&n&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=fW(),c=Xb(WR);(0,V.useLayoutEffect)(()=>(c(!!r),()=>{c(!1)}),[c,r]);let l=(0,V.useRef)({});l.current.onCloseRequest=()=>{s({openSidebar:null})},l.current.onDock=e=>n?.(e),l.current=ao(l.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});let u=(0,V.useRef)(null);(0,V.useImperativeHandle)(o,()=>u.current);let d=sW(),f=(0,V.useCallback)(()=>{document.querySelector(`.Dialog`)||s({openSidebar:null})},[s]);return nT(u,(0,V.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!r||!d.canFitSidebar)&&f()},[f,r,d.canFitSidebar])),(0,V.useEffect)(()=>{let e=e=>{e.key===z.ESCAPE&&(!r||!d.canFitSidebar)&&f()};return document.addEventListener(P.KEYDOWN,e),()=>{document.removeEventListener(P.KEYDOWN,e)}},[f,r,d.canFitSidebar]),(0,U.jsx)(uT,{...a,className:H(hn.SIDEBAR,{"sidebar--docked":r},i),"data-viewport-ui":d.formFactor===`phone`?void 0:`side`,"data-viewport-ui-name":d.formFactor===`phone`?void 0:`sidebar`,ref:u,children:(0,U.jsx)(LR.Provider,{value:l.current,children:t})})});GR.displayName=`SidebarInner`;var KR=Object.assign((0,V.forwardRef)((e,t)=>{let n=eT(),{onStateChange:r}=e,i=(0,V.useRef)(n.openSidebar);(0,V.useEffect)(()=>{(!n.openSidebar&&i?.current?.name===e.name||n.openSidebar?.name===e.name&&i?.current?.name!==e.name||i.current?.name===e.name)&&n.openSidebar!==i.current&&r?.(n.openSidebar?.name===e.name?n.openSidebar:null),i.current=n.openSidebar},[n.openSidebar,r,e.name]);let[a,o]=(0,V.useState)(!1);return(0,V.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,V.createElement)(GR,{...e,ref:t,key:e.name}):null}),{Header:RR,TabTriggers:BR,TabTrigger:zR,Tabs:HR,Tab:UR,Trigger:VR});KR.displayName=`Sidebar`;var qR=(e,t)=>{let n=Dl(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=pR(),[,i]=r(n),a=(0,V.useRef)({preferHost:!1,counter:0});return(0,V.useLayoutEffect)(()=>{let e=a.current;return i(t=>{let n=t+1;return e.counter=n,n}),()=>{i(t=>{let n=t-1;return e.counter=n,n||(e.preferHost=!1),n})}},[i]),e.__fallback||(a.current.preferHost=!0),!a.current.counter&&e.__fallback&&a.current.preferHost||a.current.counter>1&&e.__fallback?null:(0,U.jsx)(t,{...e})};return r.displayName=e,r},JR={};_l(JR,{ChangeCanvasBackground:()=>cz,ClearCanvas:()=>oz,CommandPalette:()=>rz,Export:()=>lz,Help:()=>az,LiveCollaborationTrigger:()=>dz,LoadScene:()=>ez,Preferences:()=>Cz,PreferencesToggleGridModeItem:()=>yz,PreferencesToggleZenModeItem:()=>bz,SaveAsImage:()=>nz,SaveToActiveFile:()=>tz,SearchMenu:()=>iz,Socials:()=>uz,ToggleTheme:()=>sz});var YR=Dl({active:!1});async function XR({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{ex.set(YR,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var ZR=function({onChange:e,value:t,choices:n,name:r}){return(0,U.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,U.jsxs)(`div`,{className:H(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,U.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},QR=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a,icon:o})=>{let s=sW();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[o&&(0,U.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:o}),(0,U.jsx)(`label`,{className:`dropdown-menu-item__text`,children:(0,U.jsx)(aE,{children:i})}),(0,U.jsx)(ZR,{name:a,value:e,onChange:n,choices:r})]}),t&&s.formFactor!==`phone`&&(0,U.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};QR.displayName=`DropdownMenuItemContentRadio`;var $R=QR,ez=()=>{let{t:e}=fx(),t=pW(),n=uW();return t.isActionEnabled(IO)?(0,U.jsx)(uE,{icon:sS,onSelect:async()=>{(!n.length||await XR({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,U.jsx)(hj,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,U.jsx)(`strong`,{children:e}),br:()=>(0,U.jsx)(`br`,{})})}))&&t.executeAction(IO)},"data-testid":`load-button`,shortcut:wA(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};ez.displayName=`LoadScene`;var tz=()=>{let{t:e}=fx(),t=pW();return t.isActionEnabled(PO)?(0,U.jsx)(uE,{shortcut:wA(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(PO),icon:aS,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};tz.displayName=`SaveToActiveFile`;var nz=()=>{let e=fW(),{t}=fx();return(0,U.jsx)(uE,{icon:dS,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:wA(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};nz.displayName=`SaveAsImage`;var rz=e=>{let t=fW(),{t:n}=fx();return(0,U.jsx)(uE,{icon:aw,"data-testid":`command-palette-button`,onSelect:()=>{Yw(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:wA(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};rz.displayName=`CommandPalette`;var iz=e=>{let{t}=fx(),n=pW();return(0,U.jsx)(uE,{icon:ew,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(vP)},shortcut:wA(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};iz.displayName=`SearchMenu`;var az=()=>{let{t:e}=fx(),t=pW();return(0,U.jsx)(uE,{"data-testid":`help-menu-item`,icon:Zx,onSelect:()=>t.executeAction(VO),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};az.displayName=`Help`;var oz=()=>{let{t:e}=fx(),t=Xb(NM);return pW().isActionEnabled(vD)?(0,U.jsx)(uE,{icon:Wx,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};oz.displayName=`ClearCanvas`;var sz=e=>{let{t}=fx(),n=eT(),r=pW(),i=wA(`toggleTheme`),a=oW();return r.isActionEnabled(CD)?e?.allowSystemTheme?(0,U.jsx)($R,{name:`theme`,value:e.theme,onChange:e=>{if(a.onThemeChange){a.onThemeChange(e);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:M.LIGHT,label:Jx,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:M.DARK,label:qx,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:gw,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,U.jsx)(uE,{onSelect:e=>{e.preventDefault(),r.executeAction(CD)},icon:n.theme===M.DARK?Jx:qx,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===M.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===M.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};sz.displayName=`ToggleTheme`;var cz=()=>{let{t:e}=fx(),t=eT(),n=pW(),r=oW();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,U.jsxs)(`div`,{style:{marginTop:`0.75rem`},children:[(0,U.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`0.875rem`,marginBottom:`0.25rem`,marginLeft:`0.5rem`},children:e(`labels.canvasBackground`)}),(0,U.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};cz.displayName=`ChangeCanvasBackground`;var lz=()=>{let{t:e}=fx(),t=fW();return(0,U.jsx)(uE,{icon:Xx,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};lz.displayName=`Export`;var uz=()=>{let{t:e}=fx();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(wj,{icon:eS,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,U.jsx)(wj,{icon:nS,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,U.jsx)(wj,{icon:tS,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};uz.displayName=`Socials`;var dz=({onSelect:e,isCollaborating:t})=>{let{t:n}=fx();return(0,U.jsx)(uE,{"data-testid":`collab-button`,icon:MS,className:H({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};dz.displayName=`LiveCollaborationTrigger`;var fz=()=>{let{t:e}=fx(),t=aW(),n=eT();return(0,U.jsx)(Hj,{checked:n.activeTool.locked,shortcut:wA(`toolLock`),onSelect:e=>{t.toggleLock(),e.preventDefault()},children:e(`labels.preferences_toolLock`)})},pz=()=>{let{t:e}=fx(),t=eT(),n=fW();return(0,U.jsx)($R,{name:`boxSelectionMode`,icon:Nw,value:t.boxSelectionMode,onChange:e=>{n({boxSelectionMode:e})},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`)})},mz=()=>{let{t:e}=fx(),t=eT(),n=fW();return(0,U.jsx)($R,{name:`inputDevice`,icon:Nw,value:fe(t.inputDevice),onChange:e=>{n({inputDevice:e})},choices:[{value:`trackpad`,label:e(`labels.inputDeviceTrackpad`),ariaLabel:e(`labels.inputDeviceTrackpad`)},{value:`mouse`,label:e(`labels.inputDeviceMouse`),ariaLabel:e(`labels.inputDeviceMouse`)}],children:e(`labels.inputDevice`)})},hz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.objectsSnapModeEnabled,shortcut:wA(`objectsSnapMode`),onSelect:e=>{t.executeAction(hk),e.preventDefault()},children:e(`buttons.objectsSnapMode`)})},gz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.bindingPreference===`enabled`,onSelect:e=>{t.executeAction(gk),e.preventDefault()},children:e(`labels.arrowBinding`)})},_z=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.isMidpointSnappingEnabled,onSelect:e=>{t.executeAction(_k),e.preventDefault()},children:e(`labels.midpointSnapping`)})},vz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.showHints,onSelect:e=>{t.executeAction(vk),e.preventDefault()},children:e(`labels.showHints`)})},yz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.gridModeEnabled,shortcut:wA(`gridMode`),onSelect:e=>{t.executeAction(pk),e.preventDefault()},children:e(`labels.toggleGrid`)})},bz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.zenModeEnabled,shortcut:wA(`zenMode`),onSelect:e=>{t.executeAction(mk),e.preventDefault()},children:e(`buttons.zenMode`)})},xz=()=>{let{t:e}=fx(),t=pW(),n=eT();return t.isActionEnabled(pM)?(0,U.jsx)(Hj,{checked:n.viewModeEnabled,shortcut:wA(`viewMode`),onSelect:e=>{t.executeAction(pM),e.preventDefault()},children:e(`labels.viewMode`)}):null},Sz=()=>{let{t:e}=fx(),t=pW(),n=eT();return(0,U.jsx)(Hj,{checked:n.stats.open,shortcut:wA(`stats`),onSelect:e=>{t.executeAction(yk),e.preventDefault()},children:e(`stats.fullTitle`)})},Cz=({children:e,additionalItems:t})=>{let{t:n}=fx();return(0,U.jsxs)(zj,{children:[(0,U.jsx)(zj.Trigger,{icon:Iw,children:n(`labels.preferences`)}),(0,U.jsxs)(zj.Content,{className:`excalidraw-main-menu-preferences-submenu`,children:[e||(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(pz,{}),(0,U.jsx)(mz,{}),(0,U.jsx)(fz,{}),(0,U.jsx)(hz,{}),(0,U.jsx)(yz,{}),(0,U.jsx)(bz,{}),(0,U.jsx)(xz,{}),(0,U.jsx)(Sz,{}),(0,U.jsx)(gz,{}),(0,U.jsx)(_z,{})]}),t]})]})};Cz.ToggleToolLock=fz,Cz.BoxSelectionMode=pz,Cz.InputDevice=mz,Cz.ToggleSnapMode=hz,Cz.ToggleArrowBinding=gz,Cz.ToggleMidpointSnapping=_z,Cz.ToggleShowHints=vz,Cz.ToggleGridMode=yz,Cz.ToggleZenMode=bz,Cz.ToggleViewMode=xz,Cz.ToggleElementProperties=Sz,Cz.displayName=`Preferences`;var wz=Object.assign(qR(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=pR(),r=sW(),i=eT(),a=oW(),o=fW();return(0,U.jsx)(n.In,{children:(0,U.jsxs)(Q,{open:i.openMenu===`canvas`,children:[(0,U.jsx)(Q.Trigger,{onToggle:()=>{o({openMenu:i.openMenu===`canvas`?null:`canvas`,openPopup:null,openDialog:null})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:Yx}),(0,U.jsxs)(Q.Content,{onClickOutside:()=>o({openMenu:null}),onSelect:ys(t,()=>{o({openMenu:null})}),className:`main-menu`,align:`start`,children:[e,r.formFactor===`phone`&&i.collaborators.size>0&&(0,U.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,U.jsx)(`legend`,{children:G(`labels.collaborators`)}),(0,U.jsx)(NR,{mobile:!0,collaborators:i.collaborators,userToFollow:a.userToFollow?.socketId||null,currentUserControls:a.currentUserControls})]})]})]})})}),{Trigger:Q.Trigger,Item:Q.Item,ItemLink:Q.ItemLink,ItemCustom:Q.ItemCustom,Group:Q.Group,Separator:Q.Separator,Sub:zj,DefaultItems:JR}),Tz=(0,V.forwardRef)(({children:e,icon:t,onClick:n,label:r,variant:i=`filled`,color:a=`primary`,size:o=`medium`,fullWidth:s,className:c,status:l,disabled:u},d)=>{let[f,p]=(0,V.useState)(!1),m=async e=>{let t=n?.(e);if(We(t)){let e=window.setTimeout(()=>{p(!0)},50);try{await t}catch(e){if(e instanceof nc)console.warn(e);else throw e}finally{clearTimeout(e),p(!1)}}},h=f?`loading`:l;return a=h===`success`?`success`:a,(0,U.jsx)(`button`,{className:H(`ExcButton`,`ExcButton--color-${a}`,`ExcButton--variant-${i}`,`ExcButton--size-${o}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":s},c),onClick:m,type:`button`,"aria-label":r,ref:d,disabled:u||h===`loading`||h===`success`,children:(0,U.jsxs)(`div`,{className:`ExcButton__contents`,children:[h===`loading`?(0,U.jsx)(Lw,{className:`ExcButton__statusIcon`}):h===`success`&&(0,U.jsx)(`div`,{className:`ExcButton__statusIcon`,children:IC}),t&&(0,U.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),Ez=({title:e,children:t,actionLabel:n,onClick:r})=>(0,U.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,U.jsx)(`h4`,{children:e}),(0,U.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,U.jsx)(Tz,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),Dz=Object.assign(({children:e})=>(0,U.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=fx(),t=pW(),n=fW();return(0,U.jsx)(Ez,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction(kO,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=fx(),t=pW();return(0,U.jsx)(Ez,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(FO,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),Oz=Object.assign(qR(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=pR(),[n,r]=Yb(YR);return n.active?(0,U.jsx)(t.In,{children:(0,U.jsx)(fM,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,U.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,U.jsx)(`h3`,{children:n.title}),(0,U.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,U.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:LC}),(0,U.jsx)(`div`,{children:n.description}),(0,U.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,U.jsx)(Tz,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,U.jsx)(Dz,{children:e})]})})}):null}),{Actions:Dz,Action:Ez}),kz=Dl(``),Az=Dl(null),jz=350,Mz=()=>{let e=aW(),t=fW(),n=(0,V.useRef)(null),[r,i]=Yb(kz),a=r.trim(),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)({nonce:null,items:[]}),u=(0,V.useRef)(null),d=(0,V.useRef)(void 0),[f,p]=Yb(Az),m=e.scene.getNonDeletedElementsMap();(0,V.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,Bz(a,e,(n,r)=>{l({nonce:eo(),items:n}),u.current=a,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null})}))},[o,a,m,e,t,p,d]);let h=()=>{c.items.length>0&&p(e=>e===null?0:(e+1)%c.items.length)},g=()=>{c.items.length>0&&p(e=>e===null?0:e-1<0?c.items.length-1:e-1)};(0,V.useEffect)(()=>{t(e=>e.searchMatches?{searchMatches:{focusedId:f!==null&&e.searchMatches?.matches[f]?.id||null,matches:e.searchMatches.matches.map((e,t)=>t===f?{...e,focus:!0}:{...e,focus:!1})}}:null)},[f,t]),(0,V.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=el({text:t.searchQuery,x:t.element.x+(t.matchedLines[0]?.offsetX??0),y:t.element.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:F(t.element)?xo.nameFontSize:t.element.fontSize,fontFamily:F(t.element)?Yn.Assistant:t.element.fontFamily}),i=r.fontSize,a=i*n<14;if(!Di([r],e.canvas.width/e.ownerWindow.devicePixelRatio,e.canvas.height/e.ownerWindow.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())||a){let t=a&&i<14?`contain`:`scale-down`;e.viewport.setViewport({target:Hc([r]),fit:t,animation:{duration:300},offsets:{ui:!0}})}}}},[f,c,e]),(0,V.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:null}),s(!1)},[t,p]);let _=rT({goToNextItem:h,goToPreviousItem:g,searchMatches:c});(0,V.useEffect)(()=>we(e.ownerWindow,P.KEYDOWN,r=>{let i=r.target;if(r.key===z.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}if(r[z.CTRL_OR_CMD]&&r.key===z.F){if(r.preventDefault(),r.stopPropagation(),e.state.openDialog)return;n.current?.matches(`:focus`)||(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())}i instanceof e.ownerWindow.HTMLElement&&i.closest(`.layer-ui__search`)&&_.searchMatches.items.length&&(r.key===z.ENTER&&(r.stopPropagation(),_.goToNextItem()),r.key===z.ARROW_UP?(r.stopPropagation(),_.goToPreviousItem()):r.key===z.ARROW_DOWN&&(r.stopPropagation(),_.goToNextItem()))},{capture:!0,passive:!1}),[t,_,e]);let v=`${c.items.length} ${c.items.length===1?G(`search.singleResult`):G(`search.multipleResults`)}`;return(0,U.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,U.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,U.jsx)(eM,{className:hn.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:G(`search.placeholder`),icon:ew,onChange:n=>{i(n),s(!0);let r=n.trim();Bz(r,e,(n,i)=>{l({nonce:eo(),items:n}),p(i),u.current=r,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null}),s(!1)})},selectOnRender:!0})}),(0,U.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,U.jsxs)(U.Fragment,{children:[f!==null&&f>-1?(0,U.jsxs)(`div`,{children:[f+1,` / `,v]}):(0,U.jsx)(`div`,{children:v}),(0,U.jsxs)(`div`,{className:`result-nav`,children:[(0,U.jsx)($j,{onSelect:()=>{h()},className:`result-nav-btn`,children:Cw}),(0,U.jsx)($j,{onSelect:()=>{g()},className:`result-nav-btn`,children:Tw})]})]}),c.items.length===0&&a&&u.current&&(0,U.jsx)(`div`,{style:{margin:`1rem auto`},children:G(`search.noMatch`)})]}),(0,U.jsx)(Pz,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},Nz=e=>{let t=[e.preview.moreBefore?`...`:``,e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?`...`:``];return(0,U.jsx)(`div`,{tabIndex:-1,className:H(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,U.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,U.jsx)(V.Fragment,{children:t===2?(0,U.jsx)(`b`,{children:e}):e},t))})})},Pz=(0,V.memo)(e=>{let t=(0,V.useMemo)(()=>e.matches.items.filter(e=>F(e.element)),[e.matches]),n=(0,V.useMemo)(()=>e.matches.items.filter(e=>D(e.element)),[e.matches]);return(0,U.jsxs)(`div`,{children:[t.length>0&&(0,U.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,U.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,U.jsx)(`div`,{className:`title-icon`,children:BC}),(0,U.jsx)(`div`,{children:G(`search.frames`)})]}),t.map((t,n)=>(0,U.jsx)(Nz,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.element.id+t.index)),n.length>0&&(0,U.jsx)(`div`,{className:`layer-ui__divider`})]}),n.length>0&&(0,U.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,U.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,U.jsx)(`div`,{className:`title-icon`,children:Lx}),(0,U.jsx)(`div`,{children:G(`search.texts`)})]}),n.map((n,r)=>(0,U.jsx)(Nz,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+t.length===e.focusIndex,onClick:()=>e.onItemClick(r+t.length)},n.element.id+n.index))]})]})},(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),Fz=(e,t,n)=>{let r=e.slice(0,t),i=r.split(/\s+/),a=r.endsWith(` `),o=i.length-2-1-!a,s=i.slice(o<=0?0:o).join(` `)+(a?` `:``);s=s.length>20?s.slice(-20):s;let c=e.slice(t+n.length),l=c.split(/\s+/),u=!c.startsWith(` `),d=u?6:5,f=(u?``:` `)+l.slice(0,d).join(` `);return{indexInSearchQuery:s.length,previewText:s+n+f,moreBefore:o>0,moreAfter:l.length>d}},Iz=(e,t)=>{let n=e.split(`
62
+ `),r=[],i=0;for(let e=0;e<n.length;e++){let a=n[e],o=n[e+1];if(o){let e=t.indexOf(o,i);if(e>a.length+i){let t=e-(a.length+i);for(;t>0;)a+=` `,t--}}r.push(a),i+=a.length}return r.join(`
63
+ `)},Lz=(e,t,n)=>{let r=Iz(e.text,e.originalText).split(`
64
+ `),i=[],a=0,o=0;for(let e of r){let t=a,n=t+e.length-1;i.push({line:e,startIndex:t,endIndex:n,lineNumber:o}),a=n+1,o++}let s=n,c=e.originalText.slice(n,n+t.length),l=[];for(let t of i){if(c===``)break;if(s>=t.startIndex&&s<=t.endIndex){let n=t.endIndex+1-s,r=t.line.slice(0,s-t.startIndex),i=c.slice(0,n);c=c.slice(n);let a=Oi(r,Or(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=Oi(t.line,Or(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=Oi(i,Or(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u,showOnCanvas:!0}),s+=n}}return l},Rz=(e,t,n,r)=>{let i=e.name??Eo(e),a=i.slice(n,n+t.length),o=i.slice(0,n),s=Or({fontSize:xo.nameFontSize,fontFamily:Yn.Assistant}),c=$n(Yn.Assistant),l=Oi(o,s,c);o===``&&(l.width=0);let u=Oi(a,s,c),d=l.width,f=-l.height-xo.strokeWidth,p=u.width;return[{offsetX:d,offsetY:f,width:p,height:u.height,showOnCanvas:d+p<=e.width*r}]},zz=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),Bz=(0,qb.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements(),i=r.filter(e=>D(e)),a=r.filter(e=>F(e));i.sort((e,t)=>e.y-t.y),a.sort((e,t)=>e.y-t.y);let o=[],s=new RegExp(zz(e),`gi`);for(let t of i){let n=null,r=t.originalText;for(;(n=s.exec(r))!==null;){let i=Fz(r,n.index,e),a=Lz(t,e,n.index);a.length>0&&o.push({element:t,searchQuery:e,preview:i,index:n.index,matchedLines:a})}}let c=[];for(let n of a){let r=null,i=n.name??Eo(n);for(;(r=s.exec(i))!==null;){let a=Fz(i,r.index,e),o=Rz(n,e,r.index,t.state.zoom.value);o.length>0&&c.push({element:n,searchQuery:e,preview:a,index:r.index,matchedLines:o})}}let l=new Set(t.visibleElements.map(e=>e.id)),u=[...c,...o];n(u,u.findIndex(e=>l.has(e.element.id))??null)},jz),Vz=qR(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=pR();return(0,U.jsx)(t.In,{children:(0,U.jsx)(KR.Trigger,{...e,className:`default-sidebar-trigger`,name:Vr.name})})});Vz.displayName=`DefaultSidebarTrigger`;var Hz=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=pR();return(0,U.jsx)(t.In,{children:e})};Hz.displayName=`DefaultTabTriggers`;var Uz=Object.assign(qR(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=eT(),o=fW(),{DefaultSidebarTabTriggersTunnel:s}=pR(),c=a.openSidebar?.tab===Sc;return(0,V.createElement)(KR,{...i,name:`default`,key:`default`,className:H(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:ys(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,U.jsxs)(KR.Tabs,{children:[(0,U.jsx)(KR.Header,{children:(0,U.jsxs)(KR.TabTriggers,{children:[(0,U.jsx)(KR.TabTrigger,{tab:Sc,children:ew}),(0,U.jsx)(KR.TabTrigger,{tab:Ie,children:gx}),(0,U.jsx)(s.Out,{})]})}),(0,U.jsx)(KR.Tab,{tab:Ie,children:(0,U.jsx)(lM,{})}),(0,U.jsx)(KR.Tab,{tab:Sc,children:(0,U.jsx)(Mz,{})}),e]}))}),{Trigger:Vz,TabTriggers:Hz}),Wz=300,Gz=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:i,errorLine:a})=>{let o=(0,V.useRef)(null),s=(0,V.useRef)(i);s.current=i;let[c,l]=(0,V.useState)({type:`loading`}),[u,d]=(0,V.useState)(!1),{theme:f}=eT();if((0,V.useEffect)(()=>{let e=!1,t=setTimeout(()=>{e||d(!0)},Wz);return n(()=>import(`./CodeMirrorEditor-UCMRAMCV-cMeDxAEL.js`).then(t=>{e||l({type:`ready`,component:t.default})}),[],import.meta.url).catch(()=>{e||l({type:`fallback`})}).finally(()=>{clearTimeout(t)}),()=>{e=!0,clearTimeout(t)}},[]),(0,V.useEffect)(()=>{if(c.type!==`fallback`||!s.current)return;let e=o.current;if(e){let t=e=>{e[z.CTRL_OR_CMD]&&e.key===z.ENTER&&(e.preventDefault(),s.current?.())};return e.focus(),e.addEventListener(P.KEYDOWN,t),()=>{e.removeEventListener(P.KEYDOWN,t)}}},[c.type]),c.type===`ready`){let n=c.component;return(0,U.jsx)(n,{value:e,onChange:r,onKeyboardSubmit:i,placeholder:t,theme:f,errorLine:a})}return c.type===`fallback`?(0,U.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:e=>r(e.target.value),value:e,placeholder:t,ref:o}):u?(0,U.jsx)(`div`,{className:`ttd-dialog-input ttd-dialog-input--loading`,children:(0,U.jsx)(Lw,{})}):null},Kz=/(?:Parse|Lexical) error on line (\d+)[.:]/i,qz=/Trying to inactivate an inactive participant \((.+)\)/i,Jz=/^\s*-+\^\s*$/,Yz=e=>Kz.test(e),Xz=e=>Yz(e)||qz.test(e),Zz=e=>Jz.test(e),Qz=e=>{let t=e.match(qz);return t?.[1]?t[1].trim():null},$z=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),eB=(e,t)=>{let n=Qz(e);if(!n)return null;let r=RegExp(`^\\s*deactivate\\s+${$z(n)}(?:\\s+%%.*)?\\s*$`),i=t.split(/\r?\n/);for(let e=i.length-1;e>=0;e--)if(r.test(i[e]))return e+1;return null},tB=(e,t)=>{let n=e.match(Kz);return n?Number.parseInt(n[1],10):t?eB(e,t):null},nB=(e,t)=>(e.match(t)||[]).length,rB=(e,t)=>{if(!Yz(e))return null;let n=tB(e,t),r=n?`Syntax error near line ${n}.`:`Syntax error in Mermaid diagram.`,i=[];return t&&(nB(t,/\[/g)!==nB(t,/\]/g)&&i.push(`Unbalanced square brackets in a node label.`),nB(t,/\(/g)!==nB(t,/\)/g)&&i.push(`Unbalanced parentheses in a node shape.`),nB(t,/\{/g)!==nB(t,/\}/g)&&i.push(`Unbalanced braces in a decision node.`),nB(t,/^\s*subgraph\b/gm)>nB(t,/^\s*end\s*$/gm)&&i.push("A block is missing an `end` statement.")),(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&i.push(`An extra character/token may appear after a node or label definition.`),i.length===0&&(i.push(`A node or edge line is malformed (missing/extra delimiters).`),i.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:r,likelyCauses:[...new Set(i)]}},iB=e=>Yz(e)?e.replace(/\n\s*Expecting[\s\S]*$/,``).trimEnd():e,aB=({error:e,canvasRef:t,loaded:n,hideErrorDetails:r,sourceText:i,autoFixAvailable:a,onApplyAutoFix:o})=>{let s=e?r?G(`chat.errors.mermaidParseError`):iB(e.message):null,c=e&&!r?rB(e.message,i):null,l=!!a&&!!o&&!r,u=s?.split(/\r?\n/)??[];return(0,U.jsxs)(`div`,{className:`ttd-dialog-output-wrapper ${e?`ttd-dialog-output-wrapper--error`:``}`,children:[e&&(0,U.jsx)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:(0,U.jsxs)(`div`,{className:`ttd-dialog-output-error-content`,children:[(0,U.jsx)(`div`,{className:`ttd-dialog-output-error-icon`,children:LC}),c&&(0,U.jsxs)(`div`,{className:`ttd-dialog-output-error-summary`,children:[(0,U.jsx)(`div`,{className:`ttd-dialog-output-error-summary__headline`,children:c.summary}),(0,U.jsx)(`div`,{className:`ttd-dialog-output-error-summary__label`,children:`Likely causes:`}),(0,U.jsx)(`ul`,{className:`ttd-dialog-output-error-summary__causes`,children:c.likelyCauses.map(e=>(0,U.jsx)(`li`,{children:e},e))})]}),(0,U.jsx)(`div`,{className:`ttd-dialog-output-error-message`,children:u.map((e,t)=>(0,U.jsxs)(`span`,{className:Zz(e)?`ttd-dialog-output-error-message__caret`:void 0,children:[e,t<u.length-1?`
65
+ `:``]},`error-line-${t}`))}),!r&&(0,U.jsx)(`div`,{className:`ttd-dialog-output-error-autofix-slot`,children:l?(0,U.jsx)($j,{className:`ttd-dialog-panel-button ttd-dialog-output-error-autofix`,onSelect:o,children:G(`mermaid.autoFixAvailable`)}):null})]})},`error`),n?(0,U.jsx)(`div`,{className:H(`ttd-dialog-output-canvas-container`,{invisible:!!e}),children:(0,U.jsx)(`div`,{ref:t,className:`ttd-dialog-output-canvas-content`})},`canvas`):(0,U.jsx)(Lw,{size:`2rem`})]})},oB=({label:e,children:t,panelActions:n=[],onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,className:o,panelActionJustifyContent:s=`flex-start`})=>{let c=e=>{if(e?.variant===`link`)return(0,U.jsxs)(`button`,{className:H(`ttd-dialog-panel-action-link`,e.className),onClick:e.action,disabled:e?.disabled||r,type:`button`,children:[e.label,e.icon&&(0,U.jsx)(`span`,{className:`ttd-dialog-panel-action-link__icon`,children:e.icon})]});if(e?.variant===`button`)return(0,U.jsxs)($j,{className:H(`ttd-dialog-panel-button`,e.className),onSelect:e.action?e.action:()=>{},disabled:e?.disabled||r,children:[(0,U.jsxs)(`div`,{className:H({invisible:r}),children:[e?.label,e?.icon&&(0,U.jsx)(`span`,{children:e.icon})]}),r&&(0,U.jsx)(Lw,{})]});if(e?.variant===`rateLimit`)return(0,U.jsx)(`div`,{className:H(`ttd-dialog-panel__rate-limit`,e.className),children:e.label})};return(0,U.jsxs)(`div`,{className:H(`ttd-dialog-panel`,o),children:[(e||i)&&(0,U.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[typeof e==`string`?(0,U.jsx)(`label`,{children:e}):e,i?.()]}),t,(0,U.jsxs)(`div`,{className:H(`ttd-dialog-panel-button-container`,{invisible:!n.length}),style:{justifyContent:s},children:[n.filter(Boolean).map(e=>(0,U.jsx)(V.Fragment,{children:c(e)},e.label)),!r&&a?.()]})]})},sB=({children:e})=>(0,U.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),cB=()=>(0,U.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,U.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`CtrlOrCmd`)}),(0,U.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`Enter`)})]}),lB=(e,t)=>{let n=tB(e,t);return n==null?null:n-1},uB=(e,t,n)=>{if(t<0||t>=e.length)return null;let r=n(e[t]);if(r===e[t])return null;let i=[...e];return i[t]=r,i.join(`
66
+ `)},dB=e=>{let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(t)return t[1];let n=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return n?n[1]:e},fB=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,`$1 `),pB=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),mB=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${pB(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/);for(let e=r.length-1;e>=0;e--)if(n.test(r[e]))return r.filter((t,n)=>n!==e).join(`
67
+ `);return null},hB=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${pB(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/),i=!1,a=r.filter(e=>!n.test(e)||(i=!0,!1));return i?a.join(`
68
+ `):null},gB=e=>{let t=(e.match(/^\s*subgraph\b/gm)||[]).length-(e.match(/^\s*end\s*$/gm)||[]).length;if(t<=0)return null;let n=Array.from({length:t},()=>`end`).join(`
69
+ `);return`${e.trimEnd()}
70
+ ${n}`},_B=e=>e.replace(/[“”]/g,`"`).replace(/[‘’]/g,`'`),vB=(e,t)=>{if(!Xz(t)||!e.trim())return[];let n=[],r=new Set,i=t=>{!t||t===e||r.has(t)||(r.add(t),n.push(t))},a=Qz(t);if(a&&(i(mB(e,a)),i(hB(e,a))),Yz(t)){let n=e.split(/\r?\n/),r=lB(t,e),a=r==null?[]:[r,r-1,r+1];for(let e of a)i(uB(n,e,e=>dB(e))),i(uB(n,e,e=>fB(e)));i(fB(e)),i(gB(e));let o=_B(e);i(o===e?null:o)}return n},yB=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},bB=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i,theme:a})=>{let o=e.current,s=o?.parentElement;if(!o||!s)return{success:!1};if(!n)return yB({canvasRef:e,setError:r}),{success:!1};let c;try{let e=await t.api;try{c=await e.parseMermaidToExcalidraw(n)}catch(t){let r=t;if(!n.includes(`"`))return{success:!1,error:r};try{c=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}catch{return{success:!1,error:r}}}let{elements:l,files:u={}}=c;r(null),i.current={elements:Ut(l,{regenerateIds:!0}),files:u};let d=await AA({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(s.offsetWidth,s.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:a===M.DARK}});return s.style.background=`var(--default-bg-color)`,o.replaceChildren(d),{success:!0}}catch(e){return s.style.background=`var(--default-bg-color)`,n&&r(e),{success:!1,error:e}}},xB=e=>{lj.set(wt.MERMAID_TO_EXCALIDRAW,e)},SB=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{let{elements:i,files:a}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:a,position:`center`,fit:`scale-down`}),e.setOpenDialog(null),r&&n&&xB(n))},CB=`flowchart TD
71
+ A[Christmas] -->|Get money| B(Go shopping)
72
+ B --> C{Let me think}
73
+ C -->|One| D[Laptop]
74
+ C -->|Two| E[iPhone]
75
+ C -->|Three| F[Car]`,wB=ml(xB,300),TB=500,EB=4,DB=30,OB=e=>e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:``,kB=({mermaidToExcalidrawLib:e,isActive:t})=>{let[n,r]=(0,V.useState)(()=>lj.get(wt.MERMAID_TO_EXCALIDRAW)||CB),i=(0,V.useDeferredValue)(n),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=a?.message?tB(a.message,i):null,u=(0,V.useRef)(null),d=(0,V.useRef)({elements:[],files:null}),f=aW(),{theme:p}=eT();(0,V.useEffect)(()=>{t&&((async()=>{try{if(!i.trim()){yB({canvasRef:u,setError:o});return}let t=await bB({canvasRef:u,data:d,mermaidToExcalidrawLib:e,setError:o,mermaidDefinition:i,theme:p});if(!t.success){let e=t.error??Error(`Invalid mermaid definition`);o(e)}}catch(e){Ae()&&console.error(`Failed to parse mermaid definition`,e)}})(),wB(i))},[i,e,t,p]),(0,V.useEffect)(()=>()=>{wB.flush()},[]),(0,V.useEffect)(()=>{let n=a?.message??``,r=i;if(!(t&&Xz(n)&&r.trim()&&e.loaded)){c(null);return}let o=vB(r,n);if(!o.length){c(null);return}let s=!1,l=setTimeout(async()=>{try{let t=await e.api,n=new Set([r]),i=o.map(e=>({text:e,depth:1})),a=0;for(;i.length>0&&a<DB;){let e=i.shift();if(e&&!n.has(e.text)){n.add(e.text),a+=1;try{await t.parseMermaidToExcalidraw(e.text),s||c(e.text);return}catch(t){if(e.depth>=EB)continue;let r=OB(t);if(!r)continue;let a=vB(e.text,r);for(let t of a)n.has(t)||i.push({text:t,depth:e.depth+1})}}}}catch{}s||c(null)},TB);return()=>{s=!0,clearTimeout(l)}},[i,a?.message,t,e]);let m=()=>{SB({app:f,data:d,text:n,shouldSaveMermaidDataToStorage:!0})};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,U.jsx)(hj,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,U.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,target:`_blank`,rel:`noreferrer`,children:e}),sequenceLink:e=>(0,U.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),classLink:e=>(0,U.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),erdLink:e=>(0,U.jsx)(`a`,{href:`https://mermaid.js.org/syntax/entityRelationshipDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e})})}),(0,U.jsxs)(sB,{children:[(0,U.jsx)(oB,{children:(0,U.jsx)(Gz,{input:n,placeholder:G(`mermaid.inputPlaceholder`),onChange:e=>r(e),errorLine:l,onKeyboardSubmit:()=>{m()}})}),(0,U.jsx)(oB,{panelActions:[{action:()=>{m()},label:G(`mermaid.button`),icon:GC,variant:`button`}],renderSubmitShortcut:()=>(0,U.jsx)(cB,{}),children:(0,U.jsx)(aB,{canvasRef:u,loaded:e.loaded,error:a,sourceText:n,autoFixAvailable:!!s,onApplyAutoFix:()=>{s&&r(s)}})})]})]})},AB=()=>(0,U.jsxs)(`div`,{className:`chat-interface__welcome-screen__welcome-message`,children:[(0,U.jsx)(`h3`,{children:G(`chat.placeholder.title`)}),(0,U.jsx)(`p`,{children:G(`chat.placeholder.description`)}),(0,U.jsx)(`p`,{children:G(`chat.placeholder.hint`)})]}),jB=({message:e,onMermaidTabClick:t,onAiRepairClick:n,onDeleteMessage:r,onInsertMessage:i,onRetry:a,rateLimitRemaining:o,isLastMessage:s,renderWarning:c,allowFixingParseError:l})=>{let[u,d]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!e.error||!s)return;if(e.error&&!e.lastAttemptAt){d(!0);return}let t=Date.now()-e.lastAttemptAt,n=Math.max(0,5e3-t);if(n===0){d(!0);return}d(!1);let r=setTimeout(()=>{d(!0)},n);return()=>clearTimeout(r)},[e.error,e.lastAttemptAt,s]);let f=e=>e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});if(e.type===`warning`){let t=c?.(e);return(0,U.jsx)(`div`,{className:`chat-message chat-message--system`,children:(0,U.jsxs)(`div`,{className:`chat-message__content`,children:[(0,U.jsxs)(`div`,{className:`chat-message__header`,children:[(0,U.jsx)(`span`,{className:`chat-message__role`,children:G(`chat.role.system`)}),(0,U.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,U.jsx)(`div`,{className:`chat-message__body`,children:(0,U.jsx)(`div`,{className:`chat-message__text`,children:t||(e.warningType===`messageLimitExceeded`?(0,U.jsxs)(U.Fragment,{children:[G(`chat.rateLimit.messageLimit`),(0,U.jsx)(`div`,{style:{marginTop:`10px`},children:(0,U.jsx)(Tz,{onClick:()=>{window.open(`${ca.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,`_blank`,`noopener`)},children:G(`chat.upsellBtnLabel`)})})]}):G(`chat.rateLimit.generalRateLimit`))})})]})})}return(0,U.jsxs)(`div`,{className:`chat-message chat-message--${e.type}`,children:[(0,U.jsxs)(`div`,{className:`chat-message__content`,children:[(0,U.jsxs)(`div`,{className:`chat-message__header`,children:[(0,U.jsx)(`span`,{className:`chat-message__role`,children:e.type===`user`?G(`chat.role.user`):G(`chat.role.assistant`)}),(0,U.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,U.jsx)(`div`,{className:`chat-message__body`,children:e.error?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`chat-message__error`,children:e.content}),e.errorType!==`parse`&&(0,U.jsxs)(`div`,{className:`chat-message__error_message`,children:[`Error: `,e.error||G(`chat.errors.generationFailed`)]}),e.errorType===`parse`&&l&&(0,U.jsxs)(`div`,{className:`chat-message__error_message`,children:[(0,U.jsx)(`p`,{children:G(`chat.errors.invalidDiagram`)}),(0,U.jsxs)(`div`,{className:`chat-message__error-actions`,children:[t&&(0,U.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>t(e),type:`button`,children:G(`chat.errors.fixInMermaid`)}),n&&(0,U.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>n(e),disabled:o===0,type:`button`,children:G(`chat.errors.aiRepair`)})]})]})]}):(0,U.jsxs)(`div`,{className:`chat-message__text`,children:[e.content,e.isGenerating&&(0,U.jsx)(`span`,{className:`chat-message__cursor`,children:`▋`})]})})]}),e.type===`assistant`&&!e.isGenerating&&(0,U.jsxs)(`div`,{className:`chat-message__actions`,children:[!e.error&&i&&(0,U.jsx)(`button`,{className:`chat-message__action`,onClick:()=>i(e),type:`button`,"aria-label":G(`chat.insert`),title:G(`chat.insert`),children:WC}),t&&e.content&&(0,U.jsx)(`button`,{className:`chat-message__action`,onClick:()=>t(e),type:`button`,"aria-label":G(`chat.viewAsMermaid`),title:G(`chat.viewAsMermaid`),children:xC}),r&&e.errorType!==`network`&&(0,U.jsx)(`button`,{className:`chat-message__action chat-message__action--danger`,onClick:()=>r(e.id),type:`button`,"aria-label":G(`chat.deleteMessage`),title:G(`chat.deleteMessage`),children:Wx}),e.errorType===`network`&&a&&s&&(0,U.jsx)(`button`,{className:H(`chat-message__action`,{invisible:!u}),onClick:()=>a(e),type:`button`,"aria-label":G(`chat.retry`),title:G(`chat.retry`),children:UC})]})]})},MB=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,rateLimits:o,onAbort:s,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,renderWelcomeScreen:p,renderWarning:m})=>{let h=(0,V.useRef)(null),g=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{h.current?.scrollIntoView()},[t]),(0,V.useEffect)(()=>{g.current&&g.current.focus()},[e]);let _=e=>{let t=e.target.value;r(t)},v=()=>{if(a&&s){s();return}let e=n.trim();e&&(i({prompt:e}),r(``))},y=e=>{e.key===z.ENTER&&!e.shiftKey&&(e.preventDefault(),a||v())},b=n.trim().length>3&&!a&&(o?.rateLimitRemaining??1)>0,x=a&&!!s;return(0,U.jsxs)(`div`,{className:`chat-interface`,children:[(0,U.jsxs)(`div`,{className:`chat-interface__messages`,children:[t.length===0?(0,U.jsx)(`div`,{className:`chat-interface__welcome-screen`,children:p?p({rateLimits:o??null}):(0,U.jsx)(AB,{})}):t.map((e,n)=>(0,U.jsx)(jB,{message:e,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,rateLimitRemaining:o?.rateLimitRemaining,isLastMessage:n===t.length-1,renderWarning:m,allowFixingParseError:e.errorType===`parse`&&n===t.length-1},e.id)),(0,U.jsx)(`div`,{ref:h,id:`messages-end`})]}),(0,U.jsx)(`div`,{className:`chat-interface__input-container`,children:(0,U.jsx)(`div`,{className:`chat-interface__input-outer`,children:(0,U.jsxs)(`div`,{className:`chat-interface__input-wrapper`,style:{borderColor:a?`var(--dialog-border-color)`:void 0},children:[(0,U.jsx)(`textarea`,{ref:g,autoFocus:!0,className:`chat-interface__input`,value:n,onChange:_,onKeyDown:y,placeholder:a?G(`chat.generating`):o?.rateLimitRemaining===0?G(`chat.rateLimit.messageLimitInputPlaceholder`):t.length>0?G(`chat.inputPlaceholderWithMessages`):G(`chat.inputPlaceholder`,{shortcut:`Shift + Enter`}),disabled:o?.rateLimitRemaining===0,rows:1,cols:30,onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,120)}px`}}),(0,U.jsx)(`button`,{className:`chat-interface__send-button`,onClick:v,disabled:!b&&!x,type:`button`,children:(0,U.jsx)(OE,{size:`1.5em`,icon:a?NS:GC})})]})})})]})},NB=Dl(null),PB=Dl(!1),FB=Dl(null),IB=Dl({id:Ti(),messages:[],currentPrompt:``}),LB=(e,t)=>{let{messages:n}=e,r=lt(n,e=>e.type===`assistant`);if(r===-1)return e;let i=n[r],a=n.slice();return a[r]={...i,...t},{...e,messages:a}},RB=e=>{let{messages:t}=e;return t[lt(t,e=>e.type===`assistant`)]},zB=(e,t)=>{let n=t.map(e=>({...e,id:Ti(),timestamp:new Date}));return{...e,messages:[...e.messages,...n]}},BB=e=>{let t=lt(e.messages??[],e=>e.type===`assistant`);return t===-1?e:{...e,messages:e.messages.filter((e,n)=>n!==t)}},VB=e=>{let t=[];for(let n of e.messages)n.content&&(n.type===`user`||n.type===`assistant`)&&t.push({role:n.type,content:n.content});return t},HB=()=>{let[e,t]=Yb(IB);return{addUserMessage:e=>{t(t=>zB(t,[{type:`user`,content:e}]))},addAssistantMessage:()=>{t(e=>zB(e,[{type:`assistant`,content:``,isGenerating:!0}]))},setAssistantError:(e,n=`other`,r)=>{let i=r?JSON.stringify({name:r instanceof Error?r.name:`Error`,message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0}):void 0;t(t=>LB(t,{isGenerating:!1,error:e,errorType:n,errorDetails:i}))},chatHistory:e,setChatHistory:t,setLastRetryAttempt:()=>{t(e=>LB(e,{lastAttemptAt:Date.now()}))}}},UB=e=>{let t=e.trim();return t.length<=50?t:`${t.substring(0,47)}...`},WB=Dl([]),GB=Dl(!1),KB=Dl(!1),qB=({persistenceAdapter:e})=>{let[t]=Yb(IB),[n,r]=Yb(WB),[i,a]=Yb(GB),[o,s]=Yb(KB),c=(0,V.useRef)(n);c.current=n;let l=t?.messages[t?.messages.length-1],u=(0,V.useCallback)(async()=>{if(!(o||i)){a(!0);try{let t=await e.loadChats();r(t),s(!0)}catch(e){console.warn(`Failed to load chats:`,e),r([]),s(!0)}finally{a(!1)}}},[o,i,r,a,s,e]);(0,V.useEffect)(()=>{u()},[]);let d=(0,V.useCallback)(async()=>{if(t.messages.length===0)return;let n=t.messages.find(e=>e.type===`user`);if(!n||typeof n.content!=`string`)return;let i=UB(n.content),a=c.current,o=a.find(e=>e.id===t.id),s=!o||o.messages.length!==t.messages.length||o.messages.some((e,n)=>e.id!==t.messages[n]?.id||e.content!==t.messages[n]?.content),l={id:t.id,title:i,messages:t.messages.filter(e=>e.type===`user`||e.type===`assistant`).map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),currentPrompt:t.currentPrompt,timestamp:s?Date.now():o?.timestamp??Date.now()},u=[...a.filter(e=>e.id!==t.id),l].sort((e,t)=>t.timestamp-e.timestamp).slice(0,10);r(u);try{await e.saveChats(u)}catch(e){console.warn(`Failed to save chats:`,e)}},[t,r,e]);return(0,V.useEffect)(()=>{l?.isGenerating||d()},[t.messages?.length,l?.id,l?.isGenerating]),{savedChats:n,saveCurrentChat:d,deleteChat:(0,V.useCallback)(async t=>{let n=c.current.filter(e=>e.id!==t);r(n);try{await e.saveChats(n)}catch(e){console.warn(`Failed to save after delete:`,e)}return n},[r,e]),restoreChat:(0,V.useCallback)(e=>e,[]),createNewChatId:(0,V.useCallback)(async()=>(await d(),Ti()),[d])}},JB=e=>{let t=e.trim();if(!t)return!1;let n=(t.match(/\[/g)||[]).length,r=(t.match(/\]/g)||[]).length,i=(t.match(/\{/g)||[]).length,a=(t.match(/\}/g)||[]).length,o=(t.match(/\(/g)||[]).length,s=(t.match(/\)/g)||[]).length;if(n!==r||i!==a||o!==s)return!1;let c=t.split(`
76
+ `).pop()?.trim()||``;return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(e=>e.test(c))},YB=300,XB=3e3,ZB=100,QB=100,$B=({mermaidToExcalidrawLib:e,canvasRef:t})=>{let[n]=Yb(IB),[,r]=Yb(FB),[i,a]=Yb(PB),o=(0,V.useRef)(!1),s=(0,V.useMemo)(()=>RB(n),[n]),c=(0,V.useRef)(s);(0,V.useEffect)(()=>{c.current=s},[s]);let l=(0,V.useRef)({elements:[],files:null}),u=(0,V.useRef)(0),d=(0,V.useRef)(null),f=(0,V.useRef)(!1),p=(0,V.useRef)(YB),{theme:m}=eT(),h=(0,V.useCallback)(async n=>{if(!n.trim()||!e.loaded||o.current)return!1;o.current=!0;let i=performance.now(),a=await bB({canvasRef:t,data:l,mermaidToExcalidrawLib:e,setError:r,mermaidDefinition:n,theme:m});return performance.now()-i<ZB?p.current=YB:p.current=XB,o.current=!1,a.success},[t,e,r,m]),g=(0,V.useMemo)(()=>{let e=async e=>{let t=Date.now(),n=t-u.current,r=p.current;if(!JB(e)){f.current||=(u.current=Math.max(u.current,t-r+QB),!0),d.current=e;return}if(f.current=!1,n<r){d.current=e;return}d.current=null;let i=await h(e);u.current=Date.now(),i||(u.current=u.current-r+QB,f.current=!0)};return e.flush=async()=>{if(d.current){let e=d.current;d.current=null,await h(e),u.current=Date.now()}},e.cancel=()=>{d.current=null},e},[h]),_=(0,V.useCallback)(()=>{u.current=0,d.current=null,f.current=!1,p.current=YB},[]);return(0,V.useEffect)(()=>{s?.content&&s?.isGenerating?g(s.content):s?.isGenerating||(g.flush(),_(),s?.content&&g(s.content))},[_,g,s?.isGenerating,s?.content]),(0,V.useEffect)(()=>{let e=c.current;!e?.content||e.error||i&&h(e.content)},[n?.id,h,i]),(0,V.useEffect)(()=>{if(n.messages?.filter(e=>e.type===`assistant`).length)i||a(!0);else{let e=t.current;if(e){let t=e.parentElement;t&&(t.style.background=``,e.replaceChildren())}a(!1)}},[n.messages,a,t,i]),{data:l}},eV=3,tV=1e4,nV=({onTextSubmit:e})=>{let[,t]=Yb(FB),[n,r]=Yb(NB),[i,a]=Yb(IB),{addUserMessage:o,addAssistantMessage:s,setAssistantError:c}=HB(),l=(0,V.useRef)(null),u=e=>e.length>tV||e.length<eV||n?.rateLimitRemaining===0?(e.length<eV&&t(Error(G(`chat.errors.promptTooShort`,{min:eV}))),e.length>tV&&t(Error(G(`chat.errors.promptTooLong`,{max:tV}))),!1):!0;return{onGenerate:async({prompt:n,isRepairFlow:d=!1})=>{if(!u(n))return;l.current&&l.current.abort(),t(null);let f=new AbortController;l.current=f,d?a(e=>LB(e,{isGenerating:!0,content:``,error:void 0,errorType:void 0,errorDetails:void 0})):(o(n),s());try{Yw(`ai`,`generate`,`ttd`);let{generatedResponse:o,error:s,rateLimit:l,rateLimitRemaining:u}=await e({messages:[...VB(i).slice(-3),{role:`user`,content:n}],onStreamCreated:()=>{d&&a(e=>LB(e,{content:``,error:``,isGenerating:!0}))},onChunk:e=>{a(t=>LB(t,{content:RB(t).content+e}))},signal:f.signal});if(a(e=>LB(e,{isGenerating:!1})),ee(l)&&ee(u)&&r({rateLimit:l,rateLimitRemaining:u}),(s?.status===429||u===0)&&a(e=>(s?.status===429&&(e=BB(e)),e={...e,messages:e.messages.filter(e=>e.type!==`warning`||e.warningType===`rateLimitExceeded`||e.warningType===`messageLimitExceeded`)},zB(e,[{type:`warning`,warningType:u===0?`messageLimitExceeded`:`rateLimitExceeded`}]))),s){if(s.name===`AbortError`||s.message===`Aborted`||f.signal.aborted)return;let e=Error(s.message||G(`chat.errors.requestFailed`));s.status!==429&&c(e.message,`network`),t(e);return}try{await bl(o??``),Yw(`ai`,`mermaid parse success`,`ttd`)}catch(e){Yw(`ai`,`mermaid parse failed`,`ttd`);let n=Error(e.message||G(`chat.errors.mermaidParseError`));c(n.message,`parse`),t(n)}}catch(e){let n=Error(e.message||G(`chat.errors.generationFailed`));c(n.message,`other`),t(n)}finally{l.current=null}},handleAbort:()=>{l.current&&l.current.abort()}}},rV=({persistenceAdapter:e})=>{let t=Xb(FB),[n,r]=Yb(IB),[i,a]=(0,V.useState)(!1),{restoreChat:o,deleteChat:s,createNewChatId:c}=qB({persistenceAdapter:e}),l=(0,V.useCallback)(e=>{let n=e.messages.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),i={id:e.id,messages:n,currentPrompt:``},a=RB(i);t(a?.error?Error(a?.error):null),r(i)},[t,r]),u=(0,V.useCallback)(async()=>{let e=await c();r({id:e,messages:[],currentPrompt:``}),t(null)},[c,r,t]);return{isMenuOpen:i,onRestoreChat:(0,V.useCallback)(e=>{let t=o(e);l(t),a(!1)},[o,l]),handleDeleteChat:(0,V.useCallback)(async(e,t)=>{t.stopPropagation();let r=e===n.id,i=await s(e);if(r){if(i.length>0){let e=i[0];l(e)}else await u()}},[n.id,s,l,u]),handleNewChat:(0,V.useCallback)(async()=>{await u(),a(!1)},[u]),handleMenuToggle:(0,V.useCallback)(()=>{a(e=>!e)},[]),handleMenuClose:(0,V.useCallback)(()=>{a(!1)},[])}},iV=({isOpen:e,onToggle:t,onClose:n,onNewChat:r,onRestoreChat:i,onDeleteChat:a,isNewChatBtnVisible:o,savedChats:s,activeSessionId:c,disabled:l})=>(0,U.jsxs)(`div`,{className:`ttd-chat-history-menu`,children:[o&&(0,U.jsx)(Tz,{onClick:r,disabled:l,children:G(`chat.newChat`)}),s.length>0&&(0,U.jsx)(`div`,{className:`ttd-dialog-panel__menu-wrapper`,children:(0,U.jsxs)(Q,{open:e,children:[(0,U.jsx)(Q.Trigger,{onToggle:t,className:`ttd-dialog-menu-trigger`,disabled:l,title:G(`chat.menu`),"aria-label":G(`chat.menu`),children:nw}),(0,U.jsx)(Q.Content,{onClickOutside:n,onSelect:n,children:(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsxs)(Q.ItemCustom,{className:H(`ttd-chat-menu-item`,{"ttd-chat-menu-item--active":e.id===c}),onClick:()=>{i(e)},children:[(0,U.jsx)(`span`,{className:`ttd-chat-menu-item__title`,children:e.title}),(0,U.jsx)(`button`,{className:`ttd-chat-menu-item__delete`,onClick:t=>a(e.id,t),title:G(`chat.deleteChat`),"aria-label":G(`chat.deleteChat`),type:`button`,children:Wx})]},e.id))})})]})})]}),aV=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,isMenuOpen:s,onMenuToggle:c,onMenuClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,onViewAsMermaid:x,renderWelcomeScreen:S,renderWarning:C})=>{let[w]=Yb(NB),T=(()=>{let e=[];return w&&e.push({label:G(`chat.rateLimitRemaining`,{count:w.rateLimitRemaining}),variant:`rateLimit`,className:w.rateLimitRemaining<5?`ttd-dialog-panel__rate-limit--danger`:``}),o&&e.push({action:x,label:G(`chat.viewAsMermaid`),icon:(0,U.jsx)(OE,{icon:GC}),variant:`link`}),e})();return(0,U.jsx)(oB,{label:(0,U.jsxs)(`div`,{className:`ttd-dialog-panel__label-wrapper`,children:[(0,U.jsx)(`div`,{className:`ttd-dialog-panel__label-group`}),(0,U.jsx)(`div`,{className:`ttd-dialog-panel__header-right`,children:(0,U.jsx)(iV,{isNewChatBtnVisible:!!t.length,isOpen:s,onToggle:c,onClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,disabled:a})})]}),className:`ttd-dialog-chat-panel`,panelActionJustifyContent:T.length===2?`space-between`:T.length===1&&T[0].variant===`rateLimit`?`flex-start`:`flex-end`,panelActions:T,children:(0,U.jsx)(MB,{chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,rateLimits:w,renderWelcomeScreen:S,renderWarning:C})})},oV=({canvasRef:e,error:t,loaded:n,onInsert:r,hideErrorDetails:i})=>{let a=[{action:r,label:G(`chat.insert`),icon:GC,variant:`button`}];return(0,U.jsx)(oB,{panelActionJustifyContent:`flex-end`,panelActions:a,className:`ttd-dialog-preview-panel`,children:(0,U.jsx)(aB,{canvasRef:e,error:t,loaded:n,hideErrorDetails:i})})},sV=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>{let a=aW(),o=fW(),s=(0,V.useRef)(null),[c,l]=Yb(FB),[u,d]=Yb(IB),f=Zb(PB),{savedChats:p}=qB({persistenceAdapter:i}),m=RB(u),{setLastRetryAttempt:h}=HB(),{data:g}=$B({canvasRef:s,mermaidToExcalidrawLib:e}),{onGenerate:_,handleAbort:v}=nV({onTextSubmit:t}),{isMenuOpen:y,onRestoreChat:b,handleDeleteChat:x,handleNewChat:S,handleMenuToggle:C,handleMenuClose:w}=rV({persistenceAdapter:i});return(0,U.jsxs)(`div`,{className:`ttd-dialog-layout ${f?`ttd-dialog-layout--split`:`ttd-dialog-layout--chat-only`}`,children:[(0,U.jsx)(aV,{chatId:u.id,messages:u.messages,currentPrompt:u.currentPrompt,onPromptChange:e=>{d(t=>({...t,currentPrompt:e}))},onGenerate:_,isGenerating:m?.isGenerating??!1,generatedResponse:m?.content,isMenuOpen:y,onMenuToggle:C,onMenuClose:w,onNewChat:S,onRestoreChat:b,onDeleteChat:x,savedChats:p,activeSessionId:u.id,onAbort:v,onMermaidTabClick:e=>{let t=e.content||``;t&&(xB(t),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},onAiRepairClick:async e=>{let t=e.content||``,n=e.error||``;if(!t)return;let r=`Fix the error in this Mermaid diagram. The diagram is:
77
+
78
+ \`\`\`mermaid
79
+ ${t}
80
+ \`\`\`
81
+
82
+ The exception/error is: ${n}
83
+
84
+ Please fix the Mermaid syntax and regenerate a valid diagram.`;await _({prompt:r,isRepairFlow:!0})},onDeleteMessage:e=>{let t=u.messages.findIndex(t=>t.id===e&&t.type===`assistant`),n=u.messages.slice(0,t-1);d({...u,messages:n})},onInsertMessage:async t=>{let n=t.content||``;if(!n.trim()||!e.loaded)return;let r={current:{elements:[],files:null}};(await bB({canvasRef:s,data:r,mermaidToExcalidrawLib:e,setError:l,mermaidDefinition:n,theme:a.state.theme})).success&&SB({app:a,data:r,text:n,shouldSaveMermaidDataToStorage:!0})},onRetry:async e=>{let t=u.messages.findIndex(t=>t.id===e.id);if(t>0){let e=u.messages[t-1];e.type===`user`&&typeof e.content==`string`&&(h(),await _({prompt:e.content,isRepairFlow:!0}))}},onViewAsMermaid:()=>{typeof m?.content==`string`&&(xB(m.content),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},renderWarning:r,renderWelcomeScreen:n}),f&&(0,U.jsx)(oV,{canvasRef:s,hideErrorDetails:m?.errorType===`parse`,error:c,loaded:e.loaded,onInsert:()=>{SB({app:a,data:g})}})]})},cV=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>(0,U.jsx)(sV,{mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i}),lV=e=>{let t=fW(),n=(0,V.useRef)(null),r=(0,V.useRef)(0);return(0,U.jsx)(eb,{ref:n,className:`ttd-dialog-tabs-root`,value:e.tab,onValueChange:i=>{if(!i)return;let a=n.current?.closest(`.Modal__content`);if(a){let e=a.offsetHeight||0;e>r.current&&(r.current=e,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog===`ttd`&&na([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};lV.displayName=`TTDDialogTabs`;var uV=lV,dV=({children:e,...t})=>(0,U.jsx)(tb,{className:`ttd-dialog-triggers`,...t,children:e});dV.displayName=`TTDDialogTabTriggers`;var fV=({children:e,tab:t,onSelect:n,...r})=>(0,U.jsx)(nb,{value:t,asChild:!0,onSelect:n,children:(0,U.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});fV.displayName=`TTDDialogTabTrigger`;var pV=({tab:e,children:t,...n})=>(0,U.jsx)(rb,{...n,value:e,children:t});pV.displayName=`TTDDialogTab`;var mV=e=>{let t=eT();return t.openDialog?.name===`ttd`?(0,U.jsx)(hV,{...e,tab:t.openDialog.tab}):null};mV.WelcomeMessage=AB;var hV=qR(`TTDDialogBase`,({tab:e,...t})=>{let r=aW(),[i,a]=(0,V.useState)({loaded:!1,api:n(()=>import(`./dist-DPJj-Y3l.js`),[],import.meta.url)});return(0,V.useEffect)(()=>{(async()=>{await i.api,a(e=>({...e,loaded:!0}))})()},[i.api]),(0,U.jsx)(fM,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1520,title:!1,...t,autofocus:!1,children:(0,U.jsxs)(uV,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,U.jsx)(`p`,{className:`dialog-mermaid-title`,children:G(`mermaid.title`)}):(0,U.jsxs)(dV,{children:[(0,U.jsx)(fV,{tab:`text-to-diagram`,children:(0,U.jsxs)(`div`,{className:`ttd-dialog-tab-trigger__content`,children:[G(`labels.textToDiagram`),(0,U.jsx)(`div`,{className:`ttd-dialog-tab-trigger__badge`,children:G(`chat.aiBeta`)})]})}),(0,U.jsx)(fV,{tab:`mermaid`,children:G(`mermaid.label`)})]}),!(`__fallback`in t)&&(0,U.jsx)(pV,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:(0,U.jsx)(cV,{mermaidToExcalidrawLib:i,onTextSubmit:t.onTextSubmit,renderWelcomeScreen:t.renderWelcomeScreen,renderWarning:t.renderWarning,persistenceAdapter:t.persistenceAdapter})}),(0,U.jsx)(pV,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,U.jsx)(kB,{mermaidToExcalidrawLib:i,isActive:e===`mermaid`})})]})})}),gV=.01,_V=10,vV=(e,t)=>!(t===`angle`&&F(e)),yV=(e,t)=>{let n=e+t/2;return n-n%t},bV=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>e.original!==void 0&&e.latest!==void 0),xV=(e,t,n,r,i,a,o=!0)=>{if(bo(n)&&(n.startBinding||n.endBinding)){if(Math.abs(e-n.x)<10&&Math.abs(t-n.y)<10)return;nl(n,`start`,r),nl(n,`end`,r)}let s=r.getNonDeletedElementsMap(),c=s.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=As(L(n.x,n.y),L(l,u),n.angle),p=e-d,m=t-f,[h,g]=As(L(e,t),L(l+p,u+m),-n.angle);r.mutateElement(c,{x:h,y:g},{informMutation:o,isDragging:!1}),le(c,r,i);let _=Sn(n,a);if(_){let e=s.get(_.id);e&&r.mutateElement(e,{x:_.x+p,y:_.y+m},{informMutation:o,isDragging:!1})}if(F(n)){let e=Dn(a,n.id);e.forEach(t=>{let n=s.get(t.id);if(!n)return;let[a,c]=[t.x+t.width/2,t.y+t.height/2],[l,u]=As(L(t.x,t.y),L(a,c),t.angle),d=Math.round(l+p),f=Math.round(u+m),[h,g]=As(L(d,f),L(a+p,c+m),-t.angle);r.mutateElement(n,{x:h,y:g},{informMutation:o,isDragging:!1}),le(n,r,i,{simultaneouslyUpdated:en(e)})})}},SV=(e,t)=>{let n=Mo(t).map(t=>ul(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!Rc(e)).forEach(e=>{n.push({[e.id]:!0})}),n},CV=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1,dragFinishedCallback:d})=>{let f=aW(),p=f.ownerDocument,m=f.ownerWindow,h=fW(),g=(0,V.useRef)(null),_=(0,V.useRef)(null),[v,y]=(0,V.useState)(r.toString()),b=(0,V.useRef)(null);b.current||={originalAppState:ri(l),originalElements:i,lastUpdatedValue:v,updatePending:!1},(0,V.useEffect)(()=>{let e=r.toString();y(e),b.current.lastUpdatedValue=e},[r]);let x=(e,t,i)=>{if(!b.current.updatePending)return!1;b.current.updatePending=!1;let a=Number(e);if(!Number.isFinite(a)){y(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);if(isNaN(u)||Math.abs(l-u)>=gV){b.current.lastUpdatedValue=e;let r=new Map;for(let e of f.scene.getNonDeletedElements())r.set(e.id,Yi(e));n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:!1,scene:c,nextValue:l,property:s,originalAppState:i,setInputValue:e=>y(String(e)),app:f,setAppState:h}),f.syncActionResult({captureUpdate:I.IMMEDIATELY})}},S=(0,V.useRef)({});return S.current.handleInputValue=x,(0,V.useEffect)(()=>{let e=g.current,t=S.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,b.current.originalElements,b.current.originalAppState),m.removeEventListener(P.POINTER_MOVE,t.onPointerMove,!1),m.removeEventListener(P.POINTER_UP,t.onPointerUp,!1)}},[a,m]),a?(0,U.jsxs)(`div`,{className:H(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,U.jsx)(`div`,{className:`drag-input-label`,ref:_,onPointerDown:e=>{if(g.current&&a){p.body.classList.add(`excalidraw-cursor-resize`);let e=Number(g.current.value);isNaN(e)&&(e=0);let t=null,r=f.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Yi(t)),e),new Map),a=i.map(e=>r.get(e.id)),_=ri(l),v=0,b=0,x=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(b+=i,Math.abs(b)>=u&&(b=Math.sign(b)*Math.floor(Math.abs(b)/u),v+=b,n({accumulatedChange:v,instantChange:b,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:_,setInputValue:e=>y(String(e)),app:f,setAppState:h}),b=0))}t={x:e.clientX,y:e.clientY}},C=()=>{m.removeEventListener(P.POINTER_MOVE,x,!1),f.syncActionResult({captureUpdate:I.IMMEDIATELY}),d?.({app:f,setAppState:h,originalElements:a,originalAppState:_}),t=null,v=0,b=0,a=null,r=null,p.body.classList.remove(`excalidraw-cursor-resize`),m.removeEventListener(P.POINTER_UP,C,!1)};S.current.onPointerMove=x,S.current.onPointerUp=C,m.addEventListener(P.POINTER_MOVE,x,!1),m.addEventListener(P.POINTER_UP,C,!1)}},onPointerEnter:()=>{_.current&&(_.current.style.cursor=`ew-resize`)},children:t?(0,U.jsx)(OE,{icon:t}):e}),(0,U.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.currentTarget;t instanceof m.HTMLInputElement&&e.key===z.ENTER&&(x(t.value,i,l),f.focusContainer())}},ref:g,value:v,onChange:e=>{b.current.updatePending=!0,y(e.target.value)},onFocus:e=>{e.target.select(),b.current.originalElements=i,b.current.originalAppState=ri(l)},onBlur:e=>{v?a&&x(e.target.value,b.current.originalElements,b.current.originalAppState):y(r.toString())},disabled:!a})]}):null},wV=15,TV=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i,app:a})=>{let o=i.getNonDeletedElementsMap(),s=t[0];if(s&&!vn(s)){let t=o.get(s.id);if(!t)return;if(r!==void 0){let e=l(r);i.mutateElement(t,{angle:e}),le(t,i,a.state);let n=Sn(t,o);n&&!ir(t)&&i.mutateElement(n,{angle:e});return}let c=(Math.round(Ks(s.angle)*100)/100+Math.round(e))%360;n&&(c=yV(c,wV)),c=c<0?c+360:c;let u=l(c);i.mutateElement(t,{angle:u}),le(t,i,a.state);let d=Sn(t,o);d&&!ir(t)&&i.mutateElement(d,{angle:u})}},EV=({element:e,scene:t,appState:n,property:r})=>(0,U.jsx)(CV,{label:`A`,icon:kC,value:Math.round(Ks(e.angle)%360*100)/100,elements:[e],dragInputCallback:TV,editable:vV(e,`angle`),scene:t,appState:n,property:r}),DV=5,OV=({property:e,scene:t,appState:n,setAppState:r})=>(0,U.jsx)(CV,{label:`Grid step`,sensitivity:8,elements:[],dragInputCallback:({nextValue:e,instantChange:t,shouldChangeByStepSize:n,setInputValue:i})=>{r(r=>{let a;return e?a=e:t&&(a=n?yV(r.gridStep+DV*Math.sign(t),DV):r.gridStep+t),a?(a=Bi(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),kV=10,AV=e=>e.type===`image`,jV=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:o,originalAppState:s,instantChange:c,scene:l,app:u,setAppState:d})=>{let f=l.getNonDeletedElementsMap(),p=t[0],m=f.get(p.id);if(p&&m){let t=r||AV(p),u=p.width/p.height;if(s.croppingElementId===p.id){let e=f.get(p.id);if(!e||!O(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:s,height:u}=$i(e),d=t.naturalWidth/s,m=t.naturalHeight/u,h=r?t.width+t.x:t.naturalWidth-t.x,g=i?t.height+t.y:t.naturalHeight-t.y,_=10*d,v=10*m;if(a!==void 0){if(o===`width`){let e=a*d,i=Vi(e,_,h);n={...n,width:i,x:r?t.x+t.width-i:t.x}}else if(o===`height`){let e=a*m,r=Vi(e,v,g);n={...n,height:r,y:i?t.y+t.height-r:t.y}}l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}let y=o===`width`?c:0,b=o===`height`?c:0,x=Vi(t.width+y,_,h),S=Vi(t.height+b,_,g);n={...t,x:r?t.x+t.width-x:t.x,y:i?t.y+t.height-S:t.y,width:x,height:S},l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}if(a!==void 0){let e=Math.max(o===`width`?a:t?a*u:p.width,1),r=Math.max(o===`height`?a:t?a/u:p.height,1);if(Jc(e,r,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),F(m)){let e=Ra(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()),t=Ct(l.getElementsIncludingDeleted(),e,m);l.replaceAllElements(t)}return}{let r=o===`width`?e:0,a=o===`height`?e:0,c=Math.max(0,p.width+r);o===`width`&&(c=i?yV(c,kV):Math.round(c));let f=Math.max(0,p.height+a);o===`height`&&(f=i?yV(f,kV):Math.round(f)),t&&(o===`width`?f=Math.round(c/u*100)/100:c=Math.round(f*u*100)/100),f=Math.max(1,f),c=Math.max(1,c),Jc(c,f,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),F(m)&&d({elementsToHighlight:en(Ra(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()))})}}},MV=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&F(o)){let n=Ra(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Ct(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},NV=({property:e,element:t,scene:n,appState:r})=>{let i=At(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&O(t)&&t.crop){let{width:n,height:r}=$i(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=At(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=At(t.crop.height*e,2)}}return(0,U.jsx)(CV,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:jV,value:i,editable:vV(t,e),scene:n,appState:r,property:e,dragFinishedCallback:MV})},PV=4,FV=4,IV=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t[0];if(o){let t=a.get(o.id);if(!t||!D(t))return;let s;if(r!==void 0)s=Math.max(Math.round(r),PV);else if(o.type===`text`){let t=Math.round(Zt(o,a));s=Math.max(t+Math.round(e),PV),n&&(s=yV(s,FV))}s&&(i.mutateElement(t,te(t,s,a)),ga(t,i.getContainerElement(t),i))}},LV=({element:e,scene:t,appState:n,property:r})=>{let i=D(e)?e:ke(e)?Sn(e,t.getNonDeletedElementsMap()):null;return i?(0,U.jsx)(CV,{label:`F`,value:Math.round(Zt(i,t.getNonDeletedElementsMap())*10)/10,elements:[i],dragInputCallback:IV,icon:vC,appState:n,scene:t,property:r}):null},RV=15,zV=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a})=>{let o=a.getNonDeletedElementsMap(),s=t.map(e=>o.get(e.id)).filter(e=>e&&!Rc(e)&&vV(e,i)),c=t.filter(e=>!Rc(e)&&vV(e,i));if(r!==void 0){let e=l(r);for(let t of s){if(!t)continue;a.mutateElement(t,{angle:e});let n=Sn(t,o);n&&!ir(t)&&a.mutateElement(n,{angle:e})}a.triggerUpdate();return}for(let t=0;t<s.length;t++){let r=s[t];if(!r)continue;let i=c[t],u=(Math.round(Ks(i.angle)*100)/100+Math.round(e))%360;n&&(u=yV(u,RV)),u=u<0?u+360:u;let d=l(u);a.mutateElement(r,{angle:d});let f=Sn(r,o);f&&!ir(r)&&a.mutateElement(f,{angle:d})}a.triggerUpdate()},BV=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!Rc(e)&&vV(e,`angle`)),a=i.map(e=>Math.round(Ks(e.angle)%360*100)/100),o=new Set(a).size===1?a[0]:`Mixed`,s=i.some(e=>vV(e,`angle`));return(0,U.jsx)(CV,{label:`A`,icon:kC,value:o,elements:e,dragInputCallback:zV,editable:s,appState:n,scene:t,property:r})},VV=10,HV=(e,t,n,r)=>{let i=r.x-e,a=r.y-t,o=r.width*n,s=r.height*n;return{width:o,height:s,x:e+i*n,y:t+a*n,...ps(r,o,s,!1),...D(r)?{fontSize:r.fontSize*n}:{}}},UV=(e,t,n,r,i,a,o,s)=>{let c=s.getNonDeletedElementsMap();if(D(i)&&mo(i,c))return;let l=HV(e,t,r,a);if(s.mutateElement(i,l),x(i)){Xc(i,s,{...kt(i,o,n===`width`?`e`:`s`,{proportional:!0,fromCenter:!1}),anchor:`top`});return}let u=Sn(a,o);if(u){let e=u.fontSize*r;bi(i,s);let t=c.get(u.id);t&&D(t)&&(s.mutateElement(t,{fontSize:e}),ka(i,s,n===`width`?`e`:`s`,!0))}},WV=(e,t,n,r,i,a,o,s,c,l)=>{a===`width`?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let u=t/n;for(let e=0;e<s.length;e++){let t=s[e],n=o[e];UV(i[0],i[1],a,u,n,t,c,l)}},GV=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:o,property:s,setAppState:c,app:l})=>{let u=o.getNonDeletedElementsMap(),d=SV(t,r);if(a!==void 0){for(let e of d){let t=bV(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,c,l,u]=Hc(r),d=l-i,f=u-c,p=d/f;WV(Math.max(1,s===`width`?Math.max(0,a):d),Math.max(1,s===`height`?Math.max(0,a):f),f,p,L(i,c),s,e,r,n,o)}else{let[e]=t,c=e?.latest,l=e?.original;if(c&&l&&vV(c,s)){let e=s===`width`?Math.max(0,a):c.width;s===`width`&&(e=i?yV(e,VV):Math.round(e));let t=s===`height`?Math.max(0,a):c.height;if(s===`height`&&(t=i?yV(t,VV):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Jc(e,t,c,l,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),F(c)){let e=Ra(o.getElementsIncludingDeleted(),c,r,o.getNonDeletedElementsMap()),t=Ct(o.getElementsIncludingDeleted(),e,c);o.replaceAllElements(t)}}}}o.triggerUpdate();return}let f=s===`width`?e:0,p=s===`height`?e:0,m=[];for(let e of d){let t=bV(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,c,l,u]=Hc(r),d=l-a,m=u-c,h=d/m,g=Math.max(0,d+f);s===`width`&&(g=i?yV(g,VV):Math.round(g));let _=Math.max(0,m+p);s===`height`&&(_=i?yV(_,VV):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),WV(g,_,m,h,L(a,c),s,e,r,n,o)}else{let[e]=t,a=e?.latest,c=e?.original;if(a&&c&&vV(a,s)){let e=Math.max(0,c.width+f);s===`width`&&(e=i?yV(e,VV):Math.round(e));let t=Math.max(0,c.height+p);if(s===`height`&&(t=i?yV(t,VV):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Jc(e,t,a,c,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),F(a)){let e=en(Ra(o.getElementsIncludingDeleted(),a,r,o.getNonDeletedElementsMap()));m.push(...e)}}}}c({elementsToHighlight:m}),o.triggerUpdate()},KV=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&F(o)){let n=Ra(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Ct(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},qV=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,V.useMemo)(()=>r.map(t=>{let r=bV(t,n);if(r.length>1){let[t,n,i,a]=Hc(r.map(e=>e.latest));return Math.round((e===`width`?i-t:a-n)*100)/100}let[i]=r;return Math.round((e===`width`?i.latest.width:i.latest.height)*100)/100}),[n,r,e]),s=new Set(o).size===1?Math.round(o[0]*100)/100:`Mixed`,c=o.length>0;return(0,U.jsx)(CV,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:GV,value:s,editable:c,appState:a,property:e,scene:i,dragFinishedCallback:KV})},JV=4,YV=4,XV=(e,t)=>e.reduce((e,n)=>{if(!n||Rc(n))return e;if(D(n))return e.push(n),e;if(ke(n)){let r=Sn(n,t);if(r)return e.push(r),e}return e},[]),ZV=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t.map(e=>a.get(e.id)),s;if(r){s=Math.max(Math.round(r),JV);for(let e of o)i.mutateElement(e,te(e,s,a)),ga(e,i.getContainerElement(e),i);i.triggerUpdate()}else{let r=t;for(let t=0;t<o.length;t++){let s=o[t],c=r[t],l=Math.round(Zt(c,a)),u=Math.max(l+Math.round(e),JV);n&&(u=yV(u,YV)),i.mutateElement(s,te(s,u,a)),ga(s,i.getContainerElement(s),i)}i.triggerUpdate()}},QV=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=XV(e,i);if(!a.length)return null;let o=a.map(e=>Math.round(Zt(e,i)*10)/10),s=new Set(o).size===1?o[0]:`Mixed`,c=o.length>0;return(0,U.jsx)(CV,{label:`F`,icon:vC,elements:a,dragInputCallback:ZV,value:s,editable:c,scene:t,property:r,appState:n})},$V=(e,t,n,r,i,a,o)=>{for(let s=0;s<r.length;s++){let c=r[s],[l,u]=[c.x+c.width/2,c.y+c.height/2],[d,f]=As(L(c.x,c.y),L(l,u),c.angle);xV(e===`x`?Math.round(d+t):d,e===`y`?Math.round(f+n):f,c,a,o,i,!1)}},eH=(e,t,n,r,i,a)=>{let o=i.getNonDeletedElementsMap(),[s,c,,]=Hc(n),l=e-s,u=t-c;for(let e=0;e<n.length;e++){let t=n[e],s=o.get(t.id);if(s&&(!D(s)||!s.containerId)){let[e,n]=[s.x+s.width/2,s.y+s.height/2],[o,c]=As(L(s.x,s.y),L(e,n),s.angle);xV(o+l,c+u,t,i,a,r,!1)}}},tH=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:o,originalAppState:s,app:c})=>{let l=o.getNonDeletedElementsMap();if(i!==void 0){for(let e of SV(t,s)){let t=bV(e,l,n);if(t.length>1){let[e,r,,]=Hc(t.map(e=>e.latest));eH(a===`x`?i:e,a===`y`?i:r,t.map(e=>e.original),n,o,c.state)}else{let e=t[0]?.original,r=t[0]?.latest;if(e&&r&&vV(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,l]=As(L(e.x,e.y),L(t,r),e.angle);xV(a===`x`?i:s,a===`y`?i:l,e,o,c.state,n,!1)}}}o.triggerUpdate();return}let u=r?yV(e,_V):e;$V(a,a===`x`?u:0,a===`y`?u:0,t,n,o,c.state),o.triggerUpdate()},nH=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,V.useMemo)(()=>r.map(t=>{let r=Object.keys(t).map(e=>n.get(e)).filter(e=>e!==void 0);if(r.length>1){let[t,n]=Hc(r);return Math.round((e===`x`?t:n)*100)/100}let[i]=r,[a,o]=[i.x+i.width/2,i.y+i.height/2],[s,c]=As(L(i.x,i.y),L(a,o),i.angle);return Math.round((e===`x`?s:c)*100)/100}),[r,n,e]),s=new Set(o).size===1?o[0]:`Mixed`;return(0,U.jsx)(CV,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:tH,value:s,property:e,scene:i,appState:a})},rH=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:r,shouldChangeByStepSize:i,nextValue:a,property:o,scene:s,originalAppState:c,app:l})=>{let u=s.getNonDeletedElementsMap(),d=n[0],[f,p]=[d.x+d.width/2,d.y+d.height/2],[m,h]=As(L(d.x,d.y),L(f,p),d.angle);if(c.croppingElementId===d.id){let e=u.get(d.id);if(!e||!O(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,c=e.scale[1]===-1,{width:l,height:f}=$i(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/l);r=i?{...n,x:Vi(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:Vi(a*(n.naturalWidth/l),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:Vi(a*(n.naturalHeight/f),0,n.naturalHeight-n.height)}),s.mutateElement(e,{crop:r});return}let p=(o===`x`?t:0)*(i?-1:1),m=(o===`y`?t:0)*(c?-1:1);r={...n,x:Vi(n.x+p,0,n.naturalWidth-n.width),y:Vi(n.y+m,0,n.naturalHeight-n.height)},s.mutateElement(e,{crop:r});return}if(a!==void 0){xV(o===`x`?a:m,o===`y`?a:h,d,s,l.state,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;xV(o===`x`?Math.round(i?yV(d.x+g,_V):m+g):m,o===`y`?Math.round(i?yV(d.y+_,_V):h+_):h,d,s,l.state,r)},iH=({property:e,element:t,scene:n,appState:r})=>{let[i,a]=As(L(t.x,t.y),L(t.x+t.width/2,t.y+t.height/2),t.angle),o=At(e===`x`?i:a,2);if(r.croppingElementId===t.id&&O(t)&&t.crop){let n=fi(t);n&&(o=At(e===`x`?n.x:n.y,2))}return(0,U.jsx)(CV,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:rH,scene:n,value:o,property:e,appState:r})},aH=50,oH=e=>{let t=dW(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=WP(e.app);return(0,U.jsx)(lH,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},sH=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,U.jsx)(`div`,{className:H(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});sH.displayName=`StatsRow`;var cH=({children:e,order:t,style:n,...r})=>(0,U.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});cH.displayName=`StatsRows`,oH.StatsRow=sH,oH.StatsRows=cH;var lH=(0,V.memo)(({app:e,onClose:t,renderCustomStats:n,selectedElements:r,appState:i,sceneNonce:a,gridModeEnabled:o})=>{let s=e.scene,c=s.getNonDeletedElements(),l=s.getNonDeletedElementsMap(),u=fW(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&O(d),m=p?$i(d):null,[h,g]=(0,V.useState)({width:0,height:0}),_=(0,V.useMemo)(()=>(0,Tl.default)(e=>{let t=Hc(e);g({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},aH),[]);(0,V.useEffect)(()=>{_(c)},[a,c,_]),(0,V.useEffect)(()=>()=>_.cancel(),[_]);let v=(0,V.useMemo)(()=>SV(r,i),[r,i]),y=(0,V.useMemo)(()=>cs(r),[r]);return(0,U.jsx)(`div`,{className:`exc-stats`,"data-viewport-ui":`side`,"data-viewport-ui-name":`stats`,children:(0,U.jsxs)(uT,{padding:3,children:[(0,U.jsxs)(`div`,{className:`title`,children:[(0,U.jsx)(`h2`,{children:G(`stats.title`)}),(0,U.jsx)(`div`,{className:`close`,onClick:t,children:PS})]}),(0,U.jsxs)(kE,{label:(0,U.jsx)(`h3`,{children:G(`stats.generalStats`)}),open:!!(i.stats.panels&Xt.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Xt.generalStats}})),children:[(0,U.jsxs)(cH,{children:[(0,U.jsx)(sH,{heading:!0,children:G(`stats.scene`)}),(0,U.jsxs)(sH,{columns:2,children:[(0,U.jsx)(`div`,{children:G(`stats.shapes`)}),(0,U.jsx)(`div`,{children:c.length})]}),(0,U.jsxs)(sH,{columns:2,children:[(0,U.jsx)(`div`,{children:G(`stats.width`)}),(0,U.jsx)(`div`,{children:h.width})]}),(0,U.jsxs)(sH,{columns:2,children:[(0,U.jsx)(`div`,{children:G(`stats.height`)}),(0,U.jsx)(`div`,{children:h.height})]}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(sH,{heading:!0,children:`Canvas`}),(0,U.jsx)(sH,{children:(0,U.jsx)(OV,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!y&&r.length>0&&(0,U.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,U.jsx)(kE,{label:(0,U.jsx)(`h3`,{children:G(`stats.elementProperties`)}),open:!!(i.stats.panels&Xt.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Xt.elementProperties}})),children:(0,U.jsxs)(cH,{children:[d&&(0,U.jsxs)(U.Fragment,{children:[p&&(0,U.jsx)(sH,{heading:!0,children:G(`labels.unCroppedDimension`)}),i.croppingElementId&&O(d)&&m&&(0,U.jsxs)(sH,{columns:2,children:[(0,U.jsx)(`div`,{children:G(`stats.width`)}),(0,U.jsx)(`div`,{children:At(m.width,2)})]}),i.croppingElementId&&O(d)&&m&&(0,U.jsxs)(sH,{columns:2,children:[(0,U.jsx)(`div`,{children:G(`stats.height`)}),(0,U.jsx)(`div`,{children:At(m.height,2)})]}),(0,U.jsx)(sH,{heading:!0,"data-testid":`stats-element-type`,style:{margin:`0.3125rem 0`},children:i.croppingElementId?G(`labels.imageCropping`):G(`element.${d.type}`)}),(0,U.jsx)(sH,{children:(0,U.jsx)(iH,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(iH,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(NV,{property:`width`,element:d,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(NV,{property:`height`,element:d,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(EV,{property:`angle`,element:d,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(LV,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,U.jsxs)(U.Fragment,{children:[Ua(f)&&(0,U.jsx)(sH,{heading:!0,children:G(`element.group`)}),(0,U.jsxs)(sH,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,U.jsx)(`div`,{children:G(`stats.shapes`)}),(0,U.jsx)(`div`,{children:r.length})]}),(0,U.jsx)(sH,{children:(0,U.jsx)(nH,{property:`x`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(nH,{property:`y`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(qV,{property:`width`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(qV,{property:`height`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(BV,{property:`angle`,elements:f,scene:s,appState:i})}),(0,U.jsx)(sH,{children:(0,U.jsx)(QV,{property:`fontSize`,elements:f,scene:s,appState:i,elementsMap:l})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId),uH=({sourceElementId:e,onClose:t,appState:n,scene:r,generateLinkForSelection:i=mi})=>{let a=r.getNonDeletedElementsMap(),o=a.get(e)?.link??null,[s,c]=(0,V.useState)(o),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=Kc(a,n),t=o;if(e.length>0&&i){let r=Ve(e,n);r&&(t=Ee(i(r.id,r.type)))}c(t)},[a,n,n.selectedElementIds,o,i]);let d=(0,V.useCallback)(()=>{if(s&&s!==a.get(e)?.link){let t=a.get(e);t&&r.mutateElement(t,{link:s})}if(!s&&l&&e){let t=a.get(e);t&&r.mutateElement(t,{link:null})}t?.()},[e,s,a,l,r,t]);return(0,V.useEffect)(()=>{let e=e=>{n.openDialog?.name===`elementLinkSelector`&&e.key===z.ENTER&&d(),n.openDialog?.name===`elementLinkSelector`&&e.key===z.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n,t,d]),(0,U.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,U.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,U.jsx)(`h2`,{children:G(`elementLink.title`)}),(0,U.jsx)(`p`,{children:G(`elementLink.desc`)})]}),(0,U.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,U.jsx)(eM,{value:s??``,onChange:e=>{l||u(!0),c(e)},onKeyDown:e=>{e.key===z.ENTER&&d()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),o&&s&&(0,U.jsx)(Y,{type:`button`,title:G(`buttons.remove`),"aria-label":G(`buttons.remove`),label:G(`buttons.remove`),onClick:()=>{c(null),u(!0)},className:`ElementLinkDialog__remove`,icon:Wx})]}),(0,U.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,U.jsx)(sj,{label:G(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,U.jsx)(sj,{label:G(`buttons.confirm`),onClick:d,actionType:`primary`})]})]})},dH=({children:e,onClose:t})=>{let[n,r]=(0,V.useState)(!!e),{container:i}=lW(),a=V.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,U.jsx)(U.Fragment,{children:n&&(0,U.jsx)(fM,{size:`small`,onCloseRequest:a,title:G(`errorDialog.title`),children:(0,U.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},fH=()=>(0,U.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,U.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener`,children:[(0,U.jsx)(`div`,{className:`HelpDialog__link-icon`,children:$x}),G(`helpDialog.documentation`)]}),(0,U.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener`,children:[(0,U.jsx)(`div`,{className:`HelpDialog__link-icon`,children:$x}),G(`helpDialog.blog`)]}),(0,U.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(`div`,{className:`HelpDialog__link-icon`,children:eS}),G(`helpDialog.github`)]}),(0,U.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(`div`,{className:`HelpDialog__link-icon`,children:_w}),`YouTube`]})]}),pH=e=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h3`,{children:e.title}),(0,U.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),mH=e=>(0,U.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,U.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,U.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*hH(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var gH=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),$=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,U.jsx)(_H,{children:gH(e)},e)));return(0,U.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,U.jsx)(`div`,{children:e}),(0,U.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...hH(r,n?G(`helpDialog.or`):``)]})]})},_H=e=>(0,U.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),vH=({onClose:e})=>{let t=pW(),n=V.useCallback(()=>{e&&e()},[e]);return(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(fM,{onCloseRequest:n,title:G(`helpDialog.title`),className:`HelpDialog`,children:[(0,U.jsx)(fH,{}),(0,U.jsxs)(pH,{title:G(`helpDialog.shortcuts`),children:[(0,U.jsxs)(mH,{className:`HelpDialog__island--tools`,caption:G(`helpDialog.tools`),children:[(0,U.jsx)($,{label:G(`toolBar.hand`),shortcuts:[z.H]}),(0,U.jsx)($,{label:G(`toolBar.selection`),shortcuts:[z.V,z[1]]}),(0,U.jsx)($,{label:G(`toolBar.rectangle`),shortcuts:[z.R,z[2]]}),(0,U.jsx)($,{label:G(`toolBar.diamond`),shortcuts:[z.D,z[3]]}),(0,U.jsx)($,{label:G(`toolBar.ellipse`),shortcuts:[z.O,z[4]]}),(0,U.jsx)($,{label:G(`toolBar.arrow`),shortcuts:[z.A,z[5]]}),(0,U.jsx)($,{label:G(`toolBar.line`),shortcuts:[z.L,z[6]]}),(0,U.jsx)($,{label:G(`toolBar.freedraw`),shortcuts:[z.P,z[7]]}),(0,U.jsx)($,{label:G(`toolBar.text`),shortcuts:[z.T,z[8]]}),(0,U.jsx)($,{label:G(`toolBar.stickynote`),shortcuts:[z.N]}),(0,U.jsx)($,{label:G(`toolBar.image`),shortcuts:[z[9]]}),(0,U.jsx)($,{label:G(`toolBar.eraser`),shortcuts:[z.E,z[0]]}),(0,U.jsx)($,{label:G(`toolBar.frame`),shortcuts:[z.F]}),(0,U.jsx)($,{label:G(`toolBar.laser`),shortcuts:[z.K]}),(0,U.jsx)($,{label:G(`toolBar.bucketfill`),shortcuts:[z.B]}),(0,U.jsx)($,{label:G(`labels.eyeDropper`),shortcuts:[z.I,`Shift+S`,`Shift+G`]}),(0,U.jsx)($,{label:G(`helpDialog.editLineArrowPoints`),shortcuts:[Z(`CtrlOrCmd+Enter`)]}),(0,U.jsx)($,{label:G(`helpDialog.editText`),shortcuts:[Z(`Enter`)]}),(0,U.jsx)($,{label:G(`helpDialog.textNewLine`),shortcuts:[Z(`Enter`),Z(`Shift+Enter`)]}),(0,U.jsx)($,{label:G(`helpDialog.textFinish`),shortcuts:[Z(`Esc`),Z(`CtrlOrCmd+Enter`)]}),(0,U.jsx)($,{label:G(`helpDialog.curvedArrow`),shortcuts:[`A`,G(`helpDialog.click`),G(`helpDialog.click`),G(`helpDialog.click`)],isOr:!1}),(0,U.jsx)($,{label:G(`helpDialog.curvedLine`),shortcuts:[`L`,G(`helpDialog.click`),G(`helpDialog.click`),G(`helpDialog.click`)],isOr:!1}),(0,U.jsx)($,{label:G(`helpDialog.cropStart`),shortcuts:[G(`helpDialog.doubleClick`),Z(`Enter`)],isOr:!0}),(0,U.jsx)($,{label:G(`helpDialog.cropFinish`),shortcuts:[Z(`Enter`),Z(`Escape`)],isOr:!0}),(0,U.jsx)($,{label:G(`toolBar.lock`),shortcuts:[z.Q]}),(0,U.jsx)($,{label:G(`helpDialog.preventBinding`),shortcuts:[Z(`CtrlOrCmd`)]}),(0,U.jsx)($,{label:G(`toolBar.link`),shortcuts:[Z(`CtrlOrCmd+K`)]}),(0,U.jsx)($,{label:G(`toolBar.convertElementType`),shortcuts:[`Tab`,`Shift+Tab`],isOr:!0})]}),(0,U.jsxs)(mH,{className:`HelpDialog__island--view`,caption:G(`helpDialog.view`),children:[(0,U.jsx)($,{label:G(`buttons.zoomIn`),shortcuts:[Z(`CtrlOrCmd++`)]}),(0,U.jsx)($,{label:G(`buttons.zoomOut`),shortcuts:[Z(`CtrlOrCmd+-`)]}),(0,U.jsx)($,{label:G(`buttons.resetZoom`),shortcuts:[Z(`CtrlOrCmd+0`)]}),(0,U.jsx)($,{label:G(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,U.jsx)($,{label:G(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,U.jsx)($,{label:G(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,U.jsx)($,{label:G(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,U.jsx)($,{label:G(`buttons.zenMode`),shortcuts:[Z(`Alt+Z`)]}),(0,U.jsx)($,{label:G(`buttons.objectsSnapMode`),shortcuts:[Z(`Alt+S`)]}),(0,U.jsx)($,{label:G(`labels.toggleGrid`),shortcuts:[Z(`CtrlOrCmd+'`)]}),(0,U.jsx)($,{label:G(`labels.viewMode`),shortcuts:[Z(`Alt+R`)]}),t.isActionEnabled(CD)&&(0,U.jsx)($,{label:G(`labels.toggleTheme`),shortcuts:[Z(`Alt+Shift+D`)]}),(0,U.jsx)($,{label:G(`stats.fullTitle`),shortcuts:[Z(`Alt+/`)]}),(0,U.jsx)($,{label:G(`search.title`),shortcuts:[wA(`searchMenu`)]}),(0,U.jsx)($,{label:G(`commandPalette.title`),shortcuts:Xi?[wA(`commandPalette`)]:[wA(`commandPalette`),wA(`commandPalette`,1)]})]}),(0,U.jsxs)(mH,{className:`HelpDialog__island--editor`,caption:G(`helpDialog.editor`),children:[(0,U.jsx)($,{label:G(`helpDialog.createFlowchart`),shortcuts:[Z(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,U.jsx)($,{label:G(`helpDialog.navigateFlowchart`),shortcuts:[Z(`Alt+Arrow Key`)],isOr:!0}),(0,U.jsx)($,{label:G(`labels.moveCanvas`),shortcuts:[Z(`Space+${G(`helpDialog.drag`)}`),Z(`Wheel+${G(`helpDialog.drag`)}`)],isOr:!0}),(0,U.jsx)($,{label:G(`buttons.clearReset`),shortcuts:[Z(`CtrlOrCmd+Delete`)]}),(0,U.jsx)($,{label:G(`labels.delete`),shortcuts:[Z(`Delete`)]}),(0,U.jsx)($,{label:G(`labels.cut`),shortcuts:[Z(`CtrlOrCmd+X`)]}),(0,U.jsx)($,{label:G(`labels.copy`),shortcuts:[Z(`CtrlOrCmd+C`)]}),(0,U.jsx)($,{label:G(`labels.paste`),shortcuts:[Z(`CtrlOrCmd+V`)]}),(0,U.jsx)($,{label:G(`labels.pasteAsPlaintext`),shortcuts:[Z(`CtrlOrCmd+Shift+V`)]}),(0,U.jsx)($,{label:G(`labels.selectAll`),shortcuts:[Z(`CtrlOrCmd+A`)]}),(0,U.jsx)($,{label:G(`labels.multiSelect`),shortcuts:[Z(`Shift+${G(`helpDialog.click`)}`)]}),(0,U.jsx)($,{label:G(`helpDialog.deepSelect`),shortcuts:[Z(`CtrlOrCmd+${G(`helpDialog.click`)}`)]}),(0,U.jsx)($,{label:G(`helpDialog.deepBoxSelect`),shortcuts:[Z(`CtrlOrCmd+${G(`helpDialog.drag`)}`)]}),(iO||Xi)&&(0,U.jsx)($,{label:G(`labels.copyAsPng`),shortcuts:[Z(`Shift+Alt+C`)]}),(0,U.jsx)($,{label:G(`labels.copyStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+C`)]}),(0,U.jsx)($,{label:G(`labels.pasteStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+V`)]}),(0,U.jsx)($,{label:G(`labels.sendToBack`),shortcuts:[Z(Jo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,U.jsx)($,{label:G(`labels.bringToFront`),shortcuts:[Z(Jo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,U.jsx)($,{label:G(`labels.sendBackward`),shortcuts:[Z(`CtrlOrCmd+[`)]}),(0,U.jsx)($,{label:G(`labels.bringForward`),shortcuts:[Z(`CtrlOrCmd+]`)]}),(0,U.jsx)($,{label:G(`labels.alignTop`),shortcuts:[Z(`CtrlOrCmd+Shift+Up`)]}),(0,U.jsx)($,{label:G(`labels.alignBottom`),shortcuts:[Z(`CtrlOrCmd+Shift+Down`)]}),(0,U.jsx)($,{label:G(`labels.alignLeft`),shortcuts:[Z(`CtrlOrCmd+Shift+Left`)]}),(0,U.jsx)($,{label:G(`labels.alignRight`),shortcuts:[Z(`CtrlOrCmd+Shift+Right`)]}),(0,U.jsx)($,{label:G(`labels.duplicateSelection`),shortcuts:[Z(`CtrlOrCmd+D`),Z(`Alt+${G(`helpDialog.drag`)}`)]}),(0,U.jsx)($,{label:G(`helpDialog.toggleElementLock`),shortcuts:[Z(`CtrlOrCmd+Shift+L`)]}),(0,U.jsx)($,{label:G(`buttons.undo`),shortcuts:[Z(`CtrlOrCmd+Z`)]}),(0,U.jsx)($,{label:G(`buttons.redo`),shortcuts:Wt?[Z(`CtrlOrCmd+Y`),Z(`CtrlOrCmd+Shift+Z`)]:[Z(`CtrlOrCmd+Shift+Z`)]}),(0,U.jsx)($,{label:G(`labels.group`),shortcuts:[Z(`CtrlOrCmd+G`)]}),(0,U.jsx)($,{label:G(`labels.ungroup`),shortcuts:[Z(`CtrlOrCmd+Shift+G`)]}),(0,U.jsx)($,{label:G(`labels.flipHorizontal`),shortcuts:[Z(`Shift+H`)]}),(0,U.jsx)($,{label:G(`labels.flipVertical`),shortcuts:[Z(`Shift+V`)]}),(0,U.jsx)($,{label:G(`labels.showStroke`),shortcuts:[Z(`S`)]}),(0,U.jsx)($,{label:G(`labels.showBackground`),shortcuts:[Z(`G`)]}),(0,U.jsx)($,{label:G(`labels.showFonts`),shortcuts:[Z(`Shift+F`)]}),(0,U.jsx)($,{label:G(`labels.decreaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+<`)]}),(0,U.jsx)($,{label:G(`labels.increaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+>`)]})]})]})]})})},yH=2e3,bH=()=>{let[e,t]=(0,V.useState)(null),n=(0,V.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,V.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},yH)}}},xH=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,U.jsx)(`div`,{className:H(`Switch`,{toggled:n,disabled:i}),children:(0,U.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),SH=()=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{children:G(`canvasError.cannotShowPreview`)}),(0,U.jsx)(`p`,{children:(0,U.jsx)(`span`,{children:G(`canvasError.canvasTooBig`)})}),(0,U.jsxs)(`em`,{children:[`(`,G(`canvasError.canvasTooBigTip`),`)`]})]}),CH=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a,exportWithDarkMode:o})=>{let s=Gt(t,e),[c,l]=(0,V.useState)(a),[u,d]=(0,V.useState)(s),[f,p]=(0,V.useState)(e.exportBackground),[m,h]=(0,V.useState)(e.exportEmbedScene),[g,_]=(0,V.useState)(e.exportScale),v=(0,V.useRef)(null),y=(0,V.useRef)(0),[b,x]=(0,V.useState)(null),{onCopy:S,copyStatus:C,resetCopyStatus:w}=bH();(0,V.useEffect)(()=>{w()},[c,f,o,g,m,w]);let{exportedElements:T,exportingFrame:E}=CO(t,e,u);return(0,V.useEffect)(()=>{let t=v.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;if(!r)return;let a=++y.current,s=()=>a!==y.current;return AA({elements:T,appState:{...e,name:c,exportBackground:f,exportWithDarkMode:o,exportScale:g,exportEmbedScene:m},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:E}).then(async e=>{if(!s()){try{await sr(e)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(G(`canvasError.canvasTooBig`)):e}s()||(x(null),t.replaceChildren(e))}}).catch(e=>{s()||(console.error(e),x(e))}),()=>{y.current+=1}},[e,n,T,E,c,f,o,g,m]),(0,U.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,U.jsx)(`h3`,{children:G(`imageExportDialog.header`)}),(0,U.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,U.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:v,children:b&&(0,U.jsx)(SH,{})}),(0,U.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!va&&(0,U.jsx)(`input`,{type:`text`,className:`TextInput`,value:c,style:{width:`30ch`},onChange:e=>{l(e.target.value),r.executeAction(EO,`ui`,e.target.value)}})})]}),(0,U.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,U.jsx)(`h3`,{children:G(`imageExportDialog.header`)}),s&&(0,U.jsx)(wH,{label:G(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,U.jsx)(xH,{name:`exportOnlySelected`,checked:u,onChange:e=>{d(e)}})}),(0,U.jsx)(wH,{label:G(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,U.jsx)(xH,{name:`exportBackgroundSwitch`,checked:f,onChange:e=>{p(e),r.executeAction(OO,`ui`,e)}})}),(0,U.jsx)(wH,{label:G(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,U.jsx)(xH,{name:`exportDarkModeSwitch`,checked:o,onChange:e=>{r.executeAction(LO,`ui`,e)}})}),(0,U.jsx)(wH,{label:G(`imageExportDialog.label.embedScene`),tooltip:G(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,U.jsx)(xH,{name:`exportEmbedSwitch`,checked:m,onChange:e=>{h(e),r.executeAction(kO,`ui`,e)}})}),(0,U.jsx)(wH,{label:G(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,U.jsx)(ZR,{name:`exportScale`,value:g,onChange:e=>{_(e),r.executeAction(DO,`ui`,e)},choices:Gc.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,U.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,U.jsx)(Tz,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.exportToPng`),onClick:()=>i(oa.png,T,{exportingFrame:E}),icon:MC,children:G(`imageExportDialog.button.exportToPng`)}),(0,U.jsx)(Tz,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.exportToSvg`),onClick:()=>i(oa.svg,T,{exportingFrame:E}),icon:MC,children:G(`imageExportDialog.button.exportToSvg`)}),(iO||Xi)&&(0,U.jsx)(Tz,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.copyPngToClipboard`),status:C,onClick:async()=>{await i(oa.clipboard,T,{exportingFrame:E}),S()},icon:NC,children:G(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},wH=({label:e,children:t,tooltip:n,name:r})=>(0,U.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,U.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,U.jsx)(pD,{label:n,long:!0,children:FC})]}),(0,U.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),TH=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,V.useState)(()=>({appStateSnapshot:ri(t),elementsSnapshot:ri(e)}));return(0,U.jsx)(fM,{onCloseRequest:a,size:`wide`,title:!1,children:(0,U.jsx)(CH,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o,exportWithDarkMode:t.exportWithDarkMode})})},EH={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`}},DH=({children:e,color:t})=>(0,U.jsx)(`div`,{className:`Card`,style:{"--card-color":EH[t].base,"--card-color-darker":EH[t].darker,"--card-color-darkest":EH[t].darkest},children:e}),OH=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,U.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,U.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,U.jsxs)(DH,{color:`lime`,children:[(0,U.jsx)(`div`,{className:`Card-icon`,children:fS}),(0,U.jsx)(`h2`,{children:G(`exportDialog.disk_title`)}),(0,U.jsxs)(`div`,{className:`Card-details`,children:[G(`exportDialog.disk_details`),!va&&i.renderAction(`changeProjectName`)]}),(0,U.jsx)(Y,{className:`Card-button`,type:`button`,title:G(`exportDialog.disk_button`),"aria-label":G(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(FO,`ui`)}})]}),c&&(0,U.jsxs)(DH,{color:`pink`,children:[(0,U.jsx)(`div`,{className:`Card-icon`,children:iS}),(0,U.jsx)(`h2`,{children:G(`exportDialog.link_title`)}),(0,U.jsx)(`div`,{className:`Card-details`,children:G(`exportDialog.link_details`)}),(0,U.jsx)(Y,{className:`Card-button`,type:`button`,title:G(`exportDialog.link_button`),"aria-label":G(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{Yw(`export`,`link`,`ui (${Fo()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},kH=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=V.useCallback(()=>{o({openDialog:null})},[o]);return(0,U.jsx)(U.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,U.jsx)(fM,{onCloseRequest:s,title:G(`buttons.export`),children:(0,U.jsx)(OH,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},AH=e=>(0,U.jsx)(Y,{className:H(`ToolIcon__LaserPointer`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:qC,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":`toolbar-LaserPointer`,onSelect:()=>e.onChange?.()}),jH=e=>Array.isArray(e)?`<kbd>${e.map(Z).join(` + `)}</kbd>`:`<kbd>${Z(e)}</kbd>`,MH=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let{activeTool:i,isResizing:a,isRotating:o,lastPointerDownWith:s}=e,c=e.multiElement!==null;if(e.openSidebar?.name===Vr.name&&e.openSidebar.tab===`search`&&e.searchMatches?.matches.length)return G(`hints.dismissSearch`,{shortcut:jH(`Escape`)});if(e.openSidebar&&!n.canFitSidebar)return null;if(wc(e))return G(`hints.eraserRevert`,{shortcut:jH(`Alt`)});let l=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&l[0]?.type===`arrow`)return G(`hints.arrowBindModifiers`,{shortcut_1:jH(`Ctrl`),shortcut_2:jH(`Alt`)});if(i.type===`arrow`||i.type===`line`)return c?G(`hints.linearElementMulti`,{shortcut_1:jH(`Escape`),shortcut_2:jH(`Enter`)}):i.type===`arrow`?G(`hints.arrowTool`,{shortcut:jH(`A`)}):G(`hints.linearElement`);if(i.type===`freedraw`)return G(`hints.freeDraw`);if(i.type===`text`)return G(`hints.text`);if(i.type===`embeddable`)return G(`hints.embeddable`);if(i.type===`stickynote`)return G(`hints.stickynote`);if(i.type===`autoshape`)return G(`hints.autoshape`);if(a&&s===`mouse`&&l.length===1){let e=l[0];return ja(e)&&e.points.length===2?G(`hints.lockAngle`,{shortcut:jH(`Shift`)}):x(e)&&r.activeResizeHandle?.length===2?G(`hints.resizeStickyNote`,{shortcut_1:jH(`Shift`),shortcut_2:jH(`Alt`)}):O(e)?G(`hints.resizeImage`,{shortcut_1:jH(`Shift`),shortcut_2:jH(`Alt`)}):G(`hints.resize`,{shortcut_1:jH(`Shift`),shortcut_2:jH(`Alt`)})}if(o&&s===`mouse`)return G(`hints.rotate`,{shortcut:jH(`Shift`)});if(l.length===1&&D(l[0]))return G(`hints.text_selected`,{shortcut:jH(`Enter`)});if(e.editingTextElement)return G(`hints.text_editing`,{shortcut_1:jH(`Escape`),shortcut_2:jH([`CtrlOrCmd`,`Enter`])});if(e.croppingElementId)return G(`hints.leaveCropEditor`,{shortcut_1:jH(`Enter`),shortcut_2:jH(`Escape`)});if(l.length===1&&O(l[0]))return G(`hints.enterCropEditor`,{shortcut:jH(`Enter`)});if(i.type===`selection`){if(e.selectionElement&&!l.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return G(`hints.deepBoxSelect`,{shortcut:jH(`CtrlOrCmd`)});if(WP(r)&&e.selectedElementsAreBeingDragged)return G(`hints.disableSnapping`,{shortcut:jH(`CtrlOrCmd`)});if(!l.length&&!t)return G(`hints.canvasPanning`,{shortcut_1:jH(G(`keys.mmb`)),shortcut_2:jH(`Space`)});if(l.length===1){if(ja(l[0]))return ir(l[0])&&e.selectedLinearElement?.elementId===l[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===l[0].points.length-1)?G(`hints.toggleArrowhead`):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?G(`hints.lineEditor_pointSelected`,{shortcut_1:jH(`Delete`),shortcut_2:jH([`CtrlOrCmd`,`D`])}):G(`hints.lineEditor_nothingSelected`,{shortcut_1:jH(`Shift`),shortcut_2:jH(`Alt`)}):co(l[0])?G(`hints.lineEditor_line_info`,{shortcut:jH(`Enter`)}):G(`hints.lineEditor_info`,{shortcut_1:jH(`CtrlOrCmd`),shortcut_2:jH([`CtrlOrCmd`,`Enter`])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&ve(l[0])){let e=G(`hints.bindTextToElement`,{shortcut:jH(`Enter`)}),t=G(`hints.createFlowchart`,{shortcut:jH([`CtrlOrCmd`,`↑↓`])});return ya(l[0])?(_r(l[0],r.scene.getNonDeletedElementsMap()),[e,t]):e}}}return null},NH=({appState:e,isMobile:t,editorInterface:n,app:r})=>{if(!e.showHints)return null;let i=MH({appState:e,isMobile:t,editorInterface:n,app:r});if(!i)return null;let a=(Array.isArray(i)?i.map(e=>e.replace(/\. ?$/,``)).join(`, `):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((e,t)=>{if(t%2==1){let n=e[0]===`<`&&e.match(/^<kbd>([^<]+)<\/kbd>$/);return(0,U.jsx)(`kbd`,{children:n?n[1]:e},t)}return e});return(0,U.jsx)(`div`,{className:`HintViewer`,children:(0,U.jsx)(`span`,{children:a})})},PH=e=>(0,U.jsx)(Y,{className:H(`ToolIcon__lock`,{"is-mobile":e.isMobile}),type:`toggle`,icon:e.checked?Cx:Sx,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":`toolbar-lock`,onSelect:()=>e.onChange?.()}),FH=({app:e,activeTool:t,setAppState:n,UIOptions:r})=>{let[i,a]=(0,V.useState)(!1),o=cW()===`full`,{TTDDialogTriggerTunnel:s}=pR(),c=t.type===`image`,l=t.type===`frame`,u=t.type===`autoshape`,d=t.type===`laser`,f=t.type===`bucketfill`,p=o&&t.type===`lasso`&&e.state.preferredSelectionTool.type!==`lasso`,m=t.type===`embeddable`;return(0,U.jsxs)(Q,{open:i,children:[(0,U.jsx)(Q.Trigger,{className:H(`App-toolbar__extra-tools-trigger`,{"App-toolbar__extra-tools-trigger--selected":c||l||m||o&&u||p||f||d&&!e.props.isCollaborating}),onToggle:()=>{a(!i),n({openMenu:null,openPopup:null})},title:G(`toolBar.extraTools`),children:c?zx:l?BC:m?Gx:o&&u?KC:d&&!e.props.isCollaborating?qC:p?kx:f?lS:vx}),(0,U.jsxs)(Q.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:`App-toolbar__extra-tools-dropdown`,children:[r.tools?.image!==!1&&(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:zx,shortcut:z[9],"data-testid":`toolbar-image`,selected:c,disabled:AD(e,`image`),children:G(`toolBar.image`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:BC,shortcut:z.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:AD(e,`frame`),children:G(`toolBar.frame`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:Gx,"data-testid":`toolbar-embeddable`,selected:m,disabled:AD(e,`embeddable`),children:G(`toolBar.embeddable`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:KC,shortcut:OD(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:AD(e,`autoshape`),children:G(`toolBar.autoshape`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:qC,"data-testid":`toolbar-laser`,selected:d,shortcut:z.K.toLocaleUpperCase(),disabled:AD(e,`laser`),children:G(`toolBar.laser`)}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:lS,"data-testid":`toolbar-bucketfill`,selected:f,shortcut:z.B.toLocaleUpperCase(),disabled:AD(e,`bucketfill`),children:G(`toolBar.bucketfill`)}),o&&(0,U.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`lasso`}),icon:kx,"data-testid":`toolbar-lasso`,selected:p,disabled:AD(e,`lasso`),children:G(`toolBar.lasso`)}),(0,U.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,U.jsx)(s.Out,{}),(0,U.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:HC,"data-testid":`toolbar-embeddable`,children:G(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,U.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:JC,"data-testid":`toolbar-magicframe`,badge:(0,U.jsx)(Q.Item.Badge,{children:`AI`}),disabled:AD(e,`magicframe`),children:G(`toolBar.magicframe`)})]})]})},IH=({app:e,appState:t,setAppState:n,UIOptions:r,onPenModeToggle:i,onLockToggle:a,heading:o})=>{let s=sW(),c=cW()===`compact`,l=t.activeTool,u={app:e,activeTool:l};return(0,U.jsxs)(uT,{padding:1,className:H(`App-toolbar`,{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":`top`,children:[(0,U.jsx)(NH,{appState:t,isMobile:s.formFactor===`phone`,editorInterface:s,app:e}),o,(0,U.jsxs)(yj.Row,{gap:c?.5:1,children:[!c&&(0,U.jsx)(yR,{checked:t.penMode,onChange:()=>i(null),title:G(`toolBar.penMode`),penDetected:t.penDetected}),e.props.activeTool==null&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(PH,{checked:t.activeTool.locked,onChange:a,title:G(`toolBar.lock`),disabled:e.props.activeTool!=null}),(0,U.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginRight:`0.25rem`}})]}),(0,U.jsx)(MD,{...u,hideKeyBinding:!0}),c?(0,U.jsx)(KD,{...u,setAppState:n}):t.preferredSelectionTool.type===`lasso`?(0,U.jsx)(GD,{...u}):(0,U.jsx)(WD,{...u}),(0,U.jsx)(ND,{...u}),(0,U.jsx)(PD,{...u}),(0,U.jsx)(FD,{...u}),(0,U.jsx)(ID,{...u}),(0,U.jsx)(LD,{...u}),c?(0,U.jsx)(qD,{...u}):(0,U.jsx)(RD,{...u}),(0,U.jsx)(zD,{...u}),(0,U.jsx)(BD,{...u}),(0,U.jsx)(HD,{...u}),(0,U.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginLeft:`0.25rem`}}),(0,U.jsx)(FH,{app:e,activeTool:l,setAppState:n,UIOptions:r})]})]})},LH=({UIOptions:e})=>(0,U.jsxs)(wz,{__fallback:!0,children:[(0,U.jsx)(wz.DefaultItems.LoadScene,{}),(0,U.jsx)(wz.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,U.jsx)(wz.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,U.jsx)(wz.DefaultItems.SaveAsImage,{}),(0,U.jsx)(wz.DefaultItems.SearchMenu,{}),(0,U.jsx)(wz.DefaultItems.Help,{}),(0,U.jsx)(wz.DefaultItems.ClearCanvas,{}),(0,U.jsx)(wz.Separator,{}),(0,U.jsx)(wz.Group,{title:`Excalidraw links`,children:(0,U.jsx)(wz.DefaultItems.Socials,{})}),(0,U.jsx)(wz.Separator,{}),(0,U.jsx)(wz.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),(0,U.jsx)(wz.DefaultItems.ChangeCanvasBackground,{})]}),RH=()=>(0,U.jsxs)(Oz,{__fallback:!0,children:[(0,U.jsx)(Oz.Actions.SaveToDisk,{}),(0,U.jsx)(Oz.Actions.ExportToImage,{})]}),zH=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:a,onLockToggle:o,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:l,renderTopRightUI:u,renderCustomStats:d,UIOptions:f,onExportImage:p,renderWelcomeScreen:m,children:h,app:g,defaultUIEnabled:_,zoomUIEnabled:v,scrollBackToContentUIEnabled:b,isCollaborating:x,generateLinkForSelection:S,currentUserControls:C})=>{let w=sW(),T=oW(),E=cW()===`compact`,D=hR(),ee=E?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},O=D.tunnelsJotai.Provider,[k,te]=Yb(cT),A=()=>f.canvasActions.export?(0,U.jsx)(kH,{elements:i,appState:t,files:n,actionManager:e,exportOpts:f.canvasActions.export,canvas:a,setAppState:r}):null,j=()=>!f.canvasActions.saveAsImage||t.openDialog?.name!==`imageExport`?null:(0,U.jsx)(TH,{elements:i,appState:t,files:n,actionManager:e,onExportImage:p,onCloseRequest:()=>r({openDialog:null}),name:g.getName()}),ne=()=>(0,U.jsxs)(`div`,{style:{position:`relative`},children:[(0,U.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[l?.(!1,t),(0,U.jsx)(D.MainMenuTunnel.Out,{})]}),m&&(0,U.jsx)(D.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>(0,U.jsx)(TR,{heading:`selectedShapeActions`,className:H(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:E?(0,U.jsx)(uT,{className:H(`compact-shape-actions-island`),padding:0,"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,style:{maxHeight:`${t.height-166}px`},children:(0,U.jsx)(EM,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g,setAppState:r})}):(0,U.jsx)(uT,{className:hn.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,children:(0,U.jsx)(bM,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g})})}),ie=()=>{let n=_&&Kn(t,i),a=_&&t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,U.jsx)(vR,{side:`top`,children:(0,U.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,U.jsxs)(yj.Col,{gap:ee.menuTopGap,className:H(`App-menu_top__left`),children:[ne(),_&&(0,U.jsx)(`div`,{className:H(`selected-shape-actions-container`,{"selected-shape-actions-container--compact":E}),children:n&&re()}),_&&E&&!t.viewModeEnabled&&n&&(0,U.jsx)(yR,{checked:t.penMode,onChange:()=>s(null),title:G(`toolBar.penMode`),isMobile:!0,penDetected:t.penDetected})]}),_&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,U.jsx)(TR,{heading:`shapes`,className:`shapes-section`,children:e=>(0,U.jsxs)(`div`,{style:{position:`relative`},children:[m&&(0,U.jsx)(D.WelcomeScreenToolbarHintTunnel.Out,{}),(0,U.jsx)(yj.Col,{gap:ee.toolbarColGap,align:`start`,children:(0,U.jsxs)(yj.Row,{gap:ee.toolbarRowGap,className:H(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,U.jsx)(IH,{app:g,appState:t,setAppState:r,UIOptions:f,onPenModeToggle:s,onLockToggle:o,heading:e}),x&&(0,U.jsx)(uT,{style:{marginLeft:ee.collabMarginLeft,alignSelf:`center`,height:`fit-content`},children:(0,U.jsx)(AH,{title:G(`toolBar.laser`),checked:t.activeTool.type===Ys.laser,onChange:()=>g.setActiveTool({type:Ys.laser}),isMobile:!0})})]})})]})}),(0,U.jsxs)(`div`,{className:H(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":E}),children:[_&&t.collaborators.size>0&&(0,U.jsx)(NR,{collaborators:t.collaborators,userToFollow:T.userToFollow?.socketId||null,currentUserControls:C}),u?.(w.formFactor===`phone`,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!oe||t.openSidebar?.name!==Vr.name)&&(0,U.jsx)(D.DefaultSidebarTriggerTunnel.Out,{}),a&&(0,U.jsx)(oH,{app:g,onClose:()=>{e.executeAction(yk)},renderCustomStats:d})]})]})})},ae=()=>_?(0,U.jsx)(Uz,{__fallback:!0,onDock:e=>{Yw(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${w.formFactor===`phone`?`mobile`:`desktop`})`)}}):null,oe=Zb(WR),se=!!(t.openSidebar&&oe&&w.canFitSidebar),ce=(0,U.jsxs)(U.Fragment,{children:[h,_&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(LH,{UIOptions:f}),(0,U.jsx)(Uz.Trigger,{__fallback:!0,icon:jw,title:vt(G(`toolBar.library`)),onToggle:e=>{e&&Yw(`sidebar`,`${Vr.name} (open)`,`button (${w.formFactor===`phone`?`mobile`:`desktop`})`)},tab:Vr.defaultTab})]}),(0,U.jsx)(RH,{}),t.openDialog?.name===`ttd`&&(0,U.jsx)(mV,{__fallback:!0}),_&&t.isLoading&&(0,U.jsx)(gR,{delay:250}),_&&t.errorMessage&&(0,U.jsx)(dH,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),_&&k&&w.formFactor!==`phone`&&(0,U.jsx)(lT,{colorPickerType:k.colorPickerType,onCancel:()=>{te(null)},onChange:(e,n,a,{altKey:o})=>{if(e!==`elementBackground`&&e!==`elementStroke`)return;let s=o&&k.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`;if(a.length){let e=y(i),r=Kc(i,t,{includeBoundTextElement:s===`strokeColor`});for(let t of r)oo(t,e,Wr(t,s,n,e)),wa.delete(t);g.scene.triggerUpdate()}else r(WE(UE(t,i,s),n))},onSelect:(e,t)=>{te(e=>e?.keepOpenOnAlt&&t.altKey?e:null),k?.onSelect?.(e,t)}}),t.openDialog?.name===`help`&&(0,U.jsx)(vH,{onClose:()=>{r({openDialog:null})}}),(0,U.jsx)(PM,{}),_&&t.openDialog?.name===`elementLinkSelector`&&(0,U.jsx)(uH,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:g.scene,appState:t,generateLinkForSelection:S}),(0,U.jsx)(D.OverwriteConfirmDialogTunnel.Out,{}),j(),A(),_&&t.openDialog?.name===`charts`&&(0,U.jsx)(wR,{data:t.openDialog.data,rawText:t.openDialog.rawText,onClose:()=>r({openDialog:null})}),w.formFactor===`phone`&&(0,U.jsx)(bR,{app:g,appState:t,elements:i,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:j,setAppState:r,onPenModeToggle:s,renderTopLeftUI:l,renderTopRightUI:u,renderSidebars:ae,renderWelcomeScreen:m,defaultUIEnabled:_,scrollBackToContentUIEnabled:b}),w.formFactor!==`phone`&&(0,U.jsxs)(U.Fragment,{children:[T.viewportStatusFrame?.border&&(0,U.jsx)(uR,{border:T.viewportStatusFrame.border,style:se?{right:`calc(var(--right-sidebar-width) - var(--space-factor) * 2)`}:void 0}),(0,U.jsxs)(`div`,{className:`layer-ui__wrapper`,style:se?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[m&&(0,U.jsx)(D.WelcomeScreenCenterTunnel.Out,{}),ie(),(0,U.jsx)(IR,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:m,defaultUIEnabled:_,zoomUIEnabled:v}),(t.toast||b&&t.scrolledOutside||T.viewportStatusFrame?.label)&&(0,U.jsxs)(`div`,{className:`floating-status-stack`,children:[t.toast&&(0,U.jsx)(nO,{message:t.toast.message,onClose:()=>r({toast:null}),duration:t.toast.duration,closable:t.toast.closable}),!t.toast&&b&&t.scrolledOutside&&(0,U.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Ka(i,e)}))},children:G(`buttons.scrollBackToContent`)}),T.viewportStatusFrame?.label&&(0,U.jsx)(dR,{label:T.viewportStatusFrame.label,border:T.viewportStatusFrame.border})]})]}),ae()]})]});return(0,U.jsx)($w.Provider,{value:t,children:(0,U.jsx)(O,{children:(0,U.jsx)(fR.Provider,{value:D,children:ce})})})},BH=e=>{let{cursorButton:t,scrollX:n,scrollY:r,zoom:i,shouldCacheIgnoreZoom:a,snapLines:o,originSnapOffset:s,suggestedBinding:c,frameToHighlight:l,elementsToHighlight:u,...d}=e;return d},VH=V.memo(zH,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return qr(BH(r),BH(o),{selectedElementIds:qr,selectedGroupIds:qr})&&qr(i,s)}),HH=e=>(0,U.jsx)(Y,{className:H(`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?.()}),UH=({trails:e})=>{let t=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,U.jsx)(`div`,{className:`SVGLayer`,children:(0,U.jsx)(`svg`,{ref:t})})},WH=`#ff6b6b`,GH=`#ff9090`,KH=`#da5b5b`,qH=1,JH=2,YH=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===M.LIGHT?WH:t.zenModeEnabled?KH:GH,r=(t.zenModeEnabled?qH*1.5:qH)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let i of t.snapLines)i.type===`pointer`?(e.lineWidth=r,e.strokeStyle=n,ZH(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,eU(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,XH(i,e,t));e.restore()},XH=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];$H(n,r,t)}for(let r of e.points)QH(r,n,t)},ZH=(e,t,n)=>{QH(e.points[0],n,t),n.zenModeEnabled||$H(e.points[0],e.points[1],t)},QH=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?JH*1.5:JH)/n.zoom.value;r.beginPath(),r.moveTo(e-i,t-i),r.lineTo(e+i,t+i),r.moveTo(e+i,t-i),r.lineTo(e-i,t+i),r.stroke(),r.restore()},$H=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},eU=(e,t,n,r,i)=>{let a=8/r.zoom.value,o=a/2,s=a/4;if(n===`horizontal`){let n=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||$H(L(e[0],e[1]-a),L(e[0],e[1]+a),i),$H(L(n[0]-s,n[1]-o),L(n[0]-s,n[1]+o),i),$H(L(n[0]+s,n[1]-o),L(n[0]+s,n[1]+o),i),r.zenModeEnabled||($H(L(t[0],t[1]-a),L(t[0],t[1]+a),i),$H(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||$H(L(e[0]-a,e[1]),L(e[0]+a,e[1]),i),$H(L(n[0]-o,n[1]-s),L(n[0]+o,n[1]-s),i),$H(L(n[0]-o,n[1]+s),L(n[0]+o,n[1]+s),i),r.zenModeEnabled||($H(L(t[0]-a,t[1]),L(t[0]+a,t[1]),i),$H(e,t,i))}},tU={[M.LIGHT]:`106, 189, 252`,[M.DARK]:`104, 182, 240`},nU={[M.LIGHT]:`rgba(65, 65, 65, 0.5)`,[M.DARK]:`rgba(237, 237, 237, 0.8)`},rU={[M.LIGHT]:{focus:`rgba(255, 124, 0, 0.4)`,match:`rgba(255, 226, 0, 0.4)`},[M.DARK]:{focus:`rgba(250, 123, 53, 0.4)`,match:`rgba(221, 181, 136, 0.4)`}},iU=(e,t)=>Rt(e,t===M.DARK),aU=(e,t)=>{E(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;E(n,`midPointCoords is null`),sU(n,e,t)},oU=(e,t,n)=>{let{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if(t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(i)||t.selectedLinearElement?.isDragging)return;let a=R.getElement(r,n);a&&sU(R.getPointAtIndexGlobalCoordinates(a,i,n),e,t)},sU=(e,t,n)=>{t.save(),t.translate(n.scrollX,n.scrollY),t.fillStyle=iU(`rgba(105, 101, 219, 0.4)`,n.theme),Kt(t,e[0],e[1],R.POINT_HANDLE_SIZE/n.zoom.value,!1),t.restore()},cU=(e,t,n,r,i,a,o)=>{e.strokeStyle=iU(`#5e5ad8`,t.theme),e.setLineDash([]),e.fillStyle=iU(`rgba(255, 255, 255, 0.9)`,t.theme),i?e.fillStyle=iU(`rgba(134, 131, 226, 0.9)`,t.theme):a&&(e.fillStyle=iU(`rgba(177, 151, 252, 0.7)`,t.theme)),Kt(e,n[0],n[1],(o?r*(t.selectedLinearElement?.isEditing?1.5:2):r)/t.zoom.value,!a,!o||i)},lU=(e,t,n,r,i,a=!1)=>{let o=t.element.frameId&&n.get(t.element.frameId);switch(o&&F(o)&&(e.translate(o.x,o.y),e.beginPath(),xo.radius&&e.roundRect?e.roundRect(-1,-1,o.width+1,o.height+1,xo.radius/r.zoom.value):e.rect(-1,-1,o.width+1,o.height+1),e.clip(),e.translate(-o.x,-o.y)),t.element.type){case`magicframe`:case`frame`:e.save(),e.translate(t.element.x,t.element.y),e.lineWidth=xo.strokeWidth/r.zoom.value,e.strokeStyle=`rgba(${tU[r.theme]}, 1)`,xo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,t.element.width,t.element.height,xo.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 i=Dt(t.element,n);switch(e.translate(i[0],i[1]),e.rotate(t.element.angle),e.translate(-i[0],-i[1]),e.translate(t.element.x,t.element.y),e.lineWidth=Vi(1.75,t.element.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=`rgba(${tU[r.theme]}, 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[n,r]=Pa(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}break;default:{let[n,r]=on(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}}e.restore()}if(r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&!a&&(F(t.element)||Xr(t.element))){let a=r.selectedLinearElement,o=a?.elementId&&R.getElement(a.elementId,n),s=o&&vn(o)||r.activeTool.type===`arrow`&&r.currentItemArrowType===`elbow`;if(!(i&&xr({point:i,element:t.element,elementsMap:n,threshold:0,overrideShouldTestInside:!0}))||s){e.save();let a=4/r.zoom.value,o=t.midPoint,c=Ei(t.element,n),l=c;if(!s){let e=nt(r.zoom)+t.element.strokeWidth/2,n=i&&c.reduce((e,t)=>Ke(e,i)<=Ke(t,i)?e:t);l=n&&Ke(n,i)<=e*2?[n]:[]}e.fillStyle=nU[r.theme];for(let t of l)o&&Gn(t,o)||(e.beginPath(),e.arc(t[0],t[1],a,0,2*Math.PI),e.fill());o&&(e.fillStyle=`rgba(${tU[r.theme]}, 1)`,e.beginPath(),e.arc(o[0],o[1],a,0,2*Math.PI),e.fill()),e.restore()}}},uU=(e,t,n,r,i,a,o)=>{let s=e.state.bindMode===`orbit`&&e.bindModeHandler!==null,c=700-(o?.runtime??(s?0:700)),l=Vi(1/700*c,1e-4,1),u=n.strokeWidth/2,d=n.frameId&&r.get(n.frameId);switch(d&&F(d)&&(t.translate(d.x,d.y),t.beginPath(),xo.radius&&t.roundRect?t.roundRect(-1,-1,d.width+1,d.height+1,xo.radius/i.zoom.value):t.rect(-1,-1,d.width+1,d.height+1),t.clip(),t.translate(-d.x,-d.y)),n.type){case`magicframe`:case`frame`:t.save(),t.translate(n.x,n.y),t.lineWidth=xo.strokeWidth/i.zoom.value,t.strokeStyle=`rgba(${tU[i.theme]}, ${l})`,xo.radius&&t.roundRect?(t.beginPath(),t.roundRect(0,0,n.width,n.height,xo.radius/i.zoom.value),t.stroke(),t.closePath()):t.strokeRect(0,0,n.width,n.height),t.restore();break;default:t.save();let e=Dt(n,r),a=e[0]+i.scrollX,o=e[1]+i.scrollY;switch(t.translate(a,o),t.rotate(n.angle),t.translate(-a,-o),t.translate(n.x+i.scrollX-u,n.y+i.scrollY-u),t.lineWidth=Vi(2.5,n.strokeWidth*1.75,4)/Math.max(.25,i.zoom.value),t.strokeStyle=`rgba(${tU[i.theme]}, ${l/2})`,n.type){case`ellipse`:t.beginPath(),t.ellipse((n.width+u*2)/2,(n.height+u*2)/2,(n.width+u*2)/2,(n.height+u*2)/2,0,0,2*Math.PI),t.closePath(),t.stroke();break;case`diamond`:{let[e,r]=Pa(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}break;default:{let[e,r]=on(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}}t.restore()}if(!s||(o?.runtime??0)>700)return;let f=.5*(Math.min(n.width,n.height)/2);if(!F(n)){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let a=1/700*c;if(t.strokeStyle=iU(`rgba(0, 0, 0, 0.2)`,i.theme),t.lineWidth=1/i.zoom.value,t.setLineDash([4/i.zoom.value,4/i.zoom.value]),t.lineDashOffset=-a*10/i.zoom.value,t.beginPath(),t.ellipse(n.width/2,n.height/2,f,f,0,0,2*Math.PI),t.stroke(),t.fillStyle=iU(`rgba(0, 0, 0, 0.04)`,i.theme),t.beginPath(),t.ellipse(n.width/2,n.height/2,f*(1-l),f*(1-l),0,0,2*Math.PI),t.fill(),t.restore(),i.isMidpointSnappingEnabled&&!i.gridModeEnabled&&(!e.lastPointerMoveEvent||!Fa(e.lastPointerMoveEvent))){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let e=5/i.zoom.value,a=e+5/i.zoom.value,o;if(n.type===`diamond`){let[,e]=Pa(n),t=Dt(n,r);o=e.map(e=>{let r=Ar(e,.5),i=As(r,t,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}else{let e=Dt(n,r);o=[{x:n.width/2,y:0},{x:n.width,y:n.height/2},{x:n.width/2,y:n.height},{x:0,y:n.height/2}].map(t=>{let r=L(t.x+n.x,t.y+n.y),i=As(r,e,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}o.forEach(e=>{t.clearRect(e.x-a,e.y-a,a*2,a*2)}),t.fillStyle=`rgba(${tU[i.theme]}, ${l})`,o.forEach(n=>{t.beginPath(),t.arc(n.x,n.y,e,0,2*Math.PI),t.fill()}),t.restore()}}return{runtime:(o?.runtime??0)+a}},dU=(e,t,n,r,i,a,o)=>{if(n!==null){if(Ki(`COMPLEX_BINDINGS`))return uU(e,t,n.element,r,i,a,o);t.save(),t.translate(i.scrollX,i.scrollY),lU(t,n,r,i,e.lastPointerMoveCoords?L(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,!!e.lastPointerMoveEvent&&Fa(e.lastPointerMoveEvent)),t.restore()}},fU=(e,t,n)=>{let{angle:r,x1:i,y1:a,x2:o,y2:s,selectionColors:c,cx:l,cy:u,dashed:d,activeEmbeddable:f}=n,p=o-i,m=s-a,g=(n.padding??4)/t.zoom.value,_=8/t.zoom.value,v=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(f?4:1)/t.zoom.value;let y=c.length;for(let t=0;t<y;++t)e.strokeStyle=c[t],d&&e.setLineDash([_,v+(_+v)*(y-1)]),e.lineDashOffset=(_+v)*t,h(e,i-g,a-g,p+g*2,m+g*2,l,u,r);e.restore()},pU=(e,t,n,r)=>{let[i,a,o,s]=In(n,r),c=o-i,l=s-a;e.strokeStyle=iU(`rgb(0,118,255)`,t.theme),e.lineWidth=xo.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),h(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,xo.radius/t.zoom.value),e.restore()},mU=(e,t,n,r)=>{let{colors:i=[iU(`rgb(0,118,255)`,t.theme)],dashed:a=!1}=r||{},o=n.filter(e=>e.groupIds.length===0),s=n.filter(e=>e.groupIds.length>0),c=e=>{let[t,n,r,o]=Hc(e);return{angle:0,x1:t,x2:r,y1:n,y2:o,selectionColors:i,dashed:a,cx:t+(r-t)/2,cy:n+(o-n)/2,activeEmbeddable:!1}},l=e=>{let t=ul(n,e);return c(t)};Object.entries(Nr(s,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>l(e)).concat(o.map(e=>c([e]))).forEach(n=>fU(e,t,n))},hU=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=R.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=R,o=t.selectedLinearElement?.isEditing?a:a/2,s=vn(n),c=co(n);if(i.forEach((r,a)=>{if(s&&a!==0&&a!==i.length-1)return;let l=a>0&&(a!==i.length-1||!c||!n.polygon)&&Gn(r,a===i.length-1?i[0]:i[a-1],2/t.zoom.value),u=!!t.selectedLinearElement?.isEditing&&!!t.selectedLinearElement?.selectedPointsIndices?.includes(a);c&&n.polygon&&!u&&a===n.points.length-1&&t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(u=!0),cU(e,t,r,o,u,!1,l)}),vn(n)){let o=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((s,c)=>{R.isSegmentTooShort(n,i[c+1],i[c],c,t.zoom,r)||cU(e,t,L((s[0]+i[c+1][0])/2,(s[1]+i[c+1][1])/2),a/2,!1,!o.includes(c+1),!1)})}else R.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&(!vn(n)||t!==0&&t!==r.length-1)).forEach(n=>{(t.selectedLinearElement?.isEditing||i.length===2)&&cU(e,t,n,a/2,!1,!0,!1)});e.restore()},gU=(e,t,n,r)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=iU(`rgba(134, 131, 226, 0.6)`,t.theme),e.lineWidth=1/t.zoom.value,e.setLineDash([4/t.zoom.value,4/t.zoom.value]),e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(r[0],r[1]),e.stroke(),e.restore()},_U=(e,t,n,r,i)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=iU(`rgba(134, 131, 226, 0.6)`,t.theme),e.lineWidth=1/t.zoom.value,e.setLineDash([]),e.fillStyle=iU(i?`rgba(134, 131, 226, 0.9)`:`rgba(255, 255, 255, 0.9)`,t.theme),Kt(e,n[0],n[1],r/t.zoom.value,!0,!0),e.restore()},vU=({arrow:e,appState:t,type:n,context:r,elementsMap:i})=>{let a=n===`start`?e.startBinding:e.endBinding,o=a?.elementId&&i.get(a.elementId);if(!o||!Xr(o)||o.isDeleted)return;let s=it(a.fixedPoint,o,i);if(!Re(s,e,o,i,t,n))return;let c=t.selectedLinearElement,l=!!c?.isDragging,u=n===`start`?0:e.points.length-1,d=!!c?.selectedPointsIndices?.includes(u);if(c?.hoveredFocusPointBinding===n&&!c.draggedFocusPointBinding&&sU(s,r,t),!(d&&l)){let s=it(a.fixedPoint,o,i),l=c?.hoveredFocusPointBinding===n;gU(r,t,R.getPointAtIndexGlobalCoordinates(e,u,i),s),_U(r,t,s,er/1.5,l)}},yU=(e,t,n,r,i)=>{Object.keys(r).forEach(a=>{let o=r[a];if(o!==void 0){let[r,s,c,l]=o;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),a===`rotation`?Kt(e,r+c/2,s+l/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(r,s,c,l,2/n.zoom.value),e.fill(),e.stroke()):h(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},bU=(e,t,n,r,i)=>{let[a,o,,,s,c]=In(r,i),l=3/n.zoom.value,u=l/2,d=s-a+l,f=c-o+l,p=Math.min(20/n.zoom.value,d),m=Math.min(20/n.zoom.value,f);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=l,[[[-d,-f],[0,u],[p,u],[u,0],[u,m]],[[d-u,-f],[u,u],[-p+u,u],[0,0],[0,m]],[[-d,f],[0,-u],[p,-u],[u,0],[u,-m]],[[d-u,f],[u,-u],[-p+u,-u],[0,0],[0,-m]]].forEach(t=>{let[[n,i],[a,o],[l,u],[d,f],[p,m]]=t;e.save(),e.translate(s,c),e.rotate(r.angle),e.beginPath(),e.moveTo(n+a,i+o),e.lineTo(n+l,i+u),e.stroke(),e.beginPath(),e.moveTo(n+d,i+f),e.lineTo(n+p,i+m),e.stroke(),e.restore()}),e.restore()},xU=(e,t,n,r)=>{t.save();let i=iL(n.zoom.value),a=e.width+i*2,o=e.height+i*2,s=e.x+e.width/2,c=e.y+e.height/2,l=-(e.width/2+i),u=-(e.height/2+i);t.translate(s+n.scrollX,c+n.scrollY),t.rotate(e.angle),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.globalAlpha=.5,t.setLineDash([6/n.zoom.value,4/n.zoom.value]),t.strokeRect(l,u,a,o),t.restore()},SU=(e,t,n,r,i)=>{let a=n.textToolHover,o=r.get(a.elementId);if(o&&!o.isDeleted)switch(a.type){case`text`:D(o)&&xU(Ye(o,r),t,n,i);return;case`container`:Xr(o)&&(t.save(),t.translate(n.scrollX,n.scrollY),lU(t,{element:o},r,n,e.lastPointerMoveCoords?L(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null),t.restore());return;case`arrow`:ir(o)&&sU(a.anchor===`label`?R.getBoundTextElementCenter(o,r):R.getPointAtIndexGlobalCoordinates(o,a.anchor===`start`?0:-1,r),t,n)}},CU=(e,t,n,r,i)=>{let a=aL(e,n.zoom.value,i);a&&(t.save(),t.globalAlpha=.5,t.lineWidth=1.5/n.zoom.value,t.lineCap=`round`,t.strokeStyle=r,t.beginPath(),t.moveTo(a.start[0]+n.scrollX,a.start[1]+n.scrollY),t.lineTo(a.end[0]+n.scrollX,a.end[1]+n.scrollY),t.stroke(),t.restore())},wU=({app:e,canvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:a,scale:o,appState:s,renderConfig:c,editorInterface:l,animationState:u,deltaTime:d})=>{if(t===null)return{};let f=gr(s,o),[p,m]=gt(t,o),g=u,_=to({canvas:t,scale:o,normalizedWidth:p,normalizedHeight:m});_.save(),_.scale(f.zoom.value,f.zoom.value);let v;if(r.forEach(e=>{f.selectedLinearElement?.isEditing&&f.selectedLinearElement.elementId===e.id&&e&&(v=e)}),v&&hU(_,f,v,n),f.selectionElement&&!f.isCropping)try{De(f.selectionElement,_,f,c.selectionColor)}catch(e){console.error(e)}let b=hr(i,f);if(b&&!b.autoResize&&CU(b,_,f,c.selectionColor,l.formFactor),f.editingTextElement){let e=a.get(f.editingTextElement.id);e&&!e.autoResize&&xU(e,_,f,c.selectionColor)}if(g=f.isBindingEnabled&&f.suggestedBinding?{...u,bindingHighlight:dU(e,_,f.suggestedBinding,a,f,d,u?.bindingHighlight)}:{...u,bindingHighlight:void 0},f.textToolHover&&SU(e,_,f,a,c.selectionColor),f.frameToHighlight&&pU(_,f,f.frameToHighlight,n),f.elementsToHighlight&&mU(_,f,f.elementsToHighlight),f.activeLockedId){let e=a.get(f.activeLockedId);mU(_,f,e?[e]:ul(a,f.activeLockedId),{colors:[iU(`#ced4da`,f.theme)],dashed:!0})}let x=i.some(e=>F(e));i.length===1&&f.selectedLinearElement?.isEditing&&f.selectedLinearElement.elementId===i[0].id&&hU(_,f,i[0],n);let S=f.selectedLinearElement,C=S&&R.getElement(S.elementId,a);if(C&&(f.selectedLinearElement.isDragging||(S.segmentMidPointHoveredCoords?aU(_,f):(vn(C)?S.hoverPointIndex===0||S.hoverPointIndex===C.points.length-1:S.hoverPointIndex>=0)&&oU(_,f,n)),ir(C)&&(vU({arrow:C,elementsMap:a,appState:f,context:_,type:`start`}),vU({arrow:C,elementsMap:a,appState:f,context:_,type:`end`}))),!f.multiElement&&!f.newElement&&!f.selectedLinearElement?.isEditing){let e=Ac(i,f,l),t=i.length===1&&ja(i[0]);t&&f.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&hU(_,f,i[0],n);let r=c.selectionColor||iU(`#000`,f.theme),a=iU(`#ced4da`,f.theme),o=iU(`#000`,f.theme);if(e){let e=y(i),s=[];for(let i of n.values()){let o=[],l=c.remoteSelectedElementIds.get(i.id);if(t&&vn(i)&&(i.startBinding||i.endBinding)||(e.has(i.id)&&!Hs(f,i)&&o.push(r),l&&o.push(...l.map(e=>JO(e,f.collaborators.get(e))))),o.length){let[e,t,r,c,u,d]=In(i,n,!0);s.push({angle:i.angle,x1:e,y1:t,x2:r,y2:c,selectionColors:i.locked?[a]:o,dashed:!!l||i.locked,cx:u,cy:d,activeEmbeddable:f.activeEmbeddable?.element===i&&f.activeEmbeddable.state===`active`,padding:i.id===f.croppingElementId||O(i)?0:void 0})}}let l=e=>{let t=ul(n,e),[r,i,c,l]=Hc(t);s.push({angle:0,x1:r,x2:c,y1:i,y2:l,selectionColors:t.some(e=>e.locked)?[a]:[o],dashed:!0,cx:r+(c-r)/2,cy:i+(l-i)/2,activeEmbeddable:!1})};for(let e of Mo(f))l(e);f.editingGroupId&&l(f.editingGroupId),s.forEach(e=>fU(_,f,e))}if(_.save(),_.translate(f.scrollX,f.scrollY),i.length===1){_.fillStyle=iU(`#fff`,f.theme);let t=ns(i[0],f.zoom,n,`mouse`,Wc(l));if(!f.viewModeEnabled&&e&&!D(f.editingTextElement)&&!f.croppingElementId&&yU(_,c,f,t,i[0].angle),f.croppingElementId&&!f.isCropping){let e=n.get(f.croppingElementId);e&&O(e)&&bU(_,c,f,e,n)}}else if(i.length>1&&!f.isRotating&&!i.some(e=>e.locked)){let e=4/f.zoom.value;_.fillStyle=iU(`#fff`,f.theme);let[t,a,o,s]=Hc(i,n),u=_.getLineDash();_.setLineDash([2/f.zoom.value]);let d=_.lineWidth;_.lineWidth=1/f.zoom.value,_.strokeStyle=r,h(_,t-e,a-e,o-t+e*2,s-a+e*2,(t+o)/2,(a+s)/2,0),_.lineWidth=d,_.setLineDash(u);let p=an([t,a,o,s,(t+o)/2,(a+s)/2],0,f.zoom,`mouse`,x?{...Wc(l),rotation:!0}:Wc(l));i.some(e=>!e.locked)&&yU(_,c,f,p,0)}_.restore()}f.searchMatches?.matches.forEach(({id:e,focus:t,matchedLines:r})=>{let i=n.get(e);if(i){let[e,a,,,o,s]=In(i,n,!0);_.save(),_.fillStyle=rU[f.theme][t?`focus`:`match`];let c=F(i)?f.zoom.value:1;_.translate(f.scrollX,f.scrollY),_.translate(o,s),_.rotate(i.angle),r.forEach(n=>{(n.showOnCanvas||t)&&_.fillRect(e+n.offsetX/c-o,a+n.offsetY/c-s,n.width/c,n.height/c)}),_.restore()}}),YH(_,f),_.restore(),XO({context:_,renderConfig:c,appState:f,normalizedWidth:p,normalizedHeight:m});let w;return c.renderScrollbars&&(w=wF(n,p,m,f),_.save(),_.fillStyle=iU(CF,f.theme),_.strokeStyle=iU(`rgba(255,255,255,0.8)`,f.theme),[w.horizontal,w.vertical].forEach(e=>{e&&KO(_,e.x,e.y,e.width,e.height,SF/2)}),_.restore()),{scrollBars:w,animationState:g}},TU=e=>{let t=wU(e);return e.callback(t),t},EU=`animateInteractiveScene`,DU=e=>{let t=(0,V.useRef)(!1),n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(!t.current){t.current=!0;return}let r=new Map,i=new Map,a=new Map,o=new Map,s=new Map;e.appState.collaborators.forEach((t,n)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))a.has(e)||a.set(e,[]),a.get(e).push(n);!t.pointer||t.pointer.renderCursor===!1||(t.username&&o.set(n,t.username),t.userState&&s.set(n,t.userState),i.set(n,hs({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),r.set(n,t.button))});let c=as(e.containerRef?.current);n.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:i,remotePointerButton:r,remoteSelectedElementIds:a,remotePointerUsernames:o,remotePointerUserStates:s,selectionColor:c,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},_F.running(EU)||_F.start(EU,({deltaTime:e,state:t})=>{let r=TU({...n.current,deltaTime:e,animationState:t}).animationState;if(r){for(let e in r)if(r[e]!==void 0)return r}})}),(0,U.jsx)(`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:G(`labels.drawingCanvas`)})},OU=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,textToolHover:e.textToolHover,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}),kU=V.memo(DU,(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:qr(OU(e.appState),OU(t.appState))),AU=e=>{let t=(0,V.useRef)(null),n=(0,V.useRef)(!1);return(0,V.useEffect)(()=>{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]),(0,V.useEffect)(()=>{let r=t.current;if(!r)return;let i=e.canvas;n.current||(n.current=!0,r.replaceChildren(i),i.classList.add(`excalidraw__canvas`,`static`)),He({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},hF())}),(0,U.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},jU=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}),MU=V.memo(AU,(e,t)=>e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:qr(jU(e.appState),jU(t.appState))&&qr(e.renderConfig,t.renderConfig)),NU=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let c=gr(o,a),[l,u]=gt(e,a),d=to({canvas:e,scale:a,normalizedWidth:l,normalizedHeight:u});if(d.save(),d.scale(c.zoom.value,c.zoom.value),n&&n.type!==`selection`){if(So(n))return;if((n.frameId||c.frameToHighlight?.id)&&c.frameRendering.enabled&&c.frameRendering.clip){let e=js(n,r,c);e&&ta(n,e,c,r)&&Er(e,d,s,c)}je(n,r,i,t,d,s,c)}else d.clearRect(0,0,l,u);d.restore()}},PU=Ho(e=>{NU(e)}),FU=(e,t)=>{if(t){PU(e);return}NU(e)},IU=e=>{let t=(0,V.useRef)(null);return(0,V.useEffect)(()=>{t.current&&FU({canvas:t.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},hF())}),(0,U.jsx)(`canvas`,{className:`excalidraw__canvas`,style:{width:e.appState.width,height:e.appState.height,opacity:e.opacity},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},LU=700,RU=100,zU=16,BU=3e4,VU=Dl(null),HU=e=>e===Pe.elbow?xw:e===Pe.round?Sw:bw,UU=class{constructor(e){B(this,`app`),B(this,`lastShownAt`,0),B(this,`show`,e=>{let{x:t,y:n}=this.app.viewport.lastPosition;t===0&&n===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(VU,{content:e,nonce:Math.random()}))}),B(this,`isOnCooldown`,()=>Date.now()-this.lastShownAt<BU),B(this,`onArrowTypeCycled`,e=>{this.show(HU(e))}),B(this,`onToolShortcut`,(e,t)=>{(t===`digit`||!this.isOnCooldown())&&this.show(e===`line`?Px:HU(this.app.state.currentItemArrowType))}),this.app=e}},WU=()=>{let[e,t]=Yb(VU),n=aW(),{container:r}=lW(),i=(0,V.useRef)(null),[a,o]=(0,V.useState)(!1),s=e?.nonce;return(0,V.useLayoutEffect)(()=>{if(s==null||!r)return;let e=(e,t)=>{let n=i.current;if(!n)return;let{left:a,top:o}=aT({cursor:{x:e,y:t},element:{width:n.offsetWidth,height:n.offsetHeight},container:r.getBoundingClientRect(),gap:zU});n.style.transform=`translate(${a}px, ${o}px)`};e(n.viewport.lastPosition.x,n.viewport.lastPosition.y);let t=t=>{e(t.clientX,t.clientY)};return window.addEventListener(P.POINTER_MOVE,t),()=>{window.removeEventListener(P.POINTER_MOVE,t)}},[s,r,n]),(0,V.useEffect)(()=>()=>{t(null)},[t]),(0,V.useEffect)(()=>{if(s==null)return;o(!1);let e=window.setTimeout(()=>{o(!0)},LU),n=window.setTimeout(()=>{t(null)},LU+RU),r=()=>{t(null)};return window.addEventListener(P.POINTER_DOWN,r,{capture:!0}),()=>{window.clearTimeout(e),window.clearTimeout(n),window.removeEventListener(P.POINTER_DOWN,r,{capture:!0})}},[s,t]),e?(0,U.jsx)(`div`,{ref:i,className:H(`CursorHint`,{"CursorHint--fade-out":a}),"data-testid":`cursor-hint`,children:e.content}):null},GU=class{constructor(e){this.getState=e,B(this,`listeners`,[]),B(this,`onStateChange`,(e,t,n)=>{let{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}=this.normalize(e,t,n);return a?s&&(queueMicrotask(()=>{let e=this.getState();a(i(e),e)}),o)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:o}):s?Promise.resolve(i(this.getState())):new Promise(e=>{this.subscribe({predicate:r,getValue:i,callback:t=>e(t),once:!0})})})}isStateChangePredicateOptions(e){return typeof e==`object`&&!Array.isArray(e)&&`predicate`in e}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}normalize(e,t,n){let r,i,a=t,o=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(e)){let{predicate:t,callback:n,once:c}=e;r=t,i=e=>e,a=n?(e,t)=>n(t):void 0,o=c??!1,s=t(this.getState())}else if(typeof e==`function`){let t=e;r=(e,n)=>t(e)!==t(n),i=e=>t(e)}else if(Array.isArray(e)){let t=e;r=(e,n)=>t.some(t=>e[t]!==n[t]),i=e=>e}else{let t=e;r=(e,n)=>e[t]!==n[t],i=e=>e[t]}return{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}}flush(e){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,e)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}},KU=({app:e,activeLockedId:t})=>{let n=e.scene.getElement(t);n&&!Ga(n)&&console.error(`[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element`);let r=n&&Ga(n)?n:null,i=r?[r]:ul(e.scene.getNonDeletedElementsMap(),t);if(i.length===0)return null;let[a,o]=Hc(i),{x:s,y:c}=hs({sceneX:a,sceneY:o},e.state);return(0,U.jsx)(`div`,{className:`UnlockPopup`,style:{bottom:`${e.state.height+12-c+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{(0,Cl.flushSync)(()=>{let t=Nr(i,e.state);e.setState({selectedElementIds:i.reduce((e,t)=>({...e,[t.id]:!0}),{}),selectedGroupIds:t,activeLockedId:null})}),e.actionManager.executeAction(Hk)},title:G(`labels.elementLock.unlock`),children:wx})},qU=V.createContext(null),JU=V.createContext(null),YU={formFactor:`desktop`,desktopUIMode:`full`,userAgent:tl(typeof navigator<`u`?navigator.userAgent:``),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},XU=V.createContext(YU);XU.displayName=`EditorInterfaceContext`;var ZU={"editor:mount":{cardinality:`once`,replay:`last`},"editor:initialize":{cardinality:`once`,replay:`last`},"editor:unmount":{cardinality:`once`,replay:`last`}},QU=V.createContext({container:null,id:null});QU.displayName=`ExcalidrawContainerContext`;var $U=V.createContext([]);$U.displayName=`ExcalidrawElementsContext`;var eW=V.createContext({...Se(),width:0,height:0,offsetLeft:0,offsetTop:0});eW.displayName=`ExcalidrawAppStateContext`;var tW=V.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});tW.displayName=`ExcalidrawSetAppStateContext`;var nW=V.createContext(null);nW.displayName=`ExcalidrawActionManagerContext`;var rW=V.createContext(null);rW.displayName=`ExcalidrawAPIContext`;var iW=V.createContext(null);iW.displayName=`ExcalidrawAPISetContext`;var aW=()=>(0,V.useContext)(qU),oW=()=>(0,V.useContext)(JU),sW=()=>(0,V.useContext)(XU),cW=()=>tc(sW()),lW=()=>(0,V.useContext)(QU),uW=()=>(0,V.useContext)($U),dW=()=>(0,V.useContext)(eW),fW=()=>(0,V.useContext)(tW),pW=()=>(0,V.useContext)(nW),mW=()=>(0,V.useContext)(rW),hW=!1,gW=0,_W=null,vW=!1,yW={horizontal:null,vertical:null},bW=0,xW=!1,SW=new Map,CW=4,wW=null,TW={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},EW=class e extends V.Component{constructor(t){super(t),B(this,`canvas`),B(this,`interactiveCanvas`,null),B(this,`sessionExportThemeOverride`),B(this,`rc`),B(this,`unmounted`,!1),B(this,`actionManager`),B(this,`editorInterface`,YU),B(this,`stylesPanelMode`,tc(YU)),B(this,`excalidrawContainerRef`,V.createRef()),B(this,`zenModeTransitionTimer`,0),B(this,`scene`),B(this,`fonts`),B(this,`renderer`),B(this,`visibleElements`),B(this,`hasRenderableElements`,!1),B(this,`resizeObserver`),B(this,`library`),B(this,`libraryItemsFromStorage`),B(this,`id`),B(this,`store`),B(this,`history`),B(this,`excalidrawContainerValue`),B(this,`files`,{}),B(this,`imageCache`,new Map),B(this,`iFrameRefs`,new Map),B(this,`embedsValidationStatus`,new Map),B(this,`initializedEmbeds`,new Set),B(this,`elementsPendingErasure`,new Set),B(this,`_initialized`,!1),B(this,`editorLifecycleEvents`,new oc(ZU)),B(this,`onEvent`,this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents)),B(this,`appStateObserver`,new GU(()=>this.state)),B(this,`onStateChange`,this.appStateObserver.onStateChange),B(this,`bucketFill`,new bL(this)),B(this,`duplicate`,new PL(this,{getPointerCount:()=>TW.pointers.size})),B(this,`toolDrag`,new wL(this)),B(this,`flowchart`,new FL(this)),B(this,`cursor`,new jL(this)),B(this,`arrowText`,new zF(this)),B(this,`pan`,new LL(this,{getPointerCount:()=>TW.pointers.size,isDraggingScrollBar:()=>vW})),B(this,`textTool`,new vL(this)),B(this,`clipboard`,new QI(this,{getContainer:()=>this.excalidrawContainerRef.current})),B(this,`text`,new hL(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode})),B(this,`viewport`,new tR(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>TW.pointers.size>=2||this.pan.isActive()})),B(this,`wheel`,new rR(this)),B(this,`bindModeHandler`,null),B(this,`hitLinkElement`),B(this,`lastPointerDownEvent`,null),B(this,`activeResizeHandle`,null),B(this,`lastPointerUpEvent`,null),B(this,`lastPointerUpIsDoubleClick`,!1),B(this,`lastPointerMoveEvent`,null),B(this,`lastPointerMoveCoords`,null),B(this,`lastCompletedCanvasClicks`,[]),B(this,`previousPointerMoveCoords`,null),B(this,`drawShape`,new NL(this)),B(this,`laserTrails`,new bF(this)),B(this,`eraserTrail`,new LF(this)),B(this,`lassoTrail`,new IF(this)),B(this,`cursorHints`,new UU(this)),B(this,`onChangeEmitter`,new rt),B(this,`onPointerDownEmitter`,new rt),B(this,`onPointerUpEmitter`,new rt),B(this,`onUserFollowEmitter`,new rt),B(this,`onScrollChangeEmitter`,new rt),B(this,`missingPointerEventCleanupEmitter`,new rt),B(this,`onRemoveEventListenersEmitter`,new rt),B(this,`api`),B(this,`elementRenderOverrides`,new Map),B(this,`elementRenderOffsets`,new Map),B(this,`renderOverridesUpdatePending`,!1),B(this,`getRenderOverrideConfig`,()=>({elementRenderOverrides:this.elementRenderOverrides})),B(this,`getElementRenderState`,(e,t=this.elementRenderOverrides)=>Sa(e,this.scene.getNonDeletedElementsMap(),{elementRenderOverrides:t??void 0,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null})),B(this,`isToolSupported`,(e,t=this.props)=>{if(t.UIOptions.tools?.[e]===!1)return!1;if(this.isInteractionEnabled(t))return!0;let n=typeof t.interaction==`object`&&t.interaction!==null?t.interaction.enabled?.tools:void 0;return e===`laser`?n?.laser===!0:e===`custom`&&n?.custom===!0}),B(this,`updateEditorAtom`,(e,...t)=>{let n=ex.set(e,...t);return this.triggerRender(),n}),B(this,`onWindowMessage`,e=>{if(e.origin!==`https://player.vimeo.com`&&e.origin!==`https://www.youtube.com`)return;let t=null;try{t=JSON.parse(e.data)}catch{}if(t)switch(e.origin){case`https://player.vimeo.com`:if(t.method===`paused`){let n=null,r=this.ownerDocument.body.querySelectorAll(`iframe.excalidraw__embeddable`);if(!r)break;for(let t of r)t.contentWindow===e.source&&(n=t.contentWindow);n?.postMessage(JSON.stringify({method:t.value?`play`:`pause`,value:!0}),`*`)}break;case`https://www.youtube.com`:if(t.event===`infoDelivery`&&t.info&&t.id&&typeof t.info.playerState==`number`){let e=t.id,n=t.info.playerState;Object.values(Mr).includes(n)&&SW.set(e,n)}}}),B(this,`previousHoveredBindableElement`,null),B(this,`getEffectiveGridSize`,()=>WP(this)?this.state.gridSize:null),B(this,`handleIframeLikeElementHover`,({hitElement:e,scenePointer:t,moveEvent:n})=>e&&Ge(e)&&this.isIframeLikeInteractive(e)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(e,n,t.x,t.y))?(this.cursor.set(To.POINTER),this.setState({activeEmbeddable:{element:e,state:`hover`}}),!0):(this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null}),!1)),B(this,`isDoubleClick`,(e,t)=>e!=null&&t.timeStamp-e.timeStamp<=300),B(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),wa.delete(e)}),B(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(Si(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=Qt(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else Ai(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),B(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),B(this,`frameNameBoundsCache`,{get:e=>{let t=this.frameNameBoundsCache._cache.get(e.id);if(!t||t.zoom!==this.state.zoom.value||t.versionNonce!==e.versionNonce){let n=this.ownerDocument.getElementById(this.getFrameNameDOMId(e));if(n){let r=n.getBoundingClientRect(),i=this.state.zoom.value;return t={x:e.x,y:e.y-(r.height+xo.nameOffsetY)/i,width:r.width/i,height:r.height/i,zoom:i,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),B(this,`resetEditingFrame`,e=>{e&&this.scene.mutateElement(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),B(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===M.DARK,t=this.scene.getNonDeletedFramesLikes(),n=t.length>0&&this.state.searchMatches?.focusedId&&F(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(e=>e.focus):null;return t.map(t=>{let r=this.getElementRenderState(t,t.id===this.state.editingFrame?null:this.elementRenderOverrides);if(!et(Xn(t,r.offset),this.canvas.width/this.ownerWindow.devicePixelRatio,this.canvas.height/this.ownerWindow.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===t.id&&this.resetEditingFrame(t),null;let{x:i,y:a}=hs({sceneX:t.x+r.offset.x,sceneY:t.y+r.offset.y},this.state),o,s=$o(t);if(t.id===this.state.editingFrame){let n=s;o=(0,U.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>{this.scene.mutateElement(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===z.ESCAPE||e.key===z.ENTER)&&this.resetEditingFrame(t)},style:{background:Rt(this.state.viewBackgroundColor,e),zIndex:2,border:`none`,display:`block`,padding:`6px`,borderRadius:4,boxShadow:`inset 0 0 0 1px var(--color-primary)`,fontFamily:`Assistant`,fontSize:`${xo.nameFontSize}px`,transform:`translate(-6px, 6px)`,color:e?xo.nameColorDarkTheme:xo.nameColorLightTheme,overflow:`hidden`,maxWidth:`${this.ownerDocument.body.clientWidth-i-6}px`},size:n.length+1||1,dir:`auto`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`})}else o=s;return(0,U.jsx)(`div`,{id:this.getFrameNameDOMId(t),className:hn.FRAME_NAME,style:{position:`absolute`,opacity:r.opacity,bottom:`${this.state.height+xo.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:xo.nameFontSize,color:e?xo.nameColorDarkTheme:xo.nameColorLightTheme,lineHeight:xo.nameLineHeight,width:`max-content`,maxWidth:n?.id===t.id&&n?.focus?`none`:`${t.width*this.state.zoom.value}px`,overflow:t.id===this.state.editingFrame?`visible`:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,cursor:To.MOVE,pointerEvents:this.state.viewModeEnabled?tr.disabled:tr.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:o},t.id)})}),B(this,`toggleOverscrollBehavior`,e=>{this.ownerDocument.documentElement.style.overscrollBehaviorX=e.type===`pointerenter`?`none`:`auto`}),B(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),B(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),B(this,`getSceneElementsMapIncludingDeleted`,()=>this.scene.getElementsMapIncludingDeleted()),B(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),B(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),B(this,`onExportImage`,async(e,t,n)=>{Yw(`export`,e,`ui`);let r=await wO(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(ue).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&Gr(r)&&this.setState({fileHandle:r})}),B(this,`magicGenerations`,new Map),B(this,`updateMagicGeneration`,({frameElement:e,data:t})=>{t.status===`pending`?this.scene.mutateElement(e,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(e,{customData:{generationData:t}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(e.id,t),this.triggerRender()}),B(this,`plugins`,{}),B(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:Ys.magicframe}),Yw(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&Ue(e[0])&&e[0];if(!t&&e.some(e=>F(e)||e.frameId)){this.setActiveTool({type:Ys.magicframe});return}Yw(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Hc(e);n=Ri({...xo,x:t-50,y:r-50,width:i-t+100,height:a-r+100,opacity:100,locked:!1}),this.insertNewElement(n);for(let t of e)this.scene.mutateElement(t,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,`upstream`)}}),B(this,`openEyeDropper`,({type:e})=>{this.updateEditorAtom(cT,{swapPreviewOnAlt:!0,colorPickerType:e===`stroke`?`elementStroke`:`elementBackground`,onSelect:(t,n)=>{let r=e===`background`&&n.altKey||e===`stroke`&&!n.altKey?`strokeColor`:`backgroundColor`;if(!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!==`selection`)this.syncActionResult({appState:{...this.state,...WE(UE(this.state,this.scene.getNonDeletedElements(),r),t)},captureUpdate:I.IMMEDIATELY});else{let e=this.scene.getNonDeletedElementsMap(),n=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:r===`strokeColor`}).map(e=>e.id));this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(i=>n.has(i.id)?N(i,Wr(i,r,t,e)):i),captureUpdate:I.IMMEDIATELY})}},keepOpenOnAlt:!1})}),B(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})}),B(this,`syncActionResult`,pF(e=>{if(this.unmounted||e===!1)return;this.store.scheduleAction(e.captureUpdate);let t=!1,n=null;if(e.elements&&(this.scene.replaceAllElements(e.elements),t=!0),e.files&&(this.addMissingFiles(e.files,e.replaceFiles),this.addNewImagesToImageCache()),e.appState||n||this.state.contextMenu){let r=e?.appState?.viewModeEnabled||!1,i=e?.appState?.zenModeEnabled||!1,a=e?.appState?.theme||this.props.theme||M.LIGHT,o=e?.appState?.name??this.state.name,s=e?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<`u`&&(r=this.props.viewModeEnabled),this.isInteractionEnabled()||(r=!0),typeof this.props.zenModeEnabled<`u`&&(i=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n){let t=n.id,r=e.elements.find(e=>e.id===t);n=r&&Ga(r)&&D(r)?r:null}this.setState(t=>{let c=e.appState||{};return{...t,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:r,zenModeEnabled:i,theme:a,name:o,errorMessage:s}}),t=!0}t||this.scene.triggerUpdate()})),B(this,`scheduleCapture`,()=>this.store.scheduleCapture()),B(this,`onBlur`,pF(()=>{this.pan.setSpaceHeld(!1),this.setState({isBindingEnabled:this.state.bindingPreference===`enabled`})})),B(this,`onUnload`,()=>{this.onBlur()}),B(this,`disableEvent`,e=>{e.preventDefault()}),B(this,`onDragOver`,e=>{e.preventDefault(),!this.isFileDropEnabled()&&e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}),B(this,`handleNavigationModeKeyDown`,e=>{if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}this.actionManager.handleKeyDown(e)}),B(this,`maybeHandlePageScrollKeyDown`,e=>{if(e.key!==z.PAGE_UP&&e.key!==z.PAGE_DOWN)return!1;let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return e.key===z.PAGE_DOWN&&(t=-t),e.shiftKey?this.viewport.translate(e=>({scrollX:e.scrollX+t})):this.viewport.translate(e=>({scrollY:e.scrollY+t})),!0}),B(this,`preventBrowserZoomKeyDown`,e=>{e[z.CTRL_OR_CMD]&&(e.code===d.EQUAL||e.code===d.MINUS||e.code===d.ZERO||e.code===d.NUM_ADD||e.code===d.NUM_SUBTRACT||e.code===d.NUM_ZERO)&&e.preventDefault()}),B(this,`terminateActiveInteraction`,()=>{if(this.maybeCleanupAfterMissingPointerUp(null),this.pan.setSpaceHeld(!1),vW=!1,wW=null,TW.pointers.clear(),TW.lastCenter=null,TW.initialDistance=null,TW.initialScale=null,clearTimeout(gW),gW=0,e.resetTapTwice(),this.resetContextMenuTimer(),this.clipboard.clearPlainPaste(),this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.flowchart.clear(),ex.set(cT,null),ex.set(Qk,null),this.state.editingFrame){let e=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(e&&F(e)?e:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.text.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:this.isInteractionEnabled()?this.state.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,textToolHover:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())}),B(this,`handleInteractionStateChange`,(e,t)=>{let n=this.isInteractionEnabled(e),r=n!==this.isInteractionEnabled(),i=e.viewModeEnabled!==this.props.viewModeEnabled,a=this.state.viewModeEnabled;this.isInteractionEnabled()?(i||r)&&(a=!!this.props.viewModeEnabled):a=!0,a!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:a});let o=n&&!t.viewModeEnabled,s=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(r&&!this.isInteractionEnabled()||o&&!s)&&this.terminateActiveInteraction(),r&&this.addEventListeners(),this.isLinksEnabled(e)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,Rk(),this.cursor.reset())),this.isEmbedsEnabled(e)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(t.activeTool.type,e)!==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:ln(this.state,{type:`selection`})}),(this.isBrowserZoomEnabled(e)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(e)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())}),B(this,`isSameForcedTool`,(e,t)=>e?.type===t?.type&&(e?.type===`custom`?e.customType??null:null)===(t?.type===`custom`?t.customType??null:null)),B(this,`handleForcedToolChange`,(e,t)=>{let n=this.props.activeTool;if(!n)return;let r=!this.isSameForcedTool(e.activeTool,n);if(n.type===`image`){r&&console.warn(`"image" tool cannot be forced via "props.activeTool"`);return}this.isSameForcedTool(n,this.state.activeTool)||(r||t.activeTool!==this.state.activeTool||this.isToolSupported(n.type,e)!==this.isToolSupported(n.type,this.props))&&this.setActiveTool(n)}),B(this,`resetHistory`,()=>{this.history.clear()}),B(this,`resetStore`,()=>{this.store.clear()}),B(this,`resetScene`,pF(e=>{this.elementRenderOverrides=new Map,this.elementRenderOffsets=new Map,this.scene.replaceAllElements([]),this.setState(t=>({...Se(),isLoading:!e?.resetLoadingState&&t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),B(this,`initializeScene`,async()=>{`launchQueue`in this.ownerWindow&&`LaunchParams`in this.ownerWindow&&this.ownerWindow.launchQueue.setConsumer(async e=>{if(!e.files.length)return;let t=e.files[0],n=await t.getFile();this.loadFileToCanvas(new File([n],n.name||``,{type:n.type}),t)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let e=null;try{e=typeof this.props.initialData==`function`?await this.props.initialData()||null:await this.props.initialData||null,e?.libraryItems&&this.library.updateLibrary({libraryItems:e.libraryItems,merge:!0}).catch(e=>{console.error(e)})}catch(t){console.error(t),e={appState:{errorMessage:t.message||`Encountered an error during importing or restoring scene data`}}}let t=Vn(e?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=fc(e?.appState,null),r=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:r.type===`image`||r.type===`lasso`||r.type===`selection`?{...r,type:n.preferredSelectionTool.type}:n.activeTool,isLoading:!1,toast:this.state.toast};let i={...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 e=t.filter(e=>!e.isDeleted),r=y(e),o=this.viewport.resolveInitialViewport(a,r,i);o&&(n={...n,...o})}else e?.scrollToContent&&(n={...n,...Ka(t,i)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:t,appState:n,files:e?.files,captureUpdate:I.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),Vt(this.ownerWindow.location.href)&&this.viewport.setViewport({target:this.ownerWindow.location.href,fit:`scale-down`,animation:!1})}),B(this,`getFormFactor`,(e,t)=>this.props.UIOptions.getFormFactor?.(e,t)??ki(e,t)),B(this,`refreshEditorInterface`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=dc(),i=tl(typeof navigator<`u`?navigator.userAgent:``),a=this.props.UIOptions.dockedSidebarBreakpoint==null?Wo:this.props.UIOptions.dockedSidebarBreakpoint,o=ao(this.editorInterface,{desktopUIMode:r??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(t,n),userAgent:i,canFitSidebar:t>a,isLandscape:t>n});this.editorInterface=o,this.reconcileStylesPanelMode(o)}),B(this,`reconcileStylesPanelMode`,e=>{let t=tc(e);if(t===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=t,this.viewport.invalidateUIOffset(`stylesPanel`),n!==`full`&&t===`full`&&this.setState(e=>({preferredSelectionTool:{type:`selection`,initialized:!0}}))}),B(this,`setDesktopUIMode`,e=>{let t=Mt(e);this.editorInterface=ao(this.editorInterface,{desktopUIMode:t}),this.reconcileStylesPanelMode(this.editorInterface)}),B(this,`onResize`,pF(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>wa.delete(e)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})})),B(this,`onFullscreenChange`,()=>{!this.ownerDocument.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),B(this,`renderInteractiveSceneCallback`,({scrollBars:e})=>{e&&(yW=e),this.scheduleImageRefresh()}),B(this,`onScroll`,ml(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),B(this,`onTouchStart`,t=>{if(this.isInteractionEnabled()){if(Ba&&t.preventDefault(),!hW){hW=!0,t.touches.length===1&&(_W={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(gW),gW=this.ownerWindow.setTimeout(e.resetTapTwice,300);return}if(hW&&t.touches.length===1&&_W){let e=t.touches[0];Ke(L(e.clientX,e.clientY),L(_W.x,_W.y))<=35&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY,type:`touch`,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),hW=!1,clearTimeout(gW)}t.touches.length===2&&this.setState({selectedElementIds:j({},this.state),activeEmbeddable:null})}}),B(this,`onTouchEnd`,e=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:j(this.state.previousSelectedElementIds,this.state)}):TW.pointers.clear())}),B(this,`addElementsFromPasteOrLibrary`,e=>{let t=Vn(e.elements,null,{deleteInvisibleElements:!0}),n=typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,r=typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,i=this.duplicate.duplicateAtSceneCoords(t,ws({clientX:n,clientY:r},this.state),{retainSeed:e.retainSeed,preserveFrameChildrenOrder:e.preserveFrameChildrenOrder});if(!i)return;let{nextElements:a,duplicatedElements:o}=i;this.scene.replaceAllElements(a),o.forEach(e=>{if(D(e)&&fn(e)){let t=xe(e,this.scene.getElementsMapIncludingDeleted());ga(e,t,this.scene)}}),$t&&Co.loadElementsFonts(o,this.ownerDocument).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files);let s=us(o);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&ex.get(WR)?this.state.openSidebar:null,...fr(s,this.scene.getNonDeletedElements(),this.state)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e.fit&&this.viewport.setViewport({target:o,fit:e.fit,animation:!1,offsets:{ui:!0}})}),B(this,`setAppState`,(e,t)=>{this.setState(e,t)}),B(this,`removePointer`,e=>{bW&&this.resetContextMenuTimer(),e.type===`pointercancel`&&(this.bucketFill.cancel(),this.textTool.cancel());let t=TW.pointers.size>=2;TW.pointers.delete(e.pointerId),t&&TW.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()}),B(this,`toggleLock`,(e=`ui`)=>{this.props.activeTool||(this.state.activeTool.locked||Yw(`toolbar`,`toggleLock`,`${e} (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...ln(this.state,e.activeTool.locked?{type:this.state.preferredSelectionTool.type}:e.activeTool),locked:!e.activeTool.locked}})))}),B(this,`updateFrameRendering`,e=>{this.setState(t=>{let n=typeof e==`function`?e(t.frameRendering):e;return{frameRendering:{enabled:n?.enabled??t.frameRendering.enabled,clip:n?.clip??t.frameRendering.clip,name:n?.name??t.frameRendering.name,outline:n?.outline??t.frameRendering.outline}}})}),B(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0,currentItemStrokeVariability:t.penDetected?t.currentItemStrokeVariability:`variable`}))}),B(this,`revealIfHidden`,e=>{!e.length||Di(e,this.canvas.width/this.ownerWindow.devicePixelRatio,this.canvas.height/this.ownerWindow.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:Hc(e),fit:`scale-down`,animation:{duration:300},offsets:{ui:!0}})}),B(this,`emitUserFollowIntent`,e=>{this.onUserFollowEmitter.trigger(e),this.props.onUserFollow?.(e)}),B(this,`requestUnfollow`,()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:`UNFOLLOW`})}),B(this,`setToast`,e=>{this.setState({toast:e})}),B(this,`restoreFileFromShare`,async()=>{try{let e=await caches.open(`web-share-target`),t=await e.match(`shared-file`);if(t){let n=await t.blob(),r=new File([n],n.name||``,{type:n.type});this.loadFileToCanvas(r,null),await e.delete(`shared-file`),this.ownerWindow.history.replaceState(null,rn,this.ownerWindow.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),B(this,`addFiles`,pF(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),B(this,`addMissingFiles`,(e,t=!1)=>{let n=t?{}:{...this.files},r={},i=Array.isArray(e)?e:Object.values(e);for(let e of i)if(!n[e.id]&&(r[e.id]=e,n[e.id]=e,e.mimeType===A.svg))try{let t=Zc(Tr(la(e.dataURL)),A.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),B(this,`updateScene`,pF(e=>{let{elements:t,appState:n,collaborators:r,captureUpdate:i}=e;if(i){let e=t||void 0,r=n?Cr({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:i,elements:e,appState:r})}n&&this.setState(n),t&&this.scene.replaceAllElements(t),r&&(this.laserTrails.updateCollabTrails(r),this.setState({collaborators:r}))})),B(this,`setElementRenderOverrides`,e=>{if(this.unmounted)return;let t=LP(e);!t.size&&!this.elementRenderOverrides.size||(this.elementRenderOverrides=t,this.elementRenderOffsets=RP(this.elementRenderOverrides,this.elementRenderOffsets),this.renderOverridesUpdatePending=!0,this.forceUpdate())}),B(this,`applyDeltas`,(e,t)=>{let n=Lt.squash(...e),r={...this.state},i=new Map(this.scene.getElementsMapIncludingDeleted());return Lt.applyTo(n,i,r,t)}),B(this,`mutateElement`,(e,t,n=!0)=>this.scene.mutateElement(e,t,{informMutation:n,isDragging:!1})),B(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),B(this,`toggleSidebar`,({name:e,tab:t,force:n})=>{let r;r=n===void 0?this.state.openSidebar?.name===e&&this.state.openSidebar?.tab===t?null:e:n?e:null;let i=r?{name:r}:null;return i&&t&&(i.tab=t),this.setState({openSidebar:i}),!!r}),B(this,`updateCurrentCursorPosition`,pF(e=>{this.viewport.lastPosition.x=e.clientX,this.viewport.lastPosition.y=e.clientY})),B(this,`onKeyDown`,pF(e=>{if(!this.isInteractionEnabled())return;if(`Proxy`in this.ownerWindow&&(!e.shiftKey&&/^[A-Z]$/.test(e.key)||e.shiftKey&&/^[a-z]$/.test(e.key))&&(e=new Proxy(e,{get(t,n){let r=t[n];return typeof r==`function`?r.bind(t):n===`key`?e.shiftKey?t.key.toUpperCase():t.key.toLowerCase():r}})),!cc(e.target)){if((e.key===z.ESCAPE||e.key===z.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=Kc(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&O(t[0])&&e.key===z.ENTER){this.startImageCropping(t[0]);return}if(e.key===z.ESCAPE)this.updateEditorAtom(Qk,null);else if(e.key===z.TAB&&(this.ownerDocument.activeElement===this.excalidrawContainerRef?.current||this.ownerDocument.activeElement?.classList.contains(hn.CONVERT_ELEMENT_TYPE_POPUP))){e.preventDefault();let n=aA(t);ex.get(Qk)?.type===`panel`&&iA(this,{conversionType:n,direction:e.shiftKey?`left`:`right`})&&this.store.scheduleCapture(),n&&this.updateEditorAtom(Qk,{type:`panel`})}if(this.flowchart.handleKeyEvent(e))return}if(e[z.CTRL_OR_CMD]&&e.key===z.P&&!e.shiftKey&&!e.altKey){this.setToast({message:G(`commandPalette.shortcutHint`,{shortcut:wA(`commandPalette`)})}),e.preventDefault();return}if(e[z.CTRL_OR_CMD]&&e.key.toLowerCase()===z.V&&this.clipboard.onPasteShortcut(e),e[z.CTRL_OR_CMD]&&_(e.target)&&(e.code===d.MINUS||e.code===d.EQUAL)){e.preventDefault();return}if(_(e.target)&&e.key!==z.ESCAPE||Pt(e.key)&&cc(e.target))return;if(e.key===z.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}if(e.key.toLowerCase()===z.E&&e.shiftKey&&e[z.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:`imageExport`}});return}if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}if(this.state.openDialog?.name===`elementLinkSelector`)return;if(e.key===z.ALT){if(this.state.activeTool.type===`bucketfill`){this.bucketFill.openTemporaryEyeDropper(),e.preventDefault();return}Ki(`COMPLEX_BINDINGS`)?this.handleSkipBindMode():Li({app:this,event:e})}if(this.actionManager.handleKeyDown(e))return;let t=this.props.viewModeEnabled===!0;if(!t&&this.state.viewModeEnabled&&e.key===z.ESCAPE){this.setActiveTool({type:`selection`});return}if(!t&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=kD(e.key,this,e.shiftKey);if(this.state.viewModeEnabled&&!dr(t,[`laser`,`hand`]))return;if(t){if(this.state.activeTool.type!==t&&Yw(`toolbar`,t,`keyboard (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`){let e=this.state.currentItemArrowType===Pe.sharp?Pe.round:this.state.currentItemArrowType===Pe.round?Pe.elbow:Pe.sharp;this.setState({currentItemArrowType:e}),this.cursorHints.onArrowTypeCycled(e)}else(t===`arrow`||t===`line`)&&this.cursorHints.onToolShortcut(t,/^\d$/.test(e.key)?`digit`:`letter`);t===`bucketfill`&&this.state.activeTool.type===`bucketfill`?this.bucketFill.cycleBackgroundColor():t===`lasso`&&this.state.activeTool.type===`laser`?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:t},{toggle:!0}),e.stopPropagation();return}if(e.key===z.Q){this.toggleLock(`keyboard`),e.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(e[z.CTRL_OR_CMD]&&!e.repeat&&(Ki(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),(0,Cl.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.textTool.refresh(e),Li({app:this,event:e})),Pt(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=new Set;t.filter(e=>bo(e)).filter(e=>{let n=e.startBinding&&!t.some(t=>t.id===e.startBinding?.elementId),r=e.endBinding&&!t.some(t=>t.id===e.endBinding?.elementId);return n||r}).forEach(e=>n.add(e.id)),t=t.filter(e=>!n.has(e.id));let r=this.getEffectiveGridSize()&&(e.shiftKey?1:this.getEffectiveGridSize())||(e.shiftKey?5:1),i=0,a=0;e.key===z.ARROW_LEFT?i=-r:e.key===z.ARROW_RIGHT?i=r:e.key===z.ARROW_UP?a=-r:e.key===z.ARROW_DOWN&&(a=r),t.forEach(e=>{this.scene.mutateElement(e,{x:e.x+i,y:e.y+a},{informMutation:!1,isDragging:!1}),bi(e,this.scene,{simultaneouslyUpdated:t})}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===z.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[z.CTRL_OR_CMD]||co(n))ja(n)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==n.id)&&(this.store.scheduleCapture(),vn(n)||this.actionManager.executeAction(_P));else if(D(n)||ms(n)){let t;D(n)||(t=n);let r=Oe(n,this.scene.getNonDeletedElementsMap()),i=r.x,a=r.y;this.text.startTextEditing({sceneX:i,sceneY:a,container:t}),e.preventDefault();return}else F(n)&&this.setState({editingFrame:n.id})}}if(e.key===z.SPACE&&TW.pointers.size===0&&(this.pan.setSpaceHeld(!0),this.cursor.set(To.GRAB),e.preventDefault()),(e.key===z.G||e.key===z.S)&&!e.altKey&&!e[z.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===z.G&&(Tc(this.state.activeTool.type)||t.some(e=>Tc(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===z.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[z.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===z.F){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;(this.state.activeTool.type===`text`||t.find(e=>D(e)||Sn(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}e[z.CTRL_OR_CMD]&&(e.key===z.BACKSPACE||e.key===z.DELETE)&&this.updateEditorAtom(NM,`clearCanvas`);let n=e.key.toLocaleLowerCase(),r=n===z.S&&e.shiftKey&&!e[z.CTRL_OR_CMD],i=e.key===z.I||n===z.G&&e.shiftKey;(r||i)&&this.openEyeDropper({type:r?`stroke`:`background`})})),B(this,`onKeyUp`,pF(e=>{if(this.isInteractionEnabled()){if(e.key===z.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!==`laser`||this.state.openDialog?.name===`elementLinkSelector`?this.cursor.set(To.GRAB):pa(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:j({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),this.pan.setSpaceHeld(!1)),e.key===z.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Li({app:this,event:e})),(e.key===z.ALT&&this.state.bindMode===`skip`||!e[z.CTRL_OR_CMD]&&!ol(this.state))&&(this.setState({bindMode:`orbit`}),this.lastPointerMoveEvent&&Ki(`COMPLEX_BINDINGS`))){let e=ws({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state);if(this.state.selectedLinearElement){let t=R.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());if(bo(t)){let n=_t(L(e.x,e.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.handleDelayedBindModeChange(t,n)}}}if(!e[z.CTRL_OR_CMD]){let t=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==t&&((0,Cl.flushSync)(()=>{this.setState({isBindingEnabled:t})}),this.textTool.refresh(e)),Li({app:this,event:e})}if(Pt(e.key)){lc(this.scene.getSelectedElements(this.state).filter(ir),this.scene,this.state);let e=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(ia).forEach(t=>{t.startBinding&&this.scene.mutateElement(t,{startBinding:{...t.startBinding,...Ca(t,e.get(t.startBinding.elementId),`start`,e)}}),t.endBinding&&this.scene.mutateElement(t,{endBinding:{...t.endBinding,...Ca(t,e.get(t.endBinding.elementId),`end`,e)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(e)}})),B(this,`setActiveTool`,(e,t={})=>{let{keepSelection:n=!1}=t;if(!this.isToolSupported(e.type)){console.warn(this.isInteractionEnabled()?`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`:`"${e.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,e)){console.warn(`"${e.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(JD);let r=ED.includes(e.type),i=t.toggle===!0&&r&&this.state.activeTool.type===e.type?ln(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):r&&this.state.activeTool.type!==e.type?ln(this.state,{...e,lastActiveTool:this.state.activeTool}):ln(this.state,e);i.type===`hand`?this.cursor.set(To.GRAB):this.pan.isSpaceHeld()||this.cursor.applyForTool(i),Wi(this.ownerDocument.activeElement)&&this.focusContainer(),he(i.type)||this.setState({suggestedBinding:null}),i.type===`image`&&this.onImageToolbarButtonClick(),this.setState(e=>{let t={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:pa(i.type)?e.selectedLinearElement:null,frameToHighlight:null};return i.type===`freedraw`&&this.store.scheduleCapture(),i.type===`lasso`?{...e,...t,activeTool:i,...n?{}:{selectedElementIds:j({},e),selectedGroupIds:j({},e),editingGroupId:null,multiElement:null}}:i.type===`selection`?{...e,...t,activeTool:i}:{...e,...t,activeTool:i,selectedElementIds:j({},e),selectedGroupIds:j({},e),editingGroupId:null,multiElement:null}})}),B(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),B(this,`isTouchScreenMultiTouchGesture`,()=>TW.pointers.size>=2),B(this,`getName`,()=>this.state.name||this.props.name||`${G(`labels.untitled`)}-${Zs()}`),B(this,`onGestureStart`,pF(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:j({},this.state),activeEmbeddable:null}),TW.initialScale=this.state.zoom.value)})),B(this,`onGestureChange`,pF(e=>{if(!this.isNavigationEnabled()||(e.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let t=TW.initialScale;t&&this.viewport.translate(n=>({...ti({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Oa(t*e.scale)},n)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})})),B(this,`onGestureEnd`,pF(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:j(this.state.previousSelectedElementIds,this.state)}),TW.initialScale=null)})),B(this,`startImageCropping`,e=>{this.store.scheduleCapture(),this.setState({croppingElementId:e.id})}),B(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))}),B(this,`shouldHandleBrowserCanvasDoubleClick`,e=>{if(e===`touch`||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[t,n]=this.lastCompletedCanvasClicks;return Ke(L(t.x,t.y),L(n.x,n.y))<=35}),B(this,`handleCanvasDoubleClick`,e=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(e.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!==`autoshape`)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:r}=ws(e,this.state);if(t.length===1&&ja(t[0])){let i=t[0];if((e[z.CTRL_OR_CMD]&&ia(i)||co(i))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==i.id)){this.actionManager.executeAction(_P);return}if(this.state.selectedLinearElement&&vn(t[0])){let e=R.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?R.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.scheduleCapture(),R.deleteFixedSegment(t[0],this.scene,i);let a=R.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?R.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,a,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:o,value:e,added:!1}},segmentMidPointHoveredCoords:a}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===i.id&&co(i))return}if(t.length===1&&O(t[0])){this.startImageCropping(t[0]);return}if(this.cursor.reset(),Mo(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&Vo(e,this.state.selectedGroupIds);if(t){this.store.scheduleCapture(),this.setState(n=>({...n,...sn({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let i=this.getElementAtPosition(n,r);if(Ge(i)){this.isIframeLikeInteractive(i)&&this.setState({activeEmbeddable:{element:i,state:`active`}});return}if(!this.state.selectedLinearElement?.isEditing){let i=!e[z.CTRL_OR_CMD]&&(t.length===1?ve(t[0],!1)?t[0]:null:this.text.getTextBindableContainerAtPosition(n,r));if(i&&(this.state.activeTool.type===`autoshape`||ke(i)||!Zr(i.backgroundColor)||xr({point:L(n,r),element:i,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(i)}))){let e=Oe(i,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.text.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:i||null})}}}),B(this,`handleCanvasClick`,e=>{if(this.isInteractionEnabled()){if(e.button!==Aa.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:e.clientX,y:e.clientY}]}}),B(this,`getElementLinkAtPosition`,(e,t)=>{if(t&&t.locked)return;let n=this.scene.getNonDeletedElements(),r=-1;for(let i=n.length-1;i>=0;i--){let a=n[i];if(t&&a.id===t.id&&(r=i),a.link&&i>=r&&tn(a,this.scene.getNonDeletedElementsMap(),this.state,L(e.x,e.y),this.editorInterface.formFactor===`phone`))return a}}),B(this,`handleElementLinkClick`,e=>{let t=Ke(L(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),L(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||t>10)return;let n=ws(this.lastPointerDownEvent,this.state),r=this.scene.getNonDeletedElementsMap(),i=tn(this.hitLinkElement,r,this.state,L(n.x,n.y),this.editorInterface.formFactor===`phone`),a=ws(this.lastPointerUpEvent,this.state),o=tn(this.hitLinkElement,r,this.state,L(a.x,a.y),this.editorInterface.formFactor===`phone`);if(i&&o){Rk();let t=this.hitLinkElement.link;if(t){t=Ee(t);let n;if(this.props.onLinkOpen&&(n=ie(P.EXCALIDRAW_LINK,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=wr(t)?`_self`:`_blank`,n=this.ownerWindow.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),B(this,`applyElementLinkHoverAffordance`,()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(To.POINTER),Ik(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(Rk(),!1)),B(this,`maybeHandleElementLinkClick`,(e,t)=>{if(this.editorInterface.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(t,e)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(e),!0):!1}),B(this,`handleInteractiveContentPointerMove`,e=>{let t=ws(e,this.state),n=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let r=n?.locked?null:n;if(this.handleIframeLikeElementHover({hitElement:r,scenePointer:t,moveEvent:e}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(t,n):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()}),B(this,`handleInteractiveContentPointerUp`,e=>{if(this.lastPointerUpEvent=e,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let t=ws(e,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(e,t)||this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),B(this,`getTopLayerFrameAtSceneCoords`,(e,t)=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(t=>!t.locked&&Za(e,t,n));if(!r.length)return null;let i=r.at(-1),a=this.getElementsAtPosition(e.x,e.y,{includeLockedElements:!0}).findLast(e=>!t?.excludeElementIds?.[e.id]);if(a){if(F(a)&&!a.locked)return i;let e=this.scene.getElementIndex(a.id),n=this.scene.getElementIndex(i.id);return e!==-1&&n!==-1&&e<=n?i:(t?.currentFrameId?r.find(e=>e.id===t.currentFrameId)??null:null)||(a.frameId?r.find(e=>e.id===a.frameId)??null:null)}return i}),B(this,`updateFrameToHighlight`,e=>{this.state.frameToHighlight!==e&&this.setState({frameToHighlight:e})}),B(this,`maybeUpdateFrameToHighlightOnPointerMove`,(e,t)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!t&&ae(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(e):null)}),B(this,`insertNewElements`,e=>{if(!e.length)return;let t=[];for(let n of e){let e=t[t.length-1];e?.[0].frameId===n.frameId?e.push(n):t.push([n])}for(let e of t){let t=e[0].frameId,n=t?Rn(this.scene.getElementsIncludingDeleted(),t):null;this.scene.insertElementsAtIndex(e,n)}}),B(this,`insertNewElement`,e=>{this.insertNewElements([e]);let t=e.frameId?this.scene.getNonDeletedElement(e.frameId):null;this.updateFrameToHighlight(t&&F(t)?t:null)}),B(this,`handleCanvasPointerMove`,e=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(e),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!this.pan.isActive()&&this.handleInteractiveContentPointerMove(e);return}this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent;let t=ws(e,this.state),{x:n,y:r}=t;if(this.lastPointerMoveCoords={x:n,y:r},this.updateMultiTouchGesture(e),this.pan.isNavigating())return;let i=TF(yW,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?this.cursor.set(To.AUTO):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:n,y:r},i);let a=this.textTool.updateHover(t,e,i);if(!this.state.newElement&&cF(this.state.activeTool.type)){let{originOffset:t,snapLines:i}=sF(this.scene.getNonDeletedElements(),this,{x:n,y:r},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let n=Uc(e.snapLines,i),r=e.originSnapOffset?Uc(e.originSnapOffset,t):t;return e.snapLines===n&&e.originSnapOffset===r?null:{snapLines:n,originSnapOffset:r}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let t=this.state.newElement?null:R.handlePointerMoveInEditMode(e,n,r,this);t&&t!==this.state.selectedLinearElement&&(0,Cl.flushSync)(()=>{this.setState({selectedLinearElement:t})})}if(Fr(this.state.activeTool.type)){let{newElement:e}=this.state;if(!e&&ol(this.state)){let e=L(n,r),t=this.scene.getNonDeletedElementsMap(),i={elbowed:this.state.currentItemArrowType===Pe.elbow},a=_t(e,this.scene.getNonDeletedElements(),t,this.state.zoom);a?this.setState({suggestedBinding:{element:a,midPoint:so(e,a,t,this.state.zoom,i)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:t,selectedLinearElement:i}=this.state,{x:a,y:o,points:s}=t,c=s[s.length-1],{lastCommittedPoint:l}=i;if(this.cursor.applyForTool(),c===l)Ke(L(n-a,r-o),c)>=8?(this.store.scheduleCapture(),(0,Cl.flushSync)(()=>{E(this.state.selectedLinearElement?.initialState,`initialState must be set`),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:s[s.length-1],selectedPointsIndices:[t.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:t.points.length}}})}),this.scene.mutateElement(t,{points:[...s,L(n-a,r-o)]},{informMutation:!1,isDragging:!1})):this.cursor.set(To.POINTER);else if(s.length>2&&l&&Ke(L(n-a,r-o),l)<8){this.cursor.set(To.POINTER),this.scene.mutateElement(t,{points:s.slice(0,-1)},{informMutation:!1,isDragging:!1});let e=t.points.length-1;this.setState({selectedLinearElement:{...i,selectedPointsIndices:i.selectedPointsIndices?[...new Set(i.selectedPointsIndices.map(t=>Math.min(t,e)))]:i.selectedPointsIndices,lastCommittedPoint:t.points[e],initialState:{...i.initialState,lastClickedPoint:e}}})}else{ft(s,this.state.zoom.value)&&this.cursor.set(To.POINTER);let i=this.scene.getNonDeletedElementsMap();if(ia(t)){let e=_t(L(n,r),this.scene.getNonDeletedElements(),i,this.state.zoom);Ki(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(t,e)}E(this.state.selectedLinearElement,`Expected selectedLinearElement to be set to operate on a linear element`);let a=R.handlePointerMove(e.nativeEvent,this,n,r,this.state.selectedLinearElement);a&&this.setState(a)}return}if(this.state.activeTool.type===`arrow`&&!this.state.newElement){let e=L(n,r),t=_t(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom),i=this.scene.getNonDeletedElementsMap();t&&!Va(e,t,i)&&this.setState({suggestedBinding:{element:t,midPoint:so(e,t,i,this.state.zoom,{elbowed:this.state.currentItemArrowType===Pe.elbow})}})}let o=!!e.buttons,s=this.state.activeTool.type===`laser`;if(o||!s&&this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`lasso`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let c=this.scene.getNonDeletedElements(),l=this.scene.getSelectedElements(this.state);if(this.text.isHittingTextAutoResizeHandle(l,t)){this.cursor.set(To.POINTER);return}if(l.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!==`elementLinkSelector`&&!(l.length===1&&vn(l[0]))&&(!ja(l[0])||!this.editorInterface.userAgent.isMobileDevice&&l[0].points.length!==2)){let t=Ss(c,this.state,n,r,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(t&&t.transformHandleType){this.cursor.set(de(t));return}}}else if(l.length>1&&!i&&this.state.openDialog?.name!==`elementLinkSelector`){let t=nr(Hc(l),n,r,this.state.zoom,e.pointerType,this.editorInterface);if(t){this.cursor.set(de({transformHandleType:t}));return}}if(wc(this.state))return;let u=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),d=null;if(d=u&&u.locked?null:u,this.handleIframeLikeElementHover({hitElement:d,scenePointer:t,moveEvent:e})||(this.hitLinkElement=this.getElementLinkAtPosition(t,u)),!this.applyElementLinkHoverAffordance()){if(s)return;d&&(d.link||Si(d))&&this.state.selectedElementIds[d.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?this.cursor.set(this.textTool.cursorFor(a)):!e[z.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(t,l)?this.cursor.set(To.MOVE):this.state.viewModeEnabled?this.cursor.set(To.GRAB):this.state.openDialog?.name===`elementLinkSelector`||i?this.cursor.set(To.AUTO):!e[z.CTRL_OR_CMD]&&d?.id!==this.state.editingTextElement?.id?(d||this.isHittingCommonBoundingBoxOfSelectedElements(t,l))&&!d?.locked&&(!d||!vn(d)||!(d.startBinding||d.endBinding))&&(this.state.activeTool.type!==`lasso`||l.length>0)&&this.cursor.set(To.MOVE):this.cursor.set(To.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r)}this.state.openDialog?.name===`elementLinkSelector`&&d?this.setState(e=>({hoveredElementIds:Uc(e.hoveredElementIds,sn({editingGroupId:e.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!d&&this.setState(e=>({hoveredElementIds:Uc(e.hoveredElementIds,{})}))}),B(this,`handleEraser`,(e,t)=>{let n=this.eraserTrail.addPointToPath(t.x,t.y,e.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()}),B(this,`handleTouchMove`,e=>{this.isInteractionEnabled()&&(xW=!0)}),B(this,`handleCanvasPointerDown`,e=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=e),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(e),this.pan.isActive()||this.pan.start(e));return}let t=this.scene.getSelectedElements(this.state);if(!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let n=ws(e,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=e.target;if(a.setPointerCapture&&a.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.state.activeTool.type!==`laser`&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches&&{focusedId:null,matches:e.searchMatches.matches.map(e=>({...e,focus:!1}))}})),this.updateEditorAtom(Az,null)),ex.get(Qk)&&this.updateEditorAtom(Qk,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(e),e.pointerType===`touch`&&this.state.newElement&&this.state.newElement.type===`freedraw`){let e=this.state.newElement;this.updateScene({...e.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:j(Object.keys(this.state.selectedElementIds).filter(t=>t!==e.id).reduce((e,t)=>(e[t]=this.state.selectedElementIds[t],e),{}),this.state)},captureUpdate:this.state.openDialog?.name===`elementLinkSelector`?I.EVENTUALLY:I.NEVER});return}let o=this.ownerDocument.getSelection();if(o?.anchorNode&&o.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),!this.state.penDetected&&e.pointerType===`pen`&&this.setState(e=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:`variable`})),!this.editorInterface.isTouchScreen&&[`pen`,`touch`].includes(e.pointerType)&&(this.editorInterface=ao(this.editorInterface,{isTouchScreen:!0})),this.pan.isActive()||(this.lastPointerDownEvent=e,this.pan.start(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===Aa.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Ys.eraser){this.setState({activeTool:ln(this.state,{type:Ys.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),wc(this.state)&&this.setState({activeTool:ln(this.state,{...this.state.activeTool.lastActiveTool||{type:Ys.selection},lastActiveTool:null})})},n=we(this.ownerWindow,P.POINTER_UP,t,{once:!0}),r;this.ownerWindow.requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==Aa.MAIN&&e.button!==Aa.TOUCH&&e.button!==Aa.ERASER||TW.pointers.size>1)return;let s=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.text.handleTextAutoResizeHandlePointerDown(t,s.origin)||this.handleDraggingScrollBar(e,s)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(e,s))||this.state.penMode&&e.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 t=s.hit.element&&this.isASelectedElement(s.hit.element);(e.altKey&&e[z.CTRL_OR_CMD]&&!s.resize.handleType||!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!t)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(s.origin.x,s.origin.y,e.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor===`desktop`),this.editorInterface.formFactor!==`desktop`&&s.hit.element&&!t&&(this.setState(e=>{let t={...e.selectedElementIds,[s.hit.element.id]:!0},n=[];Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)});let r=s.hit.element;if(F(r))Dn(n,r.id).forEach(e=>{delete t[e.id]});else if(r.frameId)t[r.frameId]&&delete t[r.id];else{let e=r.groupIds,i=new Set(e.flatMap(e=>ul(this.scene.getNonDeletedElements(),e)).filter(e=>F(e)).map(e=>e.id));i.size>0&&n.forEach(e=>{e.frameId&&i.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>ul(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return{...sn({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:r.link||Si(r)?`info`:!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type===`text`?this.textTool.handlePointerDown(e,s):this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`?this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`freedraw`?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`custom`?this.cursor.applyForTool():this.state.activeTool.type===Ys.frame||this.state.activeTool.type===Ys.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===`autoshape`?this.drawShape.handlePointerDown(s):this.state.activeTool.type===Ys.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,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,e),this.state.activeTool.type===`eraser`&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let c=this.onPointerMoveFromPointerDownHandler(s),l=this.onPointerUpFromPointerDownHandler(s),u=this.onKeyDownFromPointerDownHandler(s),d=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(t=>l(t||e.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(this.ownerWindow.addEventListener(P.POINTER_MOVE,c),this.ownerWindow.addEventListener(P.POINTER_UP,l),this.ownerWindow.addEventListener(P.KEYDOWN,u),this.ownerWindow.addEventListener(P.KEYUP,d),s.eventListeners.onMove=c,s.eventListeners.onUp=l,s.eventListeners.onKeyUp=d,s.eventListeners.onKeyDown=u)}),B(this,`handleCanvasPointerCancel`,e=>{this.removePointer(e),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent)}),B(this,`handleCanvasPointerUp`,e=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(e);return}if(Ki(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.removePointer(e),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,e),this.lastPointerUpEvent=e,!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let t=ws({clientX:e.clientX,clientY:e.clientY},this.state),{x:n,y:r}=t;this.lastPointerMoveCoords={x:n,y:r},!this.handleIframeLikeCenterClick()&&!this.maybeHandleElementLinkClick(e,t)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),B(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(xW=!1,bW?xW=!0:bW=this.ownerWindow.setTimeout(()=>{bW=0,xW||this.handleCanvasContextMenu(e)},500))}),B(this,`resetContextMenuTimer`,()=>{clearTimeout(bW),bW=0,xW=!1}),B(this,`maybeCleanupAfterMissingPointerUp`,e=>{this.pan.end(),wW?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),B(this,`updateMultiTouchGesture`,e=>{TW.pointers.has(e.pointerId)&&TW.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=TW.initialScale;if(TW.pointers.size===2&&TW.lastCenter&&t&&TW.initialDistance){let e=PP(TW.pointers),n=e.x-TW.lastCenter.x,r=e.y-TW.lastCenter.y;TW.lastCenter=e;let i=FP(Array.from(TW.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/TW.initialDistance,o=a?Oa(t*a):this.state.zoom.value;this.setState(t=>{let i=ti({viewportX:e.x,viewportY:e.y,nextZoom:o},t),a=i.zoom.value;return this.viewport.translate({zoom:i.zoom,scrollX:i.scrollX+2*n/a,scrollY:i.scrollY+2*r/a,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else TW.lastCenter=TW.initialDistance=TW.initialScale=null}),B(this,`clearSelectionIfNotUsingSelection`,()=>{pa(this.state.activeTool.type)||this.setState({selectedElementIds:j({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),B(this,`handleSelectionOnPointerDown`,(e,t)=>{if(pa(this.state.activeTool.type)){if(this.duplicate.hitEditedElement(t))return!1;let n=this.scene.getNonDeletedElements(),r=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.selectedLinearElement?.isEditing&&!vn(i[0])&&(!ja(i[0])||!this.editorInterface.userAgent.isMobileDevice&&i[0].points.length!==2)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=Ss(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);r!=null&&(r.transformHandleType===`rotation`?(this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType))}else i.length>1&&(t.resize.handleType=nr(Hc(i),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.editorInterface));if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=St(Lo(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&ja(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=Mi(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.selectedLinearElement,r=R.handlePointerDown(e,this,this.store,t.origin,n,this.scene);if(r.hitElement&&(t.hit.element=r.hitElement),t.hit.arrowLabel=r.hitBoundText,r.linearElementEditor&&this.setState({selectedLinearElement:r.linearElementEditor}),r.didAddPoint)return!0;let i=this.scene.getNonDeletedElementsMap(),a=R.getElement(n.elementId,i);if(a&&bo(a)){let{hitFocusPoint:e,pointerOffset:r,arrowOtherEndpointInitialBinding:o}=ht(a,t,i,this.state);if(e)return this.setState({selectedLinearElement:{...n,hoveredFocusPointBinding:e,draggedFocusPointBinding:e,pointerOffset:r,initialState:{...n.initialState,arrowOtherEndpointInitialBinding:o}}}),!1}}let n=this.getElementsAtPosition(t.origin.x,t.origin.y,{includeLockedElements:!0}),r=n.filter(e=>!e.locked),i=this.getElementAtPosition(t.origin.x,t.origin.y,{allHitElements:n});if((!i||i.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),i&&i.locked&&!r.some(e=>this.state.selectedElementIds[e.id])?t.hit.element=null:t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,i),this.hitLinkElement)return!0;if(this.state.croppingElementId&&t.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),t.hit.element&&this.getElementLinkAtPosition({x:t.origin.x,y:t.origin.y},t.hit.element))return!1;t.hit.allHitElements=r;let a=t.hit.element,o=t.hit.allHitElements.some(e=>this.isASelectedElement(e))||a!==null&&this.isASelectedElement(a);if((a===null||!o)&&!e.shiftKey&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||a&&a?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(a),this.state.selectedLinearElement?.isEditing)this.setState(e=>({selectedLinearElement:e.selectedLinearElement?{...e.selectedLinearElement,isEditing:!!a&&a.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:e.selectedLinearElement?j({[e.selectedLinearElement.elementId]:!0},this.state):j({},e)}));else if(a!=null){if(e[z.CTRL_OR_CMD])return e.altKey?(this.state.openDialog?.name===`elementLinkSelector`&&this.setOpenDialog(null),this.lassoTrail.startPath(t.origin.x,t.origin.y,e.shiftKey),this.setActiveTool({type:`lasso`,fromSelection:!0}),!1):(this.state.selectedElementIds[a.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...pe(e,a),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!Fe(a,this.state.editingGroupId)&&this.setState({selectedElementIds:j({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!o&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(e=>{let t={...e.selectedElementIds,[a.id]:!0},n=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)}),F(a))Dn(n,a.id).forEach(e=>{delete t[e.id]});else if(a.frameId)t[a.frameId]&&delete t[a.id];else{let e=a.groupIds,r=new Set(e.flatMap(e=>ul(this.scene.getNonDeletedElements(),e)).filter(e=>F(e)).map(e=>e.id));r.size>0&&n.forEach(e=>{e.frameId&&r.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>ul(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name===`elementLinkSelector`&&(a.groupIds.some(t=>e.selectedGroupIds[t])||(t={[a.id]:!0})),{...sn({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:a.link||Si(a)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),B(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=Tn(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=this.state.currentItemStrokeVariability,c=Qs({type:t,x:r,y:i,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:o,strokeOptions:{variability:s,streamline:e.pointerType===`mouse`?es:Os},locked:!1,frameId:a?a.id:null,points:[L(0,0)],pressures:o?[]:[e.pressure]});this.insertNewElement(c),this.setState(e=>{let t={...e.selectedElementIds};return delete t[c.id],{selectedElementIds:j(t,e)}}),this.setState({newElement:c,suggestedBinding:null})}),B(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=Tn(e,t,this.lastPointerDownEvent?.[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=m({type:`iframe`,x:i,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:r});return this.insertNewElement(o),o}),B(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=Tn(e,t,this.lastPointerDownEvent?.[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=il(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:G(`toast.unrecognizedLinkFormat`),closable:!0});let o=Br({type:`embeddable`,x:r,y:i,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(o),o}),B(this,`newImagePlaceholder`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=Tn(e,t,this.lastPointerDownEvent?.[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:r,y:i}):null,o=100/this.state.zoom.value;return ye({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:r-o/2,y:i-o/2,width:o,height:o})}),B(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(e.ctrlKey&&(0,Cl.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.state.multiElement){let{multiElement:t,selectedLinearElement:r}=this.state;if(E(r,`selectedLinearElement is expected to be set`),t.type===`line`&&ft(t.points,this.state.zoom.value)){(0,Cl.flushSync)(()=>{this.setState({selectedLinearElement:{...r,lastCommittedPoint:t.points[t.points.length-1],initialState:{...r.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(JD);return}if(vn(t)&&t.points.length>1){this.actionManager.executeAction(JD,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:i,y:a}=t,{lastCommittedPoint:o}=r,s=ws(e,this.state),{start:c,end:l}=bo(t)&&ol(this.state)?zs(t,new Map([[t.points.length-1,{point:t.points[t.points.length-1],isDragging:!1}]]),s.x,s.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),d=c?.mode!=null&&l.mode!=null&&c.element.id===l.element.id&&!Va(l.focusPoint,l.element,u),f=l.mode===`orbit`&&t.startBinding?.elementId!==l.element?.id,p=o&&Ke(L(n.origin.x-i,n.origin.y-a),o)<8;if(f||d||t.points.length>1&&p){this.actionManager.executeAction(JD,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(e=>({selectedElementIds:j({...e.selectedElementIds,[t.id]:!0},e)})),this.cursor.set(To.POINTER)}else{let[r,i]=Tn(n.origin.x,n.origin.y,e[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),{currentItemStartArrowhead:o,currentItemEndArrowhead:s}=this.state,[c,l]=t===`arrow`?[o,s]:[null,null],u=t===`arrow`?w({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Pe.round?{type:Un.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Pe.elbow,fixedSegments:this.state.currentItemArrowType===Pe.elbow?[]:null}):jc({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness===`round`?{type:Un.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),d=L(n.origin.x,n.origin.y),f=this.scene.getNonDeletedElementsMap(),p=ol(this.state)?_t(d,this.scene.getNonDeletedElements(),f,this.state.zoom):null;this.scene.mutateElement(u,{points:[L(0,0),L(0,0)]}),this.insertNewElement(u),bo(u)&&xc(u,new Map([[0,{point:L(0,0),isDragging:!1}]]),d[0],d[1],this.scene,this.state,{newArrow:!0,altKey:e.altKey,initialBinding:!0,angleLocked:Fa(e.nativeEvent)}),(0,Cl.flushSync)(()=>{this.setState(t=>{let r=null,i=t.selectedElementIds;if(ja(u)){r=new R(u,this.scene.getNonDeletedElementsMap());let t=u.points.length-1;r={...r,selectedPointsIndices:[t],initialState:{...r.initialState,arrowStartIsInside:e.altKey,lastClickedPoint:t,origin:L(n.origin.x,n.origin.y)}}}return i=this.isToolLocked()?t.selectedElementIds:j({[u.id]:!0},t),{...t,bindMode:`orbit`,newElement:u,suggestedBinding:p&&bo(u)?{element:p,midPoint:so(d,p,f,this.state.zoom,u)}:null,selectedElementIds:i,selectedLinearElement:r}})}),bo(u)&&Ki(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(u,p)}}),B(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=Tn(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r}),a={x:n,y:r,strokeColor:e===`stickynote`?this.state.currentItemStickynoteStrokeColor:this.state.currentItemStrokeColor,backgroundColor:e===`stickynote`?this.state.currentItemStickynoteBackgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(e),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(e),locked:!1,frameId:i?i.id:null},o;o=e===`embeddable`?Br({type:`embeddable`,...a}):e===`stickynote`?_e({type:`stickynote`,...a}):jr({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.insertNewElement(o),this.setState({multiElement:null,newElement:o}))}),B(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=Tn(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...xo},a=t===Ys.magicframe?Ri(i):Tt(i);this.insertNewElement(a),this.setState({multiElement:null,newElement:a})}),B(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),B(this,`eraseElements`,()=>{let e=!1;this.elementsPendingErasure.forEach(e=>{let t=this.scene.getElement(e);if(bo(t)){if(t.startBinding){let e=this.scene.getElement(t.startBinding.elementId);oo(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}if(t.endBinding){let e=this.scene.getElement(t.endBinding.elementId);oo(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}}else Xr(t)&&t.boundElements?.forEach(e=>{if(e.type===`arrow`){let n=this.scene.getElement(e.id);n?.startBinding?.elementId===t.id&&oo(n,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),n?.endBinding?.elementId===t.id&&oo(n,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||fn(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,N(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.scheduleCapture(),this.scene.replaceAllElements(t))}),B(this,`initializeImage`,async(e,t)=>{if(!Et(t))throw Error(G(`errors.unsupportedFileType`));let n=t.type;if(this.cursor.set(`wait`),n===A.svg)try{t=Zn(Tr(await t.text()),t.name)}catch(e){throw console.warn(e),Error(G(`errors.svgImageInsertError`))}let r=await(this.props.generateIdForFile?.(t)||gs(t));if(!r)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(G(`errors.imageInsertError`));if(!this.files[r]?.dataURL){let{maxWidthOrHeight:e,maxFileSizeBytes:n}=this.props.imageOptions;try{t=await st(t,{maxWidthOrHeight:e})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(t.size>n)throw Error(G(`errors.fileTooBig`,{maxSize:`${Math.trunc(n/1024/1024)}MB`}))}let i=this.files[r]?.dataURL||await dn(t);return new Promise(async(t,a)=>{try{let a=this.getLatestInitializedImageElement(e,r);if(this.addMissingFiles([{mimeType:n,id:r,dataURL:i,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(r)){this.addNewImagesToImageCache();let{erroredFiles:e}=await this.updateImageCache([a]);if(e.size)throw Error(`Image cache update resulted with an error.`)}let o=await this.imageCache.get(r)?.image;if(o&&this.state.newElement?.id!==a.id){a=this.getLatestInitializedImageElement(e,r);let t=this.getImageNaturalDimensions(a,o);Object.assign(a,t)}t(a)}catch(e){console.error(e),a(Error(G(`errors.imageInsertError`)))}})}),B(this,`getLatestInitializedImageElement`,(e,t)=>{let n=this.scene.getElement(e.id)??e;return N(n,{fileId:t})}),B(this,`onImageToolbarButtonClick`,async()=>{try{let e=this.state.width/2+this.state.offsetLeft,t=this.state.height/2+this.state.offsetTop,{x:n,y:r}=ws({clientX:e,clientY:t},this.state),i=await xi({description:`Image`,extensions:Object.keys(Fc),multiple:!0});this.insertImages(i,n,r)}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({newElement:null,activeTool:ln(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(JD)})}}),B(this,`getImageNaturalDimensions`,(e,t)=>{let n=Math.max(this.state.height-120,160),r=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(t.naturalHeight,r),a=i*(t.naturalWidth/t.naturalHeight);return{x:e.x+e.width/2-a/2,y:e.y+e.height/2-i/2,width:a,height:i,crop:null}}),B(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await fl({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});return r.size&&(this.store.scheduleAction(I.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>bs(e)&&r.has(e.fileId)?N(e,{status:`error`}):e))),{updatedFiles:n,erroredFiles:r}}),B(this,`addNewImagesToImageCache`,async(e=ui(this.scene.getNonDeletedElements()),t=this.files)=>{let n=e.filter(e=>!e.isDeleted&&!this.imageCache.has(e.fileId));if(n.length){let{updatedFiles:e}=await this.updateImageCache(n,t);if(e.size)for(let t of n)e.has(t.fileId)&&wa.delete(t);e.size&&this.scene.triggerUpdate()}}),B(this,`scheduleImageRefresh`,(0,Tl.default)(()=>{this.addNewImagesToImageCache()},500)),B(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(P.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(P.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas=e,this.cursor.reset(),this.interactiveCanvas.addEventListener(P.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(P.TOUCH_END,this.onTouchEnd))}),B(this,`insertImages`,async(e,t,n)=>{let r=50/this.state.zoom.value,i=Jn(e.map(()=>this.newImagePlaceholder({sceneX:t,sceneY:n})),t,n,r);this.insertNewElements(i);let a=await Promise.all(i.map(async(t,n)=>{try{return await this.initializeImage(t,await ne(e[n]))}catch(e){return this.setState({errorMessage:e.message||G(`errors.imageInsertError`)}),N(t,{isDeleted:!0})}})),o=y(a),s=Jn(a.filter(e=>!e.isDeleted),t,n,r),c=y(s),l=this.scene.getElementsIncludingDeleted().map(e=>c.get(e.id)??o.get(e.id)??e);this.updateScene({appState:{selectedElementIds:j(Object.fromEntries(s.map(e=>[e.id,!0])),this.state)},elements:l,captureUpdate:I.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(JD)})}),B(this,`handleAppOnDrop`,async e=>{if(!this.isFileDropEnabled())return;let{shiftKey:t,clientX:n,clientY:r}=e,i=t?{clientX:n,clientY:r}:void 0,{x:a,y:o}=ws(e,this.state),s=await _O(e),c=s.getFiles();if(c.length===1){let{file:e,fileHandle:t}=c[0];if(e&&(e.type===A.png||e.type===A.svg)){let n;try{n=await jo(e,this.state,this.scene.getElementsIncludingDeleted(),t)}catch(e){if(e.name!==`EncodingError`)throw Error(G(`alerts.couldNotLoadInvalidFile`))}if(n){if(i){this.addElementsFromPasteOrLibrary({elements:n.elements,files:n.files,position:i,retainSeed:!0,preserveFrameChildrenOrder:!0});return}this.syncActionResult({...n,appState:{...n.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:I.IMMEDIATELY}),this.showSceneReplacedToast();return}}}let l=c.map(e=>e.file).filter(e=>Et(e));if(l.length>0&&this.isToolSupported(`image`))return this.insertImages(l,a,o);let u=s.getData(A.excalidrawlibIds),d=s.getData(A.excalidrawlib);if(u||d){try{let t=null;if(u){let{itemIds:e}=JSON.parse(u);t=(await this.library.getLatestLibrary()).filter(t=>e.includes(t.id))}else d&&(t=Is(d));t?.length&&(t=t.map(e=>({...e,elements:se({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:KA(t),position:e,files:null}))}catch(e){this.setState({errorMessage:e.message})}return}if(c.length>0){let{file:e,fileHandle:t}=c[0];e&&await this.loadFileToCanvas(e,t,i)&&this.showSceneReplacedToast()}let f=s.findByType(A.text);if(f){let e=f.value;if(e&&Qt(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||il(e)?.type===`video`)){let t=this.insertEmbeddableElement({sceneX:a,sceneY:o,link:Ee(e)});t&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[t.id]:!0}}))}}}),B(this,`loadFileToCanvas`,async(e,t,n)=>{e=await ne(e);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Bo(e,this.state,r,t)}catch(e){let t=e instanceof uo;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:G(`errors.imageToolNotSupported`)});return}let n=G(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!i)return;if(i.type===A.excalidraw){if(n){this.addElementsFromPasteOrLibrary({elements:i.data.elements,files:i.data.files,position:n,retainSeed:!0,preserveFrameChildrenOrder:!0});return}return qc(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:I.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:I.IMMEDIATELY}),!0}i.type===A.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:G(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),B(this,`handleCanvasContextMenu`,e=>{e.preventDefault(),!this.pan.consumesContextMenuEvent()&&this.openContextMenu({clientX:e.clientX,clientY:e.clientY,button:e.button,pointerType:`pointerType`in e.nativeEvent?e.nativeEvent.pointerType:void 0})}),B(this,`openContextMenu`,e=>{if(!this.isInteractionEnabled()||(this.bucketFill.cancel(),(e.pointerType===`touch`||e.pointerType===`pen`&&e.button!==Aa.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:t,y:n}=ws(e,this.state),r=this.getElementAtPosition(t,n,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:t,y:n},i),o=r||a?`element`:`canvas`,{top:s,left:c}=this.excalidrawContainerRef.current.getBoundingClientRect(),l=e.clientX-c,u=e.clientY-s;Yw(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...sn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ja(r)?new R(r,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:l,items:this.getContextMenuItems(o)}})})}),B(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&e.boxSelection.hasOccurred&&this.state.activeTool.type!==`eraser`){or({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:oe(e.origin.x,i.x),height:oe(e.origin.y,i.y),shouldMaintainAspectRatio:is(t),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a||this.arrowText.maybeDragNewText(a,i))return;let[o,s]=Tn(i.x,i.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=bs(a)&&this.imageCache.get(a.fileId)?.image,l=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(t,[a]);let{snapOffset:u,snapLines:d}=oF(a,this,t,{x:e.originInGrid.x+(this.state.originSnapOffset?.x??0),y:e.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:o-e.originInGrid.x,y:s-e.originInGrid.y},this.scene.getNonDeletedElementsMap());o+=u.x,s+=u.y,this.setState({snapLines:d}),bo(a)||or({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:oe(e.originInGrid.x,o),height:oe(e.originInGrid.y,s),shouldMaintainAspectRatio:O(a)||x(a)?!is(t):is(t),shouldResizeFromCenter:zi(t),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:l,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===Ys.frame||this.state.activeTool.type===Ys.magicframe)&&this.setState({elementsToHighlight:Ra(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),B(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=Tn(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&O(o)){let s=e.originalElements.get(o.id),c=bs(o)&&this.imageCache.get(o.fileId)?.image;if(s&&O(s)&&c&&!(c instanceof Promise)){let[l,u]=Tn(r.x,r.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d={x:l-e.originInGrid.x,y:u-e.originInGrid.y};this.maybeCacheReferenceSnapPoints(t,[o]);let{snapOffset:f,snapLines:p}=aF([o],[s],this,t,d,n);this.scene.mutateElement(o,Dr(o,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,i+f.x,a+f.y,t.shiftKey?s.width/s.height:void 0)),bi(o,this.scene),this.setState({isCropping:n&&n!==`rotation`,snapLines:p})}return!0}return!1}),B(this,`maybeHandleResize`,(e,t)=>{let n=this.scene.getSelectedElements(this.state),r=n.filter(F),i=e.resize.handleType;if(r.length>0&&i===`rotation`||n.length===1&&vn(n[0])||this.state.croppingElementId)return!1;this.activeResizeHandle=i&&i!==`rotation`?i:null,this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=Tn(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{Dn(this.scene.getNonDeletedElements(),e.id).forEach(t=>{c.set(e.id+t.id,{x:t.x-e.x,y:t.y-e.y})})}),!this.state.selectedElementsAreBeingDragged){let[r,c]=Tn(a.x,a.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r-e.originInGrid.x,y:c-e.originInGrid.y},u=[...e.originalElements.values()];this.maybeCacheReferenceSnapPoints(t,n);let{snapOffset:d,snapLines:f}=aF(n,Kc(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}let l=n.some(e=>O(e))||n.length===1&&x(n[0])&&typeof i==`string`&&i.length===2;if(sc(e.originalElements,i,n,this.scene,Fa(t),zi(t),l?!is(t):is(t),o,s,e.resize.center.x,e.resize.center.y)){let e=new Set;return r.forEach(t=>{Ra(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()).forEach(t=>{Ga(t)?e.add(t):console.error(`[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame`)})}),this.setState({elementsToHighlight:[...e]}),!0}return!1}),B(this,`getContextMenuItems`,e=>{let t=[];if(t.push(dk,uk),e===`canvas`)return this.state.viewModeEnabled?[...t,pk,mk,pM,yk]:[ck,sR,dk,uk,fk,sR,Kw,Uk,sR,pk,hk,gk,_k,mk,pM,yk];if(t.push(fk),this.state.viewModeEnabled)return[sk,...t];let n=this.editorInterface.formFactor===`desktop`?[sR,Hw,Uw,Ww,Gw]:[];return[sR,lk,sk,ck,sR,xP,SP,CP,sR,yP,sR,...t,sR,zO,BO,sR,WO,jP,bk,xk,wk,GO,sR,QO,...n,sR,rk,ik,sR,_P,sR,Bk,xA,sR,qw,Hk,sR,Vw]}),B(this,`savePointer`,(e,t,n)=>{if(this.pan.isActive()||!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!e||!t)return;let{x:r,y:i}=ws({clientX:e,clientY:t},this.state),a={x:r,y:i,tool:this.state.activeTool.type===`laser`?`laser`:`pointer`};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:TW.pointers})}),B(this,`resetShouldCacheIgnoreZoomDebounced`,ml(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),B(this,`updateDOMRect`,e=>{if(this.excalidrawContainerRef?.current){let{width:t,height:n,left:r,top:i}=this.excalidrawContainerRef.current.getBoundingClientRect(),{width:a,height:o,offsetTop:s,offsetLeft:c}=this.state;if(t===a&&n===o&&r===c&&i===s){e&&e();return}this.setState({width:t,height:n,offsetLeft:r,offsetTop:i},()=>{e&&e()}),this.viewport.constrain()}}),B(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})}),B(this,`watchState`,()=>{});let n=Se(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:o=!1,theme:s=n.theme,name:c=`${G(`labels.untitled`)}-${Zs()}`}=t,l=null;t.activeTool&&(t.activeTool.type===`image`?console.warn(`"image" tool cannot be forced via "props.activeTool"`):this.isToolSupported(t.activeTool.type,t)?l=ln(n,t.activeTool):console.warn(`"${t.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={...n,theme:s,exportWithDarkMode:s===M.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:!this.isInteractionEnabled(t)||r,activeTool:l??n.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:o,gridModeEnabled:a??n.gridModeEnabled,name:c,width:this.ownerWindow.innerWidth,height:this.ownerWindow.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=tc(this.editorInterface),this.id=pt(),this.library=new GA(this),this.actionManager=new NP(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ii,this.canvas=this.ownerDocument.createElement(`canvas`),this.rc=Ia.canvas(this.canvas),this.renderer=new lF(this.scene),this.visibleElements=[],this.store=new Ds(this),this.history=new EP(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Co(this.scene,this.ownerDocument),this.history=new EP(this.store),this.actionManager.registerAll(Rw),this.actionManager.registerAction(kP(this.history)),this.actionManager.registerAction(AP(this.history)),this.api=this.createExcalidrawAPI()}get ownerDocument(){return this.props.ownerDocument??this.excalidrawContainerRef.current?.ownerDocument??document}get ownerWindow(){return this.ownerDocument.defaultView??window}createExcalidrawAPI(){return{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,setElementRenderOverrides:this.setElementRenderOverrides,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:e=>{this.actionManager.registerAction(e)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:e=>this.onChangeEmitter.on(e),onIncrement:e=>this.store.onStoreIncrementEmitter.on(e),onPointerDown:e=>this.onPointerDownEmitter.on(e),onPointerUp:e=>this.onPointerUpEmitter.on(e),onScrollChange:e=>this.onScrollChangeEmitter.on(e),onUserFollow:e=>this.onUserFollowEmitter.on(e),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(e=this.props){return e.interaction!==!1&&typeof e.interaction!=`object`}isLinksEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.links===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isNavigationEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.navigation===!0:e.interaction!==!1}isEmbedsEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.embeds===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isBrowserZoomEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null&&e.interaction.enabled?.browserZoom===!0}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(e=this.props){return e.ui!==!1&&(typeof e.ui!=`object`||e.ui===null)}isUIControlEnabled(e,t=this.props){return typeof t.ui==`object`&&t.ui!==null?t.ui.enabled?.[e]===!0:t.ui!==!1}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){E(this.lastPointerMoveCoords,`Missing last pointer move coords when changing bind skip mode for arrow start`);let e=this.scene.getNonDeletedElementsMap(),t=_t(L(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),e,this.state.zoom),n=R.getElement(this.state.selectedLinearElement.elementId,e);n?.startBinding&&t?.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),null),(0,Cl.flushSync)(()=>{this.setState({bindMode:`skip`})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:e,y:t}=this.lastPointerMoveCoords,n=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;E(n,`Last event must exist`);let r=e-this.state.selectedLinearElement.pointerOffset.x,i=t-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?R.handlePointerMove(n,this,r,i,this.state.selectedLinearElement):R.handlePointDragging(n,this,r,i,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode!==`orbit`&&setTimeout(()=>this.setState({bindMode:`orbit`}))}handleDelayedBindModeChange(e,t){if(e.isDeleted||vn(e))return;let n=()=>{if(this.bindModeHandler=null,E(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 t=this.state.selectedLinearElement.selectedPointsIndices.includes(0),n=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1);if(!t&&!n||t&&n)return}let{x:t,y:n}=this.lastPointerMoveCoords,r=_t(L(t,n),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);if(r&&this.state.bindMode!==`skip`){E(this.state.selectedLinearElement?.elementId===e.id,`The selectedLinearElement is expected to not change while a bind mode timeout is ticking`);let i=this.state.selectedLinearElement.initialState.arrowStartIsInside||e.startBinding?.elementId===r.id;(0,Cl.flushSync)(()=>{E(this.state.selectedLinearElement,`this.state.selectedLinearElement must exist`),this.setState({bindMode:`inside`,selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:i}}})});let a=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;E(a,`Last event must exist`);let o=t-this.state.selectedLinearElement.pointerOffset.x,s=n-this.state.selectedLinearElement.pointerOffset.y,c=this.state.multiElement?R.handlePointerMove(a,this,o,s,this.state.selectedLinearElement):R.handlePointDragging(a,this,o,s,this.state.selectedLinearElement);c&&this.setState(c)}},r=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let n=this.scene.getNonDeletedElementsMap(),i=this.state.selectedLinearElement.selectedPointsIndices.includes(0),a=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1),o=i?t:e.startBinding&&n.get(e.startBinding.elementId),s=a?t:e.endBinding&&n.get(e.endBinding.elementId),c=o&&Qr(o,n),l=s&&Qr(s,n);r=!!(c&&l&&o.id!==s.id&&yo(c,l))}let i=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(e.points.length-1),o=i?`startBinding`:a?`endBinding`:null,s=i?`endBinding`:a?`startBinding`:null,c=s&&e[s]?.mode===`inside`&&e[s]?.elementId===t?.id||o&&e[o]?.mode===`inside`&&t?.id===e[o]?.elementId;o&&s&&e[o]?.mode===`inside`&&t?.id!==e[o]?.elementId&&e[s]?.elementId!==e[o]?.elementId&&this.scene.mutateElement(e,{[o]:{...e[o],mode:`orbit`}},{informMutation:!1,isDragging:!0}),!t||this.previousHoveredBindableElement&&t.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode===`inside`&&(0,Cl.flushSync)(()=>{this.setState({bindMode:`orbit`})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!e.startBinding||r)&&!c&&(this.bindModeHandler=setTimeout(n,700)),this.previousHoveredBindableElement=t}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}isIframeLikeInteractive(e){return!Ai(e)||(e.customData?.generationData??this.magicGenerations.get(e.id))?.status!==`pending`}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Aa.MAIN||this.pan.isSpaceHeld()||!dr(this.state.activeTool.type,[`laser`,`selection`,`lasso`]))return!1;let e=L(ws({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),t=L(ws({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Ke(e,t)>10)return!1;let n=this.getElementAtPosition(e[0],e[1]);if(!(n&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&TW.pointers.size<2&&Ge(n)&&this.isIframeLikeInteractive(n)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(n,this.lastPointerUpEvent,t[0],t[1]))))return!1;let r=n;if(this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`||(setTimeout(()=>{this.setState({activeEmbeddable:{element:r,state:`active`},selectedElementIds:{[r.id]:!0},newElement:null,selectionElement:null})},100),Ai(r)))return!0;let i=this.getHTMLIFrameElement(r);if(!i?.contentWindow)return!0;if(i.src.includes(`youtube`)){let e=SW.get(r.id);switch(e||(SW.set(r.id,Mr.UNSTARTED),i.contentWindow.postMessage(JSON.stringify({event:`listening`,id:r.id}),`*`)),e){case Mr.PLAYING:case Mr.BUFFERING:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`pauseVideo`,args:``}),`*`);break;default:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`playVideo`,args:``}),`*`)}}return i.src.includes(`player.vimeo.com`)&&i.contentWindow.postMessage(JSON.stringify({method:`paused`}),`*`),!0}isIframeLikeElementCenter(e,t,n,r){return e&&!t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(this.state.activeEmbeddable?.element!==e||this.state.activeEmbeddable?.state===`hover`||!this.state.activeEmbeddable)&&n>=e.x+e.width/3&&n<=e.x+2*e.width/3&&r>=e.y+e.height/3&&r<=e.y+2*e.height/3}renderEmbeddables(){let e=this.state.zoom.value,t=this.state.width,n=this.state.height,r=this.scene.getNonDeletedElements().filter(e=>Si(e)&&this.embedsValidationStatus.get(e.id)===!0||Ai(e));return(0,U.jsx)(U.Fragment,{children:r.map(r=>{let i=this.getElementRenderState(r),{x:a,y:o}=hs({sceneX:r.x,sceneY:r.y},this.state),s=et(Xn(r,i.offset),t,n,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(r.id);if(s&&!c&&this.initializedEmbeds.add(r.id),!(s||c))return null;let l,u=!1;if(Ai(r)){l=null;let e=(r.customData?.generationData??this.magicGenerations.get(r.id))||{status:`error`,message:`No generation data`,code:`ERR_NO_GENERATION_DATA`};if(e.status===`done`){let t=e.html;l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>t}}else if(e.status===`pending`)l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>vs(`
85
+ <style>
86
+ html, body {
87
+ width: 100%;
88
+ height: 100%;
89
+ margin: 0;
90
+ }
91
+ </style>
92
+ <script>
93
+ // progressively renders the partial HTML snapshots the
94
+ // editor streams in during generation by document.write-
95
+ // ing them into this very document — feeding the
96
+ // browser's incremental HTML parser, so incomplete
97
+ // markup renders progressively
98
+ // (see App.onMagicFrameGenerate)
99
+ let writtenLength = 0;
100
+ let opened = false;
101
+
102
+ const onPartialMessage = (event) => {
103
+ const data = event.data;
104
+ if (
105
+ !data ||
106
+ data.type !== "excalidraw:diagramToCode:partial" ||
107
+ typeof data.html !== "string" ||
108
+ data.html.length <= writtenLength
109
+ ) {
110
+ return;
111
+ }
112
+ if (!opened) {
113
+ opened = true;
114
+ document.open();
115
+ // document.open() wipes all listeners from both the
116
+ // document and the window, so re-register
117
+ window.addEventListener("message", onPartialMessage);
118
+ }
119
+ document.write(data.html.slice(writtenLength));
120
+ writtenLength = data.html.length;
121
+ };
122
+
123
+ window.addEventListener("message", onPartialMessage);
124
+ <\/script>
125
+ `)},u=!0;else{let t;t=e.code===`ERR_GENERATION_INTERRUPTED`?`Generation was interrupted...`:e.message||`Generation failed`,l={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>vs(`
126
+ <style>
127
+ html, body {
128
+ height: 100%;
129
+ }
130
+ body {
131
+ display: flex;
132
+ flex-direction: column;
133
+ align-items: center;
134
+ justify-content: center;
135
+ color: ${$c.red[3]};
136
+ }
137
+ h1, h3 {
138
+ margin-top: 0;
139
+ margin-bottom: 0.5rem;
140
+ }
141
+ </style>
142
+ <h1>Error!</h1>
143
+ <h3>${t}</h3>
144
+ `)}}}else l=il(Ws(r.link||``));let d=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`,f=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`hover`,p=l?.type===`video`,m=Vi(p?e:1,.75,CW);return(0,U.jsx)(`div`,{className:H(`excalidraw__embeddable-container`,{"is-hovered":f}),style:{transform:s?`translate(${a+i.offset.x*this.state.zoom.value-this.state.offsetLeft}px, ${o+i.offset.y*this.state.zoom.value-this.state.offsetTop}px) scale(${e})`:`none`,display:s?`block`:`none`,opacity:i.opacity*(this.state.openDialog?.name===`elementLinkSelector`?xa:1),"--embeddable-radius":`${Pi(Math.min(r.width,r.height),r)}px`},children:(0,U.jsxs)(`div`,{className:`excalidraw__embeddable-container__inner`,style:{width:s?`${r.width}px`:0,height:s?`${r.height}px`:0,transform:s?`rotate(${r.angle}rad)`:`none`,pointerEvents:d?tr.enabled:tr.disabled},children:[f&&(0,U.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:G(`buttons.embeddableInteractionButton`)}),(0,U.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(0,U.jsx)(`div`,{className:`excalidraw__embeddable__content`,style:{width:`${m*100}%`,height:`${m*100}%`,transform:`scale(${1/m})`},children:(Si(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,U.jsx)(`iframe`,{ref:e=>this.cacheEmbeddableRef(r,e),className:`excalidraw__embeddable`,srcDoc:l?.type===`document`?l.srcdoc(this.state.theme):void 0,src:l?.type===`document`?void 0:l?.link??``,scrolling:`no`,referrerPolicy:`no-referrer-when-downgrade`,title:`Excalidraw Embedded Content`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,sandbox:`${l?.sandbox?.allowSameOrigin?`allow-same-origin`:``} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})}),u&&(0,U.jsxs)(`div`,{className:`excalidraw__embeddable__generating`,children:[(0,U.jsx)(Lw,{size:`1em`}),`Generating…`]})]})},r.id)})})}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderTopLeftUI:n,renderCustomStats:r}=this.props,{elementsMap:i,visibleElements:a,canvasNonce:o,newElementCanvasElement:s}=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:e,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=a,this.hasRenderableElements=i.size>0;let c=this.scene.getNonDeletedElementsMap(),l=s??this.toolDrag.preview,u=`setPointerCapture`in this.ownerWindow.HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type===`laser`&&this.state.cursorButton===`down`,d=e[0],f=ex.get(Qk)?.type===`panel`;return(0,U.jsx)(`div`,{translate:`no`,className:H(`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":u?tr.disabled:tr.enabled,"--right-sidebar-width":`${UL}px`,"--zen-mode-transition-duration":`250ms`},ref:this.excalidrawContainerRef,onDrop:this.isFileDropEnabled()?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:(0,U.jsx)(rW.Provider,{value:this.api,children:(0,U.jsx)(qU.Provider,{value:this,children:(0,U.jsx)(JU.Provider,{value:this.props,children:(0,U.jsx)(QU.Provider,{value:this.excalidrawContainerValue,children:(0,U.jsx)(XU.Provider,{value:this.editorInterface,children:(0,U.jsx)(tW.Provider,{value:this.setAppState,children:(0,U.jsx)(eW.Provider,{value:this.state,children:(0,U.jsxs)($U.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,U.jsxs)(nW.Provider,{value:this.actionManager,children:[(0,U.jsx)(VH,{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:lx().code,renderTopLeftUI:n,renderTopRightUI:t,renderCustomStats:r,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}),(0,U.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,U.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,U.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,U.jsx)(UH,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&(0,U.jsx)(WU,{}),this.isDefaultUIEnabled()&&this.isInteractionEnabled()&&!this.state.viewModeEnabled&&(0,U.jsx)(lR,{}),this.isDefaultUIEnabled()&&e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,U.jsx)(Mk,{element:d,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),this.isDefaultUIEnabled()&&this.props.aiEnabled!==!1&&e.length===1&&Ue(d)&&(0,U.jsx)(fF,{element:d,elementsMap:i,children:(0,U.jsx)(HH,{title:G(`labels.convertToCode`),icon:JC,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,`button`)})}),this.isDefaultUIEnabled()&&e.length===1&&Ai(d)&&d.customData?.generationData?.status===`done`&&(0,U.jsxs)(fF,{element:d,elementsMap:i,children:[(0,U.jsx)(HH,{title:G(`labels.copySource`),icon:NC,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),(0,U.jsx)(HH,{title:`Enter fullscreen`,icon:YC,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(d);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:`active`},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:`Couldn't enter fullscreen`})}}})]}),this.isDefaultUIEnabled()&&this.state.contextMenu&&(0,U.jsx)(cR,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:e=>{this.setState({contextMenu:null},()=>{this.focusContainer(),e?.()})}}),(0,U.jsx)(MU,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:c,visibleElements:this.elementRenderOffsets.size?this.renderer.getVisibleElementsWithRenderOffsets(a,i,this.state,this.elementRenderOffsets):a,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:this.ownerWindow.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:WP(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme,...this.getRenderOverrideConfig()}}),l&&(0,U.jsx)(IU,{appState:this.state,newElement:l,scale:this.ownerWindow.devicePixelRatio,rc:this.rc,elementsMap:i,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,...this.getRenderOverrideConfig()},opacity:this.toolDrag.preview?CL:void 0}),(0,U.jsx)(kU,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:c,selectedElements:e,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:this.ownerWindow.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.handleCanvasPointerCancel,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor===`phone`&&(0,U.jsx)(uR,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&(0,U.jsx)(KU,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&f&&(0,U.jsx)(yA,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(e){Object.assign(this.plugins,e)}async onMagicFrameGenerate(e,t){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:`No diagram to code plugin found`});return}let r=bc(this.scene.getNonDeletedElements(),e,this.scene.getNonDeletedElementsMap()).filter(e=>!Ue(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),Yw(`ai`,`generate (no-children)`,`d2c`)):this.setActiveTool({type:`magicframe`});return}let i=this.insertIframeElement({sceneX:e.x+e.width+30,sceneY:e.y,width:e.width,height:e.height});if(i){this.updateMagicGeneration({frameElement:i,data:{status:`pending`}}),this.setState({selectedElementIds:{[i.id]:!0}}),Yw(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r,onPartial:e=>{if(this.magicGenerations.get(i.id)?.status!==`pending`)return;let t=e.search(/<!doctype html|<html[\s>]/i);t!==-1&&this.getHTMLIFrameElement(i)?.contentWindow?.postMessage({type:`excalidraw:diagramToCode:partial`,html:e.slice(t)},`*`)}});if(Yw(`ai`,`generate (success)`,`d2c`),!t.trim()){this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:`Nothing genereated :(`}});return}let a=t.includes(`<!DOCTYPE html>`)&&t.includes(`</html>`)?t.slice(t.indexOf(`<!DOCTYPE html>`),t.indexOf(`</html>`)+7):t;this.updateMagicGeneration({frameElement:i,data:{status:`done`,html:a}})}catch(e){Yw(`ai`,`generate (failed)`,`d2c`),this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:e.message||`Unknown error during generation`}})}}}onIframeSrcCopy(e){e.customData?.generationData?.status===`done`&&(bO(e.customData.generationData.html),this.setToast({message:`copied to clipboard`,closable:!1,duration:1500}))}isFileDropEnabled(){return this.isInteractionEnabled()&&!this.state.viewModeEnabled}clearImageShapeCache(e){let t=e??this.files;this.scene.getNonDeletedElements().forEach(e=>{bs(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),wa.delete(e))})}async componentDidMount(){this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(pi()||Ae())&&(this.setState.bind(this),Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...e)=>this.setState(...e)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})),this.store.onDurableIncrementEmitter.on(e=>{this.history.record(e.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(e=>{this.props.onIncrement?.(e)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),typeof this.ownerWindow.ResizeObserver==`function`&&this.excalidrawContainerRef.current&&(this.resizeObserver=new this.ownerWindow.ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(this.ownerWindow.location.search.slice(1)).has(`web-share-target`)?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),ar()&&!Ne()&&this.setState({errorMessage:(0,U.jsx)(iR,{})});let e={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit(`editor:mount`,e),this.props.onMount?.(e),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let e of Object.keys(this.api))(e.startsWith(`get`)||e===`onStateChange`||e===`onEvent`)&&typeof this.api[e]==`function`&&(this.api[e]=()=>{throw Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.ownerWindow.clearTimeout(this.zenModeTransitionTimer),this.unmarkZenModeTransition(),this.editorLifecycleEvents.emit(`editor:unmount`),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),this.elementRenderOverrides=new Map,this.elementRenderOffsets=new Map,this.ownerWindow.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Ii,this.fonts=new Co(this.scene,this.ownerDocument),this.renderer=new lF(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.toolDrag.cancel(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),wa.destroy(),UP.destroy(),clearTimeout(bW),Gt.clearCache(),sn.clearCache(),bW=0,this.ownerDocument.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(this.ownerWindow,P.MESSAGE,this.onWindowMessage,!1),we(this.excalidrawContainerRef.current,P.DRAG_OVER,this.onDragOver,!1),we(this.excalidrawContainerRef.current,P.DROP,this.disableEvent,!1),we(this.ownerDocument,P.POINTER_UP,this.removePointer,{passive:!1}),we(this.ownerDocument.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),we(this.ownerWindow,P.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,P.WHEEL,this.wheel.handle,{passive:!1}),we(this.props.handleKeyboardGlobally?this.ownerDocument:this.excalidrawContainerRef.current,P.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(this.ownerDocument,P.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(this.ownerDocument,P.GESTURE_START,this.onGestureStart,!1),we(this.ownerDocument,P.GESTURE_CHANGE,this.onGestureChange,!1),we(this.ownerDocument,P.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,P.WHEEL,this.wheel.preventBrowserZoom,{passive:!1}),we(this.excalidrawContainerRef.current,P.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,P.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,P.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?this.ownerDocument:this.excalidrawContainerRef.current,P.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(this.ownerDocument,P.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,P.WHEEL,this.wheel.handle,{passive:!1}),we(this.ownerDocument,P.COPY,this.clipboard.onCopy,{passive:!1}),we(this.ownerDocument,P.KEYUP,this.onKeyUp,{passive:!0}),we(this.ownerDocument,P.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(this.ownerDocument,P.GESTURE_START,this.onGestureStart,!1),we(this.ownerDocument,P.GESTURE_CHANGE,this.onGestureChange,!1),we(this.ownerDocument,P.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(this.ownerDocument,P.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(this.ownerDocument,P.PASTE,this.clipboard.pasteFromClipboard,{passive:!1}),we(this.ownerDocument,P.CUT,this.clipboard.onCut,{passive:!1}),we(this.ownerWindow,P.RESIZE,this.onResize,!1),we(this.ownerWindow,P.UNLOAD,this.onUnload,!1),we(this.ownerWindow,P.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,P.WHEEL,this.wheel.handle,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(Sr(this.excalidrawContainerRef.current),P.SCROLL,this.onScroll,{passive:!1})))}getSnapshotBeforeUpdate(e,t){return t.zenModeEnabled!==this.state.zenModeEnabled&&this.markZenModeTransition(),null}markZenModeTransition(){let e=this.excalidrawContainerRef.current;e&&(uD(),e.setAttribute(`data-zen-mode-transition`,``),this.ownerWindow.clearTimeout(this.zenModeTransitionTimer),this.zenModeTransitionTimer=this.ownerWindow.setTimeout(()=>{this.unmarkZenModeTransition()},350))}unmarkZenModeTransition(){this.excalidrawContainerRef.current?.removeAttribute(`data-zen-mode-transition`)}componentDidUpdate(e,t){let n=this.renderOverridesUpdatePending;if(this.renderOverridesUpdatePending=!1,n&&e===this.props&&t===this.state)return;!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit(`editor:initialize`,this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(e,t),this.handleForcedToolChange(e,t),this.appStateObserver.flush(t),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===M.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),t.activeTool.type===`text`&&this.state.activeTool.type!==`text`&&(this.textTool.clearHover(),this.textTool.cancel()),(t.zoom.value!==this.state.zoom.value||t.scrollX!==this.state.scrollX||t.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom),this.textTool.refresh()),Object.keys(this.state.selectedElementIds).length&&wc(this.state)&&this.setState({activeTool:ln(this.state,{type:`selection`})}),this.state.activeTool.type===`eraser`&&t.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type===`bucketfill`&&t.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),t.activeTool.type===`selection`&&this.state.activeTool.type!==`selection`&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),wc(t)&&!wc(this.state)&&this.eraserTrail.endPath(),(t.openDialog?.name===`elementLinkSelector`||this.state.openDialog?.name===`elementLinkSelector`)&&t.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),e.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),e.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle(`theme--dark`,this.state.theme===M.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(JD)});let o=Object.keys(this.state.selectedElementIds);if(o.length){let e=o.filter(e=>{let t=this.scene.getElement(e);return!t||t.isDeleted});e.length&&this.setState(t=>{let n={...t.selectedElementIds};for(let t of e)delete n[t];return{selectedElementIds:j(n,t)}})}if(this.state.editingTextElement){let e=this.scene.getElement(this.state.editingTextElement.id);(!e||e.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?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){hW=!1,_W=null}showSceneReplacedToast(){this.setToast({message:G(`fileDrop.replacedToast`,{shortcut:Z(`CtrlOrCmd+Z`)}),closable:!0,duration:8e3})}deselectElements(){this.setState({selectedElementIds:j({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getElementAtPosition(e,t,n){let r=[];if(r=n&&`allHitElements`in n?n?.allHitElements||[]:this.getElementsAtPosition(e,t,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),r.length>1){if(n?.preferSelected){for(let e=r.length-1;e>-1;e--)if(this.state.selectedElementIds[r[e].id])return r[e]}let i=r[r.length-1];return xr({point:L(e,t),element:i,threshold:this.getElementHitThreshold(i)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:F(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n){let r=[];return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(n?.includeLockedElements||!e.locked)&&(n?.includeBoundTextElement||!(D(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>!this.isClippedByFrameAt(e,t,n)).filter(e=>!Ge(e)||(r.push(e),!1)).concat(r)}isClippedByFrameAt(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=fs(n,r);return i&&!Ga(i)&&console.error(`[NONDELETED][INVARIANT] Containing frame is deleted`),!!i&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Ge(n)&&!Za({x:e,y:t},i,r)}getElementHitThreshold(e){return Math.max(e.strokeWidth/2+.1,.85*(li/this.state.zoom.value))}hitElement(e,t,n,r=!0){return r&&this.state.selectedElementIds[n.id]&&Ac([n],this.state,this.editorInterface)&&Js(L(e,t),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||wo(L(e,t),n,this.scene.getNonDeletedElementsMap())?!0:xr({point:L(e,t),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:F(n)?this.frameNameBoundsCache.get(n):null})}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=R.getElement(e.elementId,r);if(i&&!this.state.editingTextElement){if(this.state.selectedLinearElement){let a=R.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=R.isPointHandle(i,a),s=o?null:R.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,r);o||s?this.cursor.set(To.POINTER):this.arrowText.isBoundTextGrabbable(i,t,n)?this.cursor.set(To.GRAB):this.hitElement(t,n,i)&&(!vn(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(To.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState(e=>({selectedLinearElement:e.selectedLinearElement&&{...e.selectedLinearElement,hoverPointIndex:a}})),R.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState(e=>({selectedLinearElement:e.selectedLinearElement&&{...e.selectedLinearElement,segmentMidPointHoveredCoords:s}}));let c=null,l=i;(l.startBinding||l.endBinding)&&(c=Ic(i,t,n,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState(e=>({selectedLinearElement:e.selectedLinearElement&&{...e.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}})),c&&this.cursor.set(To.POINTER)}else this.cursor.set(To.AUTO)}}updateGestureOnPointerDown(e){TW.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),TW.pointers.size===2&&(TW.lastCenter=PP(TW.pointers),TW.initialScale=this.state.zoom.value,TW.initialDistance=FP(Array.from(TW.pointers.values())))}initialPointerDownState(e){let t=ws(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Hc(n),s=n.findIndex(vn)===0;return{origin:t,withCmdOrCtrl:e[z.CTRL_OR_CMD],originInGrid:St(Tn(t.x,t.y,e[z.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:TF(yW,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Yi(t)),e),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:`origin`,center:{x:(a+r)/2,y:(o+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,advancedListMarkers:[],editedTextId:this.duplicate.handedOverTextId,arrowLabel:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(t,n)},drag:{hasOccurred:!1,offset:null,origin:{...t},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!t.scrollbars.isOverEither||this.state.multiElement)return!1;vW=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=mF(e=>{e.target instanceof this.ownerWindow.HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=pF(()=>{wW=null,vW=!1,this.cursor.applyForTool(),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),this.ownerWindow.removeEventListener(P.POINTER_MOVE,n),this.ownerWindow.removeEventListener(P.POINTER_UP,r),n.flush()});return wW=r,this.ownerWindow.addEventListener(P.POINTER_MOVE,n),this.ownerWindow.addEventListener(P.POINTER_UP,r),!0}isASelectedElement(e){return e!=null&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=Math.max(li/this.state.zoom.value,1),r=4/this.state.zoom.value,[i,a,o,s]=Hc(t);return e.x>i-r-n&&e.x<o+r+n&&e.y>a-r-n&&e.y<s+r+n}getCurrentItemRoundness(e){return this.state.currentItemRoundness===`round`?{type:qi(e)?Un.ADAPTIVE_RADIUS:Un.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(e){return lo(e,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(e,t,n=!1){GP({event:e,app:this,selectedElements:t})&&(n||!UP.getReferenceSnapPoints())&&UP.setReferenceSnapPoints(ZP(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){GP({event:e,app:this,selectedElements:t})&&(n||!UP.getVisibleGaps())&&UP.setVisibleGaps(YP(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return pF(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return pF(t=>{t.key===z.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return mF(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=ws(t,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[e,r]=Tn(n.x,n.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(i<0){let t=R.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?R.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=R.moveFixedSegment(this.state.selectedLinearElement,i,e,r,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:a.segmentMidPointHoveredCoords,initialState:a.initialState}});return}let r=this.previousPointerMoveCoords??e.origin;if(this.previousPointerMoveCoords=n,e.drag.offset===null&&(e.drag.offset=St(qo(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof this.ownerWindow.HTMLElement)||this.handlePointerMoveOverScrollbars(t,e)||this.textTool.handlePointerMove(t,e))return;if(wc(this.state)){this.handleEraser(t,n);return}if(this.state.activeTool.type===`laser`&&this.laserTrails.addPointToPath(n.x,n.y),this.drawShape.handlePointerMove(n))return;let[i,a]=Tn(n.x,n.y,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(e.resize.isResizing&&(e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeHandleCrop(e,t)||this.maybeHandleResize(e,t)))return!0;let o=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let r=this.state.selectedLinearElement;if(r.draggedFocusPointBinding){Rr(r,o,n,this.scene,this.state,this.getEffectiveGridSize(),t.altKey),this.setState({selectedLinearElement:{...r,isDragging:!1,selectedPointsIndices:[],initialState:{...r.initialState,lastClickedPoint:-1}}});return}if(this.arrowText.maybeDragLabel(r,e,n))return;if(R.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=R.addMidpoint(this.state.selectedLinearElement,n,this,!t[z.CTRL_OR_CMD],this.scene);if(!e)return;(0,Cl.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}if(r.initialState.segmentMidpoint.value!==null&&!r.initialState.segmentMidpoint.added)return;if(r.initialState.lastClickedPoint>-1){let i=R.getElement(r.elementId,o);if(i?.isDeleted)return;if(bo(i)&&Ki(`COMPLEX_BINDINGS`)){let e=_t(L(n.x,n.y),this.scene.getNonDeletedElements(),o,this.state.zoom);this.handleDelayedBindModeChange(i,e)}if(t.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Ki(`COMPLEX_BINDINGS`)&&this.handleSkipBindMode(),r.initialState.lastClickedPoint===-1)return;let a=R.handlePointDragging(t,this,n.x,n.y,r);if(a){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.drag.hasOccurred=!0,(a.suggestedBinding!==this.state.suggestedBinding||!qr(a.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||a.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||a.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==a.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==a.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(a);return}}}let s=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),c=this.state.selectedLinearElement?.isEditing&&t.shiftKey&&this.state.selectedLinearElement.elementId===e.hit.element?.id;if((s||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!e.drag.blockDragging){let i=this.scene.getSelectedElements(this.state);if(i.length>0&&i.every(e=>e.locked))return;let a=i.some(e=>F(e))?null:this.getTopLayerFrameAtSceneCoords(n,{currentFrameId:Lc(i),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(a),e.drag.hasOccurred=!0,this.state.activeTool.type===`lasso`&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!==`desktop`&&e.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type===`lasso`&&i.length>0&&e.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),i.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!==`active`){let a={x:n.x-e.drag.origin.x,y:n.y-e.drag.origin.y},s=[...e.originalElements.values()],c=t.shiftKey;if(c){let e=Math.abs(a.x),t=Math.abs(a.y),n=c&&e<t,r=c&&e>t;n&&(a.x=0),r&&(a.y=0)}if(this.state.croppingElementId){let t=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(t&&O(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=bs(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=$i(t),s=Fn(n.x-r.x,n.y-r.y);s[0]*=i.naturalWidth/a.width,s[1]*=i.naturalHeight/a.height;let[c,l,u,d,f,p]=In(t,o),m=br(As(L(c,l),L(f,p),t.angle)),h=br(As(L(u,l),L(f,p),t.angle)),g=br(As(L(c,d),L(f,p),t.angle)),_=dl(Yr(h,m)),v=dl(Yr(g,m)),y=Fn(zr(s,_),zr(s,v)),b={...e,x:Vi(e.x-y[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:Vi(e.y-y[1]*Math.sign(t.scale[1]),0,i.naturalHeight-e.height)};this.scene.mutateElement(t,{crop:b});return}}}this.maybeCacheVisibleGaps(t,i),this.maybeCacheReferenceSnapPoints(t,i);let{snapOffset:l,snapLines:u}=$P(s,a,this,t,this.scene.getNonDeletedElementsMap());this.setState({snapLines:u}),this.state.editingFrame||En(e,i,a,this.scene,l,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),t.altKey&&!e.hit.hasBeenDuplicated&&this.duplicate.duplicateDraggedSelection(e,t);return}}if(this.state.selectionElement){if(e.lastCoords.x=n.x,e.lastCoords.y=n.y,t.altKey){this.setActiveTool({type:`lasso`,fromSelection:!0},{keepSelection:t.shiftKey}),this.lassoTrail.startPath(e.origin.x,e.origin.y,t.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(e,t)}else if(this.state.activeTool.type===`lasso`)!t.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:`selection`}),this.createGenericElementOnPointerDown(`selection`,e),e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,t.shiftKey);else{let r=this.state.newElement;if(!r)return;if(r.type===`freedraw`){let e=r.points,i=n.x-r.x,a=n.y-r.y,o=e.length>0&&e[e.length-1];if(!(o&&o[0]===i&&o[1]===a)){let n=r.simulatePressure?r.pressures:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...e,L(i,a)],pressures:n},{informMutation:!1,isDragging:!1}),this.setState({newElement:r})}}else if(ja(r)&&!r.isDeleted){e.drag.hasOccurred=!0;let n=r.points;E(n.length>1,`Do not create linear elements with less than 2 points`);let o=this.state.selectedLinearElement;(!o||o.elementId!==r.id)&&(o=new R(r,this.scene.getNonDeletedElementsMap())),o&&(o.initialState.lastClickedPoint<0||o.initialState.lastClickedPoint>=n.length)&&(console.warn(`Last clicked point is out of bounds. Attempting to fix it.`),o={...o,selectedPointsIndices:[n.length-1],initialState:{...o.initialState,prevSelectedPointsIndices:null,lastClickedPoint:n.length-1},hoverPointIndex:n.length-1}),this.setState({newElement:r,...R.handlePointDragging(t,this,i,a,o)})}else e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t,!1)}if(this.state.activeTool.type===`selection`){e.boxSelection.hasOccurred=!0;let n=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)R.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&Gt(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>sn({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?S(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(t=>{let n={...r&&t.selectedElementIds,...i.reduce((e,t)=>(e[t.id]=!0,e),{})};return e.hit.element&&(i.length?delete n[e.hit.element.id]:n[e.hit.element.id]=!0),t=r?t:{...t,selectedGroupIds:{},editingGroupId:null},{...sn({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&ja(i[0])?new R(i[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:i.length===1&&(i[0].link||Si(i[0]))?`info`:!1}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,r=n-t.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-r*(yW.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,r=n-t.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-r*(yW.vertical?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return pF(t=>{let n=this.scene.getNonDeletedElementsMap();this.removePointer(t),e.drag.blockDragging=!1,e.eventListeners.onMove&&e.eventListeners.onMove.flush(),this.textTool.handlePointerUp(t,e),e.hit.hasBeenDuplicated&&this.duplicate.commitDraggedDuplicates(e,{editText:t.type===`pointerup`}),t.type===`pointerup`&&this.state.activeTool.type===Ys.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:o,activeTool:s,isResizing:l,isRotating:u,isCropping:d}=this.state;this.activeResizeHandle=null,this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:Uc(e.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,UP.setReferenceSnapPoints(null),UP.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`);let f=e.hit.allHitElements,p=ws({clientX:t.clientX,clientY:t.clientY},this.state);if(this.state.activeTool.type===`selection`&&!e.boxSelection.hasOccurred&&!e.resize.isResizing&&!f.some(e=>this.state.selectedElementIds[e.id])){let e=this.getElementAtPosition(p.x,p.y,{includeLockedElements:!0});this.text.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(Ki(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:`orbit`}),e.drag.hasOccurred&&e.hit?.element?.id){let t=n.get(e.hit.element.id);Xr(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>n.get(e.id)).filter(e=>vn(e)).forEach(e=>{e&&this.scene.mutateElement(e,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null){if(!e.boxSelection.hasOccurred&&e.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(JD);else{let n=R.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(JD,`ui`,{event:t,sceneCoords:p,hitBoundText:e.hit.arrowLabel}),n!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:n,suggestedBinding:null})}}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=R.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&this.scene.mutateElement(e,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(Ko(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):e.hit?.element?.id===this.state.selectedLinearElement.elementId?this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(JD,`ui`,{event:t,sceneCoords:p,hitBoundText:e.hit.arrowLabel})):this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}),this.state.newElement&&this.state.multiElement&&ja(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(),this.ownerWindow.removeEventListener(P.POINTER_MOVE,e.eventListeners.onMove),this.ownerWindow.removeEventListener(P.POINTER_UP,e.eventListeners.onUp),this.ownerWindow.removeEventListener(P.KEYDOWN,e.eventListeners.onKeyDown),this.ownerWindow.removeEventListener(P.KEYUP,e.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),r?.type===`freedraw`){let e=ws(t,this.state),n=r.points,i=e.x-r.x,a=e.y-r.y;i===n[0][0]&&a===n[0][1]&&(a+=1e-4,i+=1e-4);let o=r.simulatePressure?[]:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...n,L(i,a)],pressures:o}),this.actionManager.executeAction(JD);return}if(ja(r)&&this.state.activeTool.type!==`autoshape`){let n=ws(t,this.state),i=Ke(L(n.x,n.y),L(e.origin.x,e.origin.y))*this.state.zoom.value;if((!e.drag.hasOccurred||i<20)&&r&&!o){if(this.editorInterface.isTouchScreen){let e=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-e/2,points:[L(0,0),L(e,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(JD)}else this.setState({multiElement:r,newElement:r})}else e.drag.hasOccurred&&!o&&(this.store.scheduleCapture(),ja(r)&&this.actionManager.executeAction(JD,`ui`,{event:t,sceneCoords:p}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(e=>({newElement:null,activeTool:ln(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:j({...e.selectedElementIds,[r.id]:!0},e),selectedLinearElement:new R(r,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(D(r)){let e=vi(Or({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<e&&this.scene.mutateElement(r,{autoResize:!0}),this.cursor.reset(),this.text.handleTextWysiwyg(r,{isExistingElement:!0})}if(r&&x(r)){let n=this.state.zoom.value,i=r.width*n<10&&r.height*n<10,a;if(i){let[n,r]=Tn(e.origin.x-125,e.origin.y-125,t[z.CTRL_OR_CMD]?null:this.getEffectiveGridSize());a={x:n,y:r,width:250,height:250}}else{let n=Ft({fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily}),i=Math.max(r.width,n.width),o=Math.max(r.height,n.height);is(t)||(i=o=Math.max(i,o));let{originInGrid:s}=e;a={x:r.x<s.x?s.x-i:r.x,y:r.y<s.y?s.y-o:r.y,width:i,height:o}}if(this.scene.mutateElement(r,{...a,baseHeight:a.height},{informMutation:!1,isDragging:!1}),this.store.scheduleCapture(),this.scene.triggerUpdate(),s.locked){this.setState(e=>({newElement:null,selectedElementIds:j({},e)})),this.cursor.applyForTool();return}this.cursor.reset(),this.setState({newElement:null,activeTool:ln(this.state,{type:this.state.preferredSelectionTool.type})}),this.text.startTextEditing({sceneX:r.x+r.width/2,sceneY:r.y+r.height/2,container:r});return}if(s.type!==`selection`&&r&&So(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),appState:{newElement:null},captureUpdate:I.NEVER});return}if(F(r)){let e=Ir(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(_n(this.scene.getElementsMapIncludingDeleted(),e,r))}if(r&&(this.scene.mutateElement(r,jt(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=ws(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let e=this.scene.getElement(this.state.selectedLinearElement.elementId);if(e?.frameId){let t=fs(e,n);t&&e&&(Hr(e,t,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(e,{groupIds:[]}),Ya([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.scene.getSelectedElements(this.state),n=this.getTopLayerFrameAtSceneCoords(e,{currentFrameId:Lc(t),excludeElementIds:this.state.selectedElementIds}),r=this.scene.getElementsMapIncludingDeleted(),i=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(t,{groupIds:t.groupIds.slice(0,e)},{informMutation:!1,isDragging:!1})}r.forEach(e=>{e.groupIds.length&&ul(r,e.groupIds[e.groupIds.length-1]).length<2&&this.scene.mutateElement(e,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(n&&!this.state.selectedElementIds[n.id]){let e=t.filter(e=>$s(e,r,this.state));this.state.editingGroupId&&i(e),r=_n(r,e,n)}else!n&&this.state.editingGroupId&&i(t.filter(e=>e.frameId&&!$s(e,r,this.state)));r=c(r,this.state,this),this.scene.replaceAllElements(r)}}if(i&&this.store.scheduleCapture(),i&&So(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==i.id),captureUpdate:I.NEVER}),e.resize.isResizing){let e=c(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(F);for(let r of t)e=Ct(e,Ra(this.scene.getElementsIncludingDeleted(),r,this.state,n),r);this.scene.replaceAllElements(e)}let m=e.hit.element;this.state.selectedLinearElement?.elementId!==m?.id&&ja(m)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new R(m,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!m&&!d||m&&m.id!==a))&&this.finishImageCropping();let h=this.lastPointerDownEvent,g=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(wc(this.state)&&h&&g){if(this.eraserTrail.endPath(),Ke(L(h.clientX,h.clientY),L(g.clientX,g.clientY))===0){let e=ws({clientX:g.clientX,clientY:g.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}if(this.elementsPendingErasure.size&&this.restoreReadyToEraseElements(),m&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!e.boxSelection.hasOccurred)&&this.state.activeTool.type!==`lasso`&&(t.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[m.id]?Hs(this.state,m)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of m.groupIds.flatMap(e=>ul(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...m.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:j(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[m.id];let n=Kc(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...sn({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&ja(n[0])?new R(n[0],this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}}):m.frameId&&this.state.selectedElementIds[m.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[m.id]:!0};return delete t[m.frameId],(this.scene.getElement(m.frameId)?.groupIds??[]).flatMap(e=>ul(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...sn({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:m.link||Si(m)?`info`:!1}}):this.setState(e=>({selectedElementIds:j({...e.selectedElementIds,[m.id]:!0},e)})):this.setState(e=>({...sn({editingGroupId:e.editingGroupId,selectedElementIds:{[m.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:ja(m)&&e.selectedLinearElement?.elementId!==m.id?new R(m,this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}))),this.state.activeTool.type!==`lasso`&&!(m&&vn(m))&&!e.drag.hasOccurred&&!this.state.isResizing&&(m&&ra({point:L(e.origin.x,e.origin.y),element:m,elementsMap:n,threshold:this.getElementHitThreshold(m),frameNameBound:F(m)?this.frameNameBoundsCache.get(m):null},n)||!m&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(_P):this.setState({selectedElementIds:j({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(To.AUTO);return}let _=this.text.getSelectedTextEditingContainerAtPosition(m,p);if(s.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&!t.shiftKey&&!t[z.CTRL_OR_CMD]&&!t.altKey&&t.pointerType!==`touch`&&m&&(D(m)&&this.state.selectedElementIds[m.id]&&this.scene.getSelectedElements(this.state).length===1||_)){this.text.startTextEditing({sceneX:p.x,sceneY:p.y,container:_,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:p});return}if(!this.isToolLocked()&&s.type!==`freedraw`&&r&&this.setState(e=>({selectedElementIds:j({...e.selectedElementIds,[r.id]:!0},e),showHyperlinkPopup:Si(r)&&!r.link?`editor`:e.showHyperlinkPopup})),!this.text.isEditingTextContent()&&(s.type!==`selection`||Gt(this.scene.getNonDeletedElements(),this.state)||!qr(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),e.drag.hasOccurred&&!this.state.selectedLinearElement||l||u||d){let e=this.scene.getSelectedElements(this.state).filter(ir);lc(e,this.scene,this.state)}if(s.type===`laser`){this.laserTrails.endPath();return}if(s.type===`autoshape`){this.actionManager.executeAction(JD);return}t.type===`pointerup`&&!this.isToolLocked()&&s.type!==`freedraw`&&s.type!==Ys.bucketfill&&(s.type!==`lasso`||s.type===`lasso`&&s.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:ln(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.cursor.reset(),this.cursor.refreshHover()}):this.setState({newElement:null,suggestedBinding:null},()=>this.cursor.refreshHover())})}clearSelection(e){this.setState(t=>({selectedElementIds:j({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&Fe(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:j({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let{left:e,top:t}=this.excalidrawContainerRef.current.getBoundingClientRect();return{offsetLeft:e,offsetTop:t}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){await cx(ix.find(e=>e.code===this.props.langCode)||rx),this.setAppState({})}};(pi()||Ae())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(qc(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var DW=EW,OW=e=>{let[t,n]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{let t=async()=>{await cx(r),n(!1)},r=ix.find(t=>t.code===e.langCode)||rx;t()},[e.langCode]),t?(0,U.jsx)(gR,{theme:e.theme}):e.children},kW=({children:e})=>{let{FooterCenterTunnel:t}=pR(),n=eT();return(0,U.jsx)(t.In,{children:(0,U.jsx)(`div`,{className:H(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})},AW=kW;kW.displayName=`FooterCenter`;var jW=({isCollaborating:e,onSelect:t,editorInterface:n,...r})=>{let i=eT(),a=n?.formFactor!==`desktop`||i.width<1440;return(0,U.jsxs)($j,{...r,className:H(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:a?void 0:`auto`},title:G(`labels.liveCollaboration`),children:[a?_S:G(`labels.share`),i.collaborators.size>0&&(0,U.jsx)(`div`,{className:`CollabButton-collaborators`,children:i.collaborators.size})]})},MW=jW;jW.displayName=`LiveCollaborationTrigger`;var NW=()=>(0,U.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,U.jsx)(`path`,{d:`M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z`,fill:`currentColor`})}),PW=()=>(0,U.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,U.jsx)(`path`,{d:`M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,U.jsx)(`path`,{d:`M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,U.jsx)(`path`,{d:`M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z`,transform:`translate(-144.023 -51.76)`}),(0,U.jsx)(`path`,{d:`m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z`,fill:`currentColor`,transform:`translate(-144.023 -51.76)`})]}),FW=({style:e,size:t=`small`,withText:n})=>(0,U.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,U.jsx)(NW,{}),n&&(0,U.jsx)(PW,{})]}),IW=({icon:e,shortcut:t,children:n})=>{let r=sW();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,U.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&r.formFactor!==`phone`&&(0,U.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};IW.displayName=`WelcomeScreenMenuItemContent`;var LW=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,U.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,U.jsx)(IW,{icon:n,shortcut:r,children:t})});LW.displayName=`WelcomeScreenMenuItem`;var RW=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,U.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noopener`,children:(0,U.jsx)(IW,{icon:n,shortcut:r,children:e})});RW.displayName=`WelcomeScreenMenuItemLink`;var zW=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=pR();return(0,U.jsx)(t.In,{children:(0,U.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(BW,{}),(0,U.jsx)(VW,{children:G(`welcomeScreen.defaults.center_heading`)}),(0,U.jsxs)(HW,{children:[(0,U.jsx)(WW,{}),(0,U.jsx)(UW,{})]})]})})})};zW.displayName=`Center`;var BW=({children:e})=>(0,U.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,U.jsx)(FW,{withText:!0})});BW.displayName=`Logo`;var VW=({children:e})=>(0,U.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});VW.displayName=`Heading`;var HW=({children:e})=>(0,U.jsx)(`div`,{className:`welcome-screen-menu`,children:e});HW.displayName=`Menu`;var UW=()=>{let e=pW();return(0,U.jsx)(LW,{onSelect:()=>e.executeAction(VO),shortcut:`?`,icon:Zx,children:G(`helpDialog.title`)})};UW.displayName=`MenuItemHelp`;var WW=()=>{let e=eT(),t=pW();return e.viewModeEnabled?null:(0,U.jsx)(LW,{onSelect:()=>t.executeAction(IO),shortcut:wA(`loadScene`),icon:sS,children:G(`buttons.load`)})};WW.displayName=`MenuItemLoadScene`;var GW=({onSelect:e})=>{let{t}=fx();return(0,U.jsx)(LW,{shortcut:null,onSelect:e,icon:MS,children:t(`labels.liveCollaboration`)})};GW.displayName=`MenuItemLiveCollaborationTrigger`,zW.Logo=BW,zW.Heading=VW,zW.Menu=HW,zW.MenuItem=LW,zW.MenuItemLink=RW,zW.MenuItemHelp=UW,zW.MenuItemLoadScene=WW,zW.MenuItemLiveCollaborationTrigger=GW;var KW=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=pR();return(0,U.jsx)(t.In,{children:(0,U.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[Tx,(0,U.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||G(`welcomeScreen.defaults.menuHint`)})]})})};KW.displayName=`MenuHint`;var qW=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=pR();return(0,U.jsx)(t.In,{children:(0,U.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,U.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||G(`welcomeScreen.defaults.toolbarHint`)}),Dx]})})};qW.displayName=`ToolbarHint`;var JW=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=pR();return(0,U.jsx)(t.In,{children:(0,U.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,U.jsx)(`div`,{children:e||G(`welcomeScreen.defaults.helpHint`)}),Ex]})})};JW.displayName=`HelpHint`;var YW=e=>(0,U.jsx)(U.Fragment,{children:e.children||(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(zW,{}),(0,U.jsx)(KW,{}),(0,U.jsx)(qW,{}),(0,U.jsx)(JW,{})]})});YW.displayName=`WelcomeScreen`,YW.Center=zW,YW.Hints={MenuHint:KW,ToolbarHint:qW,HelpHint:JW};var XW=YW,ZW=()=>{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((n,r)=>e.call(t,n,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 n=0;n<this.length;n++)if(e.call(t,this[n],n,this))return n;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,t){let n=this.slice().reverse().findIndex((n,r)=>e.call(t,n,this.length-r-1,this));return n===-1?-1:this.length-n-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)})},QW=(e,t,n)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>n.version||t.version===n.version&&t.versionNonce<=n.versionNonce)),$W=(0,Tl.default)((e,t,n)=>{if(Ae()||pi()||window?.DEBUG_FRACTIONAL_INDICES){let r=qc(e.map(e=>({...e})));Ce(r,{shouldThrow:pi()||Ae(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})}},6e4,{leading:!0,trailing:!1}),eG=(e,t,n)=>{let r=y(e),i=[],a=new Set;for(let e of t)if(!a.has(e.id)){let t=r.get(e.id),o=QW(n,t,e);t&&o?(i.push(t),a.add(t.id)):(i.push(e),a.add(e.id))}for(let t of e)a.has(t.id)||(i.push(t),a.add(t.id));let o=kc(i);return $W(o,e,t),qc(o),o},tG=({children:e,icon:t})=>{let{t:n}=fx(),{TTDDialogTriggerTunnel:r}=pR(),i=fW();return(0,U.jsx)(r.In,{children:(0,U.jsx)(Q.Item,{onSelect:()=>{Yw(`ai`,`dialog open`,`ttd`),i({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??QC,badge:(0,U.jsx)(Q.Item.Badge,{children:`AI`}),children:e??n(`labels.textToDiagram`)})})};tG.displayName=`TTDDialogTrigger`;function nG(e){let t=e.get(`X-Ratelimit-Limit`),n=e.get(`X-Ratelimit-Remaining`);return{rateLimit:t?parseInt(t,10):void 0,rateLimitRemaining:n?parseInt(n,10):void 0}}async function*rG(e){let t=new TextDecoder,n=``;try{for(;;){let{done:r,value:i}=await e.read();if(r)break;n+=t.decode(i,{stream:!0});let a=n.split(`
145
+ `);n=a.pop()||``;for(let e of a){let t=e.trim();t&&t.startsWith(`data: `)&&(yield t.slice(6))}}}finally{e.releaseLock()}}async function iG(e){let{url:t,messages:n,onChunk:r,onStreamCreated:i,extractRateLimits:a=!0,signal:o}=e;try{let e=``,s={},c=null,l=await fetch(t,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`},body:JSON.stringify({messages:n}),signal:o});if(a&&(s=nG(l.headers)),!l.ok){if(l.status===429)return{...s,error:new Me({message:`Rate limit exceeded`,status:429})};let e=await l.text();throw new Me({message:e||`Generation failed...`,status:l.status})}let u=l.body?.getReader();if(!u)throw new Me({message:`Couldn't get reader from response body`,status:500});i?.();try{for await(let t of rG(u)){if(t===`[DONE]`)break;try{let n=JSON.parse(t);if(n===null)break;switch(n.type){case`content`:{let t=n.delta;t&&(e+=t,r?.(t));break}case`error`:c=new Me({message:n.error.message,status:500})}}catch(e){console.warn(`Failed to parse SSE data:`,t,e)}}}catch(e){c=e.name===`AbortError`?new Me({message:`Request aborted`,status:499}):new Me({message:e.message||`Streaming error`,status:500})}return c?{...s,error:c}:e?{generatedResponse:e,error:null,...s}:{...s,error:new Me({message:`Generation failed...`,status:l.status})}}catch(e){return e.name===`AbortError`?{error:new Me({message:`Request aborted`,status:499})}:{error:new Me({message:e.message||`Request failed`,status:500})}}}var aG=e=>{let t=aW();return(0,V.useLayoutEffect)(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};ZW();var oG=({children:e})=>{let[t,n]=(0,V.useState)(null);return(0,U.jsx)(rW.Provider,{value:t,children:(0,U.jsx)(iW.Provider,{value:n,children:e})})},sG=V.memo(e=>{let{onExport:t,className:r,ownerDocument:i=document,onChange:a,onThemeChange:o,onIncrement:s,initialData:c,initialState:l,onExcalidrawAPI:u,onMount:d,onUnmount:f,onInitialize:p,isCollaborating:m=!1,onPointerUpdate:h,renderTopLeftUI:g,renderTopRightUI:_,langCode:v=rx.code,viewModeEnabled:y,interaction:b,ui:x,activeTool:S,zenModeEnabled:C,gridModeEnabled:w,libraryReturnUrl:T,theme:E,name:D,renderCustomStats:ee,onPaste:O,detectScroll:k=!0,handleKeyboardGlobally:te=!1,onLibraryChange:A,autoFocus:j=!1,generateIdForFile:ne,onLinkOpen:re,generateLinkForSelection:ie,onPointerDown:ae,onPointerUp:oe,onScrollChange:se,onUserFollow:ce,userToFollow:le,onDuplicate:ue,children:de,validateEmbeddable:fe,renderEmbeddable:pe,aiEnabled:me,showDeprecatedFonts:he,renderScrollbars:_e,viewportStatusFrame:ve,currentUserControls:ye,imageOptions:be}=e,xe=e.UIOptions?.canvasActions,Se={...e.UIOptions,canvasActions:{...pn.canvasActions,...xe},tools:{image:e.UIOptions?.tools?.image??!0}};xe?.export&&(Se.canvasActions.export.saveFileToDisk=xe.export?.saveFileToDisk??pn.canvasActions.export.saveFileToDisk),Se.canvasActions.toggleTheme===null&&(E==null||o)&&(Se.canvasActions.toggleTheme=!0);let Ce={maxFileSizeBytes:be?.maxFileSizeBytes??ge.maxFileSizeBytes,maxWidthOrHeight:be?.maxWidthOrHeight??ge.maxWidthOrHeight},we=(0,V.useContext)(iW),Te=(0,V.useRef)(u);Te.current=u;let Ee=(0,V.useCallback)(e=>{we?.(e),Te.current?.(e)},[we]),De=typeof b==`object`&&!!b&&b.enabled?.browserZoom===!0&&b.enabled?.navigation!==!0;return(0,V.useEffect)(()=>{if((async()=>{await n(()=>import(`./roundRect-D01gJrlt.js`),[],import.meta.url)})(),De)return;let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return i.addEventListener(`touchmove`,e,{passive:!1}),()=>{i.removeEventListener(`touchmove`,e)}},[De,i]),(0,U.jsx)($b,{store:ex,children:(0,U.jsx)(OW,{langCode:v,theme:E,children:(0,U.jsx)(DW,{onExport:t,className:r,ownerDocument:i,onChange:a,onThemeChange:o,onIncrement:s,initialData:c,initialState:l,onExcalidrawAPI:Ee,onMount:d,onUnmount:f,onInitialize:p,isCollaborating:m,onPointerUpdate:h,renderTopLeftUI:g,renderTopRightUI:_,langCode:v,viewModeEnabled:y,interaction:b,ui:x,activeTool:S,zenModeEnabled:C,gridModeEnabled:w,libraryReturnUrl:T,theme:E,name:D,renderCustomStats:ee,UIOptions:Se,onPaste:O,detectScroll:k,handleKeyboardGlobally:te,onLibraryChange:A,autoFocus:j,generateIdForFile:ne,onLinkOpen:re,generateLinkForSelection:ie,onPointerDown:ae,onPointerUp:oe,onScrollChange:se,onUserFollow:ce,userToFollow:le,onDuplicate:ue,validateEmbeddable:fe,renderEmbeddable:pe,aiEnabled:me!==!1,showDeprecatedFonts:he,renderScrollbars:_e,viewportStatusFrame:ve,currentUserControls:ye,imageOptions:Ce,children:de})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:r={},imageOptions:i,interaction:a,ui:o,activeTool:s,...c}=e,{initialData:l,UIOptions:u={},imageOptions:d,interaction:f,ui:p,activeTool:m,...h}=t;if(!(s===m||s?.type===m?.type&&(s?.type===`custom`?s.customType:null)===(m?.type===`custom`?m.customType:null))||!(a===f||typeof a==`object`&&a&&typeof f==`object`&&f&&!!a.enabled?.links==!!f.enabled?.links&&!!a.enabled?.embeds==!!f.enabled?.embeds&&!!a.enabled?.interactiveContent==!!f.enabled?.interactiveContent&&!!a.enabled?.navigation==!!f.enabled?.navigation&&!!a.enabled?.browserZoom==!!f.enabled?.browserZoom&&!!a.enabled?.tools?.laser==!!f.enabled?.tools?.laser&&!!a.enabled?.tools?.custom==!!f.enabled?.tools?.custom)||!(o===p||typeof o==`object`&&o&&typeof p==`object`&&p&&!!o.enabled?.zoom==!!p.enabled?.zoom&&!!o.enabled?.scrollBackToContent==!!p.enabled?.scrollBackToContent))return!1;let g=Object.keys(r),_=Object.keys(u);if(g.length!==_.length)return!1;let v=g.every(e=>e===`getFormFactor`?!0:e===`canvasActions`?Object.keys(r.canvasActions).every(e=>e===`export`&&r?.canvasActions?.export&&u?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===u.canvasActions.export.saveFileToDisk:r?.canvasActions?.[e]===u?.canvasActions?.[e]):r[e]===u[e]),y=(i?.maxWidthOrHeight??ge.maxWidthOrHeight)===(d?.maxWidthOrHeight??ge.maxWidthOrHeight)&&(i?.maxFileSizeBytes??ge.maxFileSizeBytes)===(d?.maxFileSizeBytes??ge.maxFileSizeBytes);return v&&y&&qr(c,h)});sG.displayName=`Excalidraw`;function cG(e){return gD(e,!1)}export{MW as A,NA as C,JA as D,gI as E,aG as F,sW as I,cW as L,AW as M,MA as N,VM as O,oH as P,iG as R,XW as S,qI as T,oG as _,GI as a,ix as b,rG as c,aE as d,Uz as f,cG as g,wz as h,AA as i,rW as j,UA as k,$j as l,ej as m,sG as n,mV as o,rx as p,KR as r,_D as s,nj as t,fx as u,jA as v,mW as w,eG as x,tG as y,Sl as z};