@excalidraw/excalidraw 0.18.0-432a46e → 0.18.0-6fc8502

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 (410) hide show
  1. package/dist/dev/{chunk-ZG3EI5XS.js → chunk-H7XJ5UVD.js} +2 -2
  2. package/dist/dev/{chunk-ZG3EI5XS.js.map → chunk-H7XJ5UVD.js.map} +1 -1
  3. package/dist/dev/{chunk-S7W4OWSF.js → chunk-KYBDXI6F.js} +417 -120
  4. package/dist/dev/chunk-KYBDXI6F.js.map +7 -0
  5. package/dist/dev/{chunk-LMHBUWQS.js → chunk-X3RYHLJU.js} +2 -1
  6. package/dist/dev/chunk-X3RYHLJU.js.map +7 -0
  7. package/dist/dev/data/{image-5HAY2PCR.js → image-NKFINVKH.js} +3 -3
  8. package/dist/dev/index.css +43 -46
  9. package/dist/dev/index.css.map +2 -2
  10. package/dist/dev/index.js +508 -99
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-OZCJJ2HN.js → en-CKWC2GMK.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-CAN5RS4P.js +31 -0
  16. package/dist/prod/{chunk-6U3AYISY.js → chunk-IUH5AXLB.js} +1 -1
  17. package/dist/prod/{chunk-U24AOZ3B.js → chunk-KJYFYP64.js} +1 -1
  18. package/dist/prod/data/image-5XD47O4X.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +14 -14
  21. package/dist/prod/locales/{en-B4ZKOASM.js → en-SBO6ZHT2.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/{packages/common → common}/src/colors.d.ts +1 -0
  25. package/dist/types/{packages/common → common}/src/constants.d.ts +1 -0
  26. package/dist/types/{packages/common → common}/src/utils.d.ts +1 -0
  27. package/dist/types/{packages/element → element}/src/binding.d.ts +2 -1
  28. package/dist/types/{packages/element → element}/src/bounds.d.ts +5 -0
  29. package/dist/types/{packages/element → element}/src/heading.d.ts +0 -1
  30. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionAddToLibrary.d.ts +3 -0
  31. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionBoundText.d.ts +2 -0
  32. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionCanvas.d.ts +192 -3
  33. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionClipboard.d.ts +6 -0
  34. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionCropEditor.d.ts +1 -0
  35. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionDeleteSelected.d.ts +3 -0
  36. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionElementLink.d.ts +1 -0
  37. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionElementLock.d.ts +2 -1
  38. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionEmbeddable.d.ts +1 -0
  39. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionExport.d.ts +9 -0
  40. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionFinalize.d.ts +2 -0
  41. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionFrame.d.ts +4 -0
  42. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionGroup.d.ts +2 -0
  43. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionLinearEditor.d.ts +1 -0
  44. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionLink.d.ts +1 -0
  45. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionMenu.d.ts +3 -0
  46. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionNavigate.d.ts +2 -0
  47. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionProperties.d.ts +15 -0
  48. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionSelectAll.d.ts +1 -0
  49. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionStyles.d.ts +1 -0
  50. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleGridMode.d.ts +1 -0
  51. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleObjectsSnapMode.d.ts +1 -0
  52. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleSearchMenu.d.ts +2 -0
  53. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleStats.d.ts +1 -1
  54. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleViewMode.d.ts +1 -1
  55. package/dist/types/{packages/excalidraw → excalidraw}/actions/actionToggleZenMode.d.ts +1 -1
  56. package/dist/types/{packages/excalidraw → excalidraw}/actions/types.d.ts +1 -1
  57. package/dist/types/{packages/excalidraw → excalidraw}/animated-trail.d.ts +7 -1
  58. package/dist/types/{packages/excalidraw → excalidraw}/appState.d.ts +1 -0
  59. package/dist/types/{packages/excalidraw → excalidraw}/components/App.d.ts +6 -1
  60. package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +7 -0
  61. package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  62. package/dist/types/{packages/excalidraw → excalidraw}/components/icons.d.ts +1 -0
  63. package/dist/types/excalidraw/lasso/index.d.ts +15 -0
  64. package/dist/types/excalidraw/lasso/utils.d.ts +13 -0
  65. package/dist/types/{packages/excalidraw → excalidraw}/types.d.ts +2 -1
  66. package/dist/types/{packages/math → math}/src/polygon.d.ts +1 -0
  67. package/dist/types/{packages/math → math}/src/segment.d.ts +1 -1
  68. package/package.json +19 -2
  69. package/dist/dev/chunk-LMHBUWQS.js.map +0 -7
  70. package/dist/dev/chunk-S7W4OWSF.js.map +0 -7
  71. package/dist/prod/chunk-LRITYP5X.js +0 -31
  72. package/dist/prod/data/image-W3GRS73V.js +0 -1
  73. package/dist/types/excalidraw-app/app_constants.d.ts +0 -44
  74. package/dist/types/packages/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +0 -8
  75. package/dist/types/packages/excalidraw/tests/fixtures/diagramFixture.d.ts +0 -504
  76. package/dist/types/packages/excalidraw/tests/fixtures/elementFixture.d.ts +0 -7
  77. package/dist/types/packages/excalidraw/tests/helpers/api.d.ts +0 -89
  78. package/dist/types/packages/excalidraw/tests/helpers/colorize.d.ts +0 -2
  79. package/dist/types/packages/excalidraw/tests/helpers/mocks.d.ts +0 -5
  80. package/dist/types/packages/excalidraw/tests/helpers/polyfills.d.ts +0 -36
  81. package/dist/types/packages/excalidraw/tests/helpers/ui.d.ts +0 -189
  82. package/dist/types/packages/excalidraw/tests/queries/dom.d.ts +0 -2
  83. package/dist/types/packages/excalidraw/tests/queries/toolQueries.d.ts +0 -2
  84. package/dist/types/packages/excalidraw/tests/test-utils.d.ts +0 -139
  85. /package/dist/dev/data/{image-5HAY2PCR.js.map → image-NKFINVKH.js.map} +0 -0
  86. /package/dist/dev/locales/{en-OZCJJ2HN.js.map → en-CKWC2GMK.js.map} +0 -0
  87. /package/dist/types/{packages/common → common}/src/binary-heap.d.ts +0 -0
  88. /package/dist/types/{packages/common → common}/src/font-metadata.d.ts +0 -0
  89. /package/dist/types/{packages/common → common}/src/index.d.ts +0 -0
  90. /package/dist/types/{packages/common → common}/src/keys.d.ts +0 -0
  91. /package/dist/types/{packages/common → common}/src/points.d.ts +0 -0
  92. /package/dist/types/{packages/common → common}/src/promise-pool.d.ts +0 -0
  93. /package/dist/types/{packages/common → common}/src/queue.d.ts +0 -0
  94. /package/dist/types/{packages/common → common}/src/random.d.ts +0 -0
  95. /package/dist/types/{packages/common → common}/src/url.d.ts +0 -0
  96. /package/dist/types/{packages/common → common}/src/utility-types.d.ts +0 -0
  97. /package/dist/types/{packages/element → element}/src/Shape.d.ts +0 -0
  98. /package/dist/types/{packages/element → element}/src/ShapeCache.d.ts +0 -0
  99. /package/dist/types/{packages/element → element}/src/align.d.ts +0 -0
  100. /package/dist/types/{packages/element → element}/src/collision.d.ts +0 -0
  101. /package/dist/types/{packages/element → element}/src/comparisons.d.ts +0 -0
  102. /package/dist/types/{packages/element → element}/src/containerCache.d.ts +0 -0
  103. /package/dist/types/{packages/element → element}/src/cropElement.d.ts +0 -0
  104. /package/dist/types/{packages/element → element}/src/distance.d.ts +0 -0
  105. /package/dist/types/{packages/element → element}/src/distribute.d.ts +0 -0
  106. /package/dist/types/{packages/element → element}/src/dragElements.d.ts +0 -0
  107. /package/dist/types/{packages/element → element}/src/duplicate.d.ts +0 -0
  108. /package/dist/types/{packages/element → element}/src/elbowArrow.d.ts +0 -0
  109. /package/dist/types/{packages/element → element}/src/elementLink.d.ts +0 -0
  110. /package/dist/types/{packages/element → element}/src/embeddable.d.ts +0 -0
  111. /package/dist/types/{packages/element → element}/src/flowchart.d.ts +0 -0
  112. /package/dist/types/{packages/element → element}/src/fractionalIndex.d.ts +0 -0
  113. /package/dist/types/{packages/element → element}/src/frame.d.ts +0 -0
  114. /package/dist/types/{packages/element → element}/src/groups.d.ts +0 -0
  115. /package/dist/types/{packages/element → element}/src/image.d.ts +0 -0
  116. /package/dist/types/{packages/element → element}/src/index.d.ts +0 -0
  117. /package/dist/types/{packages/element → element}/src/linearElementEditor.d.ts +0 -0
  118. /package/dist/types/{packages/element → element}/src/mutateElement.d.ts +0 -0
  119. /package/dist/types/{packages/element → element}/src/newElement.d.ts +0 -0
  120. /package/dist/types/{packages/element → element}/src/renderElement.d.ts +0 -0
  121. /package/dist/types/{packages/element → element}/src/resizeElements.d.ts +0 -0
  122. /package/dist/types/{packages/element → element}/src/resizeTest.d.ts +0 -0
  123. /package/dist/types/{packages/element → element}/src/selection.d.ts +0 -0
  124. /package/dist/types/{packages/element → element}/src/shapes.d.ts +0 -0
  125. /package/dist/types/{packages/element → element}/src/showSelectedShapeActions.d.ts +0 -0
  126. /package/dist/types/{packages/element → element}/src/sizeHelpers.d.ts +0 -0
  127. /package/dist/types/{packages/element → element}/src/sortElements.d.ts +0 -0
  128. /package/dist/types/{packages/element → element}/src/textElement.d.ts +0 -0
  129. /package/dist/types/{packages/element → element}/src/textMeasurements.d.ts +0 -0
  130. /package/dist/types/{packages/element → element}/src/textWrapping.d.ts +0 -0
  131. /package/dist/types/{packages/element → element}/src/transformHandles.d.ts +0 -0
  132. /package/dist/types/{packages/element → element}/src/typeChecks.d.ts +0 -0
  133. /package/dist/types/{packages/element → element}/src/types.d.ts +0 -0
  134. /package/dist/types/{packages/element → element}/src/utils.d.ts +0 -0
  135. /package/dist/types/{packages/element → element}/src/zindex.d.ts +0 -0
  136. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionAlign.d.ts +0 -0
  137. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionDistribute.d.ts +0 -0
  138. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionDuplicateSelection.d.ts +0 -0
  139. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionFlip.d.ts +0 -0
  140. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionHistory.d.ts +0 -0
  141. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionTextAutoResize.d.ts +0 -0
  142. /package/dist/types/{packages/excalidraw → excalidraw}/actions/actionZindex.d.ts +0 -0
  143. /package/dist/types/{packages/excalidraw → excalidraw}/actions/index.d.ts +0 -0
  144. /package/dist/types/{packages/excalidraw → excalidraw}/actions/manager.d.ts +0 -0
  145. /package/dist/types/{packages/excalidraw → excalidraw}/actions/register.d.ts +0 -0
  146. /package/dist/types/{packages/excalidraw → excalidraw}/actions/shortcuts.d.ts +0 -0
  147. /package/dist/types/{packages/excalidraw → excalidraw}/analytics.d.ts +0 -0
  148. /package/dist/types/{packages/excalidraw → excalidraw}/animation-frame-handler.d.ts +0 -0
  149. /package/dist/types/{packages/excalidraw → excalidraw}/change.d.ts +0 -0
  150. /package/dist/types/{packages/excalidraw → excalidraw}/charts.d.ts +0 -0
  151. /package/dist/types/{packages/excalidraw → excalidraw}/clients.d.ts +0 -0
  152. /package/dist/types/{packages/excalidraw → excalidraw}/clipboard.d.ts +0 -0
  153. /package/dist/types/{packages/excalidraw → excalidraw}/components/Actions.d.ts +0 -0
  154. /package/dist/types/{packages/excalidraw → excalidraw}/components/ActiveConfirmDialog.d.ts +0 -0
  155. /package/dist/types/{packages/excalidraw → excalidraw}/components/Avatar.d.ts +0 -0
  156. /package/dist/types/{packages/excalidraw → excalidraw}/components/BraveMeasureTextError.d.ts +0 -0
  157. /package/dist/types/{packages/excalidraw → excalidraw}/components/Button.d.ts +0 -0
  158. /package/dist/types/{packages/excalidraw → excalidraw}/components/ButtonIcon.d.ts +0 -0
  159. /package/dist/types/{packages/excalidraw → excalidraw}/components/ButtonIconCycle.d.ts +0 -0
  160. /package/dist/types/{packages/excalidraw → excalidraw}/components/ButtonIconSelect.d.ts +0 -0
  161. /package/dist/types/{packages/excalidraw → excalidraw}/components/ButtonSelect.d.ts +0 -0
  162. /package/dist/types/{packages/excalidraw → excalidraw}/components/ButtonSeparator.d.ts +0 -0
  163. /package/dist/types/{packages/excalidraw → excalidraw}/components/Card.d.ts +0 -0
  164. /package/dist/types/{packages/excalidraw → excalidraw}/components/CheckboxItem.d.ts +0 -0
  165. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/ColorInput.d.ts +0 -0
  166. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/ColorPicker.d.ts +0 -0
  167. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/CustomColorList.d.ts +0 -0
  168. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/Picker.d.ts +0 -0
  169. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/PickerColorList.d.ts +0 -0
  170. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/PickerHeading.d.ts +0 -0
  171. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/ShadeList.d.ts +0 -0
  172. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/TopPicks.d.ts +0 -0
  173. /package/dist/types/{packages/excalidraw → excalidraw}/components/ColorPicker/keyboardNavHandlers.d.ts +0 -0
  174. /package/dist/types/{packages/excalidraw → excalidraw}/components/CommandPalette/CommandPalette.d.ts +0 -0
  175. /package/dist/types/{packages/excalidraw → excalidraw}/components/CommandPalette/defaultCommandPaletteItems.d.ts +0 -0
  176. /package/dist/types/{packages/excalidraw → excalidraw}/components/CommandPalette/types.d.ts +0 -0
  177. /package/dist/types/{packages/excalidraw → excalidraw}/components/ConfirmDialog.d.ts +0 -0
  178. /package/dist/types/{packages/excalidraw → excalidraw}/components/ContextMenu.d.ts +0 -0
  179. /package/dist/types/{packages/excalidraw → excalidraw}/components/DarkModeToggle.d.ts +0 -0
  180. /package/dist/types/{packages/excalidraw → excalidraw}/components/DefaultSidebar.d.ts +0 -0
  181. /package/dist/types/{packages/excalidraw → excalidraw}/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -0
  182. /package/dist/types/{packages/excalidraw → excalidraw}/components/Dialog.d.ts +0 -0
  183. /package/dist/types/{packages/excalidraw → excalidraw}/components/DialogActionButton.d.ts +0 -0
  184. /package/dist/types/{packages/excalidraw → excalidraw}/components/ElementCanvasButtons.d.ts +0 -0
  185. /package/dist/types/{packages/excalidraw → excalidraw}/components/ElementLinkDialog.d.ts +0 -0
  186. /package/dist/types/{packages/excalidraw → excalidraw}/components/ErrorDialog.d.ts +0 -0
  187. /package/dist/types/{packages/excalidraw → excalidraw}/components/ExcalidrawLogo.d.ts +0 -0
  188. /package/dist/types/{packages/excalidraw → excalidraw}/components/EyeDropper.d.ts +0 -0
  189. /package/dist/types/{packages/excalidraw → excalidraw}/components/FilledButton.d.ts +0 -0
  190. /package/dist/types/{packages/excalidraw → excalidraw}/components/FixedSideContainer.d.ts +0 -0
  191. /package/dist/types/{packages/excalidraw → excalidraw}/components/FollowMode/FollowMode.d.ts +0 -0
  192. /package/dist/types/{packages/excalidraw → excalidraw}/components/FontPicker/FontPicker.d.ts +0 -0
  193. /package/dist/types/{packages/excalidraw → excalidraw}/components/FontPicker/FontPickerList.d.ts +0 -0
  194. /package/dist/types/{packages/excalidraw → excalidraw}/components/FontPicker/FontPickerTrigger.d.ts +0 -0
  195. /package/dist/types/{packages/excalidraw → excalidraw}/components/FontPicker/keyboardNavHandlers.d.ts +0 -0
  196. /package/dist/types/{packages/excalidraw → excalidraw}/components/HandButton.d.ts +0 -0
  197. /package/dist/types/{packages/excalidraw → excalidraw}/components/HelpButton.d.ts +0 -0
  198. /package/dist/types/{packages/excalidraw → excalidraw}/components/HelpDialog.d.ts +0 -0
  199. /package/dist/types/{packages/excalidraw → excalidraw}/components/HintViewer.d.ts +0 -0
  200. /package/dist/types/{packages/excalidraw → excalidraw}/components/IconPicker.d.ts +0 -0
  201. /package/dist/types/{packages/excalidraw → excalidraw}/components/ImageExportDialog.d.ts +0 -0
  202. /package/dist/types/{packages/excalidraw → excalidraw}/components/InitializeApp.d.ts +0 -0
  203. /package/dist/types/{packages/excalidraw → excalidraw}/components/InlineIcon.d.ts +0 -0
  204. /package/dist/types/{packages/excalidraw → excalidraw}/components/Island.d.ts +0 -0
  205. /package/dist/types/{packages/excalidraw → excalidraw}/components/JSONExportDialog.d.ts +0 -0
  206. /package/dist/types/{packages/excalidraw → excalidraw}/components/LaserPointerButton.d.ts +0 -0
  207. /package/dist/types/{packages/excalidraw → excalidraw}/components/LayerUI.d.ts +0 -0
  208. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenu.d.ts +0 -0
  209. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenuBrowseButton.d.ts +0 -0
  210. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenuControlButtons.d.ts +0 -0
  211. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenuHeaderContent.d.ts +0 -0
  212. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenuItems.d.ts +0 -0
  213. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryMenuSection.d.ts +0 -0
  214. /package/dist/types/{packages/excalidraw → excalidraw}/components/LibraryUnit.d.ts +0 -0
  215. /package/dist/types/{packages/excalidraw → excalidraw}/components/LoadingMessage.d.ts +0 -0
  216. /package/dist/types/{packages/excalidraw → excalidraw}/components/LockButton.d.ts +0 -0
  217. /package/dist/types/{packages/excalidraw → excalidraw}/components/MagicButton.d.ts +0 -0
  218. /package/dist/types/{packages/excalidraw → excalidraw}/components/MobileMenu.d.ts +0 -0
  219. /package/dist/types/{packages/excalidraw → excalidraw}/components/Modal.d.ts +0 -0
  220. /package/dist/types/{packages/excalidraw → excalidraw}/components/OverwriteConfirm/OverwriteConfirm.d.ts +0 -0
  221. /package/dist/types/{packages/excalidraw → excalidraw}/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +0 -0
  222. /package/dist/types/{packages/excalidraw → excalidraw}/components/OverwriteConfirm/OverwriteConfirmState.d.ts +0 -0
  223. /package/dist/types/{packages/excalidraw → excalidraw}/components/Paragraph.d.ts +0 -0
  224. /package/dist/types/{packages/excalidraw → excalidraw}/components/PasteChartDialog.d.ts +0 -0
  225. /package/dist/types/{packages/excalidraw → excalidraw}/components/PenModeButton.d.ts +0 -0
  226. /package/dist/types/{packages/excalidraw → excalidraw}/components/Popover.d.ts +0 -0
  227. /package/dist/types/{packages/excalidraw → excalidraw}/components/ProjectName.d.ts +0 -0
  228. /package/dist/types/{packages/excalidraw → excalidraw}/components/PropertiesPopover.d.ts +0 -0
  229. /package/dist/types/{packages/excalidraw → excalidraw}/components/PublishLibrary.d.ts +0 -0
  230. /package/dist/types/{packages/excalidraw → excalidraw}/components/QuickSearch.d.ts +0 -0
  231. /package/dist/types/{packages/excalidraw → excalidraw}/components/RadioGroup.d.ts +0 -0
  232. /package/dist/types/{packages/excalidraw → excalidraw}/components/Range.d.ts +0 -0
  233. /package/dist/types/{packages/excalidraw → excalidraw}/components/SVGLayer.d.ts +0 -0
  234. /package/dist/types/{packages/excalidraw → excalidraw}/components/ScrollableList.d.ts +0 -0
  235. /package/dist/types/{packages/excalidraw → excalidraw}/components/SearchMenu.d.ts +0 -0
  236. /package/dist/types/{packages/excalidraw → excalidraw}/components/Section.d.ts +0 -0
  237. /package/dist/types/{packages/excalidraw → excalidraw}/components/ShareableLinkDialog.d.ts +0 -0
  238. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/Sidebar.d.ts +0 -0
  239. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarHeader.d.ts +0 -0
  240. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarTab.d.ts +0 -0
  241. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarTabTrigger.d.ts +0 -0
  242. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarTabTriggers.d.ts +0 -0
  243. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarTabs.d.ts +0 -0
  244. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/SidebarTrigger.d.ts +0 -0
  245. /package/dist/types/{packages/excalidraw → excalidraw}/components/Sidebar/common.d.ts +0 -0
  246. /package/dist/types/{packages/excalidraw → excalidraw}/components/Spinner.d.ts +0 -0
  247. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stack.d.ts +0 -0
  248. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/Angle.d.ts +0 -0
  249. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/CanvasGrid.d.ts +0 -0
  250. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/Collapsible.d.ts +0 -0
  251. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/Dimension.d.ts +0 -0
  252. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/DragInput.d.ts +0 -0
  253. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/FontSize.d.ts +0 -0
  254. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/MultiAngle.d.ts +0 -0
  255. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/MultiDimension.d.ts +0 -0
  256. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/MultiFontSize.d.ts +0 -0
  257. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/MultiPosition.d.ts +0 -0
  258. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/Position.d.ts +0 -0
  259. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/index.d.ts +0 -0
  260. /package/dist/types/{packages/excalidraw → excalidraw}/components/Stats/utils.d.ts +0 -0
  261. /package/dist/types/{packages/excalidraw → excalidraw}/components/Switch.d.ts +0 -0
  262. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/MermaidToExcalidraw.d.ts +0 -0
  263. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialog.d.ts +0 -0
  264. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogInput.d.ts +0 -0
  265. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogOutput.d.ts +0 -0
  266. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogPanel.d.ts +0 -0
  267. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogPanels.d.ts +0 -0
  268. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +0 -0
  269. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogTab.d.ts +0 -0
  270. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogTabTrigger.d.ts +0 -0
  271. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogTabTriggers.d.ts +0 -0
  272. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogTabs.d.ts +0 -0
  273. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/TTDDialogTrigger.d.ts +0 -0
  274. /package/dist/types/{packages/excalidraw → excalidraw}/components/TTDDialog/common.d.ts +0 -0
  275. /package/dist/types/{packages/excalidraw → excalidraw}/components/TextField.d.ts +0 -0
  276. /package/dist/types/{packages/excalidraw → excalidraw}/components/Toast.d.ts +0 -0
  277. /package/dist/types/{packages/excalidraw → excalidraw}/components/ToolButton.d.ts +0 -0
  278. /package/dist/types/{packages/excalidraw → excalidraw}/components/Tooltip.d.ts +0 -0
  279. /package/dist/types/{packages/excalidraw → excalidraw}/components/Trans.d.ts +0 -0
  280. /package/dist/types/{packages/excalidraw → excalidraw}/components/UserList.d.ts +0 -0
  281. /package/dist/types/{packages/excalidraw → excalidraw}/components/canvases/InteractiveCanvas.d.ts +0 -0
  282. /package/dist/types/{packages/excalidraw → excalidraw}/components/canvases/NewElementCanvas.d.ts +0 -0
  283. /package/dist/types/{packages/excalidraw → excalidraw}/components/canvases/StaticCanvas.d.ts +0 -0
  284. /package/dist/types/{packages/excalidraw → excalidraw}/components/canvases/index.d.ts +0 -0
  285. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenu.d.ts +0 -0
  286. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuContent.d.ts +0 -0
  287. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuGroup.d.ts +0 -0
  288. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuItem.d.ts +0 -0
  289. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuItemContent.d.ts +0 -0
  290. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +0 -0
  291. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuItemCustom.d.ts +0 -0
  292. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuItemLink.d.ts +0 -0
  293. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuSeparator.d.ts +0 -0
  294. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -0
  295. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/common.d.ts +0 -0
  296. /package/dist/types/{packages/excalidraw → excalidraw}/components/dropdownMenu/dropdownMenuUtils.d.ts +0 -0
  297. /package/dist/types/{packages/excalidraw → excalidraw}/components/footer/Footer.d.ts +0 -0
  298. /package/dist/types/{packages/excalidraw → excalidraw}/components/footer/FooterCenter.d.ts +0 -0
  299. /package/dist/types/{packages/excalidraw → excalidraw}/components/hoc/withInternalFallback.d.ts +0 -0
  300. /package/dist/types/{packages/excalidraw → excalidraw}/components/hyperlink/Hyperlink.d.ts +0 -0
  301. /package/dist/types/{packages/excalidraw → excalidraw}/components/hyperlink/helpers.d.ts +0 -0
  302. /package/dist/types/{packages/excalidraw → excalidraw}/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -0
  303. /package/dist/types/{packages/excalidraw → excalidraw}/components/main-menu/DefaultItems.d.ts +0 -0
  304. /package/dist/types/{packages/excalidraw → excalidraw}/components/main-menu/MainMenu.d.ts +0 -0
  305. /package/dist/types/{packages/excalidraw → excalidraw}/components/shapes.d.ts +0 -0
  306. /package/dist/types/{packages/excalidraw → excalidraw}/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -0
  307. /package/dist/types/{packages/excalidraw → excalidraw}/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -0
  308. /package/dist/types/{packages/excalidraw → excalidraw}/components/welcome-screen/WelcomeScreen.d.ts +0 -0
  309. /package/dist/types/{packages/excalidraw → excalidraw}/context/tunnels.d.ts +0 -0
  310. /package/dist/types/{packages/excalidraw → excalidraw}/context/ui-appState.d.ts +0 -0
  311. /package/dist/types/{packages/excalidraw → excalidraw}/cursor.d.ts +0 -0
  312. /package/dist/types/{packages/excalidraw → excalidraw}/data/EditorLocalStorage.d.ts +0 -0
  313. /package/dist/types/{packages/excalidraw → excalidraw}/data/ai/types.d.ts +0 -0
  314. /package/dist/types/{packages/excalidraw → excalidraw}/data/blob.d.ts +0 -0
  315. /package/dist/types/{packages/excalidraw → excalidraw}/data/encode.d.ts +0 -0
  316. /package/dist/types/{packages/excalidraw → excalidraw}/data/encryption.d.ts +0 -0
  317. /package/dist/types/{packages/excalidraw → excalidraw}/data/filesystem.d.ts +0 -0
  318. /package/dist/types/{packages/excalidraw → excalidraw}/data/image.d.ts +0 -0
  319. /package/dist/types/{packages/excalidraw → excalidraw}/data/index.d.ts +0 -0
  320. /package/dist/types/{packages/excalidraw → excalidraw}/data/json.d.ts +0 -0
  321. /package/dist/types/{packages/excalidraw → excalidraw}/data/library.d.ts +0 -0
  322. /package/dist/types/{packages/excalidraw → excalidraw}/data/reconcile.d.ts +0 -0
  323. /package/dist/types/{packages/excalidraw → excalidraw}/data/resave.d.ts +0 -0
  324. /package/dist/types/{packages/excalidraw → excalidraw}/data/restore.d.ts +0 -0
  325. /package/dist/types/{packages/excalidraw → excalidraw}/data/transform.d.ts +0 -0
  326. /package/dist/types/{packages/excalidraw → excalidraw}/data/types.d.ts +0 -0
  327. /package/dist/types/{packages/excalidraw → excalidraw}/deburr.d.ts +0 -0
  328. /package/dist/types/{packages/excalidraw → excalidraw}/editor-jotai.d.ts +0 -0
  329. /package/dist/types/{packages/excalidraw → excalidraw}/emitter.d.ts +0 -0
  330. /package/dist/types/{packages/excalidraw → excalidraw}/errors.d.ts +0 -0
  331. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Cascadia/index.d.ts +0 -0
  332. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/ComicShanns/index.d.ts +0 -0
  333. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Emoji/index.d.ts +0 -0
  334. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/ExcalidrawFontFace.d.ts +0 -0
  335. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Excalifont/index.d.ts +0 -0
  336. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Fonts.d.ts +0 -0
  337. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Helvetica/index.d.ts +0 -0
  338. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Liberation/index.d.ts +0 -0
  339. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Lilita/index.d.ts +0 -0
  340. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Nunito/index.d.ts +0 -0
  341. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Virgil/index.d.ts +0 -0
  342. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/Xiaolai/index.d.ts +0 -0
  343. /package/dist/types/{packages/excalidraw → excalidraw}/fonts/index.d.ts +0 -0
  344. /package/dist/types/{packages/excalidraw → excalidraw}/gesture.d.ts +0 -0
  345. /package/dist/types/{packages/excalidraw → excalidraw}/history.d.ts +0 -0
  346. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useCallbackRefState.d.ts +0 -0
  347. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useCopiedIndicator.d.ts +0 -0
  348. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useCreatePortalContainer.d.ts +0 -0
  349. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useEmitter.d.ts +0 -0
  350. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useLibraryItemSvg.d.ts +0 -0
  351. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useOutsideClick.d.ts +0 -0
  352. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useScrollPosition.d.ts +0 -0
  353. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useStable.d.ts +0 -0
  354. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useStableCallback.d.ts +0 -0
  355. /package/dist/types/{packages/excalidraw → excalidraw}/hooks/useTransition.d.ts +0 -0
  356. /package/dist/types/{packages/excalidraw → excalidraw}/i18n.d.ts +0 -0
  357. /package/dist/types/{packages/excalidraw → excalidraw}/index-node.d.ts +0 -0
  358. /package/dist/types/{packages/excalidraw → excalidraw}/index.d.ts +0 -0
  359. /package/dist/types/{packages/excalidraw → excalidraw}/laser-trails.d.ts +0 -0
  360. /package/dist/types/{packages/excalidraw → excalidraw}/mermaid.d.ts +0 -0
  361. /package/dist/types/{packages/excalidraw → excalidraw}/polyfill.d.ts +0 -0
  362. /package/dist/types/{packages/excalidraw → excalidraw}/reactUtils.d.ts +0 -0
  363. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/helpers.d.ts +0 -0
  364. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/interactiveScene.d.ts +0 -0
  365. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/renderNewElementScene.d.ts +0 -0
  366. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/renderSnaps.d.ts +0 -0
  367. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/roundRect.d.ts +0 -0
  368. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/staticScene.d.ts +0 -0
  369. /package/dist/types/{packages/excalidraw → excalidraw}/renderer/staticSvgScene.d.ts +0 -0
  370. /package/dist/types/{packages/excalidraw → excalidraw}/scene/Renderer.d.ts +0 -0
  371. /package/dist/types/{packages/excalidraw → excalidraw}/scene/Scene.d.ts +0 -0
  372. /package/dist/types/{packages/excalidraw → excalidraw}/scene/export.d.ts +0 -0
  373. /package/dist/types/{packages/excalidraw → excalidraw}/scene/index.d.ts +0 -0
  374. /package/dist/types/{packages/excalidraw → excalidraw}/scene/normalize.d.ts +0 -0
  375. /package/dist/types/{packages/excalidraw → excalidraw}/scene/scroll.d.ts +0 -0
  376. /package/dist/types/{packages/excalidraw → excalidraw}/scene/scrollbars.d.ts +0 -0
  377. /package/dist/types/{packages/excalidraw → excalidraw}/scene/types.d.ts +0 -0
  378. /package/dist/types/{packages/excalidraw → excalidraw}/scene/zoom.d.ts +0 -0
  379. /package/dist/types/{packages/excalidraw → excalidraw}/snapping.d.ts +0 -0
  380. /package/dist/types/{packages/excalidraw → excalidraw}/store.d.ts +0 -0
  381. /package/dist/types/{packages/excalidraw → excalidraw}/subset/harfbuzz/harfbuzz-bindings.d.ts +0 -0
  382. /package/dist/types/{packages/excalidraw → excalidraw}/subset/harfbuzz/harfbuzz-loader.d.ts +0 -0
  383. /package/dist/types/{packages/excalidraw → excalidraw}/subset/harfbuzz/harfbuzz-wasm.d.ts +0 -0
  384. /package/dist/types/{packages/excalidraw → excalidraw}/subset/subset-main.d.ts +0 -0
  385. /package/dist/types/{packages/excalidraw → excalidraw}/subset/subset-shared.chunk.d.ts +0 -0
  386. /package/dist/types/{packages/excalidraw → excalidraw}/subset/subset-worker.chunk.d.ts +0 -0
  387. /package/dist/types/{packages/excalidraw → excalidraw}/subset/woff2/woff2-bindings.d.ts +0 -0
  388. /package/dist/types/{packages/excalidraw → excalidraw}/subset/woff2/woff2-loader.d.ts +0 -0
  389. /package/dist/types/{packages/excalidraw → excalidraw}/subset/woff2/woff2-wasm.d.ts +0 -0
  390. /package/dist/types/{packages/excalidraw → excalidraw}/visualdebug.d.ts +0 -0
  391. /package/dist/types/{packages/excalidraw → excalidraw}/workers.d.ts +0 -0
  392. /package/dist/types/{packages/excalidraw → excalidraw}/wysiwyg/textWysiwyg.d.ts +0 -0
  393. /package/dist/types/{packages/math → math}/src/angle.d.ts +0 -0
  394. /package/dist/types/{packages/math → math}/src/curve.d.ts +0 -0
  395. /package/dist/types/{packages/math → math}/src/ellipse.d.ts +0 -0
  396. /package/dist/types/{packages/math → math}/src/index.d.ts +0 -0
  397. /package/dist/types/{packages/math → math}/src/line.d.ts +0 -0
  398. /package/dist/types/{packages/math → math}/src/point.d.ts +0 -0
  399. /package/dist/types/{packages/math → math}/src/range.d.ts +0 -0
  400. /package/dist/types/{packages/math → math}/src/rectangle.d.ts +0 -0
  401. /package/dist/types/{packages/math → math}/src/triangle.d.ts +0 -0
  402. /package/dist/types/{packages/math → math}/src/types.d.ts +0 -0
  403. /package/dist/types/{packages/math → math}/src/utils.d.ts +0 -0
  404. /package/dist/types/{packages/math → math}/src/vector.d.ts +0 -0
  405. /package/dist/types/{packages/utils → utils}/src/bbox.d.ts +0 -0
  406. /package/dist/types/{packages/utils → utils}/src/collision.d.ts +0 -0
  407. /package/dist/types/{packages/utils → utils}/src/export.d.ts +0 -0
  408. /package/dist/types/{packages/utils → utils}/src/index.d.ts +0 -0
  409. /package/dist/types/{packages/utils → utils}/src/shape.d.ts +0 -0
  410. /package/dist/types/{packages/utils → utils}/src/withinBounds.d.ts +0 -0
@@ -1,20 +1,20 @@
1
- import{$ as Ds,$a as i1,$b as x1,$c as A1,$d as eb,$e as gb,$f as vl,A as Jm,Aa as ol,Ab as or,Ac as kr,Ad as ro,Ae as nr,Af as _p,Ag as Ji,B as Of,Ba as Qt,Bb as Fn,Bc as he,Bd as Js,Be as ab,Bf as Dp,Bg as Kb,C as Ja,Ca as Bs,Cb as qe,Cc as zt,Cd as V1,Ce as lb,Cf as Pp,Cg as Up,D as Qm,Da as rl,Db as Hn,Dc as Kn,Dd as Y1,De as Yi,Df as Rp,Dg as dn,E as Se,Ea as Cr,Eb as Pi,Ec as Oi,Ed as W1,Ee as sb,Ef as Zi,Eg as Qi,F as tr,Fa as At,Fb as Un,Fc as Z,Fd as K1,Fe as Qn,Ff as Np,Fg as xc,G as Bn,Ga as zs,Gb as d1,Gc as T1,Gd as Ui,Ge as cb,Gf as kb,Gg as Gp,H as Qa,Ha as it,Hb as m1,Hc as Xs,Hd as Gi,He as Wi,Hf as oi,Hg as wl,I as Ho,Ia as qr,Ib as Gn,Ic as ie,Id as Z1,Ie as nc,If as Mb,Ig as Ec,J as Ot,Ja as e1,Jb as Ge,Jc as Ep,Jd as yp,Je as db,Jf as Lb,Jg as Vp,K as de,Ka as nl,Kb as R,Kc as ce,Kd as X1,Ke as ic,Kf as Ab,Kg as Yp,L as Uo,La as eo,Lb as $e,Lc as Pe,Ld as jn,Le as ir,Lf as _b,Lg as Zb,M as Ls,Ma as xt,Mb as Bt,Mc as ee,Md as $1,Me as Lp,Mf as _5,Mg as Xb,N as Tr,Na as t1,Nb as sl,Nc as C1,Nd as j1,Ne as mb,Nf as cn,Ng as $b,O as Zr,Oa as o1,Ob as en,Oc as Mr,Od as Qs,Oe as ac,Of as Ye,Og as yc,P as As,Pa as r1,Pb as Vs,Pc as I1,Pd as qn,Pe as lc,Pf as Db,Pg as Tl,Q as ep,Qa as Ir,Qb as bp,Qc as Zn,Qd as ec,Qe as sc,Qf as ye,Qg as vc,R as Xr,Ra as n1,Rb as Sr,Rc as Lr,Rd as hl,Re as pb,Rf as uc,Rg as wc,S as _s,Sa as pe,Sb as Vn,Sc as S1,Sd as Vo,Se as Ap,Sf as Xi,Sg as jb,T as Bf,Ta as T,Tb as p1,Tc as Xn,Td as q1,Te as ze,Tf as _t,Tg as qb,U as el,Ua as Fs,Ub as u1,Uc as Tt,Ud as an,Ue as ub,Uf as Op,Ug as Tc,V as zf,Va as zn,Vb as h1,Vc as Be,Vd as at,Ve as J,Vf as Pb,Vg as ea,W as Ff,Wa as Hs,Wb as g1,Wc as Bi,Wd as vp,We as cc,Wf as Rb,Wg as Jb,X as tp,Xa as Ai,Xb as f1,Xc as k1,Xd as wp,Xe as Me,Xf as Ut,Xg as Wp,Y as tl,Ya as Us,Yb as ne,Yc as M1,Yd as J1,Ye as hb,Yf as Bp,Yg as D5,Z as ue,Za as wt,Zb as b1,Zc as zi,Zd as tc,Ze as ut,Zf as Nb,Zg as ta,_ as Hf,_a as So,_b as rr,_c as L1,_d as Q1,_e as dc,_f as $i,_g as Cl,a as Tf,aa as $r,ab as lp,ac as dt,ad as _1,ae as gl,af as Yo,ag as Gt,ah as Qb,b as Nn,ba as Uf,bb as il,bc as Fe,bd as D1,be as fl,bf as fb,bg as Ob,c as Cf,ca as Gf,cb as _i,cc as Ys,cd as P1,ce as tb,cf as bb,cg as Bb,ch as e0,d as If,da as Vf,db as Di,dc as Ri,dd as R1,de as oc,df as Ki,dg as lr,dh as t0,e as Sf,ea as Yf,eb as sp,ec as E1,ed as N1,ee as B,ef as Ue,eg as ji,eh as Cc,f as Io,fa as Wf,fb as Gs,fc as tn,fd as ml,fe as oe,ff as xb,fg as hc,fh as o0,g as Ts,ga as Li,gb as cp,gc as cl,gd as O1,ge as bl,gf as Eb,gg as zp,gh as Ic,h as Cs,ha as op,hb as dp,hc as Je,hd as B1,he as Jn,hf as yb,hg as ri,hh as Kp,i as Is,ia as rp,ib as a1,ic as on,id as pl,ie as xl,if as ei,ig as zb,ih as Sc,j as kf,ja as Kf,jb as mp,jc as Yn,jd as z1,je as Vi,jf as vb,jg as qi,jh as r0,k as Mf,ka as Zf,kb as M,kc as rn,kd as F1,ke as Tp,kf as wb,kg as Fb,kh as Zp,l as Lf,la as Ps,lb as se,lc as y1,ld as Ft,le as Cp,lf as ar,lg as Hb,lh as Dr,m as Af,ma as Rs,mb as pp,mc as Ws,md as $s,me as ob,mf as Tb,mg as Ub,mh as n0,n as Fo,na as np,nb as Jr,nc as to,nd as Fi,ne as k5,nf as Cb,ng as Fp,nh as kc,o as Ss,oa as Xf,ob as up,oc as Ni,od as H1,oe as Ip,of as mc,og as gc,oh as i0,p as _f,pa as $f,pb as po,pc as Ve,pd as $n,pe as Sp,pf as Ht,pg as fc,ph as a0,q as wr,qa as jf,qb as al,qc as v1,qd as U1,qe as Ee,qf as _r,qg as bc,qh as l0,r as Df,ra as qf,rb as ll,rc as w1,rd as js,re as kp,rf as ln,rg as ni,rh as Il,s as ks,sa as Ns,sb as l1,sc as nn,sd as S5,se as M5,sf as j,sg as Gb,sh as Xp,t as Pf,ta as jr,tb as hp,tc as xp,td as G1,te as L5,tf as ti,tg as Yb,th as s0,u as ja,ua as Jf,ub as pt,uc as dl,ud as Hi,ue as A5,uf as Ib,ug as ii,uh as c0,v as qa,va as ip,vb as gp,vc as Wn,vd as Qe,ve as rb,vf as Sb,vg as sr,vh as d0,w as Rf,wa as Qf,wb as Qr,wc as oo,wd as ul,we as nb,wf as pc,wg as Wb,wh as m0,x as On,xa as Os,xb as s1,xc as Go,xd as qs,xe as rc,xf as El,xg as cr,y as Ms,ya as ap,yb as fp,yc as Ks,yd as Ar,ye as Mp,yf as sn,yg as no,z as Nf,za as Jt,zb as c1,zc as Zs,zd as ge,ze as ib,zf as yl,zg as Wo}from"./chunk-LRITYP5X.js";import{a as S}from"./chunk-U24AOZ3B.js";import{J as Hp}from"./chunk-6U3AYISY.js";import{c as Vb}from"./chunk-Z3N5DIM6.js";import{b as vf,c as wf,d as k}from"./chunk-SRAX5OIU.js";import qL,{useEffect as JL}from"react";import a5 from"clsx";import IL from"lodash.throttle";import vr,{useContext as Pn}from"react";import{flushSync as ki}from"react-dom";import SL from"roughjs/bin/rough";import{nanoid as kL}from"nanoid";var P5=e=>{let o=e.slice(),t=new Set,r=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...r(s)]:l},n=new Map;return o.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=o.slice(a).filter(c=>{let m=c?.groupIds?.some(d=>d===l);return m&&n.set(c.id,!0),m});for(let c of r(s))t.add(c)}else t.add(i)}),t.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...t]},R5=e=>{let o=b1(e),t=e.slice(),r=new Set;return t.forEach((n,i)=>{n&&(n.boundElements?.length?(r.add(n),t[i]=null,n.boundElements.forEach(a=>{let l=o.get(a.id);l&&a.type==="text"&&(r.add(l[0]),t[l[1]]=null)})):n.type==="text"&&n.containerId&&o.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(r.add(n),t[i]=null))}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},p0=e=>R5(P5(e));var N5=(e,o,t,r,n)=>{let i=uo(t);return dt()&&O5(i,t.id),i.id=oo(),i.updated=f1(),n&&(i.seed=Wn(),bl(i)),i.groupIds=Tb(i.groupIds,e,a=>(o.has(a)||o.set(a,oo()),o.get(a))),r&&(i=Object.assign(i,r)),i},ai=e=>{let{elements:o}=e,t="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=e.type==="in-place"?e.reverseOrder:!1,n=new Map,i=new Map,a=[],l=[],s=new Map,c=new Map,m=ne(o),d=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(o.map(x=>[x.id,x]));if(e.type==="in-place")for(let x of Object.keys(e.appState.selectedGroupIds))o.filter(E=>E.groupIds?.includes(x)).forEach(E=>d.set(E.id,E));o=p0(o);let p=o.slice(),u=x=>{let w=dl(x).reduce((y,v)=>{if(n.has(v.id))return y;n.set(v.id,!0);let C=N5(t.editingGroupId,i,v,e.overrides?.(v),e.randomizeSeed);return n.set(C.id,!0),c.set(C.id,C),s.set(v.id,C.id),l.push(v),a.push(C),y.push(C),y},[]);return Array.isArray(x)?w:w[0]||null},h=(x,E)=>{if(E){if(r&&x<1){p.unshift(...dl(E));return}if(!r&&x>p.length-1){p.push(...dl(E));return}p.splice(x+(r?0:1),0,...dl(E))}},b=new Set(o.filter(x=>d.has(x.id)&&ie(x)).map(x=>x.id));for(let x of o){if(n.has(x.id)||!d.has(x.id))continue;let E=gb(t,x);if(E){let w=Ue(o,E).flatMap(v=>ie(v)?[...nr(o,v.id),v]:[v]),y=r?p.findIndex(v=>v.groupIds?.includes(E)):Sr(p,v=>v.groupIds?.includes(E));h(y,u(w));continue}if(!(x.frameId&&b.has(x.frameId))){if(ie(x)){let w=x.id,y=nr(o,w),v=Sr(p,C=>C.frameId===w||C.id===w);h(v,u([...y,x]));continue}if(Tt(x)){let w=ge(x,m),y=Sr(p,v=>v.id===x.id||"containerId"in v&&v.containerId===x.id);w?h(y+(r?-1:0),u([x,w])):h(y,u(x));continue}if(Be(x)){let w=ro(x,m),y=Sr(p,v=>v.id===x.id||v.id===w?.id);w?h(y,u([w,x])):h(y,u(x));continue}h(Sr(p,w=>w.id===x.id),u(x))}}return J1(a,s,c),rb(p,l,s),{newElements:a,elementsWithClones:p}},$p=(e,o=0)=>{if(e==null||typeof e!="object")return e;let t=Object.prototype.toString.call(e);if(t==="[object Object]"){let r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(o===0&&(n==="shape"||n==="canvas"))continue;r[n]=$p(e[n],o+1)}return r}if(Array.isArray(e)){let r=e.length,n=new Array(r);for(;r--;)n[r]=$p(e[r],o+1);return n}return S.DEV&&t!=="[object Object]"&&t!=="[object Array]"&&t.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${t}. This value will not be cloned!`),e},uo=e=>$p(e),O5=(e,o)=>{Object.defineProperty(e,o1,{value:o,writable:!1,enumerable:!1})};var u0={mouse:8,pen:16,touch:28},B5=16,g0={e:!0,s:!0,n:!0,w:!0};var h0={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},jp={e:!0,s:!0,n:!0,w:!0},Pr=(e,o,t,r,n,i,a)=>{let[l,s]=se(M(e+t/2,o+r/2),M(n,i),a);return[l-t/2,s-r/2,t,r]},Mc=e=>!(e.viewport.isMobile||e.isTouchScreen&&(_f||ks)),li=e=>Mc(e)?g0:{},Sl=([e,o,t,r,n,i],a,l,s,c={},m=4,d=Xr)=>{let p=u0[s],u=p/l.value,h=p/l.value,b=p/l.value,x=p/l.value,E=t-e,w=r-o,y=m/l.value,v=(p-d*2)/(2*l.value),C={nw:c.nw?void 0:Pr(e-y-b+v,o-y-x+v,u,h,n,i,a),ne:c.ne?void 0:Pr(t+y-v,o-y-x+v,u,h,n,i,a),sw:c.sw?void 0:Pr(e-y-b+v,r+y-v,u,h,n,i,a),se:c.se?void 0:Pr(t+y-v,r+y-v,u,h,n,i,a),rotation:c.rotation?void 0:Pr(e+E/2-u/2,o-y-x+v-B5/l.value,u,h,n,i,a)},I=5*u0.mouse/l.value;return Math.abs(E)>I&&(c.n||(C.n=Pr(e+E/2-u/2,o-y-x+v,u,h,n,i,a)),c.s||(C.s=Pr(e+E/2-u/2,r+y-v,u,h,n,i,a))),Math.abs(w)>I&&(c.w||(C.w=Pr(e-y-b+v,o+w/2-h/2,u,h,n,i,a)),c.e||(C.e=Pr(t+y-v,o+w/2-h/2,u,h,n,i,a))),C},Lc=(e,o,t,r="mouse",n=g0)=>{if(e.locked||ee(e))return{};if(e.type==="freedraw"||ce(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=jp:a[0]>0&&a[1]<0?n=h0:a[0]>0&&a[1]>0?n=jp:a[0]<0&&a[1]>0?n=h0:a[0]<0&&a[1]<0&&(n=jp)}}else ie(e)&&(n={...n,rotation:!0});let i=ce(e)?Xr+8:he(e)?0:Xr;return Sl(Ye(e,t,!0),e.angle,o,r,n,i,he(e)?0:void 0)},Ac=(e,o)=>{if(o.editingLinearElement)return!1;if(e.length>1)return!0;let t=e[0];return ee(t)?!1:ce(t)?t.points.length>2:!0};var oa=100,si=100,Qp=e=>{switch(e){case T.ARROW_UP:return"up";case T.ARROW_DOWN:return"down";case T.ARROW_RIGHT:return"right";case T.ARROW_LEFT:return"left";default:return"right"}},f0=(e,o,t,r)=>{let n=[...t.values()].reduce((i,a)=>{let l;if(ee(a)&&(l=a[e==="predecessors"?"startBinding":"endBinding"])&&a[e==="predecessors"?"endBinding":"startBinding"]?.elementId===o.id){let s=t.get(l.elementId);if(!s)return i;rn(Zn(s),"not an ExcalidrawBindableElement");let c=e==="predecessors"?a.points[a.points.length-1]:[0,0],m=O1(o,Sb(o),[c[0]+a.x,c[1]+a.y]);i.push({relative:s,heading:m})}return i},[]);switch(r){case"up":return n.filter(i=>ml(i.heading,N1)).map(i=>i.relative);case"down":return n.filter(i=>ml(i.heading,P1)).map(i=>i.relative);case"right":return n.filter(i=>ml(i.heading,D1)).map(i=>i.relative);case"left":return n.filter(i=>ml(i.heading,R1)).map(i=>i.relative)}},qp=(e,o,t)=>f0("successors",e,o,t),Jp=(e,o,t)=>f0("predecessors",e,o,t),z5=(e,o,t)=>{let r=si+e.width;if(t==="up"||t==="down"){let l=oa+e.height,s=e.x,c=e.x+e.width;if(o.every(m=>m.x+m.width<s||m.x>c))return{x:0,y:l*(t==="up"?-1:1)}}else if(t==="right"||t==="left"){let l=e.y,s=e.y+e.height;if(o.every(c=>c.y+c.height<l||c.y>s))return{x:(si+e.width)*(t==="left"?-1:1),y:0}}if(t==="up"||t==="down"){let l=oa+e.height,s=(o.length===0,l),c=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*r:o.length/2*r*-1;return t==="up"?{x:c,y:s*-1}:{x:c,y:s}}let n=oa+e.height,i=(o.length===0,si+e.width),a=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*n:o.length/2*n*-1;return t==="left"?{x:i*-1,y:a}:{x:i,y:a}},F5=(e,o,t,r)=>{let n=qp(e,o,r),i=Jp(e,o,r),a=z5(e,[...n,...i],r),l=Ut({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});rn(Xn(l),"not an ExcalidrawFlowchartNodeElement");let s=b0(e,l,o,r,t);return{nextNode:l,bindingArrow:s}},H5=(e,o,t,r,n)=>{let i=[];for(let a=0;a<n;a++){let l,s;if(r==="left"||r==="right"){let d=oa*(n-1)+n*e.height,p=e.y+e.height/2-d/2,u=si+e.width;r==="left"&&(u*=-1),l=e.x+u;let h=(oa+e.height)*a;s=p+h}else{let d=si*(n-1)+n*e.width,p=e.x+e.width/2-d/2,u=oa+e.height;r==="up"&&(u*=-1),s=e.y+u;let h=(si+e.width)*a;l=p+h}let c=Ut({type:e.type,x:l,y:s,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});rn(Xn(c),"not an ExcalidrawFlowchartNodeElement");let m=b0(e,c,o,r,t);i.push(c),i.push(m)}return i},b0=(e,o,t,r,n)=>{let i,a;switch(r){case"up":{i=e.x+e.width/2,a=e.y-6;break}case"down":{i=e.x+e.width/2,a=e.y+e.height+6;break}case"right":{i=e.x+e.width+6,a=e.y+e.height/2;break}case"left":{i=e.x-6,a=e.y+e.height/2;break}}let s,c;switch(r){case"up":{s=o.x+o.width/2-i,c=o.y+o.height-a+6;break}case"down":{s=o.x+o.width/2-i,c=o.y-a-6;break}case"right":{s=o.x-i-6,c=o.y-a+o.height/2;break}case"left":{s=o.x+o.width-i+6,c=o.y-a+o.height/2;break}}let m=ji({type:"arrow",x:i,y:a,startArrowhead:null,endArrowhead:n.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[M(0,0),M(s,c)],elbowed:!0});Vo(m,e,"start",t),Vo(m,o,"end",t);let d=new Map;d.set(e.id,e),d.set(o.id,o),d.set(m.id,m),j.movePoints(m,[{index:1,point:m.points[1]}]);let p=oc(m,nn(new Map([...t.entries(),[e.id,e],[o.id,o],[m.id,m]])),{points:m.points});return{...m,...p}},_c=class{constructor(){k(this,"isExploring",!1);k(this,"sameLevelNodes",[]);k(this,"sameLevelIndex",0);k(this,"direction",null);k(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(o,t,r){if(!Zn(o))return null;if(r!==this.direction&&this.clear(),this.visitedNodes.has(o.id)||this.visitedNodes.add(o.id),this.isExploring&&r===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let n=[...qp(o,t,r),...Jp(o,t,r)];if(n.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=n,this.direction=r,this.visitedNodes.add(n[0].id),n[0].id;if(r===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(o.id);let a=["up","right","down","left"].filter(l=>l!==r).map(l=>[...qp(o,t,l),...Jp(o,t,l)]).flat().filter(l=>!this.visitedNodes.has(l.id));for(let l of a)if(!this.visitedNodes.has(l.id))return this.visitedNodes.add(l.id),this.isExploring=!0,this.direction=r,l.id}return null}},Dc=class{constructor(){k(this,"isCreatingChart",!1);k(this,"numberOfNodes",0);k(this,"direction","right");k(this,"pendingNodes",null)}createNodes(o,t,r,n){if(n!==this.direction){let{nextNode:i,bindingArrow:a}=F5(o,t,r,n);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=n,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=H5(o,t,r,n,this.numberOfNodes);this.isCreatingChart=!0,this.direction=n,this.pendingNodes=i}if(o.frameId){let i=t.get(o.frameId);rn(i&&T1(i),"not an ExcalidrawFrameElement"),i&&this.pendingNodes.every(a=>nb([a],i,t)||rc(a,i,t))&&(this.pendingNodes=this.pendingNodes.map(a=>B(a,{frameId:o.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},x0=(e,o)=>{for(let[,t]of o)if(t.type==="arrow"&&(t.startBinding?.elementId===e.id||t.endBinding?.elementId===e.id))return!0;return!1};var E0=(e,o,t,r,n,i,a,l,s,c,m,d)=>{if(t.length===1){let[p]=t;if(o==="rotation")ee(p)||(U5(p,r,n,s,c,i),at(p,r));else{if(Z(p)&&o)return G5(e,p,r,o,a,s,c),at(p,r),!0;if(o){let u=t[0].id,h=r.get(u),b=e.get(u);if(h&&b){let{nextWidth:x,nextHeight:E}=K5(h,b,r,e,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});ci(x,E,h,b,r,e,o,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a})}}}return!0}else if(t.length>1){if(o==="rotation")return V5(e,t,r,n,s,c,i,m,d),!0;if(o){let{nextWidth:p,nextHeight:u,flipByX:h,flipByY:b,originalBoundingBox:x}=Z5(t,e,r,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});return tu(t,r,o,n,e,{shouldResizeFromCenter:a,shouldMaintainAspectRatio:l,flipByX:h,flipByY:b,nextWidth:p,nextHeight:u,originalBoundingBox:x}),!0}}return!1},U5=(e,o,t,r,n,i)=>{let[a,l,s,c]=Ye(e,o),m=(a+s)/2,d=(l+c)/2,p;ie(e)?p=0:(p=5*Math.PI/2+Math.atan2(n-d,r-m),i&&(p=p+Ja/2,p=p-p%Ja),p=il(p));let u=Ar(e);if(B(e,{angle:p}),u){let h=t.getElement(u);h&&!Pe(e)&&B(h,{angle:p})}},Pc=(e,o,t,r)=>ce(e)||Ep(e)?{points:hp(0,o,hp(1,t,e.points,r),r)}:{},eu=(e,o,t)=>{let r=e.width;if(Be(e)){let a=ro(e,o);a&&(r=Gi(a,e))}let i=e.fontSize*(t/r);return i<Ls?null:{size:i}},G5=(e,o,t,r,n,i,a)=>{let[l,s,c,m,d,p]=Ye(o,t),[u,h]=se(M(i,a),M(d,p),-o.angle),b=0,x=0;r!=="e"&&r!=="w"&&(r.includes("e")&&(b=(u-l)/(c-l)),r.includes("w")&&(b=(c-u)/(c-l)),r.includes("n")&&(x=(m-h)/(m-s)),r.includes("s")&&(x=(h-s)/(m-s)));let E=Math.max(b,x);if(E>0){let w=o.width*E,y=o.height*E,v=eu(o,t,w);if(v===null)return;let C=[l,s],I=[c,m],_=[d,p],L=M(l,s);if(["n","w","nw"].includes(r)&&(L=M(I[0]-Math.abs(w),I[1]-Math.abs(y))),r==="ne"){let H=[C[0],I[1]];L=M(H[0],H[1]-Math.abs(y))}if(r==="sw"){let H=[I[0],C[1]];L=M(H[0]-Math.abs(w),H[1])}["s","n"].includes(r)&&(L[0]=_[0]-w/2),["e","w"].includes(r)&&(L[1]=_[1]-y/2),n&&(L[0]=_[0]-Math.abs(w)/2,L[1]=_[1]-Math.abs(y)/2);let N=o.angle,P=se(L,M(d,p),N),z=M(L[0]+Math.abs(w)/2,L[1]+Math.abs(y)/2),V=se(z,M(d,p),N);L=se(P,V,-N);let[U,q]=L;B(o,{fontSize:v.size,width:w,height:y,x:U,y:q})}if(r==="e"||r==="w"){let w=e.get(o.id),[y,v,C,I]=Xi(w,w.width,w.height,!0),_=M(y,v),L=M(C,I),N=pp(_,L),P=se(M(i,a),N,-w.angle),[z,,V]=Xi(o,o.width,o.height,!0),U=V-z,q=L[0]-_[0],H=Fi(qe({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight),G=q/U;r.includes("e")&&(G=(P[0]-_[0])/U),r.includes("w")&&(G=(L[0]-P[0])/U);let Y=o.width*G<H?H:o.width*G,re=Hi(o.originalText,qe(o),Math.abs(Y)),$=Ft(re,qe(o),o.lineHeight),le=$.height,[be,Te,ot,$t]=Xi(w,Y,le,!0),zo=ot-be,Qo=$t-Te,jt=[..._];["n","w","nw"].includes(r)&&(jt=[L[0]-Math.abs(zo),_[1]]);let er=w.angle,Yr=se(jt,N,er),qt=M(jt[0]+Math.abs(zo)/2,jt[1]+Math.abs(Qo)/2),Wr=se(qt,N,er);jt=se(Yr,Wr,-er);let mo={width:Math.abs(Y),height:Math.abs($.height),x:jt[0],y:jt[1],text:re,autoResize:!1};B(o,mo)}},V5=(e,o,t,r,n,i,a,l,s)=>{let c=5*Math.PI/2+Math.atan2(i-s,n-l);a&&(c+=Ja/2,c-=c%Ja);for(let m of o)if(!ie(m)){let[d,p,u,h]=Ye(m,t),b=(d+u)/2,x=(p+h)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=se(M(b,x),M(l,s),c+E-m.angle);ee(m)?B(m,{points:tb(m,t)}):B(m,{x:m.x+(w-b),y:m.y+(y-x),angle:il(c+E)},!1),at(m,t,{simultaneouslyUpdated:o});let v=ge(m,t);v&&!Pe(m)&&B(v,{x:v.x+(w-b),y:v.y+(y-x),angle:il(c+E)},!1)}r.triggerUpdate()},y0=(e,o,t,r,n)=>{let[i,a,l,s]=o.length===1?Ye(o[0],t):ye(o),c=(i+l)/2,m=(a+s)/2,d=o.length===1?o[0].angle:0;switch([r,n]=se(M(r,n),M(c,m),-d),e){case"n":return se(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return se(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return se(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return se(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return se(M(r-i,n-a),M(0,0),d);case"ne":return se(M(r-l,n-a),M(0,0),d);case"sw":return se(M(r-i,n-s),M(0,0),d);case"se":return se(M(r-l,n-s),M(0,0),d);default:return[0,0]}},v0=(e,o)=>{let[,[t,r]]=o.points;return e==="nw"&&(t<0||r<0)||e==="ne"&&t>=0||e==="sw"&&t<=0||e==="se"&&(t>0||r>0)?"end":"origin"},Y5=(e,o,t)=>{if(t)return"center";if(o)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},W5=(e,o,t,r,n,i,a,l,s)=>{let c=Y5(a,l,s),[m,d]=e;switch(c){case"top-left":return{x:m+(o-r)/2+(r-o)/2*Math.cos(i)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(r-o)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"top-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(o-r)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"bottom-left":return{x:m+(o-r)/2*(1-Math.cos(i))+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(r-o)/2*Math.sin(i)};case"bottom-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(o-r)/2*Math.sin(i)};case"center":return{x:m-(r-o)/2,y:d-(n-t)/2};case"east-side":return{x:m+(o-r)/2*(Math.cos(i)+1),y:d+(o-r)/2*Math.sin(i)+(t-n)/2};case"west-side":return{x:m+(o-r)/2*(1-Math.cos(i)),y:d+(r-o)/2*Math.sin(i)+(t-n)/2};case"north-side":return{x:m+(o-r)/2+(t-n)/2*Math.sin(i),y:d+(n-t)/2*(Math.cos(i)-1)};case"south-side":return{x:m+(o-r)/2+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)}}},ci=(e,o,t,r,n,i,a,{shouldInformMutation:l=!0,shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let m={},d=ge(t,n);if(d){let b=i.get(d.id);if(b&&(m={fontSize:b.fontSize}),s){let x={...t,width:e,height:o},E=eu(d,n,Gi(x,d));if(E===null)return;m={fontSize:E.size}}else{let x=$s(qe(d),d.lineHeight),E=js(d.fontSize,d.lineHeight);e=Math.max(e,x),o=Math.max(o,E)}}let p=Pc(r,e,o,!0),u=M(r.x,r.y);if(ce(r)){let[b,x]=Db(r,i);u=M(b,x)}let h=W5(u,r.width,r.height,e,o,r.angle,a,s,c);if(ce(r)&&p.points){let b=r.x-u[0],x=r.y-u[1];h.x+=b,h.y+=x;let E=p.points[0][0],w=p.points[0][1];h.x+=E,h.y+=w,p.points=p.points.map(y=>M(y[0]-E,y[1]-w))}if(e<0&&(h.x=h.x+e),o<0&&(h.y=h.y+o),"scale"in t&&"scale"in r&&B(t,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(o)||r.scale[1])*r.scale[1]]}),Pe(t)&&d&&s){let b=e/t.width*d.fontSize;if(b<Ls)return;m.fontSize=b}if(e!==0&&o!==0&&Number.isFinite(h.x)&&Number.isFinite(h.y)){let b={...h,width:Math.abs(e),height:Math.abs(o),...p};B(t,b,l),at(t,n,{newSize:{width:e,height:o}}),d&&m!=null&&B(d,{fontSize:m.fontSize}),ul(t,n,a,s)}},K5=(e,o,t,r,n,i,a,{shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:s=!1}={})=>{let[c,m,d,p]=Xi(o,o.width,o.height,!0),u=M(c,m),h=M(d,p),b=pp(u,h),x=se(M(i,a),b,-o.angle),[E,w,y,v]=Xi(e,e.width,e.height,!0),C=y-E,I=v-w,_=h[0]-u[0],L=h[1]-u[1],N=_/C,P=L/I;n.includes("e")&&(N=(x[0]-u[0])/C),n.includes("s")&&(P=(x[1]-u[1])/I),n.includes("w")&&(N=(h[0]-x[0])/C),n.includes("n")&&(P=(h[1]-x[1])/I);let z=e.width*N,V=e.height*P;if(s&&(z=2*z-o.width,V=2*V-o.height),l){let U=Math.abs(z)/o.width,q=Math.abs(V)/o.height;if(n.length===1&&(V*=U,z*=q),n.length===2){let H=Math.max(U,q);z=o.width*H*Math.sign(z),V=o.height*H*Math.sign(V)}}return{nextWidth:z,nextHeight:V}},Z5=(e,o,t,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(U=>o.get(U.id)),c=s.reduce((U,q)=>{if(!ce(q))return U;let H=Ar(q);if(!H)return U;let G=o.get(H)??null;return Be(G)?[...U,{...G,...j.getBoundTextElementPosition(q,G,t)}]:U},[]),m=_t(s.map(U=>U).concat(c)),{minX:d,minY:p,maxX:u,maxY:h,midX:b,midY:x}=m,E=u-d,w=h-p,y={ne:[d,h],se:[d,p],sw:[u,p],nw:[u,h],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,h],s:[d+E/2,p]},[v,C]=l?[b,x]:y[r],I=l?2:1,_=Math.max(Math.abs(n-v)/E||0,Math.abs(i-C)/w||0)*I,L=r.includes("e")||r.includes("w")?Math.abs(n-v)*I:E,N=r.includes("n")||r.includes("s")?Math.abs(i-C)*I:w;a&&(L=E*_*Math.sign(n-v),N=w*_*Math.sign(i-C));let P={ne:[n<v,i>C],se:[n<v,i<C],sw:[n>v,i<C],nw:[n>v,i>C],e:[n<v,!1],w:[n>v,!1],n:[!1,i>C],s:[!1,i<C]},[z,V]=P[r].map(U=>U);return{originalBoundingBox:m,nextWidth:L,nextHeight:N,flipByX:z,flipByY:V}},tu=(e,o,t,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1,flipByX:l=!1,flipByY:s=!1,nextHeight:c,nextWidth:m,originalBoundingBox:d}={})=>{if(m===void 0&&c===void 0&&l===void 0&&s===void 0||c===0||m===0)return;n||(n=o);let p=e.reduce((I,_)=>{let L=n.get(_.id);return L&&I.push({orig:L,latest:_}),I},[]),u;if(d)u=d;else{let I=p.reduce((_,{orig:L})=>{if(!ce(L))return _;let N=Ar(L);if(!N)return _;let P=n.get(N)??null;return Be(P)?[..._,{...P,...j.getBoundTextElementPosition(L,P,o)}]:_},[]);u=_t(p.map(({orig:_})=>_).concat(I))}let{minX:h,minY:b,maxX:x,maxY:E,midX:w,midY:y}=u,v=x-h,C=E-b;if(m===void 0&&c===void 0&&(m=v,c=C),i&&(m===void 0?m=c*(v/C):c===void 0?c=m*(C/v):Math.abs(m/c-v/C)>.001&&(m=c*(v/C))),m&&c){let I=t.includes("e")||t.includes("w")?Math.abs(m)/v:1,_=t.includes("n")||t.includes("s")?Math.abs(c)/C:1,L;t.length===1?L=t.includes("e")||t.includes("w")?I:_:L=Math.max(Math.abs(m)/v||0,Math.abs(c)/C||0);let N={ne:[h,E],se:[h,b],sw:[x,b],nw:[x,E],e:[h,b+C/2],w:[x,b+C/2],n:[h+v/2,E],s:[h+v/2,b]},[P,z]=a?[w,y]:N[t],V=i||p.some(Y=>Y.latest.angle!==0||Z(Y.latest)||ar(Y.latest));V&&(I=L,_=L);let[U,q]=[l?-1:1,s?-1:1],H=[];for(let{orig:Y,latest:re}of p){if(Z(Y)&&Be(Y))continue;let $=Y.width*I,le=Y.height*_,be=il(Y.angle*U*q),Te=ce(Y)||Ep(Y),ot=Y.x-P,$t=Y.y-z,zo=l&&!Te?$:0,Qo=s&&!Te?le:0,jt=P+U*(ot*I+zo),er=z+q*($t*_+Qo),Yr=Pc(Y,$*U,le*q,!1),qt={x:jt,y:er,width:$,height:le,angle:be,...Yr};if(ee(Y)&&(Y.startBinding&&(qt.startBinding={...Y.startBinding,fixedPoint:[l?-Y.startBinding.fixedPoint[0]+1:Y.startBinding.fixedPoint[0],s?-Y.startBinding.fixedPoint[1]+1:Y.startBinding.fixedPoint[1]]}),Y.endBinding&&(qt.endBinding={...Y.endBinding,fixedPoint:[l?-Y.endBinding.fixedPoint[0]+1:Y.endBinding.fixedPoint[0],s?-Y.endBinding.fixedPoint[1]+1:Y.endBinding.fixedPoint[1]]}),Y.fixedSegments&&Yr.points&&(qt.fixedSegments=Y.fixedSegments.map(mo=>({...mo,start:Yr.points[mo.index-1],end:Yr.points[mo.index]})))),he(Y)&&(qt.scale=[Y.scale[0]*U,Y.scale[1]*q]),Z(Y)){let mo=eu(Y,o,$);if(!mo)return;qt.fontSize=mo.size}let Wr=n.get(Ar(Y)??"");if(Wr)if(V){let mo=Wr.fontSize*L;if(mo<Ls)return;qt.boundTextFontSize=mo}else qt.boundTextFontSize=Wr.fontSize;H.push({element:re,update:qt})}let G=H.map(({element:Y})=>Y);for(let{element:Y,update:{boundTextFontSize:re,...$}}of H){let{width:le,height:be,angle:Te}=$;B(Y,$,!1,{isDragging:!0}),at(Y,o,{simultaneouslyUpdated:G,newSize:{width:le,height:be}});let ot=ge(Y,o);ot&&re&&(B(ot,{fontSize:re,angle:ce(Y)?void 0:Te},!1),ul(Y,o,t,!0))}r.triggerUpdate()}};var ru=(e,o,t)=>o>=e[0]&&o<=e[0]+e[2]&&t>=e[1]&&t<=e[1]+e[3],X5=(e,o,t,r,n,i,a,l)=>{if(!t.selectedElementIds[e.id])return!1;let{rotation:s,...c}=Lc(e,i,o,a,li(l));if(s&&ru(s,r,n))return"rotation";let m=Object.keys(c).filter(d=>{let p=c[d];return p?ru(p,r,n):!1});if(m.length>0)return m[0];if(Mc(l)){let[d,p,u,h,b,x]=Ye(e,o);if(!(ce(e)&&e.points.length<=2)){let E=he(e)?0:_s/i.value,w=_s/i.value,y=w0(M(d-E,p-E),M(u+E,h+E),M(b,x),e.angle);for(let[v,C]of Object.entries(y))if(up(M(r,n),C,w))return v}}return!1},nu=(e,o,t,r,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let m=X5(c,a,o,t,r,n,i,l);return m?{element:c,transformHandleType:m}:null},null),iu=([e,o,t,r],n,i,a,l,s)=>{let c=Sl([e,o,t,r,(e+t)/2,(o+r)/2],0,a,l,li(s)),m=Object.keys(c).find(d=>{let p=c[d];return p&&ru(p,n,i)});if(m)return m;if(Mc(s)){let d=(e+t)/2,p=(o+r)/2,u=_s/a.value,h=w0(M(e-u,o-u),M(t+u,r+u),M(d,p),0);for(let[b,x]of Object.entries(h))if(up(M(n,i),x,u))return b}return!1},ou=["ns","nesw","ew","nwse"],$5=(e,o)=>{let t=ou.indexOf(e);if(t>=0){let r=Math.round(o/(Math.PI/4));e=ou[(t+r)%ou.length]}return e},au=e=>{let{element:o,transformHandleType:t}=e,r=o&&Math.sign(o.height)*Math.sign(o.width)===-1,n=null;switch(t){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":r?n="nesw":n="nwse";break;case"ne":case"sw":r?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&o&&(n=$5(n,o.angle)),n?`${n}-resize`:""},w0=([e,o],[t,r],n,i)=>{let a=se(M(e,o),n,i),l=se(M(t,o),n,i),s=se(M(e,r),n,i),c=se(M(t,r),n,i);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}};var C0=(e,o,t,r,n,i)=>{if(o.length===1&&ee(o[0])&&(o[0].startBinding||o[0].endBinding))return;let a=o.filter(d=>{if(ee(d)&&d.startBinding&&d.endBinding){let p=o.find(h=>h.id===d.startBinding?.elementId),u=o.find(h=>h.id===d.endBinding?.elementId);return p&&u}return!0}),l=new Set(a),s=a.filter(d=>ie(d)).map(d=>d.id);if(s.length>0)for(let d of r.getNonDeletedElements())d.frameId!==null&&s.includes(d.frameId)&&l.add(d);let c=[];for(let d of l){let p=e.originalElements.get(d.id);if(!p)return;c.push(p)}let m=j5(ye(c),t,n,i);l.forEach(d=>{if(T0(e,d,m),!Pe(d)){let p=ge(d,r.getNonDeletedElementsMap());p&&T0(e,p,m),at(d,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})}})},j5=(e,o,t,r)=>{let[n,i]=e,a=n+o.x+t.x,l=i+o.y+t.y;if(t.x===0||t.y===0){let[s,c]=pt(n+o.x,i+o.y,r);t.x===0&&(a=s),t.y===0&&(l=c)}return{x:a-n,y:l-i}},T0=(e,o,t)=>{let r=e.originalElements.get(o.id)??o,n=r.x+t.x,i=r.y+t.y;B(o,{x:n,y:i})},I0=(e,o,t)=>{let[r,n]=ye(e);return[o-r,t-n]},lu=({newElement:e,elementType:o,originX:t,originY:r,x:n,y:i,width:a,height:l,shouldMaintainAspectRatio:s,shouldResizeFromCenter:c,zoom:m,widthAspectRatio:d=null,originOffset:p=null,informMutation:u=!0})=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-r)>Math.abs(n-t)?{width:a,height:l}=Tp(o,l,n<t?-a:a):{width:a,height:l}=Tp(o,a,i<r?-l:l),l<0&&(l=-l)));let h=n<t?t-a:t,b=i<r?r-l:r;c&&(a+=a,l+=l,h=t-a/2,b=r-l/2);let x=null;if(Z(e)){l=e.height;let E=Fi(qe({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,E),Math.abs(n-t)>Rf/m&&(x={autoResize:!1}),b=r,c&&(h=t-a/2)}if(a!==0&&l!==0){let E=null;he(e)&&(E={initialWidth:a,initialHeight:l}),B(e,{x:h+(p?.x??0),y:b+(p?.y??0),width:a,height:l,...x,...E},u)}};import{atom as Le,createStore as q5}from"jotai";import{createIsolation as J5}from"jotai-scope";var S0=J5();var{useAtom:ve,useSetAtom:mn,useAtomValue:Rc,useStore:hA}=S0,k0=S0.Provider,St=q5();var Q5=vf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-B4ZKOASM.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var eT=85,dr={code:"en",label:"English"},na=[dr,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>Vb[e.code]>=eT).sort((e,o)=>e.label>o.label?1:-1)],Oc="__test__";Fe()&&na.unshift({code:Oc,label:"test language"},{code:`${Oc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ra=dr,Nc={},Bc=async e=>{if(ra=e,document.documentElement.dir=ra.rtl?"rtl":"ltr",document.documentElement.lang=ra.code,e.code.startsWith(Oc))Nc={};else try{Nc=await Q5(`./locales/${ra.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Nc=Hp}St.set(L0,e.code)},Rr=()=>ra,M0=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},f=(e,o,t)=>{if(ra.code.startsWith(Oc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=M0(Nc,r)||M0(Hp,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},L0=Le(dr.code),mt=()=>{let e=Rc(L0);return{t:f,langCode:e}};var rt=class e{constructor(o,t){this.deleted=o;this.inserted=t}static create(o,t,r,n){let i=r&&n!=="inserted"?r(o):o,a=r&&n!=="deleted"?r(t):t;return new e(i,a)}static calculate(o,t,r,n){if(o===t)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",o,t))i[c]=o[c],a[c]=t[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,r)}static empty(){return new e({},{})}static isEmpty(o){return!Object.keys(o.deleted).length&&!Object.keys(o.inserted).length}static mergeObjects(o,t,r){let n={...o};for(let i of Object.keys(r))delete n[i];return{...n,...t}}static mergeArrays(o,t,r,n){return Object.values(e.mergeObjects(rr(o??[],n),rr(t??[],n),rr(r??[],n)))}static diffObjects(o,t,r,n){if(!(!o[r]&&!t[r])&&(typeof o[r]=="object"||typeof t[r]=="object")){let i=o[r]??{},a=t[r]??{},l=e.getLeftDifferences(i,a).reduce((c,m)=>(c[m]=n(i[m]),c),{}),s=e.getRightDifferences(i,a).reduce((c,m)=>(c[m]=n(a[m]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(o,r,l),Reflect.set(t,r,s)):(Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r))}}static diffArrays(o,t,r,n){if(!(!o[r]&&!t[r])&&(Array.isArray(o[r])||Array.isArray(t[r]))){let i=Array.isArray(o[r])?o[r]:[],a=Array.isArray(t[r])?t[r]:[],l=rr(e.getLeftDifferences(rr(i,n),rr(a,n))),s=rr(e.getRightDifferences(rr(i,n),rr(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(d=>l[n?n(d):String(d)]),m=a.filter(d=>s[n?n(d):String(d)]);Reflect.set(o,r,c),Reflect.set(t,r,m)}else Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r)}}static isLeftDifferent(o,t,r=!1){return!!this.distinctKeysIterator("left",o,t,r).next().value}static isRightDifferent(o,t,r=!1){return!!this.distinctKeysIterator("right",o,t,r).next().value}static getLeftDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("left",o,t,r))}static getRightDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("right",o,t,r))}static*distinctKeysIterator(o,t,r,n=!1){if(t===r)return;let i=[];o==="left"?i=Object.keys(t):o==="right"?i=Object.keys(r):o==="full"?i=Array.from(new Set([...Object.keys(t),...Object.keys(r)])):Yn(o,`Unknown distinctKeysIterator's join param "${o}"`,!0);for(let a of i){let l=t[a],s=r[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&Je(l,s))continue;yield a}}}},kl=class e{constructor(o){this.delta=o}static calculate(o,t){let r=rt.calculate(o,t,void 0,e.postProcess);return new e(r)}static empty(){return new e(rt.create({},{}))}inverse(){let o=rt.create(this.delta.inserted,this.delta.deleted);return new e(o)}applyTo(o,t){try{let{selectedElementIds:r={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,m=rt.mergeObjects(o.selectedElementIds,i,r),d=rt.mergeObjects(o.selectedGroupIds,a,n),p=l&&t.has(l)?new j(t.get(l)):null,u=s&&t.has(s)?new j(t.get(s)):null,h={...o,...c,selectedElementIds:m,selectedGroupIds:d,selectedLinearElement:typeof l<"u"?p:o.selectedLinearElement,editingLinearElement:typeof s<"u"?u:o.editingLinearElement},b=this.filterInvisibleChanges(o,h,t);return[h,b]}catch(r){if(console.error("Couldn't apply appstate change",r),dt()||Fe())throw r;return[o,!1]}}isEmpty(){return rt.isEmpty(this.delta)}static postProcess(o,t){try{rt.diffObjects(o,t,"selectedElementIds",r=>!0),rt.diffObjects(o,t,"selectedGroupIds",r=>r??!1)}catch(r){if(console.error("Couldn't postprocess appstate change deltas."),dt()||Fe())throw r}finally{return[o,t]}}filterInvisibleChanges(o,t,r){let n=Ll(o),i=Ll(t),a=rt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=rt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=rt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),m=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(m=vb(r));for(let d of c)switch(d){case"selectedElementIds":t[d]=e.filterSelectedElements(t[d],r,s);break;case"selectedGroupIds":t[d]=e.filterSelectedGroups(t[d],m,s);break;case"croppingElementId":{let b=t[d],x=b&&r.get(b);x&&!x.isDeleted?s.value=!0:t[d]=null;break}case"editingGroupId":let p=t[d];p?m.has(p)?s.value=!0:t[d]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(d),h=t[u];if(!h)s.value=!0;else{let b=r.get(h.elementId);b&&!b.isDeleted?s.value=!0:t[u]=null}break;default:Yn(d,`Unknown ObservedElementsAppState's key "${d}"`,!0)}}return s.value}static convertToAppStateKey(o){switch(o){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(o,t,r){let n=Object.keys(o);if(!n.length)return r.value=!0,o;let i={...o};for(let a of n){let l=t.get(a);l&&!l.isDeleted?r.value=!0:delete i[a]}return i}static filterSelectedGroups(o,t,r){if(!Object.keys(o).length)return r.value=!0,o;let i={...o};for(let a of Object.keys(i))t.has(a)?r.value=!0:delete i[a];return i}static stripElementsProps(o){let{editingGroupId:t,selectedGroupIds:r,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,croppingElementId:l,...s}=o;return s}static stripStandaloneProps(o){let{name:t,viewBackgroundColor:r,...n}=o;return n}},Ae=class Ae{constructor(o,t,r){this.added=o;this.removed=t;this.updated=r}static create(o,t,r,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,l=new Map,s=new Map,c=[...o,...t,...r];for(let[m,d]of c)this.satisfiesAddition(d)?a.set(m,d):this.satisfiesRemoval(d)?l.set(m,d):s.set(m,d);i=new Ae(a,l,s)}else i=new Ae(o,t,r);return(dt()||Fe())&&(Ae.validate(i,"added",this.satisfiesAddition),Ae.validate(i,"removed",this.satisfiesRemoval),Ae.validate(i,"updated",this.satisfiesUpdate)),i}static validate(o,t,r){for(let[n,i]of o[t].entries())if(!r(i))throw console.error(`Broken invariant for "${t}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(o,t){if(o===t)return Ae.empty();let r=new Map,n=new Map,i=new Map;for(let a of o.values())if(!t.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},m=rt.create(s,c,Ae.stripIrrelevantProps);n.set(a.id,m)}for(let a of t.values()){let l=o.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},m=rt.create(s,c,Ae.stripIrrelevantProps);r.set(a.id,m);continue}if(l.versionNonce!==a.versionNonce){let s=rt.calculate(l,a,Ae.stripIrrelevantProps,Ae.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?r.set(a.id,s):n.set(a.id,s);continue}rt.isEmpty(s)||i.set(a.id,s)}}return Ae.create(r,n,i)}static empty(){return Ae.create(new Map,new Map,new Map)}inverse(){let o=i=>{let a=new Map;for(let[l,s]of i.entries())a.set(l,rt.create(s.inserted,s.deleted));return a},t=o(this.added),r=o(this.removed),n=o(this.updated);return Ae.create(r,t,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(o){let t=l=>s=>{let c={};for(let m of Object.keys(s))switch(m){case"boundElements":c[m]=s[m];break;default:c[m]=l[m]}return c},r=l=>{let s=new Map;for(let[c,m]of l.entries()){let d=o.get(c);if(d){let p=rt.create(m.deleted,m.inserted,t(d),"inserted");s.set(c,p)}else s.set(c,m)}return s},n=r(this.added),i=r(this.removed),a=r(this.updated);return Ae.create(n,i,a,{shouldRedistribute:!0})}applyTo(o,t){let r=nn(new Map(o)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=Ae.createApplier(r,t,i),l=a(this.added),s=a(this.removed),c=a(this.updated),m=this.resolveConflicts(o,r);n=new Map([...l,...s,...c,...m])}catch(a){if(console.error("Couldn't apply elements change",a),dt()||Fe())throw a;return[o,!0]}try{Ae.redrawTextBoundingBoxes(r,n),r=Ae.reorderElements(r,n,i),Ae.redrawBoundArrows(r,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),dt()||Fe())throw a}finally{return[r,i.containsVisibleDifference]}}static applyDelta(o,t,r={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=t.inserted;if(t.deleted.boundElements?.length||t.inserted.boundElements?.length){let a=rt.mergeArrays(o.boundElements,t.inserted.boundElements,t.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(he(o)){let a=t;(a.deleted.crop||a.inserted.crop)&&Object.assign(i,{crop:a.inserted.crop??null})}if(!r.containsVisibleDifference){let{index:a,...l}=i,s=Ae.checkForVisibleDifference(o,l);r.containsVisibleDifference=s}return r.containsZindexDifference||(r.containsZindexDifference=t.deleted.index!==t.inserted.index),oe(o,i)}static checkForVisibleDifference(o,t){return o.isDeleted&&t.isDeleted!==!1?!1:o.isDeleted&&t.isDeleted===!1||o.isDeleted===!1&&t.isDeleted?!0:rt.isRightDifferent(o,t)}resolveConflicts(o,t){let r=new Map,n=(c,m)=>{let d=t.get(c.id);if(!d)return;let p;o.get(c.id)===d?p=oe(d,m):p=B(d,m),r.set(p.id,p),t.set(p.id,p)};for(let[c]of this.removed)Ae.unbindAffected(o,t,c,n);for(let[c]of this.added)Ae.rebindAffected(o,t,c,n);for(let[c]of Array.from(this.updated).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>eb.has(p)))){let m=t.get(c);!m||m.isDeleted||Ae.rebindAffected(o,t,c,n)}let i=new Map(Array.from(o).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=Ae.calculate(i,r);for(let[c,m]of a)this.added.set(c,m);for(let[c,m]of l)this.removed.set(c,m);for(let[c,m]of s)this.updated.set(c,m);return r}static unbindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);gl.unbindAffected(t,i(),n),gl.unbindAffected(t,a(),n),fl.unbindAffected(t,i(),n),fl.unbindAffected(t,a(),n)}static rebindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);gl.unbindAffected(t,i(),n),gl.rebindAffected(t,a(),n),fl.unbindAffected(t,i(),(l,s)=>{Z(l)&&n(l,s)}),fl.rebindAffected(t,a(),n)}static redrawTextBoundingBoxes(o,t){let r=new Map;for(let n of t.values()){if(Be(n)){let{containerId:i}=n,a=i?o.get(i):void 0;a&&r.set(a.id,{container:a,boundText:n})}if(Tt(n)){let i=Ar(n),a=i?o.get(i):void 0;a&&r.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of r.values())n.isDeleted||i.isDeleted||Qe(i,n,o,!1)}static redrawBoundArrows(o,t){for(let r of t.values())!r.isDeleted&&Zn(r)&&at(r,o,{changedElements:t})}static reorderElements(o,t,r){if(!r.containsZindexDifference)return o;let n=Array.from(o.values()),i=mc([...n]),a=rt.getRightDifferences(n,i,!0).reduce((l,s)=>{let c=n[Number(s)];return c&&t.has(c.id)&&l.set(c.id,c),l},new Map);return!r.containsVisibleDifference&&a.size&&(r.containsVisibleDifference=!0),ne(Ht(i,a))}static postProcess(o,t){try{rt.diffArrays(o,t,"boundElements",r=>r.id)}catch(r){if(console.error("Couldn't postprocess elements change deltas."),dt()||Fe())throw r}finally{return[o,t]}}static stripIrrelevantProps(o){let{id:t,updated:r,version:n,versionNonce:i,seed:a,...l}=o;return l}};k(Ae,"satisfiesAddition",({deleted:o,inserted:t})=>o.isDeleted===!0&&!t.isDeleted),k(Ae,"satisfiesRemoval",({deleted:o,inserted:t})=>!o.isDeleted&&t.isDeleted===!0),k(Ae,"satisfiesUpdate",({deleted:o,inserted:t})=>!!o.isDeleted==!!t.isDeleted),k(Ae,"createApplier",(o,t,r)=>{let n=Ae.createGetter(o,t,r);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let m=Ae.applyDelta(c,s,r);o.set(m.id,m),a.set(m.id,m)}return a},new Map)}),k(Ae,"createGetter",(o,t,r)=>(n,i)=>{let a=o.get(n);return a||(a=t.get(n),a&&(r.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(r.containsVisibleDifference=!0))),a});var Ml=Ae;var Dt=class{constructor(){k(this,"subscribers",[])}on(...o){let t=o.flat().filter(r=>typeof r=="function");return this.subscribers.push(...t),()=>this.off(t)}once(...o){let t=o.flat().filter(n=>typeof n=="function");t.push(()=>r());let r=this.on(...t);return r}off(...o){let t=o.flat();this.subscribers=this.subscribers.filter(r=>!t.includes(r))}trigger(...o){for(let t of this.subscribers)t(...o);return this}clear(){this.subscribers=[]}};var A0="__observedAppState",Ll=e=>{let o={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null,croppingElementId:e.croppingElementId};return Reflect.defineProperty(o,A0,{value:!0,enumerable:!1}),o},tT=e=>!!Reflect.get(e,A0),A={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},su=class{constructor(o,t){this.elementsChange=o;this.appStateChange=t}},zc=class{constructor(){k(this,"onStoreIncrementEmitter",new Dt);k(this,"scheduledActions",new Set);k(this,"_snapshot",Fc.empty());k(this,"shouldCaptureIncrement",()=>{this.scheduleAction(A.IMMEDIATELY)});k(this,"shouldUpdateSnapshot",()=>{this.scheduleAction(A.NEVER)});k(this,"scheduleAction",o=>{this.scheduledActions.add(o),this.satisfiesScheduledActionsInvariant()});k(this,"commit",(o,t)=>{try{this.scheduledActions.has(A.IMMEDIATELY)?this.captureIncrement(o,t):this.scheduledActions.has(A.NEVER)&&this.updateSnapshot(o,t)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}});k(this,"captureIncrement",(o,t)=>{let r=this.snapshot,n=this.snapshot.maybeClone(o,t);if(r!==n){let i=n.meta.didElementsChange?Ml.calculate(r.elements,n.elements):Ml.empty(),a=n.meta.didAppStateChange?kl.calculate(r.appState,n.appState):kl.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new su(i,a)),this.snapshot=n}});k(this,"updateSnapshot",(o,t)=>{let r=this.snapshot.maybeClone(o,t);this.snapshot!==r&&(this.snapshot=r)});k(this,"filterUncomittedElements",(o,t)=>{for(let[r,n]of o.entries()){if(!t.get(r))continue;let a=this.snapshot.elements.get(r);a?a.version<n.version&&t.set(r,a):t.delete(r)}return t});k(this,"clear",()=>{this.snapshot=Fc.empty(),this.scheduledActions=new Set});k(this,"satisfiesScheduledActionsInvariant",()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let o=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(o,this.scheduledActions.values()),dt()||Fe())throw new Error(o)}})}get snapshot(){return this._snapshot}set snapshot(o){this._snapshot=o}},Fc=class e{constructor(o,t,r={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=o;this.appState=t;this.meta=r}static empty(){return new e(new Map,Ll(cr()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(o,t){let r=this.maybeCreateElementsSnapshot(o),n=this.maybeCreateAppStateSnapshot(t),i=!1,a=!1;return this.elements!==r&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(r,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(o){if(!o)return this.appState;let t=tT(o)?o:Ll(o);return this.detectChangedAppState(t)?t:this.appState}detectChangedAppState(o){return!Je(this.appState,o,{selectedElementIds:Je,selectedGroupIds:Je})}maybeCreateElementsSnapshot(o){return o?this.detectChangedElements(o)?this.createElementsSnapshot(o):this.elements:this.elements}detectChangedElements(o){if(this.elements===o)return!1;if(this.elements.size!==o.size)return!0;let t=Array.from(o.keys());for(let r=t.length-1;r>=0;r--){let n=this.elements.get(t[r]),i=o.get(t[r]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(o){let t=new Map;for(let[r,n]of this.elements.entries())o.get(r)?t.set(r,n):t.set(r,oe(n,{isDeleted:!0}));for(let[r,n]of o.entries()){let i=t.get(r);(!i||i&&i.versionNonce!==n.versionNonce)&&t.set(r,uo(n))}return t}};import oT from"clsx";import rT from"open-color";import kt from"react";import{Fragment as Re,jsx as g,jsxs as O}from"react/jsx-runtime";var Ko=e=>"var(--icon-fill-color)",_0=e=>e===de.LIGHT?rT.white:"#1e1e1e",D=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:oT({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},K={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},e_=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("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"})]}),K),ia=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),K),D0=D(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),K),P0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),K),R0=D(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),K),di=D(O("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),aa=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),N0=D(O(Re,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),O0=D(O(Re,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),B0=D(O(Re,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),t_=D(g("g",{fill:"currentColor",children:g("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),z0=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),F0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),K),H0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),K),U0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),K),G0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),K),V0=D(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),Y0=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),K),pn=D(O("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Hc=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),K),W0=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),K0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),K),cu=D(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),du=D(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),Z0=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),K),ho=D(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),X0=D(O("g",{strokeWidth:"1.25",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),me),Al=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),_l=D(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Dl=D(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),Uc=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),K),mi=D(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),la=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),K),$0=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),K),mu=D(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),Gc=D(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),j0=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),q0=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),K),J0=D(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Pl=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),Q0=D("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}),ex=D("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}),sa=D(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),o_=D("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}),tx=D("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"),Vc=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),K),Yc=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),K),ox=D("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}),r_=D("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}),n_=D("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}),rx=D("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"),i_=D("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"),pu=D(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),uu=D(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),nx=D("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}),ix=D(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),a_=D("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"),l_=D("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}),s_=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),K),c_=D(O(Re,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),d_=D(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),ax=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),lx=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),hu=D(lx,K),gu=D(lx,{...K,style:{transform:"rotate(180deg)"}}),fu=D(ax,K),bu=D(ax,{...K,style:{transform:"rotate(180deg)"}}),xu=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Eu=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),yu=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),vu=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),sx=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),cx=D(O(Re,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),wu=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Tu=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Wc=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),K),m_=D("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"),p_=D("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"),ko=D(O(Re,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),u_=D("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}),h_=D("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}),g_=D("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}),Cu=kt.memo(({theme:e})=>D(O(Re,{children:[g("path",{d:"M25 26H111V111H25",fill:Ko(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Ko(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Ko(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Ko(e),strokeWidth:"2"}),O("g",{fill:_0(e),stroke:Ko(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Iu=kt.memo(({theme:e})=>D(O(Re,{children:[g("path",{d:"M25 26H111V111H25",fill:Ko(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Ko(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Ko(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Ko(e),strokeWidth:"2"}),O("g",{fill:_0(e),stroke:Ko(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),dx=D(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),mx=D(O(Re,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),px=D(O(Re,{children:[O("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),ux=D(O(Re,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Su=D(g(Re,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),hx=D(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),gx=D(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),f_=kt.memo(({theme:e})=>D(g("path",{d:"M6 10H34",stroke:Ko(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),fx=D(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),K),bx=D(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),K),xx=D(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),Ex=D(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),yx=D(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),vx=D(O("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),me),wx=D(O("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),K),Tx=D(O("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),K),Cx=kt.memo(({flip:e=!1})=>D(O("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Ix=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Sx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),kx=kt.memo(({flip:e=!1})=>D(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Mx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Lx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Ax=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),_x=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Dx=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Px=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Rx=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Nx=D(O(Re,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ox=D(O(Re,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Bx=D(O(Re,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),zx=D(g(Re,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),pi=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),K),Fx=D(g(Re,{children:O("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),K),Rl=D(g(Re,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),Kc=D(O(Re,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Hx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),K),Ux=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),K),Gx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),K),Vx=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),K)),Yx=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),K)),Wx=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),K)),Zc=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),K),Kx=D(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),b_=D(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Xc=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),K),ku=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),K),ca=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),K),Zx=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),K),Xx=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),K),x_=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),K),E_=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),K),$x=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),K),jx=D(O(Re,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),K),qx=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),K),Jx=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),K),$c=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),K),jc=D(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),da=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),qc=D(O("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Jc=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),K),y_=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),K),v_=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),K),Qx=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),K),ma=D(O("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),K),eE=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),K),tE=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),K),oE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),K),go=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),K),rE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),K),nE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),K),iE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),K),Qc=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),K),aE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),K),lE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),K),sE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),K),cE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),K),Mu=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),K),ed=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),K),dE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),K),mE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),K),pE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),K),uE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),K),hE=D(O("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...K,strokeWidth:1.5}),w_=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),K),gE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),K),fE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),K),bE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),K),xE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),K),EE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),K),yE=D(O("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),K),td=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),K),vE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),K),wE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),K),Lu=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),K),od=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),K);import TE from"clsx";import _u,{useEffect as aT,useRef as CE,useState as lT}from"react";import nT from"react";import{jsx as Au}from"react/jsx-runtime";var iT=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(nT.useRef(Date.now()).current%1600);return Au("div",{className:`Spinner ${r}`,children:Au("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Au("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Mt=iT;import{jsx as Nl,jsxs as Ol}from"react/jsx-runtime";var Q=_u.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=ht(),a=_u.useRef(null);_u.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=lT(!1),m=CE(!0),d=async u=>{let h="onClick"in r&&r.onClick?.(u);if(tn(h))try{c(!0),await h}catch(b){if(b instanceof Ji)console.warn(b);else throw b}finally{m.current&&c(!1)}};aT(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=CE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Ol("button",{className:TE("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Ol("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Nl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Nl(Mt,{})]}),r.showAriaLabel&&Ol("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Nl(Mt,{})]}),r.children]})}return Ol("label",{className:TE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Nl("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Ol("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Nl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});Q.displayName="ToolButton";var rd=[],F=e=>(rd=rd.concat(e),e);import{jsx as cT}from"react/jsx-runtime";var sT=(e,o,t)=>{let r=new Set(J(e.filter(m=>ie(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=nr(e,m);for(let p of d)if(!a.has(p.id)){if(Be(p)){let u=ro(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let d=Be(m)?ro(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):d?.frameId&&r.has(d?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&ee(u)&&(B(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding}),B(u,{points:u.points}))}),oe(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,Be(m)||(n[m.id]=!0),oe(m,{frameId:null})):Be(m)&&o.selectedElementIds[m.containerId]?oe(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Ue(s,o.editingGroupId).filter(d=>!d.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let d=m[0];if(d){let p=d.groupIds.findIndex(h=>h===o.editingGroupId),u=d.groupIds[p+1];if(u){let h=Ue(s,u).filter(b=>!b.isDeleted);h.length>1&&(c=u,h.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...ut({selectedElementIds:n,editingGroupId:c},s,o,null)}}},IE=(e,o)=>{if(e.editingGroupId){let t=Ue(Ee(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Bl=F({name:"deleteSelectedElements",label:"labels.delete",icon:ho,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=j.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?oe(b,{isDeleted:!0}):b),h=IE(o,u);return{elements:u,appState:{...h,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return j.deletePoints(d,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:A.IMMEDIATELY}}let{elements:n,appState:i}=sT(e,o,r);return tc(n,n.filter(a=>a.isDeleted)),i=IE(i,n),{elements:n,appState:{...i,activeTool:Ge(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ze(Ee(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>cT(Q,{type:"button",icon:ho,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),visible:ze(Ee(e),o)})});var Du=(e,o)=>e.frameId===o||e.id===o,kE=(e,o,t)=>{let r=[],n=[],i=null,a=-1,l=ne(t||J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(r=r.concat(n),n=[]),r.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return r},dT=e=>{let o=0;return e.reduce((t,r,n)=>(n>0&&e[n-1]!==r-1&&(o=++o),(t[o]||(t[o]=[])).push(r),t),[])},SE=(e,o,t,r)=>{if("containerId"in e&&e.containerId){let n=r.getElement(e.containerId);if(n)return t==="left"?Math.min(o.indexOf(n),o.indexOf(e)):Math.max(o.indexOf(n),o.indexOf(e))}else{let n=e.boundElements?.find(i=>i.type!=="arrow")?.id;if(n){let i=r.getElement(n);if(i)return t==="left"?Math.min(o.indexOf(i),o.indexOf(e)):Math.max(o.indexOf(i),o.indexOf(e))}}},mT=(e,o)=>{let t=-1,r=-1;return e.forEach((n,i)=>{Du(n,o)&&(t===-1&&(t=i),r=i)}),t===-1?[]:e.slice(t,r+1)},pT=(e,o,t,r,n,i)=>{let a=o[t],l=p=>p.isDeleted?!1:n?p.frameId===n:e.editingGroupId?p.groupIds.includes(e.editingGroupId):!0,s=r==="left"?Sr(o,p=>l(p),Math.max(0,t-1)):bp(o,p=>l(p),t+1),c=o[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join("")===c?.groupIds.join(""))return SE(c,o,r,i)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(c.frameId||ie(c))){let p=mT(o,c.frameId||c.id);return r==="left"?o.indexOf(p[0]):o.indexOf(p[p.length-1])}if(!c.groupIds.length)return SE(c,o,r,i)??s;let m=e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1],d=Ue(o,m);return d.length?r==="left"?o.indexOf(d[0]):o.indexOf(d[d.length-1]):s},ME=(e,o)=>o.reduce((t,r)=>{let n=e[r];return t.set(n.id,n),t},new Map),LE=(e,o,t,r)=>{let n=kE(e,o),i=ME(e,n),a=dT(n);t==="right"&&(a=a.reverse());let l=new Set(n.filter(s=>ie(e[s])).map(s=>e[s].id));return a.forEach((s,c)=>{let m=s[0],d=s[s.length-1],p=t==="left"?m:d,u=s.some(y=>{let v=e[y];return v.frameId&&l.has(v.frameId)})?null:e[p]?.frameId,h=pT(o,e,p,t,u,r);if(h===-1||p===h)return;let b=t==="left"?e.slice(0,h):e.slice(0,m),x=e.slice(m,d+1),E=t==="left"?e.slice(h,m):e.slice(d+1,h+1),w=t==="left"?e.slice(d+1):e.slice(h+1);e=t==="left"?[...b,...x,...E,...w]:[...b,...E,...x,...w]}),Ht(e,i),e},AE=(e,o,t,r,n)=>{let i=kE(e,o,n),a=ME(e,i),l=[],s,c;if(t==="left"){if(r)s=bp(e,h=>Du(h,r));else if(o.editingGroupId){let h=Ue(e,o.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(r)c=Sr(e,h=>Du(h,r));else if(o.editingGroupId){let h=Ue(e,o.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);let m=Array.from(a.values()),d=e.slice(0,s),p=e.slice(c+1),u=t==="left"?[...d,...m,...l,...p]:[...d,...l,...m,...p];return Ht(u,a),u};function _E(e,o,t,r){let n=ne(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&ie(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ie(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let m=i.frameChildren.get(c.frameId)||[];m.push(c),i.frameChildren.set(c.frameId,m)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,m]of s)l=r(e,o,t,c,m);return r(l,o,t,null,i.regularElements)}var DE=(e,o,t)=>LE(e,o,"left",t),PE=(e,o,t)=>LE(e,o,"right",t),RE=(e,o)=>_E(e,o,"left",AE),NE=(e,o)=>_E(e,o,"right",AE);import{jsx as nd}from"react/jsx-runtime";var Pu=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:gu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:DE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:gu})}),Ru=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:hu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:PE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:hu})}),Nu=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:bu,trackEvent:{category:"element"},perform:(e,o)=>({elements:RE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Fo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Fo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:bu})}),Ou=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:fu,trackEvent:{category:"element"},perform:(e,o)=>({elements:NE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Fo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Fo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:fu})});var Bu=F({name:"selectAll",label:"labels.selectAll",icon:aE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Z(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...ut({editingGroupId:null,selectedElementIds:n},Ee(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ce(e[0])?new j(e[0]):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as hT}from"react/jsx-runtime";var zu=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Al,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.editingLinearElement)try{let a=j.duplicateSelectedPoints(o,r.scene.getNonDeletedElementsMap());return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{newElements:n,elementsWithClones:i}=ai({type:"in-place",elements:e,idsOfElementsToDuplicate:ne(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:a=>({x:a.x+tp/2,y:a.y+tp/2}),reverseOrder:!1});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Ht(i,ne(n)),appState:{...o,...uT(n),...ut({editingGroupId:o.editingGroupId,selectedElementIds:sc(n).reduce((a,l)=>(Be(l)||(a[l.id]=!0),a),{})},Ee(i),o,null)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t})=>hT(Q,{type:"button",icon:Al,title:`${f("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),visible:ze(Ee(e),o)})}),uT=e=>{let o=e.filter(ce);if(o.length===1){let t=o[0],r=t.boundElements?.map(i=>i.id)??[];if(e.every(i=>i.id===t.id||r.includes(i.id)))return{selectedLinearElement:new j(t)}}return{selectedLinearElement:null}};import{useEffect as rh,useMemo as G6,useRef as nh,useState as V6}from"react";var gT=new Set(["command_palette","export"]),xe=(e,o,t,r)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!gT.has(e)||Fe())return;S.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import ET from"clsx";import fT from"clsx";import{forwardRef as bT}from"react";import{jsx as xT}from"react/jsx-runtime";var id=bT((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return xT("button",{type:"button",ref:o,title:t,"data-testid":n,className:fT(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as Fu,jsxs as yT}from"react/jsx-runtime";var Mo=e=>Fu("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?Fu(id,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):yT("label",{className:ET({active:e.value===o.value}),title:o.text,children:[Fu("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as md from"@radix-ui/react-popover";import n6 from"clsx";import{useRef as i6}from"react";import{jsx as vT}from"react/jsx-runtime";var ad=()=>vT("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as IT,useRef as ST}from"react";import{createPortal as kT}from"react-dom";import OE from"react";var Hu=OE.createContext(null),_e=()=>OE.useContext(Hu);import{useState as wT,useLayoutEffect as BE}from"react";var ld=e=>{let[o,t]=wT(null),r=Ce(),{theme:n}=_e(),{container:i}=ht();return BE(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===de.DARK))},[o,n,r.editor.isMobile,e?.className]),BE(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as TT}from"react";function pa(e,o,t){TT(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,o,t])}import{useRef as CT}from"react";var un=e=>{let o=CT(e);return Object.assign(o.current,e),o.current};import{jsx as MT}from"react/jsx-runtime";var hn=Le(null),zE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=ld({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=_e(),a=gn(),l=lt(),s=J(a,i),c=un({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=ht();IT(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),b=({clientX:I,clientY:_})=>{let L=h.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return Af(L[0],L[1],L[2])},x=({clientX:I,clientY:_,altKey:L})=>{p.style.top=`${_+20}px`,p.style.left=`${I+20}px`;let N=b({clientX:I,clientY:_});u&&c.onChange(r,N,c.selectedElements,{altKey:L}),p.style.background=N},E=()=>{c.onCancel()},w=(I,_)=>{c.onSelect(I,_)},y=I=>{u=!0,I.stopImmediatePropagation()},v=I=>{u=!1,m?.focus(),I.stopImmediatePropagation(),I.preventDefault(),w(b(I),I)},C=I=>{I.key===T.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=ST(null);return pa(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?kT(MT("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as ua from"@radix-ui/react-popover";import DT from"clsx";import PT from"react";import LT from"react";import AT from"clsx";import{jsx as _T}from"react/jsx-runtime";var Et=LT.forwardRef(({children:e,padding:o,className:t,style:r},n)=>_T("div",{className:AT("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Uu,jsxs as RT}from"react/jsx-runtime";var sd=PT.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=Ce();return Uu(ua.Portal,{container:o,children:RT(ua.Content,{ref:c,className:DT("focus-visible-none",e),"data-prevent-outside-click":!0,side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!c1(document.activeElement)&&o.focus(),n()},children:[Uu(Et,{padding:3,style:r,children:t}),Uu(ua.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import NT from"clsx";import{useCallback as OT,useEffect as Vu,useRef as GE,useState as BT}from"react";var fn=({palette:e,color:o})=>{for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},zl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Gu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),HE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Gu({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,Tf)},Ao=Le(null),FE=(e,o,t)=>(e*299+o*587+t*114)/1e3>=160?"black":"white",UE=(e,o)=>{if(o){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),l=parseInt(a[0]),s=parseInt(a[1]),c=parseInt(a[2]);return FE(l,s,c)}}if(e==="transparent")return"black";let t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return FE(t,r,n)};import{Fragment as zT,jsx as cd,jsxs as VE}from"react/jsx-runtime";var YE=({color:e,onChange:o,label:t,colorPickerType:r})=>{let n=Ce(),[i,a]=BT(e),[l,s]=ve(Ao);Vu(()=>{a(e)},[e]);let c=OT(h=>{let b=h.toLowerCase(),x=WE(b);x&&o(x),a(b)},[o]),m=GE(null),d=GE(null);Vu(()=>{m.current&&m.current.focus()},[l]);let[p,u]=ve(hn);return Vu(()=>()=>{u(null)},[u]),VE("div",{className:"color-picker__input-label",children:[cd("div",{className:"color-picker__input-hash",children:"#"}),cd("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==T.TAB&&(h.key===T.ESCAPE&&d.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&VE(zT,{children:[cd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),cd("div",{ref:d,className:NT("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:b=>o(b),colorPickerType:r}),title:`${f("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${R("Alt")} `,children:qx})]})]})};import qE,{useEffect as JE,useState as o6}from"react";import UT from"clsx";import{useEffect as GT,useRef as VT}from"react";import{jsxs as HT}from"react/jsx-runtime";var FT=({color:e,keyLabel:o,isCustomColor:t=!1,isShade:r=!1})=>HT("div",{className:"color-picker__button__hotkey-label",style:{color:UE(e,t)},children:[r&&"\u21E7",o]}),ha=FT;import{jsx as Yu,jsxs as YT}from"react/jsx-runtime";var KE=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ve(Ao),a=VT(null);return GT(()=>{a.current&&a.current.focus()},[o,n]),Yu("div",{className:"color-picker-content--default",children:e.map((l,s)=>YT("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:UT("color-picker__button color-picker__button--large",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Yu("div",{className:"color-picker__button-outline"}),Yu(ha,{color:l,keyLabel:s+1,isCustomColor:!0})]},s))})};import WT from"clsx";import{useEffect as KT,useRef as ZT}from"react";import{jsx as Wu,jsxs as $T}from"react/jsx-runtime";var XT=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=fn({color:o||"transparent",palette:e}),[a,l]=ve(Ao),s=ZT(null);return KT(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Wu("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=zl[d],h=f(`colors.${c.replace(/\d+/,"")}`,null,"");return $T("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:WT("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[Wu("div",{className:"color-picker__button-outline"}),Wu(ha,{color:p,keyLabel:u})]},c)})})},ZE=XT;import{jsx as qT}from"react/jsx-runtime";var jT=({children:e})=>qT("div",{className:"color-picker__heading",children:e}),ga=jT;import JT from"clsx";import{useEffect as QT,useRef as e6}from"react";import{jsx as Fl,jsxs as XE}from"react/jsx-runtime";var $E=({hex:e,onChange:o,palette:t})=>{let r=fn({color:e||"transparent",palette:t}),[n,i]=ve(Ao),a=e6(null);if(QT(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return Fl("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>XE("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:JT("color-picker__button color-picker__button--large",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[Fl("div",{className:"color-picker__button-outline"}),Fl(ha,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return XE("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Fl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Fl("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:f("colorPicker.noShades")})]})};var Ku=(e,o,t)=>{let r=Math.ceil(t/Nn);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+Nn;return n>=t?o%Nn:n}case"ArrowUp":{let n=o-Nn,i=n<0?Nn*r+n:n;return i>=t?void 0:i}}},t6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(zl.includes(e.key)){let l=zl.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},jE=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let d=fn({color:r,palette:t});if(e.key===T.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,v])=>(v&&w.push(y),w),[]),h=u.indexOf(o),b=e.shiftKey?-1:1,x=h+b>u.length-1?0:h+b<0?u.length-1:h+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(Io.black)),e.preventDefault(),e.stopPropagation(),!0}if(t6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=Ku(e.key,p,Nn);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),h=u.indexOf(p),b=Ku(e.key,h,u.length);if(b!==void 0){let x=u[b],E=t[x];return n(Array.isArray(E)?E[s]:E),!0}}if(o==="custom"){let p=i.indexOf(r),u=Ku(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};import{jsx as ui,jsxs as dd}from"react/jsx-runtime";var QE=({color:e,onChange:o,label:t,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=qE.useState(()=>r==="canvasBackground"?[]:HE(n,r,i)),[d,p]=ve(Ao),u=fn({color:e,palette:i});JE(()=>{if(!d){let E=Gu({color:e,palette:i}),w=E&&!m.includes(e);p(w?"hex":E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[h,b]=o6(u?.shade??(r==="elementBackground"?Sf:If));JE(()=>{u?.shade!=null&&b(u.shade);let E=w=>{w.key===T.ALT&&s(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,s]);let x=qE.useRef(null);return ui("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:dd("div",{ref:x,onKeyDown:E=>{jE({event:E,activeColorPickerSection:d,palette:i,color:e,onChange:o,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&dd("div",{children:[ui(ga,{children:f("colorPicker.mostUsedCustomColors")}),ui(KE,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),dd("div",{children:[ui(ga,{children:f("colorPicker.colors")}),ui(ZE,{color:e,label:t,palette:i,onChange:o,activeShade:h})]}),dd("div",{children:[ui(ga,{children:f("colorPicker.shades")}),ui($E,{hex:e,onChange:o,palette:i})]}),l]})})};import r6 from"clsx";import{jsx as Zu}from"react/jsx-runtime";var ey=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=Ts),o==="elementBackground"&&(n=Cs),o==="canvasBackground"&&(n=Is),r&&(n=r),n?Zu("div",{className:"color-picker__top-picks",children:n.map(i=>Zu("button",{className:r6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Zu("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Zo,jsxs as Xu}from"react/jsx-runtime";var ty=e=>{let o=new Option().style;return o.color=e,!!o.color},WE=e=>Vn(e)?e:ty(`#${e}`)?`#${e}`:ty(e)?e:null,a6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,updateData:a})=>{let{container:l}=ht(),[,s]=ve(Ao),[c,m]=ve(hn),d=Xu("div",{children:[Zo(ga,{children:f("colorPicker.hexCode")}),Zo(YE,{color:o,label:r,onChange:h=>{t(h)},colorPickerType:e})]}),p=i6(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return Zo(sd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:h=>{u(),h.preventDefault()},onPointerDownOutside:h=>{c&&h.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Zo(QE,{palette:i,color:o,onChange:h=>{t(h)},onEyeDropperToggle:h=>{m(b=>h?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):h===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:h=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},l6=({label:e,color:o,type:t})=>Zo(md.Trigger,{type:"button",className:n6("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:Zo("div",{className:"color-picker__button-outline"})}),Hl=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,topPicks:a,updateData:l,appState:s})=>Zo("div",{children:Xu("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Zo(ey,{activeColor:o,onChange:t,type:e,topPicks:a}),Zo(ad,{}),Xu(md.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Zo(l6,{color:o,label:r,type:e}),s.openPopup===e&&Zo(a6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as my from"@radix-ui/react-popover";import A6,{useCallback as _6,useMemo as D6}from"react";import T6,{useMemo as bn,useState as C6,useRef as I6,useEffect as S6,useCallback as k6}from"react";import s6 from"clsx";import c6 from"react";import{jsx as d6,jsxs as m6}from"react/jsx-runtime";var pd=c6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>m6("div",{className:s6("QuickSearch__wrapper",e),children:[go,d6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import p6 from"clsx";import{Children as u6}from"react";import{jsx as oy}from"react/jsx-runtime";var ud=({className:e,placeholder:o,children:t})=>{let r=!u6.count(t);return oy("div",{className:p6("ScrollableList__wrapper",e),role:"menu",children:r?oy("div",{className:"empty",children:o}):t})};import{jsx as h6,jsxs as g6}from"react/jsx-runtime";var ry=({children:e,className:o="",style:t,title:r})=>g6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&h6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Ul=ry;ry.displayName="DropdownMenuGroup";import{useEffect as v6,useRef as w6}from"react";import{Fragment as b6,jsx as $u,jsxs as x6}from"react/jsx-runtime";var f6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Ce();return x6(b6,{children:[o&&$u("div",{className:"dropdown-menu-item__icon",children:o}),$u("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&$u("div",{className:"dropdown-menu-item__shortcut",children:t})]})},hd=f6;import E6,{useContext as y6}from"react";var ju=E6.createContext({}),gd=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
- ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),fd=(e,o)=>{let t=y6(ju);return on(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as qu}from"react/jsx-runtime";var Ju=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,...d})=>{let p=fd(m,c),u=w6(null);return v6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),qu("button",{...d,ref:u,value:o,onClick:p,className:gd(i,l,a),title:d.title??d["aria-label"],children:qu(hd,{textStyle:s,icon:e,shortcut:n,children:r})})};Ju.displayName="DropdownMenuItem";var fa={GREEN:"green",RED:"red",BLUE:"blue"},bd=({type:e=fa.BLUE,children:o})=>{let{theme:t}=mr(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===de.LIGHT?"1.5px solid white":"none"};switch(e){case fa.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case fa.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case fa.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return qu("div",{className:"DropDownMenuItemBadge",style:r,children:o})};bd.displayName="DropdownMenuItemBadge";Ju.Badge=bd;var Vt=Ju;var ny=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return o.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return t?.value&&i(t.value),!0;if(e.key===T.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===T.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Gl,jsxs as iy}from"react/jsx-runtime";var M6=e=>{switch(e){case Ot.Excalifont:case Ot.Virgil:return pn;case Ot.Nunito:case Ot.Helvetica:return Rl;case Ot["Lilita One"]:return Fx;case Ot["Comic Shanns"]:case Ot.Cascadia:return Kc;default:return Rl}},ay=T6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=ht(),{fonts:s}=lt(),{showDeprecatedFonts:c}=pr(),[m,d]=C6(""),p=I6(null),u=bn(()=>Array.from(dn.registered.entries()).filter(([L,{metadata:N}])=>!N.serverSide&&!N.fallback).map(([L,{metadata:N,fontFaces:P}])=>{let z={value:L,icon:M6(L),text:P[0]?.fontFace?.family??"Unknown"};return N.deprecated&&Object.assign(z,{deprecated:N.deprecated,badge:{type:fa.RED,placeholder:f("fontList.badge.old")}}),z}).sort((L,N)=>L.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),h=bn(()=>new Set(s.getSceneFamilies()),[e]),b=bn(()=>u.filter(L=>h.has(L.value)),[u,h]),x=bn(()=>u.filter(L=>!h.has(L.value)&&(c||!L.deprecated)),[u,h,c]),E=bn(()=>x1([...b,...x].filter(L=>L.text?.toLowerCase().includes(m))),[b,x,m]),w=bn(()=>{let L;return o?L=E.find(N=>N.value===o):e&&(L=E.find(N=>N.value===e)),!L&&m&&(E[0]?.value?r(E[0].value):n()),L},[o,e,m,E,r,n]),y=k6(L=>{ny({event:L,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[w,E,t,r,a]);S6(()=>(i(),()=>{a()}),[]);let v=bn(()=>E.filter(L=>h.has(L.value)),[E,h]),C=bn(()=>E.filter(L=>!h.has(L.value)),[E,h]),I=(L,N)=>iy(Vt,{icon:L.icon,value:L.value,order:N,textStyle:{fontFamily:Fn({fontFamily:L.value})},hovered:L.value===w?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{w?.value!==L.value&&r(L.value)},children:[L.text,L.badge&&Gl(bd,{type:L.badge.type,children:L.badge.placeholder})]},L.value),_=[];return v.length&&_.push(Gl(Ul,{title:f("fontList.sceneFonts"),children:v.map(I)},"group_1")),C.length&&_.push(Gl(Ul,{title:f("fontList.availableFonts"),children:C.map((L,N)=>I(L,N+v.length))},"group_2")),iy(sd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[Gl(pd,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Hn(d,20)}),Gl(ud,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as ly from"@radix-ui/react-popover";import{useMemo as L6}from"react";import{jsx as Qu}from"react/jsx-runtime";var sy=({selectedFontFamily:e})=>{let o=L6(()=>!!(e&&!cy(e)),[e]);return Qu(ly.Trigger,{asChild:!0,children:Qu("div",{children:Qu(id,{standalone:!0,icon:Hc,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as xd,jsxs as dy}from"react/jsx-runtime";var py=[{value:Ot.Excalifont,icon:pn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Ot.Nunito,icon:Rl,text:f("labels.normal"),testId:"font-family-normal"},{value:Ot["Comic Shanns"],icon:Kc,text:f("labels.code"),testId:"font-family-code"}],P6=new Set(py.map(e=>e.value)),cy=e=>e?P6.has(e):!1,uy=A6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=D6(()=>py,[]),s=_6(c=>{c&&r(c)},[r]);return dy("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[xd(Mo,{type:"button",options:l,value:o,onClick:s}),xd(ad,{}),dy(my.Root,{open:e,onOpenChange:a,children:[xd(sy,{selectedFontFamily:o}),e&&xd(ay,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as ba from"@radix-ui/react-popover";import B6 from"clsx";import Ed,{useEffect as z6}from"react";import{jsx as R6}from"react/jsx-runtime";var xn=({icon:e})=>R6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as O6,jsx as hy,jsxs as gy}from"react/jsx-runtime";var N6=({label:e,open:o,openTrigger:t,children:r,className:n})=>gy(O6,{children:[gy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,hy(xn,{icon:o?vE:td})]}),o&&hy("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Vl=N6;import{jsx as hi,jsxs as eh}from"react/jsx-runtime";var F6=Le(!1);function H6({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=Ce(),l=u=>{let h=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&h)r(h.value),u.preventDefault();else if(u.key===T.TAB){let b=e.findIndex(E=>E.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(zn(u.key)){let b=Rr().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,w=x;switch(u.key){case(b?T.ARROW_LEFT:T.ARROW_RIGHT):w=(x+1)%E;break;case(b?T.ARROW_RIGHT:T.ARROW_LEFT):w=(E+x-1)%E;break;case T.ARROW_DOWN:{w=(x+(i??1))%E;break}case T.ARROW_UP:{w=(E+x-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===T.ESCAPE||u.key===T.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ve(F6),m=Ed.useMemo(()=>e.slice(0,i),[e,i]),d=Ed.useMemo(()=>e.slice(i),[e,i]);z6(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>hi("div",{className:"picker-content",children:u.map((h,b)=>eh("button",{type:"button",className:B6("picker-option",{active:o===h.value}),onClick:x=>{r(h.value)},title:`${h.text} ${h.keyBinding&&`\u2014 ${h.keyBinding.toUpperCase()}`}`,"aria-label":h.text||"none","aria-keyshortcuts":h.keyBinding||void 0,ref:x=>{o===h.value&&setTimeout(()=>{x?.focus()},0)},children:[h.icon,h.keyBinding&&hi("span",{className:"picker-keybinding",children:h.keyBinding})]},h.text))});return hi(ba.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:eh("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&hi(Vl,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function th({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ed.useState(!1),s=Ed.useRef(null);return hi("div",{children:eh(ba.Root,{open:a,onOpenChange:c=>l(c),children:[hi(ba.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&hi(H6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import fy,{useEffect as U6}from"react";import{jsx as oh,jsxs as by}from"react/jsx-runtime";var xy=({updateData:e,appState:o,elements:t,testId:r})=>{let n=fy.useRef(null),i=fy.useRef(null),a=Pt(t,o,l=>l.opacity,!0,o.currentItemOpacity);return U6(()=>{if(n.current&&i.current){let l=n.current,s=i.current,c=l.offsetWidth,m=15,d=a/100*(c-m)+m/2;s.style.left=`${d}px`,l.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${a}%, var(--button-bg) ${a}%, var(--button-bg) 100%)`}},[a]),by("label",{className:"control-label",children:[f("labels.opacity"),by("div",{className:"range-wrapper",children:[oh("input",{ref:n,type:"range",min:"0",max:"100",step:"10",onChange:l=>{e(+l.target.value)},value:a,className:"range-input","data-testid":r}),oh("div",{className:"value-bubble",ref:i,children:a!==0?a:null}),oh("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as vy,jsx as fe,jsxs as fo}from"react/jsx-runtime";var yy=.1,Yt=(e,o,t,r=!1)=>{let n=ne(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Pt=function(e,o,t,r,n){let i=o.editingTextElement,a=Ee(e),l=null;return i&&(l=t(i)),l||(ze(a,o)?l=ub(r===!0?a:a.filter(c=>r(c)),o,t)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},Y6=(e,o)=>Be(o)||!o.autoResize?o:B(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2},!1),ih=(e,o,t,r,n)=>{let i=new Set,a=Yt(e,o,s=>{if(Z(s)){let c=r(s);i.add(c);let m=oe(s,{fontSize:c});return Qe(m,t.scene.getContainerElement(s),t.scene.getNonDeletedElementsMap()),m=Y6(s,m),m}return s},!0),l=ne(a);return J(e,o,{includeBoundTextElement:!0}).forEach(s=>{Z(s)&&at(s,l)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},W6=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Yt(e,o,r=>yl(r.type)?oe(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(vy,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.stroke")}),fe(Hl,{topPicks:Ts,palette:kf,type:"elementStroke",label:f("labels.stroke"),color:Pt(e,o,n=>n.strokeColor,!0,o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),K6=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemBackgroundColor&&{elements:Yt(e,o,r=>oe(r,{backgroundColor:t.currentItemBackgroundColor}))},appState:{...o,...t},captureUpdate:t.currentItemBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(vy,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.background")}),fe(Hl,{topPicks:Cs,palette:Mf,type:"elementBackground",label:f("labels.background"),color:Pt(e,o,n=>n.backgroundColor,!0,o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),Z6=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(xe("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Yt(e,o,n=>oe(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o),n=r.length>0&&r.every(i=>i.fillStyle==="zigzag");return fo("fieldset",{children:[fe("legend",{children:f("labels.fill")}),fe(Mo,{type:"button",options:[{value:"hachure",text:`${n?f("labels.zigzag"):f("labels.hachure")} (${R("Alt-Click")})`,icon:n?dx:mx,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:px,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:ux,testId:"fill-solid"}],value:Pt(e,o,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:o.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&r.every(s=>s.fillStyle==="hachure")?"zigzag":i;t(l)}})]})}}),X6=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>oe(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeWidth")}),fe(Mo,{group:"stroke-width",options:[{value:Bs.thin,text:f("labels.thin"),icon:Su,testId:"strokeWidth-thin"},{value:Bs.bold,text:f("labels.bold"),icon:hx,testId:"strokeWidth-bold"},{value:Bs.extraBold,text:f("labels.extraBold"),icon:gx,testId:"strokeWidth-extraBold"}],value:Pt(e,o,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})]})}),$6=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>oe(r,{seed:Wn(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.sloppiness")}),fe(Mo,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:xx},{value:1,text:f("labels.artist"),icon:Ex},{value:2,text:f("labels.cartoonist"),icon:yx}],value:Pt(e,o,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})]})}),yB=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>oe(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeStyle")}),fe(Mo,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Su},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:fx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:bx}],value:Pt(e,o,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})]})}),j6=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>oe(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fe(xy,{updateData:t,elements:e,appState:o,testId:"opacity"})}),q6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>ih(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fo("fieldset",{children:[fe("legend",{children:f("labels.fontSize")}),fe(Mo,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:Nx,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:Ox,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:Bx,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:zx,testId:"fontSize-veryLarge"}],value:Pt(e,o,n=>{if(Z(n))return n.fontSize;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Tr),onChange:n=>t(n)})]})}),ah=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:pi,trackEvent:!1,perform:(e,o,t,r)=>ih(e,o,r,n=>Math.round(1/(1+yy)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),lh=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:pi,trackEvent:!1,perform:(e,o,t,r)=>ih(e,o,r,n=>Math.round(n.fontSize*(1+yy))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),J6=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Yt(e,o,b=>{let x=n?.get(b.id);return x?oe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:A.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=A.EVENTUALLY,d,p=!1;if(s)d=s,m=A.IMMEDIATELY;else if(c){d=c,m=A.EVENTUALLY;let h=J(e,o,{includeBoundTextElement:!0}).filter(b=>Z(b));if(h.length>200)p=!0;else{let b=0,x=0;for(;b<h.length&&x<5e3;){let E=h[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let h=new Map,b=new Set,x=!1,E=Array.from(dn.loadedFontsCache.values()),w=Object.entries(Ot).find(([C,I])=>I===d)?.[0];c&&w&&E.some(C=>C.startsWith(w))&&(x=!0),Object.assign(u,{elements:Yt(e,o,C=>{if(Z(C)&&(C.fontFamily!==d||s)){let I=oe(C,{fontFamily:d,lineHeight:Ir(d)}),_=n?.get(C.containerId||"")||{},L=r.scene.getContainerElement(C);return a&&L&&_&&B(L,{..._},!1),x||(b=new Set([...b,...Array.from(I.originalText)])),h.set(I,L),I}return C},!0)});let y=`10px ${Fn({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,I]of h)Qe(C,I,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(y,v).then(C=>{for(let[I,_]of h){let L=r.scene.getElement(I.id),N=_?r.scene.getElement(_.id):null;L&&Qe(L,N,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=nh(new Map),i=nh(null),[a,l]=V6({}),s=nh(!0),c=G6(()=>{let m=(d,p)=>Pt(d,o,u=>{if(Z(u))return u.fontFamily;let h=ge(u,p);return h?h.fontFamily:null},u=>Z(u)||ge(u,p)!==null,u=>u?null:o.currentItemFontFamily||Zr);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t.scene]);return rh(()=>{i.current=c},[c]),rh(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),rh(()=>(s.current=!1,()=>{s.current=!0}),[]),fo("fieldset",{children:[fe("legend",{children:f("labels.fontFamily")}),fe(uy,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),n.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:m=>{if(m){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,oe(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,oe(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),Q6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Yt(e,o,n=>{if(Z(n)){let i=oe(n,{textAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return fo("fieldset",{children:[fe("legend",{children:f("labels.textAlign")}),fe(Mo,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:Hx,testId:"align-left"},{value:"center",text:f("labels.center"),icon:Ux,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:Gx,testId:"align-right"}],value:Pt(e,o,i=>{if(Z(i))return i.textAlign;let a=ge(i,n);return a?a.textAlign:null},i=>Z(i)||ge(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})]})}}),e4=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Yt(e,o,n=>{if(Z(n)){let i=oe(n,{verticalAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fe("fieldset",{children:fe(Mo,{group:"text-align",options:[{value:Jt.TOP,text:f("labels.alignTop"),icon:fe(Vx,{theme:o.theme}),testId:"align-top"},{value:Jt.MIDDLE,text:f("labels.centerVertically"),icon:fe(Wx,{theme:o.theme}),testId:"align-middle"},{value:Jt.BOTTOM,text:f("labels.alignBottom"),icon:fe(Yx,{theme:o.theme}),testId:"align-bottom"}],value:Pt(e,o,n=>{if(Z(n)&&n.containerId)return n.verticalAlign;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Jt.MIDDLE),onChange:n=>t(n)})})}),vB=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>ee(r)?r:oe(r,{roundness:t==="round"?{type:Bi(r.type)?Qt.ADAPTIVE_RADIUS:Qt.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=cc(Ee(e),o).some(i=>i.roundness?.type===Qt.LEGACY);return fo("fieldset",{children:[fe("legend",{children:f("labels.edges")}),fe(Mo,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:vx},{value:"round",text:f("labels.round"),icon:wx}],value:Pt(e,o,i=>n?null:i.roundness?"round":"sharp",i=>!Pe(i)&&i.hasOwnProperty("roundness"),i=>i?null:o.currentItemRoundness),onChange:i=>t(i)})]})}}),Ey=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Tx},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:fe(Cx,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:fe(Mx,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:fe(Lx,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:fe(Ix,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:fe(Sx,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:fe(Ax,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:fe(_x,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:fe(kx,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:fe(Px,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:fe(Dx,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:fe(Rx,{flip:e}),keyBinding:"v"}],wB=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Yt(e,o,r=>{if(ce(r)){let{position:n,type:i}=t;if(n==="start")return oe(r,{startArrowhead:i});if(n==="end")return oe(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Rr().rtl;return fo("fieldset",{children:[fe("legend",{children:f("labels.arrowheads")}),fo("div",{className:"iconSelectList buttonList",children:[fe(th,{label:"arrowhead_start",options:Ey(!r),value:Pt(e,o,n=>ce(n)&&Zi(n.type)?n.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:n=>t({position:"start",type:n}),numberOfOptionsToAlwaysShow:4}),fe(th,{label:"arrowhead_end",group:"arrowheads",options:Ey(!!r),value:Pt(e,o,n=>ce(n)&&Zi(n.type)?n.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:n=>t({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),TB=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Yt(e,o,l=>{if(!Pe(l))return l;let s=oe(l,{roundness:t===xt.round?{type:Qt.PROPORTIONAL_RADIUS}:null,elbowed:t===xt.elbow,points:t===xt.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(ee(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=j.getPointAtIndexGlobalCoordinates(s,0,c),d=j.getPointAtIndexGlobalCoordinates(s,-1,c),p=!s.startBinding&&an(en(m),e,c,o.zoom,!1,!0),u=!s.endBinding&&an(en(d),e,c,o.zoom,!1,!0),h=p||s.startBinding&&c.get(s.startBinding.elementId),b=u||s.endBinding&&c.get(s.endBinding.elementId),x=p?vp(s,p,"start"):m,E=u?vp(s,u,"end"):d;p&&Vo(s,p,"start",c),u&&Vo(s,u,"end",c);let w=h&&s.startBinding?{...s.startBinding,...wp(s,h,"start",c)}:null,y=b&&s.endBinding?{...s.endBinding,...wp(s,b,"end",c)}:null;s={...s,startBinding:w,endBinding:y,...oc(s,c,{points:[x,E].map(v=>M(v[0]-s.x,v[1]-s.y)),startBinding:w,endBinding:y,fixedSegments:null})},j.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Vo(s,m,"start",c)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Vo(s,m,"end",c)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new j(l))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.arrowtypes")}),fe(Mo,{group:"arrowtypes",options:[{value:xt.sharp,text:f("labels.arrowtype_sharp"),icon:xE,testId:"sharp-arrow"},{value:xt.round,text:f("labels.arrowtype_round"),icon:yE,testId:"round-arrow"},{value:xt.elbow,text:f("labels.arrowtype_elbowed"),icon:EE,testId:"elbow-arrow"}],value:Pt(e,o,r=>Pe(r)?r.elbowed?xt.elbow:r.roundness?xt.round:xt.sharp:null,r=>Pe(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})]})});import{useEffect as t4}from"react";import{jsx as r4}from"react/jsx-runtime";var xa=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},sh=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},o4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();sh(o,n)},bo=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(t4(()=>()=>xa().classList.remove("excalidraw-tooltip--visible"),[]),n?null:r4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>o4(i.currentTarget,xa(),o,t),onPointerLeave:()=>xa().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import yd from"open-color";var Ty='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',n4='<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"/>',Cy='<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"/>',i4=`data:${ue.svg},${encodeURIComponent(`${Ty}${Cy}</svg>`)}`,a4=`data:${ue.svg},${encodeURIComponent(`${Ty}${n4}${Cy}</svg>`)}`,xo=e=>{e&&(e.style.cursor="")},De=(e,o)=>{e&&(e.style.cursor=o)},ur,wy,ch=(e,o)=>{let r=()=>{let n=o===de.DARK;ur=document.createElement("canvas"),ur.theme=o,ur.height=20,ur.width=20;let i=ur.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(ur.width/2,ur.height/2,5,0,2*Math.PI),i.fillStyle=n?yd.black:yd.white,i.fill(),i.strokeStyle=n?yd.white:yd.black,i.stroke(),wy=ur.toDataURL(ue.svg)};(!ur||ur.theme!==o)&&r(),De(e,`url(${wy}) ${20/2} ${20/2}, auto`)},Eo=(e,o)=>{if(e)if(o.activeTool.type==="selection")xo(e);else if(Wo(o))e.style.cursor=Se.GRAB;else if(no(o))ch(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===de.LIGHT?i4:a4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Se.AUTO):e.style.cursor=Se.CROSSHAIR};var Nr=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),c=-(n-n/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as Cd,jsxs as d4}from"react/jsx-runtime";var l4=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Cd(Hl,{palette:null,topPicks:Is,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Or=F({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:ho,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>oe(n,{isDeleted:!0})),appState:{...cr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:"selection"}:o.activeTool},captureUpdate:A.IMMEDIATELY})}),vd=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:cu,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Nr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:sr(o.zoom.value+Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Cd(Q,{type:"button",className:"zoom-in-button zoom-button",icon:cu,title:`${f("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=rp,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.EQUAL||e.code===pe.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),wd=F({name:"zoomOut",label:"buttons.zoomOut",icon:du,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Nr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:sr(o.zoom.value-Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Cd(Q,{type:"button",className:"zoom-out-button zoom-button",icon:du,title:`${f("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=op,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.MINUS||e.code===pe.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),Td=F({name:"resetZoom",label:"buttons.resetZoom",icon:Z0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Nr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:sr(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Cd(bo,{label:f("buttons.resetZoom"),style:{height:"100%"},children:d4(Q,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===pe.ZERO||e.code===pe.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),s4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,c=a-n,m=o.height/c,p=Math.min(s,m)*wt(t,.1,1);return Math.min(p,1)},Iy=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=wt(n,op,rp);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,h=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,w=o.height-h-x,y;if(r){let I=c-l,_=m-s;y=Math.min(E/I,w/_)*n}else y=s4(e,{width:E,height:w},n);let v=sr(wt(i1(y,Li,"floor"),i,a)),C=Yb({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:A.EVENTUALLY}},Yl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=ye(Ee(o));return Iy({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},iz=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ed,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Yl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),az=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ed,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Yl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),c4=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ed,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Yl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===pe.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),gi=F({name:"toggleTheme",label:(e,o)=>o.theme===de.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===de.LIGHT?_l:Dl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===de.LIGHT?de.DARK:de.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===pe.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),lz=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return no(o)?t=Ge(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Ge(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===T.E}),Sy=F({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:Xc,viewMode:!1,perform:(e,o,t,r)=>{let n;return Wo(o)?n=Ge(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Ge(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),De(r.interactiveCanvas,Se.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var m4=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Ge(o,{type:"embeddable"});return Eo(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ge(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as p4}from"react/jsx-runtime";var yo=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,l=a.getNonDeletedElementsMap();if(o.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=o.editingLinearElement,b=j.getElement(p,l);if(b)return Mr(b)&&Qs(b,u,h,l,a),{elements:b.points.length<2||Jn(b)?e.filter(x=>x.id!==b.id):void 0,appState:{...o,cursorButton:"up",editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let s=e,c=o.pendingImageElementId&&a.getElement(o.pendingImageElementId);c&&B(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let m=o.multiElement?o.multiElement:o.newElement?.type==="freedraw"?o.newElement:null;if(m){if(m.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=m;(!h||u[u.length-1]!==h)&&B(m,{points:m.points.slice(0,-1)})}Jn(m)&&(s=s.filter(u=>u.id!==m.id));let p=El(m.points,o.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,h=u[0];B(m,{points:u.map((b,x)=>x===u.length-1?M(h[0],h[1]):b)})}if(Mr(m)&&!p&&m.points.length>1){let[u,h]=j.getPointAtIndexGlobalCoordinates(m,-1,ne(e));hl(m,o,{x:u,y:h},l,e)}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&xo(n);let d;return o.activeTool.type==="eraser"?d=Ge(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=Ge(o,{type:"selection"}),{elements:s,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&m?o.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[m.id]:!0}:o.selectedElementIds,selectedLinearElement:m&&ce(m)?new j(m):o.selectedLinearElement,pendingImageElementId:null},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===T.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>p4(Q,{type:"button",icon:rx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import u4 from"clsx";import{jsx as ky,jsxs as h4}from"react/jsx-runtime";var Wl=({children:e,checked:o,onChange:t,className:r})=>h4("div",{className:u4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[ky("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:J0}),ky("div",{className:"Checkbox-label",children:e})]});import{jsx as Kl}from"react/jsx-runtime";var Ly=e=>{let o=e.title||(e.value===de.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Kl(Q,{type:"icon",icon:e.value===de.LIGHT?My.MOON:My.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===de.DARK?de.LIGHT:de.DARK),"data-testid":"toggle-dark-mode"})},My={SUN:Kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Kl("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:Kl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Kl("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as g4}from"react";import{jsx as Ay,jsxs as f4}from"react/jsx-runtime";var _y=e=>{let{id:o}=ht(),[t,r]=g4(e.value),n=a=>{e.ignoreFocus||h1(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===T.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return f4("div",{className:"ProjectName",children:[Ay("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Ay("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var Xo=32,He=12,En=256,Py=50,fi="NOT_SPREADSHEET",Ea="VALID_SPREADSHEET",Zl=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},dh=(e,o)=>e.slice(1).every(t=>Zl(t[o])!==null),Dy=e=>{let o=e[0].length;if(o>2)return{type:fi,reason:"More than 2 columns"};if(o===1){if(!dh(e,0))return{type:fi,reason:"Value is not numeric"};let s=Zl(e[0][0])===null,c=(s?e.slice(1):e).map(m=>Zl(m[0]));return c.length<2?{type:fi,reason:"Less than two rows"}:{type:Ea,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=dh(e,0),r=dh(e,1);if(!t&&!r)return{type:fi,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Zl(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:fi,reason:"Less than 2 rows"}:{type:Ea,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Zl(s[i]))}}},b4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Ry=e=>{let o=e.trim().split(`
1
+ import{$ as Kf,$a as So,$b as C1,$c as Bi,$d as Sp,$e as J,$f as Up,$g as kc,A as Uf,Aa as Qt,Ab as yp,Ac as Mr,Ad as Qe,Ae as H5,Af as Nb,Ag as t0,Ah as E0,B as tp,Ba as rl,Bb as on,Bc as ro,Bd as hl,Be as ub,Bf as Ob,Bg as ai,Bh as y0,C as Gf,Ca as eo,Cb as b1,Cc as Vo,Cd as tc,Ce as hb,Cf as fc,Cg as cr,Ch as v0,D as Qa,Da as Gs,Db as vp,Dc as js,Dd as Dr,De as lc,Df as yl,Dg as o0,Dh as w0,E as op,Ea as nl,Eb as x1,Ec as qs,Ed as ge,Ee as Pp,Ef as mn,Eg as dr,F as Se,Fa as Ir,Fb as rr,Fc as Lr,Fd as _t,Fe as gb,Ff as vl,Fg as no,G as or,Ga as At,Gb as Gn,Gc as he,Gd as oc,Ge as ko,Gf as Op,Gg as Ko,H as Hn,Ha as Vs,Hb as qe,Hc as Ft,Hd as J1,He as fb,Hf as Bp,Hg as Ji,I as el,Ia as it,Ib as Vn,Ic as Zn,Id as Q1,Ie as bb,If as zp,Ig as r0,J as Uo,Ja as en,Jb as Pi,Jc as Oi,Jd as eb,Je as Yi,Jf as Fp,Jg as Kp,K as Bt,Ka as i1,Kb as nr,Kc as Z,Kd as tb,Ke as xb,Kf as Zi,Kg as un,L as de,La as il,Lb as E1,Lc as D1,Ld as Ui,Le as ei,Lf as Hp,Lg as Qi,M as Go,Ma as to,Mb as y1,Mc as Js,Md as Gi,Me as Eb,Mf as Bb,Mg as wc,N as Rs,Na as xt,Nb as Yn,Nc as ne,Nd as ob,Ne as Wi,Nf as ri,Ng as Zp,O as Cr,Oa as a1,Ob as Fe,Oc as Cp,Od as Ip,Oe as sc,Of as zb,Og as Tl,P as jr,Pa as l1,Pb as R,Pc as ae,Pd as rb,Pe as yb,Pf as Fb,Pg as Tc,Q as Ns,Qa as s1,Qb as $e,Qc as Re,Qd as qn,Qe as cc,Qf as Hb,Qg as Xp,R as rp,Ra as Sr,Rb as zt,Rc as ee,Rd as nb,Re as ar,Rf as Ub,Rg as $p,S as qr,Sa as c1,Sb as cl,Sc as P1,Sd as ib,Se as Rp,Sf as U5,Sg as n0,T as Os,Ta as pe,Tb as rn,Tc as Ar,Td as rc,Te as vb,Tf as pn,Tg as i0,U as Vf,Ua as T,Ub as Zs,Uc as R1,Ud as Jn,Ue as dc,Uf as We,Ug as a0,V as tl,Va as Ys,Vb as wp,Vc as Xn,Vd as nc,Ve as mc,Vf as Gb,Vg as Cc,W as Yf,Wa as Un,Wb as kr,Wc as _r,Wd as gl,We as pc,Wf as Vb,Wg as Cl,X as Wf,Xa as mp,Xb as Wn,Xc as N1,Xd as Yo,Xe as wb,Xf as ye,Xg as Ic,Y as np,Ya as Ai,Yb as v1,Yc as $n,Yd as ab,Ye as Np,Yf as bc,Yg as Sc,Z as ol,Za as Ws,Zb as w1,Zc as Tt,Zd as cn,Ze as ze,Zf as Xi,Zg as l0,_ as ue,_a as wt,_b as T1,_c as Be,_d as at,_e as Tb,_f as Dt,_g as s0,a as ks,aa as Bs,ab as d1,ac as I1,ad as O1,ae as kp,af as uc,ag as Yb,ah as ea,b as Lf,ba as Jr,bb as pp,bc as re,bd as B1,be as lb,bf as ke,bg as Wb,bh as c0,c as zn,ca as Zf,cb as al,cc as S1,cd as zi,ce as sb,cf as Cb,cg as Gt,ch as jp,d as Af,da as Xf,db as _i,dc as ir,dd as z1,de as ic,df as lt,dg as Gp,dh as G5,e as _f,ea as $f,eb as Di,ec as k1,ed as F1,ee as cb,ef as hc,eg as Kb,eh as ta,f as Df,fa as jf,fb as up,fc as mt,fd as H1,fe as db,ff as Ib,fg as $i,fh as Il,g as Io,ga as qf,gb as Ks,gc as He,gd as U1,ge as fl,gf as Wo,gg as wl,h as Ms,ha as Li,hb as hp,hc as Xs,hd as G1,he as bl,hf as Sb,hg as Vt,hh as d0,i as Ls,ia as ip,ib as gp,ic as Ri,id as V1,ie as mb,if as kb,ig as Zb,j as As,ja as ap,jb as m1,jc as M1,jd as Y1,je as ac,jf as Ki,jg as Xb,jh as m0,k as Pf,ka as Jf,kb as fp,kc as nn,kd as pl,ke as B,kf as Ge,kg as sr,kh as p0,l as Rf,la as Qf,lb as M,lc as dl,ld as W1,le as te,lf as Mb,lg as ji,lh as Mc,m as Nf,ma as zs,mb as ce,mc as Je,md as K1,me as xl,mf as Lb,mg as xc,mh as u0,n as Of,na as Fs,nb as bp,nc as an,nd as ul,ne as Qn,nf as Ab,ng as Vp,nh as Lc,o as Ho,oa as lp,ob as tn,oc as Kn,od as Z1,oe as El,of as ti,og as ni,oh as qp,p as _s,pa as e1,pb as p1,pc as ln,pd as X1,pe as Vi,pf as _b,pg as $b,ph as Ac,q as Bf,qa as t1,qb as xp,qc as L1,qd as Ht,qe as Mp,qf as Db,qg as qi,qh as h0,r as Tr,ra as o1,rb as u1,rc as $s,rd as Qs,re as Lp,rf as lr,rg as jb,rh as Jp,s as zf,sa as r1,sb as h1,sc as oo,sd as Fi,se as pb,sf as Pb,sg as qb,sh as Rr,t as Ds,ta as Hs,tb as g1,tc as Ni,td as $1,te as B5,tf as Rb,tg as Jb,th as g0,u as Ff,ua as Qr,ub as po,uc as Ye,ud as jn,ue as Ap,uf as gc,ug as Yp,uh as _c,v as qa,va as n1,vb as ll,vc as A1,vd as j1,ve as _p,vf as Ut,vg as Ec,vh as f0,w as Ja,wa as sp,wb as sl,wc as _1,wd as ec,we as Ee,wf as Pr,wg as yc,wh as b0,x as Hf,xa as cp,xb as f1,xc as sn,xd as O5,xe as Dp,xf as dn,xg as vc,xh as x0,y as Fn,ya as Us,yb as Ep,yc as Tp,yd as q1,ye as z5,yf as j,yg as ii,yh as Sl,z as Ps,za as dp,zb as ut,zc as ml,zd as Hi,ze as F5,zf as oi,zg as Qb,zh as Qp}from"./chunk-CAN5RS4P.js";import{a as k}from"./chunk-KJYFYP64.js";import{J as Wp}from"./chunk-IUH5AXLB.js";import{c as e0}from"./chunk-Z3N5DIM6.js";import{b as kf,c as Mf,d as I}from"./chunk-SRAX5OIU.js";import d7,{useEffect as m7}from"react";import f5 from"clsx";import z8 from"lodash.throttle";import wr,{useContext as On}from"react";import{flushSync as ki}from"react-dom";import F8 from"roughjs/bin/rough";import{nanoid as H8}from"nanoid";var V5=e=>{let o=e.slice(),t=new Set,r=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...r(s)]:l},n=new Map;return o.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=o.slice(a).filter(c=>{let m=c?.groupIds?.some(d=>d===l);return m&&n.set(c.id,!0),m});for(let c of r(s))t.add(c)}else t.add(i)}),t.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...t]},Y5=e=>{let o=S1(e),t=e.slice(),r=new Set;return t.forEach((n,i)=>{n&&(n.boundElements?.length?(r.add(n),t[i]=null,n.boundElements.forEach(a=>{let l=o.get(a.id);l&&a.type==="text"&&(r.add(l[0]),t[l[1]]=null)})):n.type==="text"&&n.containerId&&o.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(r.add(n),t[i]=null))}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},T0=e=>Y5(V5(e));var W5=(e,o,t,r,n)=>{let i=uo(t);return mt()&&K5(i,t.id),i.id=ro(),i.updated=I1(),n&&(i.seed=Mr(),xl(i)),i.groupIds=Pb(i.groupIds,e,a=>(o.has(a)||o.set(a,ro()),o.get(a))),r&&(i=Object.assign(i,r)),i},li=e=>{let{elements:o}=e,t="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=e.type==="in-place"?e.reverseOrder:!1,n=new Map,i=new Map,a=[],l=[],s=new Map,c=new Map,m=re(o),d=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(o.map(x=>[x.id,x]));if(e.type==="in-place")for(let x of Object.keys(e.appState.selectedGroupIds))o.filter(E=>E.groupIds?.includes(x)).forEach(E=>d.set(E.id,E));o=T0(o);let p=o.slice(),u=x=>{let w=ml(x).reduce((y,v)=>{if(n.has(v.id))return y;n.set(v.id,!0);let C=W5(t.editingGroupId,i,v,e.overrides?.(v),e.randomizeSeed);return n.set(C.id,!0),c.set(C.id,C),s.set(v.id,C.id),l.push(v),a.push(C),y.push(C),y},[]);return Array.isArray(x)?w:w[0]||null},h=(x,E)=>{if(E){if(r&&x<1){p.unshift(...ml(E));return}if(!r&&x>p.length-1){p.push(...ml(E));return}p.splice(x+(r?0:1),0,...ml(E))}},b=new Set(o.filter(x=>d.has(x.id)&&ne(x)).map(x=>x.id));for(let x of o){if(n.has(x.id)||!d.has(x.id))continue;let E=Ib(t,x);if(E){let w=Ge(o,E).flatMap(v=>ne(v)?[...ko(o,v.id),v]:[v]),y=r?p.findIndex(v=>v.groupIds?.includes(E)):kr(p,v=>v.groupIds?.includes(E));h(y,u(w));continue}if(!(x.frameId&&b.has(x.frameId))){if(ne(x)){let w=x.id,y=ko(o,w),v=kr(p,C=>C.frameId===w||C.id===w);h(v,u([...y,x]));continue}if(Tt(x)){let w=ge(x,m),y=kr(p,v=>v.id===x.id||"containerId"in v&&v.containerId===x.id);w?h(y+(r?-1:0),u([x,w])):h(y,u(x));continue}if(Be(x)){let w=_t(x,m),y=kr(p,v=>v.id===x.id||v.id===w?.id);w?h(y,u([w,x])):h(y,u(x));continue}h(kr(p,w=>w.id===x.id),u(x))}}return lb(a,s,c),r&&sb(d,p,s),ub(p,l,s),{newElements:a,elementsWithClones:p}},eu=(e,o=0)=>{if(e==null||typeof e!="object")return e;let t=Object.prototype.toString.call(e);if(t==="[object Object]"){let r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(o===0&&(n==="shape"||n==="canvas"))continue;r[n]=eu(e[n],o+1)}return r}if(Array.isArray(e)){let r=e.length,n=new Array(r);for(;r--;)n[r]=eu(e[r],o+1);return n}return k.DEV&&t!=="[object Object]"&&t!=="[object Array]"&&t.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${t}. This value will not be cloned!`),e},uo=e=>eu(e),K5=(e,o)=>{Object.defineProperty(e,l1,{value:o,writable:!1,enumerable:!1})};var C0={mouse:8,pen:16,touch:28},Z5=16,S0={e:!0,s:!0,n:!0,w:!0};var I0={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},tu={e:!0,s:!0,n:!0,w:!0},Nr=(e,o,t,r,n,i,a)=>{let[l,s]=ce(M(e+t/2,o+r/2),M(n,i),a);return[l-t/2,s-r/2,t,r]},Dc=e=>!(e.viewport.isMobile||e.isTouchScreen&&(Bf||Ds)),si=e=>Dc(e)?S0:{},kl=([e,o,t,r,n,i],a,l,s,c={},m=4,d=qr)=>{let p=C0[s],u=p/l.value,h=p/l.value,b=p/l.value,x=p/l.value,E=t-e,w=r-o,y=m/l.value,v=(p-d*2)/(2*l.value),C={nw:c.nw?void 0:Nr(e-y-b+v,o-y-x+v,u,h,n,i,a),ne:c.ne?void 0:Nr(t+y-v,o-y-x+v,u,h,n,i,a),sw:c.sw?void 0:Nr(e-y-b+v,r+y-v,u,h,n,i,a),se:c.se?void 0:Nr(t+y-v,r+y-v,u,h,n,i,a),rotation:c.rotation?void 0:Nr(e+E/2-u/2,o-y-x+v-Z5/l.value,u,h,n,i,a)},S=5*C0.mouse/l.value;return Math.abs(E)>S&&(c.n||(C.n=Nr(e+E/2-u/2,o-y-x+v,u,h,n,i,a)),c.s||(C.s=Nr(e+E/2-u/2,r+y-v,u,h,n,i,a))),Math.abs(w)>S&&(c.w||(C.w=Nr(e-y-b+v,o+w/2-h/2,u,h,n,i,a)),c.e||(C.e=Nr(t+y-v,o+w/2-h/2,u,h,n,i,a))),C},Pc=(e,o,t,r="mouse",n=S0)=>{if(e.locked||ee(e))return{};if(e.type==="freedraw"||ae(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=tu:a[0]>0&&a[1]<0?n=I0:a[0]>0&&a[1]>0?n=tu:a[0]<0&&a[1]>0?n=I0:a[0]<0&&a[1]<0&&(n=tu)}}else ne(e)&&(n={...n,rotation:!0});let i=ae(e)?qr+8:he(e)?0:qr;return kl(We(e,t,!0),e.angle,o,r,n,i,he(e)?0:void 0)},Rc=(e,o)=>{if(o.editingLinearElement)return!1;if(e.length>1)return!0;let t=e[0];return ee(t)?!1:ae(t)?t.points.length>2:!0};var oa=100,ci=100,nu=e=>{switch(e){case T.ARROW_UP:return"up";case T.ARROW_DOWN:return"down";case T.ARROW_RIGHT:return"right";case T.ARROW_LEFT:return"left";default:return"right"}},k0=(e,o,t,r)=>{let n=[...t.values()].reduce((i,a)=>{let l;if(ee(a)&&(l=a[e==="predecessors"?"startBinding":"endBinding"])&&a[e==="predecessors"?"endBinding":"startBinding"]?.elementId===o.id){let s=t.get(l.elementId);if(!s)return i;ln(Xn(s),"not an ExcalidrawBindableElement");let c=e==="predecessors"?a.points[a.points.length-1]:[0,0],m=W1(o,Ob(o),[c[0]+a.x,c[1]+a.y]);i.push({relative:s,heading:m})}return i},[]);switch(r){case"up":return n.filter(i=>pl(i.heading,Y1)).map(i=>i.relative);case"down":return n.filter(i=>pl(i.heading,G1)).map(i=>i.relative);case"right":return n.filter(i=>pl(i.heading,U1)).map(i=>i.relative);case"left":return n.filter(i=>pl(i.heading,V1)).map(i=>i.relative)}},ou=(e,o,t)=>k0("successors",e,o,t),ru=(e,o,t)=>k0("predecessors",e,o,t),X5=(e,o,t)=>{let r=ci+e.width;if(t==="up"||t==="down"){let l=oa+e.height,s=e.x,c=e.x+e.width;if(o.every(m=>m.x+m.width<s||m.x>c))return{x:0,y:l*(t==="up"?-1:1)}}else if(t==="right"||t==="left"){let l=e.y,s=e.y+e.height;if(o.every(c=>c.y+c.height<l||c.y>s))return{x:(ci+e.width)*(t==="left"?-1:1),y:0}}if(t==="up"||t==="down"){let l=oa+e.height,s=(o.length===0,l),c=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*r:o.length/2*r*-1;return t==="up"?{x:c,y:s*-1}:{x:c,y:s}}let n=oa+e.height,i=(o.length===0,ci+e.width),a=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*n:o.length/2*n*-1;return t==="left"?{x:i*-1,y:a}:{x:i,y:a}},$5=(e,o,t,r)=>{let n=ou(e,o,r),i=ru(e,o,r),a=X5(e,[...n,...i],r),l=Gt({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});ln($n(l),"not an ExcalidrawFlowchartNodeElement");let s=M0(e,l,o,r,t);return{nextNode:l,bindingArrow:s}},j5=(e,o,t,r,n)=>{let i=[];for(let a=0;a<n;a++){let l,s;if(r==="left"||r==="right"){let d=oa*(n-1)+n*e.height,p=e.y+e.height/2-d/2,u=ci+e.width;r==="left"&&(u*=-1),l=e.x+u;let h=(oa+e.height)*a;s=p+h}else{let d=ci*(n-1)+n*e.width,p=e.x+e.width/2-d/2,u=oa+e.height;r==="up"&&(u*=-1),s=e.y+u;let h=(ci+e.width)*a;l=p+h}let c=Gt({type:e.type,x:l,y:s,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});ln($n(c),"not an ExcalidrawFlowchartNodeElement");let m=M0(e,c,o,r,t);i.push(c),i.push(m)}return i},M0=(e,o,t,r,n)=>{let i,a;switch(r){case"up":{i=e.x+e.width/2,a=e.y-6;break}case"down":{i=e.x+e.width/2,a=e.y+e.height+6;break}case"right":{i=e.x+e.width+6,a=e.y+e.height/2;break}case"left":{i=e.x-6,a=e.y+e.height/2;break}}let s,c;switch(r){case"up":{s=o.x+o.width/2-i,c=o.y+o.height-a+6;break}case"down":{s=o.x+o.width/2-i,c=o.y-a-6;break}case"right":{s=o.x-i-6,c=o.y-a+o.height/2;break}case"left":{s=o.x+o.width-i+6,c=o.y-a+o.height/2;break}}let m=ji({type:"arrow",x:i,y:a,startArrowhead:null,endArrowhead:n.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[M(0,0),M(s,c)],elbowed:!0});Yo(m,e,"start",t),Yo(m,o,"end",t);let d=new Map;d.set(e.id,e),d.set(o.id,o),d.set(m.id,m),j.movePoints(m,[{index:1,point:m.points[1]}]);let p=ac(m,sn(new Map([...t.entries(),[e.id,e],[o.id,o],[m.id,m]])),{points:m.points});return{...m,...p}},Nc=class{constructor(){I(this,"isExploring",!1);I(this,"sameLevelNodes",[]);I(this,"sameLevelIndex",0);I(this,"direction",null);I(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(o,t,r){if(!Xn(o))return null;if(r!==this.direction&&this.clear(),this.visitedNodes.has(o.id)||this.visitedNodes.add(o.id),this.isExploring&&r===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let n=[...ou(o,t,r),...ru(o,t,r)];if(n.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=n,this.direction=r,this.visitedNodes.add(n[0].id),n[0].id;if(r===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(o.id);let a=["up","right","down","left"].filter(l=>l!==r).map(l=>[...ou(o,t,l),...ru(o,t,l)]).flat().filter(l=>!this.visitedNodes.has(l.id));for(let l of a)if(!this.visitedNodes.has(l.id))return this.visitedNodes.add(l.id),this.isExploring=!0,this.direction=r,l.id}return null}},Oc=class{constructor(){I(this,"isCreatingChart",!1);I(this,"numberOfNodes",0);I(this,"direction","right");I(this,"pendingNodes",null)}createNodes(o,t,r,n){if(n!==this.direction){let{nextNode:i,bindingArrow:a}=$5(o,t,r,n);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=n,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=j5(o,t,r,n,this.numberOfNodes);this.isCreatingChart=!0,this.direction=n,this.pendingNodes=i}if(o.frameId){let i=t.get(o.frameId);ln(i&&D1(i),"not an ExcalidrawFrameElement"),i&&this.pendingNodes.every(a=>hb([a],i,t)||lc(a,i,t))&&(this.pendingNodes=this.pendingNodes.map(a=>B(a,{frameId:o.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},L0=(e,o)=>{for(let[,t]of o)if(t.type==="arrow"&&(t.startBinding?.elementId===e.id||t.endBinding?.elementId===e.id))return!0;return!1};var A0=(e,o,t,r,n,i,a,l,s,c,m,d)=>{if(t.length===1){let[p]=t;if(o==="rotation")ee(p)||(q5(p,r,n,s,c,i),at(p,r));else{if(Z(p)&&o)return J5(e,p,r,o,a,s,c),at(p,r),!0;if(o){let u=t[0].id,h=r.get(u),b=e.get(u);if(h&&b){let{nextWidth:x,nextHeight:E}=oT(h,b,r,e,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});di(x,E,h,b,r,e,o,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a})}}}return!0}else if(t.length>1){if(o==="rotation")return Q5(e,t,r,n,s,c,i,m,d),!0;if(o){let{nextWidth:p,nextHeight:u,flipByX:h,flipByY:b,originalBoundingBox:x}=rT(t,e,r,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});return au(t,r,o,n,e,{shouldResizeFromCenter:a,shouldMaintainAspectRatio:l,flipByX:h,flipByY:b,nextWidth:p,nextHeight:u,originalBoundingBox:x}),!0}}return!1},q5=(e,o,t,r,n,i)=>{let[a,l,s,c]=We(e,o),m=(a+s)/2,d=(l+c)/2,p;ne(e)?p=0:(p=5*Math.PI/2+Math.atan2(n-d,r-m),i&&(p=p+Qa/2,p=p-p%Qa),p=al(p));let u=Dr(e);if(B(e,{angle:p}),u){let h=t.getElement(u);h&&!Re(e)&&B(h,{angle:p})}},Bc=(e,o,t,r)=>ae(e)||Cp(e)?{points:Ep(0,o,Ep(1,t,e.points,r),r)}:{},iu=(e,o,t)=>{let r=e.width;if(Be(e)){let a=_t(e,o);a&&(r=Gi(a,e))}let i=e.fontSize*(t/r);return i<Rs?null:{size:i}},J5=(e,o,t,r,n,i,a)=>{let[l,s,c,m,d,p]=We(o,t),[u,h]=ce(M(i,a),M(d,p),-o.angle),b=0,x=0;r!=="e"&&r!=="w"&&(r.includes("e")&&(b=(u-l)/(c-l)),r.includes("w")&&(b=(c-u)/(c-l)),r.includes("n")&&(x=(m-h)/(m-s)),r.includes("s")&&(x=(h-s)/(m-s)));let E=Math.max(b,x);if(E>0){let w=o.width*E,y=o.height*E,v=iu(o,t,w);if(v===null)return;let C=[l,s],S=[c,m],_=[d,p],L=M(l,s);if(["n","w","nw"].includes(r)&&(L=M(S[0]-Math.abs(w),S[1]-Math.abs(y))),r==="ne"){let H=[C[0],S[1]];L=M(H[0],H[1]-Math.abs(y))}if(r==="sw"){let H=[S[0],C[1]];L=M(H[0]-Math.abs(w),H[1])}["s","n"].includes(r)&&(L[0]=_[0]-w/2),["e","w"].includes(r)&&(L[1]=_[1]-y/2),n&&(L[0]=_[0]-Math.abs(w)/2,L[1]=_[1]-Math.abs(y)/2);let N=o.angle,P=ce(L,M(d,p),N),F=M(L[0]+Math.abs(w)/2,L[1]+Math.abs(y)/2),K=ce(F,M(d,p),N);L=ce(P,K,-N);let[U,q]=L;B(o,{fontSize:v.size,width:w,height:y,x:U,y:q})}if(r==="e"||r==="w"){let w=e.get(o.id),[y,v,C,S]=Xi(w,w.width,w.height,!0),_=M(y,v),L=M(C,S),N=bp(_,L),P=ce(M(i,a),N,-w.angle),[F,,K]=Xi(o,o.width,o.height,!0),U=K-F,q=L[0]-_[0],H=Fi(qe({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight),G=q/U;r.includes("e")&&(G=(P[0]-_[0])/U),r.includes("w")&&(G=(L[0]-P[0])/U);let V=o.width*G<H?H:o.width*G,ie=Hi(o.originalText,qe(o),Math.abs(V)),$=Ht(ie,qe(o),o.lineHeight),se=$.height,[be,Te,ot,jt]=Xi(w,V,se,!0),Fo=ot-be,er=jt-Te,qt=[..._];["n","w","nw"].includes(r)&&(qt=[L[0]-Math.abs(Fo),_[1]]);let tr=w.angle,Zr=ce(qt,N,tr),Jt=M(qt[0]+Math.abs(Fo)/2,qt[1]+Math.abs(er)/2),Xr=ce(Jt,N,tr);qt=ce(Zr,Xr,-tr);let mo={width:Math.abs(V),height:Math.abs($.height),x:qt[0],y:qt[1],text:ie,autoResize:!1};B(o,mo)}},Q5=(e,o,t,r,n,i,a,l,s)=>{let c=5*Math.PI/2+Math.atan2(i-s,n-l);a&&(c+=Qa/2,c-=c%Qa);for(let m of o)if(!ne(m)){let[d,p,u,h]=We(m,t),b=(d+u)/2,x=(p+h)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=ce(M(b,x),M(l,s),c+E-m.angle);ee(m)?B(m,{points:mb(m,t)}):B(m,{x:m.x+(w-b),y:m.y+(y-x),angle:al(c+E)},!1),at(m,t,{simultaneouslyUpdated:o});let v=ge(m,t);v&&!Re(m)&&B(v,{x:v.x+(w-b),y:v.y+(y-x),angle:al(c+E)},!1)}r.triggerUpdate()},_0=(e,o,t,r,n)=>{let[i,a,l,s]=o.length===1?We(o[0],t):ye(o),c=(i+l)/2,m=(a+s)/2,d=o.length===1?o[0].angle:0;switch([r,n]=ce(M(r,n),M(c,m),-d),e){case"n":return ce(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return ce(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return ce(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return ce(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return ce(M(r-i,n-a),M(0,0),d);case"ne":return ce(M(r-l,n-a),M(0,0),d);case"sw":return ce(M(r-i,n-s),M(0,0),d);case"se":return ce(M(r-l,n-s),M(0,0),d);default:return[0,0]}},D0=(e,o)=>{let[,[t,r]]=o.points;return e==="nw"&&(t<0||r<0)||e==="ne"&&t>=0||e==="sw"&&t<=0||e==="se"&&(t>0||r>0)?"end":"origin"},eT=(e,o,t)=>{if(t)return"center";if(o)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},tT=(e,o,t,r,n,i,a,l,s)=>{let c=eT(a,l,s),[m,d]=e;switch(c){case"top-left":return{x:m+(o-r)/2+(r-o)/2*Math.cos(i)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(r-o)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"top-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(o-r)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"bottom-left":return{x:m+(o-r)/2*(1-Math.cos(i))+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(r-o)/2*Math.sin(i)};case"bottom-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(o-r)/2*Math.sin(i)};case"center":return{x:m-(r-o)/2,y:d-(n-t)/2};case"east-side":return{x:m+(o-r)/2*(Math.cos(i)+1),y:d+(o-r)/2*Math.sin(i)+(t-n)/2};case"west-side":return{x:m+(o-r)/2*(1-Math.cos(i)),y:d+(r-o)/2*Math.sin(i)+(t-n)/2};case"north-side":return{x:m+(o-r)/2+(t-n)/2*Math.sin(i),y:d+(n-t)/2*(Math.cos(i)-1)};case"south-side":return{x:m+(o-r)/2+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)}}},di=(e,o,t,r,n,i,a,{shouldInformMutation:l=!0,shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let m={},d=ge(t,n);if(d){let b=i.get(d.id);if(b&&(m={fontSize:b.fontSize}),s){let x={...t,width:e,height:o},E=iu(d,n,Gi(x,d));if(E===null)return;m={fontSize:E.size}}else{let x=Qs(qe(d),d.lineHeight),E=ec(d.fontSize,d.lineHeight);e=Math.max(e,x),o=Math.max(o,E)}}let p=Bc(r,e,o,!0),u=M(r.x,r.y);if(ae(r)){let[b,x]=Vb(r,i);u=M(b,x)}let h=tT(u,r.width,r.height,e,o,r.angle,a,s,c);if(ae(r)&&p.points){let b=r.x-u[0],x=r.y-u[1];h.x+=b,h.y+=x;let E=p.points[0][0],w=p.points[0][1];h.x+=E,h.y+=w,p.points=p.points.map(y=>M(y[0]-E,y[1]-w))}if(e<0&&(h.x=h.x+e),o<0&&(h.y=h.y+o),"scale"in t&&"scale"in r&&B(t,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(o)||r.scale[1])*r.scale[1]]}),Re(t)&&d&&s){let b=e/t.width*d.fontSize;if(b<Rs)return;m.fontSize=b}if(e!==0&&o!==0&&Number.isFinite(h.x)&&Number.isFinite(h.y)){let b={...h,width:Math.abs(e),height:Math.abs(o),...p};B(t,b,l),at(t,n,{newSize:{width:e,height:o}}),d&&m!=null&&B(d,{fontSize:m.fontSize}),hl(t,n,a,s)}},oT=(e,o,t,r,n,i,a,{shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:s=!1}={})=>{let[c,m,d,p]=Xi(o,o.width,o.height,!0),u=M(c,m),h=M(d,p),b=bp(u,h),x=ce(M(i,a),b,-o.angle),[E,w,y,v]=Xi(e,e.width,e.height,!0),C=y-E,S=v-w,_=h[0]-u[0],L=h[1]-u[1],N=_/C,P=L/S;n.includes("e")&&(N=(x[0]-u[0])/C),n.includes("s")&&(P=(x[1]-u[1])/S),n.includes("w")&&(N=(h[0]-x[0])/C),n.includes("n")&&(P=(h[1]-x[1])/S);let F=e.width*N,K=e.height*P;if(s&&(F=2*F-o.width,K=2*K-o.height),l){let U=Math.abs(F)/o.width,q=Math.abs(K)/o.height;if(n.length===1&&(K*=U,F*=q),n.length===2){let H=Math.max(U,q);F=o.width*H*Math.sign(F),K=o.height*H*Math.sign(K)}}return{nextWidth:F,nextHeight:K}},rT=(e,o,t,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(U=>o.get(U.id)),c=s.reduce((U,q)=>{if(!ae(q))return U;let H=Dr(q);if(!H)return U;let G=o.get(H)??null;return Be(G)?[...U,{...G,...j.getBoundTextElementPosition(q,G,t)}]:U},[]),m=Dt(s.map(U=>U).concat(c)),{minX:d,minY:p,maxX:u,maxY:h,midX:b,midY:x}=m,E=u-d,w=h-p,y={ne:[d,h],se:[d,p],sw:[u,p],nw:[u,h],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,h],s:[d+E/2,p]},[v,C]=l?[b,x]:y[r],S=l?2:1,_=Math.max(Math.abs(n-v)/E||0,Math.abs(i-C)/w||0)*S,L=r.includes("e")||r.includes("w")?Math.abs(n-v)*S:E,N=r.includes("n")||r.includes("s")?Math.abs(i-C)*S:w;a&&(L=E*_*Math.sign(n-v),N=w*_*Math.sign(i-C));let P={ne:[n<v,i>C],se:[n<v,i<C],sw:[n>v,i<C],nw:[n>v,i>C],e:[n<v,!1],w:[n>v,!1],n:[!1,i>C],s:[!1,i<C]},[F,K]=P[r].map(U=>U);return{originalBoundingBox:m,nextWidth:L,nextHeight:N,flipByX:F,flipByY:K}},au=(e,o,t,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1,flipByX:l=!1,flipByY:s=!1,nextHeight:c,nextWidth:m,originalBoundingBox:d}={})=>{if(m===void 0&&c===void 0&&l===void 0&&s===void 0||c===0||m===0)return;n||(n=o);let p=e.reduce((S,_)=>{let L=n.get(_.id);return L&&S.push({orig:L,latest:_}),S},[]),u;if(d)u=d;else{let S=p.reduce((_,{orig:L})=>{if(!ae(L))return _;let N=Dr(L);if(!N)return _;let P=n.get(N)??null;return Be(P)?[..._,{...P,...j.getBoundTextElementPosition(L,P,o)}]:_},[]);u=Dt(p.map(({orig:_})=>_).concat(S))}let{minX:h,minY:b,maxX:x,maxY:E,midX:w,midY:y}=u,v=x-h,C=E-b;if(m===void 0&&c===void 0&&(m=v,c=C),i&&(m===void 0?m=c*(v/C):c===void 0?c=m*(C/v):Math.abs(m/c-v/C)>.001&&(m=c*(v/C))),m&&c){let S=t.includes("e")||t.includes("w")?Math.abs(m)/v:1,_=t.includes("n")||t.includes("s")?Math.abs(c)/C:1,L;t.length===1?L=t.includes("e")||t.includes("w")?S:_:L=Math.max(Math.abs(m)/v||0,Math.abs(c)/C||0);let N={ne:[h,E],se:[h,b],sw:[x,b],nw:[x,E],e:[h,b+C/2],w:[x,b+C/2],n:[h+v/2,E],s:[h+v/2,b]},[P,F]=a?[w,y]:N[t],K=i||p.some(V=>V.latest.angle!==0||Z(V.latest)||lr(V.latest));K&&(S=L,_=L);let[U,q]=[l?-1:1,s?-1:1],H=[];for(let{orig:V,latest:ie}of p){if(Z(V)&&Be(V))continue;let $=V.width*S,se=V.height*_,be=al(V.angle*U*q),Te=ae(V)||Cp(V),ot=V.x-P,jt=V.y-F,Fo=l&&!Te?$:0,er=s&&!Te?se:0,qt=P+U*(ot*S+Fo),tr=F+q*(jt*_+er),Zr=Bc(V,$*U,se*q,!1),Jt={x:qt,y:tr,width:$,height:se,angle:be,...Zr};if(ee(V)&&(V.startBinding&&(Jt.startBinding={...V.startBinding,fixedPoint:[l?-V.startBinding.fixedPoint[0]+1:V.startBinding.fixedPoint[0],s?-V.startBinding.fixedPoint[1]+1:V.startBinding.fixedPoint[1]]}),V.endBinding&&(Jt.endBinding={...V.endBinding,fixedPoint:[l?-V.endBinding.fixedPoint[0]+1:V.endBinding.fixedPoint[0],s?-V.endBinding.fixedPoint[1]+1:V.endBinding.fixedPoint[1]]}),V.fixedSegments&&Zr.points&&(Jt.fixedSegments=V.fixedSegments.map(mo=>({...mo,start:Zr.points[mo.index-1],end:Zr.points[mo.index]})))),he(V)&&(Jt.scale=[V.scale[0]*U,V.scale[1]*q]),Z(V)){let mo=iu(V,o,$);if(!mo)return;Jt.fontSize=mo.size}let Xr=n.get(Dr(V)??"");if(Xr)if(K){let mo=Xr.fontSize*L;if(mo<Rs)return;Jt.boundTextFontSize=mo}else Jt.boundTextFontSize=Xr.fontSize;H.push({element:ie,update:Jt})}let G=H.map(({element:V})=>V);for(let{element:V,update:{boundTextFontSize:ie,...$}}of H){let{width:se,height:be,angle:Te}=$;B(V,$,!1,{isDragging:!0}),at(V,o,{simultaneouslyUpdated:G,newSize:{width:se,height:be}});let ot=ge(V,o);ot&&ie&&(B(ot,{fontSize:ie,angle:ae(V)?void 0:Te},!1),hl(V,o,t,!0))}r.triggerUpdate()}};var su=(e,o,t)=>o>=e[0]&&o<=e[0]+e[2]&&t>=e[1]&&t<=e[1]+e[3],nT=(e,o,t,r,n,i,a,l)=>{if(!t.selectedElementIds[e.id])return!1;let{rotation:s,...c}=Pc(e,i,o,a,si(l));if(s&&su(s,r,n))return"rotation";let m=Object.keys(c).filter(d=>{let p=c[d];return p?su(p,r,n):!1});if(m.length>0)return m[0];if(Dc(l)){let[d,p,u,h,b,x]=We(e,o);if(!(ae(e)&&e.points.length<=2)){let E=he(e)?0:Os/i.value,w=Os/i.value,y=P0(M(d-E,p-E),M(u+E,h+E),M(b,x),e.angle);for(let[v,C]of Object.entries(y))if(xp(M(r,n),C,w))return v}}return!1},cu=(e,o,t,r,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let m=nT(c,a,o,t,r,n,i,l);return m?{element:c,transformHandleType:m}:null},null),du=([e,o,t,r],n,i,a,l,s)=>{let c=kl([e,o,t,r,(e+t)/2,(o+r)/2],0,a,l,si(s)),m=Object.keys(c).find(d=>{let p=c[d];return p&&su(p,n,i)});if(m)return m;if(Dc(s)){let d=(e+t)/2,p=(o+r)/2,u=Os/a.value,h=P0(M(e-u,o-u),M(t+u,r+u),M(d,p),0);for(let[b,x]of Object.entries(h))if(xp(M(n,i),x,u))return b}return!1},lu=["ns","nesw","ew","nwse"],iT=(e,o)=>{let t=lu.indexOf(e);if(t>=0){let r=Math.round(o/(Math.PI/4));e=lu[(t+r)%lu.length]}return e},mu=e=>{let{element:o,transformHandleType:t}=e,r=o&&Math.sign(o.height)*Math.sign(o.width)===-1,n=null;switch(t){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":r?n="nesw":n="nwse";break;case"ne":case"sw":r?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&o&&(n=iT(n,o.angle)),n?`${n}-resize`:""},P0=([e,o],[t,r],n,i)=>{let a=ce(M(e,o),n,i),l=ce(M(t,o),n,i),s=ce(M(e,r),n,i),c=ce(M(t,r),n,i);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}};var N0=(e,o,t,r,n,i)=>{if(o.length===1&&ee(o[0])&&(o[0].startBinding||o[0].endBinding))return;let a=o.filter(d=>{if(ee(d)&&d.startBinding&&d.endBinding){let p=o.find(h=>h.id===d.startBinding?.elementId),u=o.find(h=>h.id===d.endBinding?.elementId);return p&&u}return!0}),l=new Set(a),s=a.filter(d=>ne(d)).map(d=>d.id);if(s.length>0)for(let d of r.getNonDeletedElements())d.frameId!==null&&s.includes(d.frameId)&&l.add(d);let c=[];for(let d of l){let p=e.originalElements.get(d.id);if(!p)return;c.push(p)}let m=aT(ye(c),t,n,i);l.forEach(d=>{if(R0(e,d,m),!Re(d)){let p=ge(d,r.getNonDeletedElementsMap());p&&R0(e,p,m),at(d,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})}})},aT=(e,o,t,r)=>{let[n,i]=e,a=n+o.x+t.x,l=i+o.y+t.y;if(t.x===0||t.y===0){let[s,c]=ut(n+o.x,i+o.y,r);t.x===0&&(a=s),t.y===0&&(l=c)}return{x:a-n,y:l-i}},R0=(e,o,t)=>{let r=e.originalElements.get(o.id)??o,n=r.x+t.x,i=r.y+t.y;B(o,{x:n,y:i})},O0=(e,o,t)=>{let[r,n]=ye(e);return[o-r,t-n]},pu=({newElement:e,elementType:o,originX:t,originY:r,x:n,y:i,width:a,height:l,shouldMaintainAspectRatio:s,shouldResizeFromCenter:c,zoom:m,widthAspectRatio:d=null,originOffset:p=null,informMutation:u=!0})=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-r)>Math.abs(n-t)?{width:a,height:l}=Mp(o,l,n<t?-a:a):{width:a,height:l}=Mp(o,a,i<r?-l:l),l<0&&(l=-l)));let h=n<t?t-a:t,b=i<r?r-l:r;c&&(a+=a,l+=l,h=t-a/2,b=r-l/2);let x=null;if(Z(e)){l=e.height;let E=Fi(qe({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,E),Math.abs(n-t)>Hf/m&&(x={autoResize:!1}),b=r,c&&(h=t-a/2)}if(a!==0&&l!==0){let E=null;he(e)&&(E={initialWidth:a,initialHeight:l}),B(e,{x:h+(p?.x??0),y:b+(p?.y??0),width:a,height:l,...x,...E},u)}};import{atom as Ae,createStore as lT}from"jotai";import{createIsolation as sT}from"jotai-scope";var B0=sT();var{useAtom:ve,useSetAtom:hn,useAtomValue:zc,useStore:kA}=B0,z0=B0.Provider,St=lT();var cT=kf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-SBO6ZHT2.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var dT=85,mr={code:"en",label:"English"},na=[mr,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>e0[e.code]>=dT).sort((e,o)=>e.label>o.label?1:-1)],Hc="__test__";He()&&na.unshift({code:Hc,label:"test language"},{code:`${Hc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ra=mr,Fc={},Uc=async e=>{if(ra=e,document.documentElement.dir=ra.rtl?"rtl":"ltr",document.documentElement.lang=ra.code,e.code.startsWith(Hc))Fc={};else try{Fc=await cT(`./locales/${ra.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Fc=Wp}St.set(H0,e.code)},Or=()=>ra,F0=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},f=(e,o,t)=>{if(ra.code.startsWith(Hc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=F0(Fc,r)||F0(Wp,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(k.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},H0=Ae(mr.code),pt=()=>{let e=zc(H0);return{t:f,langCode:e}};var rt=class e{constructor(o,t){this.deleted=o;this.inserted=t}static create(o,t,r,n){let i=r&&n!=="inserted"?r(o):o,a=r&&n!=="deleted"?r(t):t;return new e(i,a)}static calculate(o,t,r,n){if(o===t)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",o,t))i[c]=o[c],a[c]=t[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,r)}static empty(){return new e({},{})}static isEmpty(o){return!Object.keys(o.deleted).length&&!Object.keys(o.inserted).length}static mergeObjects(o,t,r){let n={...o};for(let i of Object.keys(r))delete n[i];return{...n,...t}}static mergeArrays(o,t,r,n){return Object.values(e.mergeObjects(ir(o??[],n),ir(t??[],n),ir(r??[],n)))}static diffObjects(o,t,r,n){if(!(!o[r]&&!t[r])&&(typeof o[r]=="object"||typeof t[r]=="object")){let i=o[r]??{},a=t[r]??{},l=e.getLeftDifferences(i,a).reduce((c,m)=>(c[m]=n(i[m]),c),{}),s=e.getRightDifferences(i,a).reduce((c,m)=>(c[m]=n(a[m]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(o,r,l),Reflect.set(t,r,s)):(Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r))}}static diffArrays(o,t,r,n){if(!(!o[r]&&!t[r])&&(Array.isArray(o[r])||Array.isArray(t[r]))){let i=Array.isArray(o[r])?o[r]:[],a=Array.isArray(t[r])?t[r]:[],l=ir(e.getLeftDifferences(ir(i,n),ir(a,n))),s=ir(e.getRightDifferences(ir(i,n),ir(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(d=>l[n?n(d):String(d)]),m=a.filter(d=>s[n?n(d):String(d)]);Reflect.set(o,r,c),Reflect.set(t,r,m)}else Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r)}}static isLeftDifferent(o,t,r=!1){return!!this.distinctKeysIterator("left",o,t,r).next().value}static isRightDifferent(o,t,r=!1){return!!this.distinctKeysIterator("right",o,t,r).next().value}static getLeftDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("left",o,t,r))}static getRightDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("right",o,t,r))}static*distinctKeysIterator(o,t,r,n=!1){if(t===r)return;let i=[];o==="left"?i=Object.keys(t):o==="right"?i=Object.keys(r):o==="full"?i=Array.from(new Set([...Object.keys(t),...Object.keys(r)])):Kn(o,`Unknown distinctKeysIterator's join param "${o}"`,!0);for(let a of i){let l=t[a],s=r[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&Je(l,s))continue;yield a}}}},Ml=class e{constructor(o){this.delta=o}static calculate(o,t){let r=rt.calculate(o,t,void 0,e.postProcess);return new e(r)}static empty(){return new e(rt.create({},{}))}inverse(){let o=rt.create(this.delta.inserted,this.delta.deleted);return new e(o)}applyTo(o,t){try{let{selectedElementIds:r={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,m=rt.mergeObjects(o.selectedElementIds,i,r),d=rt.mergeObjects(o.selectedGroupIds,a,n),p=l&&t.has(l)?new j(t.get(l)):null,u=s&&t.has(s)?new j(t.get(s)):null,h={...o,...c,selectedElementIds:m,selectedGroupIds:d,selectedLinearElement:typeof l<"u"?p:o.selectedLinearElement,editingLinearElement:typeof s<"u"?u:o.editingLinearElement},b=this.filterInvisibleChanges(o,h,t);return[h,b]}catch(r){if(console.error("Couldn't apply appstate change",r),mt()||He())throw r;return[o,!1]}}isEmpty(){return rt.isEmpty(this.delta)}static postProcess(o,t){try{rt.diffObjects(o,t,"selectedElementIds",r=>!0),rt.diffObjects(o,t,"selectedGroupIds",r=>r??!1)}catch(r){if(console.error("Couldn't postprocess appstate change deltas."),mt()||He())throw r}finally{return[o,t]}}filterInvisibleChanges(o,t,r){let n=Al(o),i=Al(t),a=rt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=rt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=rt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),m=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(m=_b(r));for(let d of c)switch(d){case"selectedElementIds":t[d]=e.filterSelectedElements(t[d],r,s);break;case"selectedGroupIds":t[d]=e.filterSelectedGroups(t[d],m,s);break;case"croppingElementId":{let b=t[d],x=b&&r.get(b);x&&!x.isDeleted?s.value=!0:t[d]=null;break}case"editingGroupId":let p=t[d];p?m.has(p)?s.value=!0:t[d]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(d),h=t[u];if(!h)s.value=!0;else{let b=r.get(h.elementId);b&&!b.isDeleted?s.value=!0:t[u]=null}break;default:Kn(d,`Unknown ObservedElementsAppState's key "${d}"`,!0)}}return s.value}static convertToAppStateKey(o){switch(o){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(o,t,r){let n=Object.keys(o);if(!n.length)return r.value=!0,o;let i={...o};for(let a of n){let l=t.get(a);l&&!l.isDeleted?r.value=!0:delete i[a]}return i}static filterSelectedGroups(o,t,r){if(!Object.keys(o).length)return r.value=!0,o;let i={...o};for(let a of Object.keys(i))t.has(a)?r.value=!0:delete i[a];return i}static stripElementsProps(o){let{editingGroupId:t,selectedGroupIds:r,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,croppingElementId:l,...s}=o;return s}static stripStandaloneProps(o){let{name:t,viewBackgroundColor:r,...n}=o;return n}},_e=class _e{constructor(o,t,r){this.added=o;this.removed=t;this.updated=r}static create(o,t,r,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,l=new Map,s=new Map,c=[...o,...t,...r];for(let[m,d]of c)this.satisfiesAddition(d)?a.set(m,d):this.satisfiesRemoval(d)?l.set(m,d):s.set(m,d);i=new _e(a,l,s)}else i=new _e(o,t,r);return(mt()||He())&&(_e.validate(i,"added",this.satisfiesAddition),_e.validate(i,"removed",this.satisfiesRemoval),_e.validate(i,"updated",this.satisfiesUpdate)),i}static validate(o,t,r){for(let[n,i]of o[t].entries())if(!r(i))throw console.error(`Broken invariant for "${t}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(o,t){if(o===t)return _e.empty();let r=new Map,n=new Map,i=new Map;for(let a of o.values())if(!t.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},m=rt.create(s,c,_e.stripIrrelevantProps);n.set(a.id,m)}for(let a of t.values()){let l=o.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},m=rt.create(s,c,_e.stripIrrelevantProps);r.set(a.id,m);continue}if(l.versionNonce!==a.versionNonce){let s=rt.calculate(l,a,_e.stripIrrelevantProps,_e.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?r.set(a.id,s):n.set(a.id,s);continue}rt.isEmpty(s)||i.set(a.id,s)}}return _e.create(r,n,i)}static empty(){return _e.create(new Map,new Map,new Map)}inverse(){let o=i=>{let a=new Map;for(let[l,s]of i.entries())a.set(l,rt.create(s.inserted,s.deleted));return a},t=o(this.added),r=o(this.removed),n=o(this.updated);return _e.create(r,t,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(o){let t=l=>s=>{let c={};for(let m of Object.keys(s))switch(m){case"boundElements":c[m]=s[m];break;default:c[m]=l[m]}return c},r=l=>{let s=new Map;for(let[c,m]of l.entries()){let d=o.get(c);if(d){let p=rt.create(m.deleted,m.inserted,t(d),"inserted");s.set(c,p)}else s.set(c,m)}return s},n=r(this.added),i=r(this.removed),a=r(this.updated);return _e.create(n,i,a,{shouldRedistribute:!0})}applyTo(o,t){let r=sn(new Map(o)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=_e.createApplier(r,t,i),l=a(this.added),s=a(this.removed),c=a(this.updated),m=this.resolveConflicts(o,r);n=new Map([...l,...s,...c,...m])}catch(a){if(console.error("Couldn't apply elements change",a),mt()||He())throw a;return[o,!0]}try{_e.redrawTextBoundingBoxes(r,n),r=_e.reorderElements(r,n,i),_e.redrawBoundArrows(r,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),mt()||He())throw a}finally{return[r,i.containsVisibleDifference]}}static applyDelta(o,t,r={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=t.inserted;if(t.deleted.boundElements?.length||t.inserted.boundElements?.length){let a=rt.mergeArrays(o.boundElements,t.inserted.boundElements,t.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(he(o)){let a=t;(a.deleted.crop||a.inserted.crop)&&Object.assign(i,{crop:a.inserted.crop??null})}if(!r.containsVisibleDifference){let{index:a,...l}=i,s=_e.checkForVisibleDifference(o,l);r.containsVisibleDifference=s}return r.containsZindexDifference||(r.containsZindexDifference=t.deleted.index!==t.inserted.index),te(o,i)}static checkForVisibleDifference(o,t){return o.isDeleted&&t.isDeleted!==!1?!1:o.isDeleted&&t.isDeleted===!1||o.isDeleted===!1&&t.isDeleted?!0:rt.isRightDifferent(o,t)}resolveConflicts(o,t){let r=new Map,n=(c,m)=>{let d=t.get(c.id);if(!d)return;let p;o.get(c.id)===d?p=te(d,m):p=B(d,m),r.set(p.id,p),t.set(p.id,p)};for(let[c]of this.removed)_e.unbindAffected(o,t,c,n);for(let[c]of this.added)_e.rebindAffected(o,t,c,n);for(let[c]of Array.from(this.updated).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>db.has(p)))){let m=t.get(c);!m||m.isDeleted||_e.rebindAffected(o,t,c,n)}let i=new Map(Array.from(o).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=_e.calculate(i,r);for(let[c,m]of a)this.added.set(c,m);for(let[c,m]of l)this.removed.set(c,m);for(let[c,m]of s)this.updated.set(c,m);return r}static unbindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);fl.unbindAffected(t,i(),n),fl.unbindAffected(t,a(),n),bl.unbindAffected(t,i(),n),bl.unbindAffected(t,a(),n)}static rebindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);fl.unbindAffected(t,i(),n),fl.rebindAffected(t,a(),n),bl.unbindAffected(t,i(),(l,s)=>{Z(l)&&n(l,s)}),bl.rebindAffected(t,a(),n)}static redrawTextBoundingBoxes(o,t){let r=new Map;for(let n of t.values()){if(Be(n)){let{containerId:i}=n,a=i?o.get(i):void 0;a&&r.set(a.id,{container:a,boundText:n})}if(Tt(n)){let i=Dr(n),a=i?o.get(i):void 0;a&&r.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of r.values())n.isDeleted||i.isDeleted||Qe(i,n,o,!1)}static redrawBoundArrows(o,t){for(let r of t.values())!r.isDeleted&&Xn(r)&&at(r,o,{changedElements:t})}static reorderElements(o,t,r){if(!r.containsZindexDifference)return o;let n=Array.from(o.values()),i=gc([...n]),a=rt.getRightDifferences(n,i,!0).reduce((l,s)=>{let c=n[Number(s)];return c&&t.has(c.id)&&l.set(c.id,c),l},new Map);return!r.containsVisibleDifference&&a.size&&(r.containsVisibleDifference=!0),re(Ut(i,a))}static postProcess(o,t){try{rt.diffArrays(o,t,"boundElements",r=>r.id)}catch(r){if(console.error("Couldn't postprocess elements change deltas."),mt()||He())throw r}finally{return[o,t]}}static stripIrrelevantProps(o){let{id:t,updated:r,version:n,versionNonce:i,seed:a,...l}=o;return l}};I(_e,"satisfiesAddition",({deleted:o,inserted:t})=>o.isDeleted===!0&&!t.isDeleted),I(_e,"satisfiesRemoval",({deleted:o,inserted:t})=>!o.isDeleted&&t.isDeleted===!0),I(_e,"satisfiesUpdate",({deleted:o,inserted:t})=>!!o.isDeleted==!!t.isDeleted),I(_e,"createApplier",(o,t,r)=>{let n=_e.createGetter(o,t,r);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let m=_e.applyDelta(c,s,r);o.set(m.id,m),a.set(m.id,m)}return a},new Map)}),I(_e,"createGetter",(o,t,r)=>(n,i)=>{let a=o.get(n);return a||(a=t.get(n),a&&(r.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(r.containsVisibleDifference=!0))),a});var Ll=_e;var Pt=class{constructor(){I(this,"subscribers",[])}on(...o){let t=o.flat().filter(r=>typeof r=="function");return this.subscribers.push(...t),()=>this.off(t)}once(...o){let t=o.flat().filter(n=>typeof n=="function");t.push(()=>r());let r=this.on(...t);return r}off(...o){let t=o.flat();this.subscribers=this.subscribers.filter(r=>!t.includes(r))}trigger(...o){for(let t of this.subscribers)t(...o);return this}clear(){this.subscribers=[]}};var U0="__observedAppState",Al=e=>{let o={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null,croppingElementId:e.croppingElementId};return Reflect.defineProperty(o,U0,{value:!0,enumerable:!1}),o},mT=e=>!!Reflect.get(e,U0),A={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},uu=class{constructor(o,t){this.elementsChange=o;this.appStateChange=t}},Gc=class{constructor(){I(this,"onStoreIncrementEmitter",new Pt);I(this,"scheduledActions",new Set);I(this,"_snapshot",Vc.empty());I(this,"shouldCaptureIncrement",()=>{this.scheduleAction(A.IMMEDIATELY)});I(this,"shouldUpdateSnapshot",()=>{this.scheduleAction(A.NEVER)});I(this,"scheduleAction",o=>{this.scheduledActions.add(o),this.satisfiesScheduledActionsInvariant()});I(this,"commit",(o,t)=>{try{this.scheduledActions.has(A.IMMEDIATELY)?this.captureIncrement(o,t):this.scheduledActions.has(A.NEVER)&&this.updateSnapshot(o,t)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}});I(this,"captureIncrement",(o,t)=>{let r=this.snapshot,n=this.snapshot.maybeClone(o,t);if(r!==n){let i=n.meta.didElementsChange?Ll.calculate(r.elements,n.elements):Ll.empty(),a=n.meta.didAppStateChange?Ml.calculate(r.appState,n.appState):Ml.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new uu(i,a)),this.snapshot=n}});I(this,"updateSnapshot",(o,t)=>{let r=this.snapshot.maybeClone(o,t);this.snapshot!==r&&(this.snapshot=r)});I(this,"filterUncomittedElements",(o,t)=>{for(let[r,n]of o.entries()){if(!t.get(r))continue;let a=this.snapshot.elements.get(r);a?a.version<n.version&&t.set(r,a):t.delete(r)}return t});I(this,"clear",()=>{this.snapshot=Vc.empty(),this.scheduledActions=new Set});I(this,"satisfiesScheduledActionsInvariant",()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let o=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(o,this.scheduledActions.values()),mt()||He())throw new Error(o)}})}get snapshot(){return this._snapshot}set snapshot(o){this._snapshot=o}},Vc=class e{constructor(o,t,r={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=o;this.appState=t;this.meta=r}static empty(){return new e(new Map,Al(dr()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(o,t){let r=this.maybeCreateElementsSnapshot(o),n=this.maybeCreateAppStateSnapshot(t),i=!1,a=!1;return this.elements!==r&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(r,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(o){if(!o)return this.appState;let t=mT(o)?o:Al(o);return this.detectChangedAppState(t)?t:this.appState}detectChangedAppState(o){return!Je(this.appState,o,{selectedElementIds:Je,selectedGroupIds:Je})}maybeCreateElementsSnapshot(o){return o?this.detectChangedElements(o)?this.createElementsSnapshot(o):this.elements:this.elements}detectChangedElements(o){if(this.elements===o)return!1;if(this.elements.size!==o.size)return!0;let t=Array.from(o.keys());for(let r=t.length-1;r>=0;r--){let n=this.elements.get(t[r]),i=o.get(t[r]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(o){let t=new Map;for(let[r,n]of this.elements.entries())o.get(r)?t.set(r,n):t.set(r,te(n,{isDeleted:!0}));for(let[r,n]of o.entries()){let i=t.get(r);(!i||i&&i.versionNonce!==n.versionNonce)&&t.set(r,uo(n))}return t}};import pT from"clsx";import uT from"open-color";import kt from"react";import{Fragment as Ne,jsx as g,jsxs as O}from"react/jsx-runtime";var Zo=e=>"var(--icon-fill-color)",G0=e=>e===de.LIGHT?uT.white:"#1e1e1e",D=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:pT({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},W={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},u_=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("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"})]}),W),ia=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),W),V0=D(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),W),Y0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),W),W0=D(O("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),W),mi=D(O("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),aa=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),K0=D(O(Ne,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Z0=D(O(Ne,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),X0=D(O(Ne,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),h_=D(g("g",{fill:"currentColor",children:g("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),$0=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),_l=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),j0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),W),q0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),W),J0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),W),Q0=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),W),ex=D(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),tx=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),W),gn=D(O("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Yc=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),W),ox=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),rx=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),W),hu=D(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),gu=D(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),nx=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),W),ho=D(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),fu=D(O("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),me),Dl=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),Pl=D(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Rl=D(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),Wc=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),W),pi=D(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),la=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),ix=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),bu=D(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),Kc=D(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),ax=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),lx=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),W),sx=D(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Nl=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),cx=D("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}),dx=D("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}),sa=D(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),g_=D("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}),mx=D("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"),Zc=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),W),Xc=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),W),px=D("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}),f_=D("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}),b_=D("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}),ux=D("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"),x_=D("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"),xu=D(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Eu=D(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),hx=D("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}),gx=D(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),E_=D("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"),y_=D("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}),v_=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),W),w_=D(O(Ne,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),T_=D(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),fx=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),bx=O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),yu=D(bx,W),vu=D(bx,{...W,style:{transform:"rotate(180deg)"}}),wu=D(fx,W),Tu=D(fx,{...W,style:{transform:"rotate(180deg)"}}),Cu=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Iu=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Su=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),ku=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),xx=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ex=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Mu=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Lu=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),$c=D(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),W),C_=D("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"),I_=D("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"),Mo=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),S_=D("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_=D("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}),M_=D("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}),Au=kt.memo(({theme:e})=>D(O(Ne,{children:[g("path",{d:"M25 26H111V111H25",fill:Zo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Zo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Zo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Zo(e),strokeWidth:"2"}),O("g",{fill:G0(e),stroke:Zo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),_u=kt.memo(({theme:e})=>D(O(Ne,{children:[g("path",{d:"M25 26H111V111H25",fill:Zo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Zo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Zo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Zo(e),strokeWidth:"2"}),O("g",{fill:G0(e),stroke:Zo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),yx=D(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),vx=D(O(Ne,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),wx=D(O(Ne,{children:[O("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Tx=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Du=D(g(Ne,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Cx=D(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),Ix=D(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),L_=kt.memo(({theme:e})=>D(g("path",{d:"M6 10H34",stroke:Zo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Sx=D(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),W),kx=D(O("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),W),Mx=D(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),Lx=D(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),Ax=D(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),_x=D(O("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),me),Dx=D(O("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),W),Px=D(O("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),W),Rx=kt.memo(({flip:e=!1})=>D(O("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Nx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Ox=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Bx=kt.memo(({flip:e=!1})=>D(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),zx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Fx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Hx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Ux=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Gx=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Vx=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Yx=kt.memo(({flip:e=!1})=>D(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Wx=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Kx=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Zx=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Xx=D(g(Ne,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),ui=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),W),$x=D(g(Ne,{children:O("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),W),Ol=D(g(Ne,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),jc=D(O(Ne,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),jx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),W),qx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),W),Jx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),W),Qx=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),W)),eE=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),W)),tE=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),W)),qc=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),W),oE=D(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),A_=D(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Jc=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),W),Pu=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),W),ca=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),W),rE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),W),nE=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),__=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),W),D_=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),W),iE=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),W),aE=D(O(Ne,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),W),lE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),W),sE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),W),Bl=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),W),Qc=D(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),da=D(O("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),zl=D(O("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),ed=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),P_=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),R_=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),W),cE=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),W),ma=D(O("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),W),dE=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),W),mE=D(O("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),pE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),go=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),W),uE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),W),hE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),W),gE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),W),td=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),W),fE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),W),bE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),W),xE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),W),EE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),W),Ru=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),W),od=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),W),yE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),W),vE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),W),wE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),W),TE=D(O("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),W),CE=D(O("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...W,strokeWidth:1.5}),N_=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),W),IE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),W),SE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),W),kE=D(O("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),W),ME=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),W),LE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),W),AE=D(O("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),W),rd=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),W),_E=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),W),DE=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),W),Nu=D(O("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),W),nd=D(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),W);import PE from"clsx";import Bu,{useEffect as fT,useRef as RE,useState as bT}from"react";import hT from"react";import{jsx as Ou}from"react/jsx-runtime";var gT=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(hT.useRef(Date.now()).current%1600);return Ou("div",{className:`Spinner ${r}`,children:Ou("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Ou("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Mt=gT;import{jsx as Fl,jsxs as Hl}from"react/jsx-runtime";var Q=Bu.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=ht(),a=Bu.useRef(null);Bu.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=bT(!1),m=RE(!0),d=async u=>{let h="onClick"in r&&r.onClick?.(u);if(nn(h))try{c(!0),await h}catch(b){if(b instanceof Ji)console.warn(b);else throw b}finally{m.current&&c(!1)}};fT(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=RE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Hl("button",{className:PE("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Hl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Fl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Fl(Mt,{})]}),r.showAriaLabel&&Hl("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Fl(Mt,{})]}),r.children]})}return Hl("label",{className:PE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Fl("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Hl("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Fl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});Q.displayName="ToolButton";var id=[],z=e=>(id=id.concat(e),e);import{jsx as ET}from"react/jsx-runtime";var xT=(e,o,t)=>{let r=new Set(J(e.filter(m=>ne(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=ko(e,m);for(let p of d)if(!a.has(p.id)){if(Be(p)){let u=_t(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let d=Be(m)?_t(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):d?.frameId&&r.has(d?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&ee(u)&&(B(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding}),B(u,{points:u.points}))}),te(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,Be(m)||(n[m.id]=!0),te(m,{frameId:null})):Be(m)&&o.selectedElementIds[m.containerId]?te(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Ge(s,o.editingGroupId).filter(d=>!d.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let d=m[0];if(d){let p=d.groupIds.findIndex(h=>h===o.editingGroupId),u=d.groupIds[p+1];if(u){let h=Ge(s,u).filter(b=>!b.isDeleted);h.length>1&&(c=u,h.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...lt({selectedElementIds:n,editingGroupId:c},s,o,null)}}},NE=(e,o)=>{if(e.editingGroupId){let t=Ge(Ee(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ul=z({name:"deleteSelectedElements",label:"labels.delete",icon:ho,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=j.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?te(b,{isDeleted:!0}):b),h=NE(o,u);return{elements:u,appState:{...h,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return j.deletePoints(d,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:A.IMMEDIATELY}}let{elements:n,appState:i}=xT(e,o,r);return ic(n,n.filter(a=>a.isDeleted)),i=NE(i,n),{elements:n,appState:{...i,activeTool:Fe(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ze(Ee(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>ET(Q,{type:"button",icon:ho,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),visible:ze(Ee(e),o)})});var zu=(e,o)=>e.frameId===o||e.id===o,BE=(e,o,t)=>{let r=[],n=[],i=null,a=-1,l=re(t||J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(r=r.concat(n),n=[]),r.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return r},yT=e=>{let o=0;return e.reduce((t,r,n)=>(n>0&&e[n-1]!==r-1&&(o=++o),(t[o]||(t[o]=[])).push(r),t),[])},OE=(e,o,t,r)=>{if("containerId"in e&&e.containerId){let n=r.getElement(e.containerId);if(n)return t==="left"?Math.min(o.indexOf(n),o.indexOf(e)):Math.max(o.indexOf(n),o.indexOf(e))}else{let n=e.boundElements?.find(i=>i.type!=="arrow")?.id;if(n){let i=r.getElement(n);if(i)return t==="left"?Math.min(o.indexOf(i),o.indexOf(e)):Math.max(o.indexOf(i),o.indexOf(e))}}},vT=(e,o)=>{let t=-1,r=-1;return e.forEach((n,i)=>{zu(n,o)&&(t===-1&&(t=i),r=i)}),t===-1?[]:e.slice(t,r+1)},wT=(e,o,t,r,n,i)=>{let a=o[t],l=p=>p.isDeleted?!1:n?p.frameId===n:e.editingGroupId?p.groupIds.includes(e.editingGroupId):!0,s=r==="left"?kr(o,p=>l(p),Math.max(0,t-1)):wp(o,p=>l(p),t+1),c=o[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join("")===c?.groupIds.join(""))return OE(c,o,r,i)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(c.frameId||ne(c))){let p=vT(o,c.frameId||c.id);return r==="left"?o.indexOf(p[0]):o.indexOf(p[p.length-1])}if(!c.groupIds.length)return OE(c,o,r,i)??s;let m=e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1],d=Ge(o,m);return d.length?r==="left"?o.indexOf(d[0]):o.indexOf(d[d.length-1]):s},zE=(e,o)=>o.reduce((t,r)=>{let n=e[r];return t.set(n.id,n),t},new Map),FE=(e,o,t,r)=>{let n=BE(e,o),i=zE(e,n),a=yT(n);t==="right"&&(a=a.reverse());let l=new Set(n.filter(s=>ne(e[s])).map(s=>e[s].id));return a.forEach((s,c)=>{let m=s[0],d=s[s.length-1],p=t==="left"?m:d,u=s.some(y=>{let v=e[y];return v.frameId&&l.has(v.frameId)})?null:e[p]?.frameId,h=wT(o,e,p,t,u,r);if(h===-1||p===h)return;let b=t==="left"?e.slice(0,h):e.slice(0,m),x=e.slice(m,d+1),E=t==="left"?e.slice(h,m):e.slice(d+1,h+1),w=t==="left"?e.slice(d+1):e.slice(h+1);e=t==="left"?[...b,...x,...E,...w]:[...b,...E,...x,...w]}),Ut(e,i),e},HE=(e,o,t,r,n)=>{let i=BE(e,o,n),a=zE(e,i),l=[],s,c;if(t==="left"){if(r)s=wp(e,h=>zu(h,r));else if(o.editingGroupId){let h=Ge(e,o.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(r)c=kr(e,h=>zu(h,r));else if(o.editingGroupId){let h=Ge(e,o.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);let m=Array.from(a.values()),d=e.slice(0,s),p=e.slice(c+1),u=t==="left"?[...d,...m,...l,...p]:[...d,...l,...m,...p];return Ut(u,a),u};function UE(e,o,t,r){let n=re(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&ne(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ne(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let m=i.frameChildren.get(c.frameId)||[];m.push(c),i.frameChildren.set(c.frameId,m)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,m]of s)l=r(e,o,t,c,m);return r(l,o,t,null,i.regularElements)}var GE=(e,o,t)=>FE(e,o,"left",t),VE=(e,o,t)=>FE(e,o,"right",t),YE=(e,o)=>UE(e,o,"left",HE),WE=(e,o)=>UE(e,o,"right",HE);import{jsx as ad}from"react/jsx-runtime";var Fu=z({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:vu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:GE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>ad("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:vu})}),Hu=z({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:yu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:VE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>ad("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:yu})}),Uu=z({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Tu,trackEvent:{category:"element"},perform:(e,o)=>({elements:YE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Ho?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>ad("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Ho?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Tu})}),Gu=z({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:wu,trackEvent:{category:"element"},perform:(e,o)=>({elements:WE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Ho?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>ad("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Ho?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:wu})});var Vu=z({name:"selectAll",label:"labels.selectAll",icon:fE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Z(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...lt({editingGroupId:null,selectedElementIds:n},Ee(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ae(e[0])?new j(e[0]):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as CT}from"react/jsx-runtime";var Yu=z({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Dl,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.editingLinearElement)try{let a=j.duplicateSelectedPoints(o,r.scene.getNonDeletedElementsMap());return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{newElements:n,elementsWithClones:i}=li({type:"in-place",elements:e,idsOfElementsToDuplicate:re(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:a=>({x:a.x+np/2,y:a.y+np/2}),reverseOrder:!1});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Ut(i,re(n)),appState:{...o,...TT(n),...lt({editingGroupId:o.editingGroupId,selectedElementIds:pc(n).reduce((a,l)=>(Be(l)||(a[l.id]=!0),a),{})},Ee(i),o,null)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t})=>CT(Q,{type:"button",icon:Dl,title:`${f("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),visible:ze(Ee(e),o)})}),TT=e=>{let o=e.filter(ae);if(o.length===1){let t=o[0],r=t.boundElements?.map(i=>i.id)??[];if(e.every(i=>i.id===t.id||r.includes(i.id)))return{selectedLinearElement:new j(t)}}return{selectedLinearElement:null}};import{useEffect as ch,useMemo as J6,useRef as dh,useState as Q6}from"react";var IT=new Set(["command_palette","export"]),xe=(e,o,t,r)=>{try{if(typeof window>"u"||k.VITE_WORKER_ID||k.VITE_APP_ENABLE_TRACKING!=="true"||!IT.has(e)||He())return;k.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import LT from"clsx";import ST from"clsx";import{forwardRef as kT}from"react";import{jsx as MT}from"react/jsx-runtime";var ld=kT((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return MT("button",{type:"button",ref:o,title:t,"data-testid":n,className:ST(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as Wu,jsxs as AT}from"react/jsx-runtime";var Lo=e=>Wu("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?Wu(ld,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):AT("label",{className:LT({active:e.value===o.value}),title:o.text,children:[Wu("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as ud from"@radix-ui/react-popover";import h6 from"clsx";import{useRef as g6}from"react";import{jsx as _T}from"react/jsx-runtime";var sd=()=>_T("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as NT,useRef as OT}from"react";import{createPortal as BT}from"react-dom";import KE from"react";var Ku=KE.createContext(null),De=()=>KE.useContext(Ku);import{useState as DT,useLayoutEffect as ZE}from"react";var cd=e=>{let[o,t]=DT(null),r=Ce(),{theme:n}=De(),{container:i}=ht();return ZE(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===de.DARK))},[o,n,r.editor.isMobile,e?.className]),ZE(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as PT}from"react";function pa(e,o,t){PT(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,o,t])}import{useRef as RT}from"react";var fn=e=>{let o=RT(e);return Object.assign(o.current,e),o.current};import{jsx as zT}from"react/jsx-runtime";var bn=Ae(null),XE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=cd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=De(),a=xn(),l=st(),s=J(a,i),c=fn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=ht();NT(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),b=({clientX:S,clientY:_})=>{let L=h.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return Of(L[0],L[1],L[2])},x=({clientX:S,clientY:_,altKey:L})=>{p.style.top=`${_+20}px`,p.style.left=`${S+20}px`;let N=b({clientX:S,clientY:_});u&&c.onChange(r,N,c.selectedElements,{altKey:L}),p.style.background=N},E=()=>{c.onCancel()},w=(S,_)=>{c.onSelect(S,_)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),w(b(S),S)},C=S=>{S.key===T.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=OT(null);return pa(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?BT(zT("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as ua from"@radix-ui/react-popover";import GT from"clsx";import VT from"react";import FT from"react";import HT from"clsx";import{jsx as UT}from"react/jsx-runtime";var Et=FT.forwardRef(({children:e,padding:o,className:t,style:r},n)=>UT("div",{className:HT("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Zu,jsxs as YT}from"react/jsx-runtime";var dd=VT.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=Ce();return Zu(ua.Portal,{container:o,children:YT(ua.Content,{ref:c,className:GT("focus-visible-none",e),"data-prevent-outside-click":!0,side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!x1(document.activeElement)&&o.focus(),n()},children:[Zu(Et,{padding:3,style:r,children:t}),Zu(ua.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import WT from"clsx";import{useCallback as KT,useEffect as $u,useRef as qE,useState as ZT}from"react";var En=({palette:e,color:o})=>{for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Gl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Xu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),jE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Xu({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,Lf)},_o=Ae(null),$E=(e,o,t)=>(e*299+o*587+t*114)/1e3,ha=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),c=parseInt(l[1]),m=parseInt(l[2]);return $E(s,c,m)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return $E(t,r,n)<o};import{Fragment as XT,jsx as md,jsxs as JE}from"react/jsx-runtime";var QE=({color:e,onChange:o,label:t,colorPickerType:r})=>{let n=Ce(),[i,a]=ZT(e),[l,s]=ve(_o);$u(()=>{a(e)},[e]);let c=KT(h=>{let b=h.toLowerCase(),x=ey(b);x&&o(x),a(b)},[o]),m=qE(null),d=qE(null);$u(()=>{m.current&&m.current.focus()},[l]);let[p,u]=ve(bn);return $u(()=>()=>{u(null)},[u]),JE("div",{className:"color-picker__input-label",children:[md("div",{className:"color-picker__input-hash",children:"#"}),md("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==T.TAB&&(h.key===T.ESCAPE&&d.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&JE(XT,{children:[md("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),md("div",{ref:d,className:WT("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:b=>o(b),colorPickerType:r}),title:`${f("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${R("Alt")} `,children:lE})]})]})};import ay,{useEffect as ly,useState as p6}from"react";import qT from"clsx";import{useEffect as JT,useRef as QT}from"react";import{jsxs as jT}from"react/jsx-runtime";var $T=({color:e,keyLabel:o,isShade:t=!1})=>jT("div",{className:"color-picker__button__hotkey-label",style:{color:ha(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ga=$T;import{jsx as ju,jsxs as e6}from"react/jsx-runtime";var ty=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ve(_o),a=QT(null);return JT(()=>{a.current&&a.current.focus()},[o,n]),ju("div",{className:"color-picker-content--default",children:e.map((l,s)=>e6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:qT("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[ju("div",{className:"color-picker__button-outline"}),ju(ga,{color:l,keyLabel:s+1})]},s))})};import t6 from"clsx";import{useEffect as o6,useRef as r6}from"react";import{jsx as qu,jsxs as i6}from"react/jsx-runtime";var n6=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=En({color:o||"transparent",palette:e}),[a,l]=ve(_o),s=r6(null);return o6(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),qu("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=Gl[d],h=f(`colors.${c.replace(/\d+/,"")}`,null,"");return i6("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:t6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[qu("div",{className:"color-picker__button-outline"}),qu(ga,{color:p,keyLabel:u})]},c)})})},oy=n6;import{jsx as l6}from"react/jsx-runtime";var a6=({children:e})=>l6("div",{className:"color-picker__heading",children:e}),fa=a6;import s6 from"clsx";import{useEffect as c6,useRef as d6}from"react";import{jsx as Vl,jsxs as ry}from"react/jsx-runtime";var ny=({hex:e,onChange:o,palette:t})=>{let r=En({color:e||"transparent",palette:t}),[n,i]=ve(_o),a=d6(null);if(c6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return Vl("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>ry("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:s6("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[Vl("div",{className:"color-picker__button-outline"}),Vl(ga,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return ry("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Vl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Vl("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:f("colorPicker.noShades")})]})};var Ju=(e,o,t)=>{let r=Math.ceil(t/zn);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+zn;return n>=t?o%zn:n}case"ArrowUp":{let n=o-zn,i=n<0?zn*r+n:n;return i>=t?void 0:i}}},m6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(Gl.includes(e.key)){let l=Gl.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},iy=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let d=En({color:r,palette:t});if(e.key===T.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,v])=>(v&&w.push(y),w),[]),h=u.indexOf(o),b=e.shiftKey?-1:1,x=h+b>u.length-1?0:h+b<0?u.length-1:h+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(Io.black)),e.preventDefault(),e.stopPropagation(),!0}if(m6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=Ju(e.key,p,zn);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),h=u.indexOf(p),b=Ju(e.key,h,u.length);if(b!==void 0){let x=u[b],E=t[x];return n(Array.isArray(E)?E[s]:E),!0}}if(o==="custom"){let p=i.indexOf(r),u=Ju(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};import{jsx as hi,jsxs as pd}from"react/jsx-runtime";var sy=({color:e,onChange:o,label:t,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=ay.useState(()=>r==="canvasBackground"?[]:jE(n,r,i)),[d,p]=ve(_o),u=En({color:e,palette:i});ly(()=>{if(!d){let E=Xu({color:e,palette:i}),w=E&&!m.includes(e);p(w?"hex":E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[h,b]=p6(u?.shade??(r==="elementBackground"?Df:_f));ly(()=>{u?.shade!=null&&b(u.shade);let E=w=>{w.key===T.ALT&&s(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,s]);let x=ay.useRef(null);return hi("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:pd("div",{ref:x,onKeyDown:E=>{iy({event:E,activeColorPickerSection:d,palette:i,color:e,onChange:o,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&pd("div",{children:[hi(fa,{children:f("colorPicker.mostUsedCustomColors")}),hi(ty,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),pd("div",{children:[hi(fa,{children:f("colorPicker.colors")}),hi(oy,{color:e,label:t,palette:i,onChange:o,activeShade:h})]}),pd("div",{children:[hi(fa,{children:f("colorPicker.shades")}),hi(ny,{hex:e,onChange:o,palette:i})]}),l]})})};import u6 from"clsx";import{jsx as Qu}from"react/jsx-runtime";var cy=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=Ms),o==="elementBackground"&&(n=Ls),o==="canvasBackground"&&(n=As),r&&(n=r),n?Qu("div",{className:"color-picker__top-picks",children:n.map(i=>Qu("button",{className:u6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ha(i,ks)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Qu("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Xo,jsxs as eh}from"react/jsx-runtime";var dy=e=>{let o=new Option().style;return o.color=e,!!o.color},ey=e=>Wn(e)?e:dy(`#${e}`)?`#${e}`:dy(e)?e:null,f6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,updateData:a})=>{let{container:l}=ht(),[,s]=ve(_o),[c,m]=ve(bn),d=eh("div",{children:[Xo(fa,{children:f("colorPicker.hexCode")}),Xo(QE,{color:o,label:r,onChange:h=>{t(h)},colorPickerType:e})]}),p=g6(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return Xo(dd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:h=>{u(),h.preventDefault()},onPointerDownOutside:h=>{c&&h.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Xo(sy,{palette:i,color:o,onChange:h=>{t(h)},onEyeDropperToggle:h=>{m(b=>h?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):h===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:h=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},b6=({label:e,color:o,type:t})=>Xo(ud.Trigger,{type:"button",className:h6("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o,"has-outline":!ha(o,ks)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:Xo("div",{className:"color-picker__button-outline"})}),Yl=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,topPicks:a,updateData:l,appState:s})=>Xo("div",{children:eh("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Xo(cy,{activeColor:o,onChange:t,type:e,topPicks:a}),Xo(sd,{}),eh(ud.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Xo(b6,{color:o,label:r,type:e}),s.openPopup===e&&Xo(f6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as yy from"@radix-ui/react-popover";import H6,{useCallback as U6,useMemo as G6}from"react";import P6,{useMemo as yn,useState as R6,useRef as N6,useEffect as O6,useCallback as B6}from"react";import x6 from"clsx";import E6 from"react";import{jsx as y6,jsxs as v6}from"react/jsx-runtime";var hd=E6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>v6("div",{className:x6("QuickSearch__wrapper",e),children:[go,y6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import w6 from"clsx";import{Children as T6}from"react";import{jsx as my}from"react/jsx-runtime";var gd=({className:e,placeholder:o,children:t})=>{let r=!T6.count(t);return my("div",{className:w6("ScrollableList__wrapper",e),role:"menu",children:r?my("div",{className:"empty",children:o}):t})};import{jsx as C6,jsxs as I6}from"react/jsx-runtime";var py=({children:e,className:o="",style:t,title:r})=>I6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&C6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Wl=py;py.displayName="DropdownMenuGroup";import{useEffect as _6,useRef as D6}from"react";import{Fragment as k6,jsx as th,jsxs as M6}from"react/jsx-runtime";var S6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Ce();return M6(k6,{children:[o&&th("div",{className:"dropdown-menu-item__icon",children:o}),th("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&th("div",{className:"dropdown-menu-item__shortcut",children:t})]})},fd=S6;import L6,{useContext as A6}from"react";var oh=L6.createContext({}),bd=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
+ ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),xd=(e,o)=>{let t=A6(oh);return an(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as rh}from"react/jsx-runtime";var nh=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,...d})=>{let p=xd(m,c),u=D6(null);return _6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),rh("button",{...d,ref:u,value:o,onClick:p,className:bd(i,l,a),title:d.title??d["aria-label"],children:rh(fd,{textStyle:s,icon:e,shortcut:n,children:r})})};nh.displayName="DropdownMenuItem";var ba={GREEN:"green",RED:"red",BLUE:"blue"},Ed=({type:e=ba.BLUE,children:o})=>{let{theme:t}=pr(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===de.LIGHT?"1.5px solid white":"none"};switch(e){case ba.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ba.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ba.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return rh("div",{className:"DropDownMenuItemBadge",style:r,children:o})};Ed.displayName="DropdownMenuItemBadge";nh.Badge=Ed;var Yt=nh;var uy=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return o.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return t?.value&&i(t.value),!0;if(e.key===T.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===T.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Kl,jsxs as hy}from"react/jsx-runtime";var z6=e=>{switch(e){case Bt.Excalifont:case Bt.Virgil:return gn;case Bt.Nunito:case Bt.Helvetica:return Ol;case Bt["Lilita One"]:return $x;case Bt["Comic Shanns"]:case Bt.Cascadia:return jc;default:return Ol}},gy=P6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=ht(),{fonts:s}=st(),{showDeprecatedFonts:c}=ur(),[m,d]=R6(""),p=N6(null),u=yn(()=>Array.from(un.registered.entries()).filter(([L,{metadata:N}])=>!N.serverSide&&!N.fallback).map(([L,{metadata:N,fontFaces:P}])=>{let F={value:L,icon:z6(L),text:P[0]?.fontFace?.family??"Unknown"};return N.deprecated&&Object.assign(F,{deprecated:N.deprecated,badge:{type:ba.RED,placeholder:f("fontList.badge.old")}}),F}).sort((L,N)=>L.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),h=yn(()=>new Set(s.getSceneFamilies()),[e]),b=yn(()=>u.filter(L=>h.has(L.value)),[u,h]),x=yn(()=>u.filter(L=>!h.has(L.value)&&(c||!L.deprecated)),[u,h,c]),E=yn(()=>k1([...b,...x].filter(L=>L.text?.toLowerCase().includes(m))),[b,x,m]),w=yn(()=>{let L;return o?L=E.find(N=>N.value===o):e&&(L=E.find(N=>N.value===e)),!L&&m&&(E[0]?.value?r(E[0].value):n()),L},[o,e,m,E,r,n]),y=B6(L=>{uy({event:L,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[w,E,t,r,a]);O6(()=>(i(),()=>{a()}),[]);let v=yn(()=>E.filter(L=>h.has(L.value)),[E,h]),C=yn(()=>E.filter(L=>!h.has(L.value)),[E,h]),S=(L,N)=>hy(Yt,{icon:L.icon,value:L.value,order:N,textStyle:{fontFamily:Gn({fontFamily:L.value})},hovered:L.value===w?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{w?.value!==L.value&&r(L.value)},children:[L.text,L.badge&&Kl(Ed,{type:L.badge.type,children:L.badge.placeholder})]},L.value),_=[];return v.length&&_.push(Kl(Wl,{title:f("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&_.push(Kl(Wl,{title:f("fontList.availableFonts"),children:C.map((L,N)=>S(L,N+v.length))},"group_2")),hy(dd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[Kl(hd,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Vn(d,20)}),Kl(gd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as fy from"@radix-ui/react-popover";import{useMemo as F6}from"react";import{jsx as ih}from"react/jsx-runtime";var by=({selectedFontFamily:e})=>{let o=F6(()=>!!(e&&!xy(e)),[e]);return ih(fy.Trigger,{asChild:!0,children:ih("div",{children:ih(ld,{standalone:!0,icon:Yc,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as yd,jsxs as Ey}from"react/jsx-runtime";var vy=[{value:Bt.Excalifont,icon:gn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Bt.Nunito,icon:Ol,text:f("labels.normal"),testId:"font-family-normal"},{value:Bt["Comic Shanns"],icon:jc,text:f("labels.code"),testId:"font-family-code"}],V6=new Set(vy.map(e=>e.value)),xy=e=>e?V6.has(e):!1,wy=H6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=G6(()=>vy,[]),s=U6(c=>{c&&r(c)},[r]);return Ey("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[yd(Lo,{type:"button",options:l,value:o,onClick:s}),yd(sd,{}),Ey(yy.Root,{open:e,onOpenChange:a,children:[yd(by,{selectedFontFamily:o}),e&&yd(gy,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as xa from"@radix-ui/react-popover";import Z6 from"clsx";import vd,{useEffect as X6}from"react";import{jsx as Y6}from"react/jsx-runtime";var vn=({icon:e})=>Y6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as K6,jsx as Ty,jsxs as Cy}from"react/jsx-runtime";var W6=({label:e,open:o,openTrigger:t,children:r,className:n})=>Cy(K6,{children:[Cy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,Ty(vn,{icon:o?_E:rd})]}),o&&Ty("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Zl=W6;import{jsx as gi,jsxs as ah}from"react/jsx-runtime";var $6=Ae(!1);function j6({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=Ce(),l=u=>{let h=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&h)r(h.value),u.preventDefault();else if(u.key===T.TAB){let b=e.findIndex(E=>E.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(Un(u.key)){let b=Or().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,w=x;switch(u.key){case(b?T.ARROW_LEFT:T.ARROW_RIGHT):w=(x+1)%E;break;case(b?T.ARROW_RIGHT:T.ARROW_LEFT):w=(E+x-1)%E;break;case T.ARROW_DOWN:{w=(x+(i??1))%E;break}case T.ARROW_UP:{w=(E+x-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===T.ESCAPE||u.key===T.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ve($6),m=vd.useMemo(()=>e.slice(0,i),[e,i]),d=vd.useMemo(()=>e.slice(i),[e,i]);X6(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>gi("div",{className:"picker-content",children:u.map((h,b)=>ah("button",{type:"button",className:Z6("picker-option",{active:o===h.value}),onClick:x=>{r(h.value)},title:`${h.text} ${h.keyBinding&&`\u2014 ${h.keyBinding.toUpperCase()}`}`,"aria-label":h.text||"none","aria-keyshortcuts":h.keyBinding||void 0,ref:x=>{o===h.value&&setTimeout(()=>{x?.focus()},0)},children:[h.icon,h.keyBinding&&gi("span",{className:"picker-keybinding",children:h.keyBinding})]},h.text))});return gi(xa.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:ah("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&gi(Zl,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function lh({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=vd.useState(!1),s=vd.useRef(null);return gi("div",{children:ah(xa.Root,{open:a,onOpenChange:c=>l(c),children:[gi(xa.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&gi(j6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Iy,{useEffect as q6}from"react";import{jsx as sh,jsxs as Sy}from"react/jsx-runtime";var ky=({updateData:e,appState:o,elements:t,testId:r})=>{let n=Iy.useRef(null),i=Iy.useRef(null),a=Rt(t,o,l=>l.opacity,!0,o.currentItemOpacity);return q6(()=>{if(n.current&&i.current){let l=n.current,s=i.current,c=l.offsetWidth,m=15,d=a/100*(c-m)+m/2;s.style.left=`${d}px`,l.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${a}%, var(--button-bg) ${a}%, var(--button-bg) 100%)`}},[a]),Sy("label",{className:"control-label",children:[f("labels.opacity"),Sy("div",{className:"range-wrapper",children:[sh("input",{ref:n,type:"range",min:"0",max:"100",step:"10",onChange:l=>{e(+l.target.value)},value:a,className:"range-input","data-testid":r}),sh("div",{className:"value-bubble",ref:i,children:a!==0?a:null}),sh("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Ay,jsx as fe,jsxs as fo}from"react/jsx-runtime";var Ly=.1,Wt=(e,o,t,r=!1)=>{let n=re(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Rt=function(e,o,t,r,n){let i=o.editingTextElement,a=Ee(e),l=null;return i&&(l=t(i)),l||(ze(a,o)?l=Tb(r===!0?a:a.filter(c=>r(c)),o,t)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},e4=(e,o)=>Be(o)||!o.autoResize?o:B(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2},!1),mh=(e,o,t,r,n)=>{let i=new Set,a=Wt(e,o,s=>{if(Z(s)){let c=r(s);i.add(c);let m=te(s,{fontSize:c});return Qe(m,t.scene.getContainerElement(s),t.scene.getNonDeletedElementsMap()),m=e4(s,m),m}return s},!0),l=re(a);return J(e,o,{includeBoundTextElement:!0}).forEach(s=>{Z(s)&&at(s,l)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},t4=z({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Wt(e,o,r=>vl(r.type)?te(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(Ay,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.stroke")}),fe(Yl,{topPicks:Ms,palette:Pf,type:"elementStroke",label:f("labels.stroke"),color:Rt(e,o,n=>n.strokeColor,!0,o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),o4=z({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemBackgroundColor&&{elements:Wt(e,o,r=>te(r,{backgroundColor:t.currentItemBackgroundColor}))},appState:{...o,...t},captureUpdate:t.currentItemBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(Ay,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.background")}),fe(Yl,{topPicks:Ls,palette:Rf,type:"elementBackground",label:f("labels.background"),color:Rt(e,o,n=>n.backgroundColor,!0,o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),r4=z({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(xe("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Wt(e,o,n=>te(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o),n=r.length>0&&r.every(i=>i.fillStyle==="zigzag");return fo("fieldset",{children:[fe("legend",{children:f("labels.fill")}),fe(Lo,{type:"button",options:[{value:"hachure",text:`${n?f("labels.zigzag"):f("labels.hachure")} (${R("Alt-Click")})`,icon:n?yx:vx,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:wx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Tx,testId:"fill-solid"}],value:Rt(e,o,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:o.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&r.every(s=>s.fillStyle==="hachure")?"zigzag":i;t(l)}})]})}}),n4=z({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>te(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeWidth")}),fe(Lo,{group:"stroke-width",options:[{value:Gs.thin,text:f("labels.thin"),icon:Du,testId:"strokeWidth-thin"},{value:Gs.bold,text:f("labels.bold"),icon:Cx,testId:"strokeWidth-bold"},{value:Gs.extraBold,text:f("labels.extraBold"),icon:Ix,testId:"strokeWidth-extraBold"}],value:Rt(e,o,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})]})}),i4=z({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>te(r,{seed:Mr(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.sloppiness")}),fe(Lo,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:Mx},{value:1,text:f("labels.artist"),icon:Lx},{value:2,text:f("labels.cartoonist"),icon:Ax}],value:Rt(e,o,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})]})}),RB=z({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>te(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeStyle")}),fe(Lo,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Du},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Sx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:kx}],value:Rt(e,o,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})]})}),a4=z({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>te(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fe(ky,{updateData:t,elements:e,appState:o,testId:"opacity"})}),l4=z({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>mh(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fo("fieldset",{children:[fe("legend",{children:f("labels.fontSize")}),fe(Lo,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:Wx,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:Kx,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:Zx,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:Xx,testId:"fontSize-veryLarge"}],value:Rt(e,o,n=>{if(Z(n))return n.fontSize;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Cr),onChange:n=>t(n)})]})}),ph=z({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:ui,trackEvent:!1,perform:(e,o,t,r)=>mh(e,o,r,n=>Math.round(1/(1+Ly)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),uh=z({name:"increaseFontSize",label:"labels.increaseFontSize",icon:ui,trackEvent:!1,perform:(e,o,t,r)=>mh(e,o,r,n=>Math.round(n.fontSize*(1+Ly))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),s4=z({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Wt(e,o,b=>{let x=n?.get(b.id);return x?te(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:A.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=A.EVENTUALLY,d,p=!1;if(s)d=s,m=A.IMMEDIATELY;else if(c){d=c,m=A.EVENTUALLY;let h=J(e,o,{includeBoundTextElement:!0}).filter(b=>Z(b));if(h.length>200)p=!0;else{let b=0,x=0;for(;b<h.length&&x<5e3;){let E=h[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let h=new Map,b=new Set,x=!1,E=Array.from(un.loadedFontsCache.values()),w=Object.entries(Bt).find(([C,S])=>S===d)?.[0];c&&w&&E.some(C=>C.startsWith(w))&&(x=!0),Object.assign(u,{elements:Wt(e,o,C=>{if(Z(C)&&(C.fontFamily!==d||s)){let S=te(C,{fontFamily:d,lineHeight:Sr(d)}),_=n?.get(C.containerId||"")||{},L=r.scene.getContainerElement(C);return a&&L&&_&&B(L,{..._},!1),x||(b=new Set([...b,...Array.from(S.originalText)])),h.set(S,L),S}return C},!0)});let y=`10px ${Gn({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of h)Qe(C,S,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(y,v).then(C=>{for(let[S,_]of h){let L=r.scene.getElement(S.id),N=_?r.scene.getElement(_.id):null;L&&Qe(L,N,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=dh(new Map),i=dh(null),[a,l]=Q6({}),s=dh(!0),c=J6(()=>{let m=(d,p)=>Rt(d,o,u=>{if(Z(u))return u.fontFamily;let h=ge(u,p);return h?h.fontFamily:null},u=>Z(u)||ge(u,p)!==null,u=>u?null:o.currentItemFontFamily||jr);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t.scene]);return ch(()=>{i.current=c},[c]),ch(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),ch(()=>(s.current=!1,()=>{s.current=!0}),[]),fo("fieldset",{children:[fe("legend",{children:f("labels.fontFamily")}),fe(wy,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),n.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:m=>{if(m){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,te(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,te(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),c4=z({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Wt(e,o,n=>{if(Z(n)){let i=te(n,{textAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return fo("fieldset",{children:[fe("legend",{children:f("labels.textAlign")}),fe(Lo,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:jx,testId:"align-left"},{value:"center",text:f("labels.center"),icon:qx,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:Jx,testId:"align-right"}],value:Rt(e,o,i=>{if(Z(i))return i.textAlign;let a=ge(i,n);return a?a.textAlign:null},i=>Z(i)||ge(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})]})}}),d4=z({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Wt(e,o,n=>{if(Z(n)){let i=te(n,{verticalAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fe("fieldset",{children:fe(Lo,{group:"text-align",options:[{value:Qt.TOP,text:f("labels.alignTop"),icon:fe(Qx,{theme:o.theme}),testId:"align-top"},{value:Qt.MIDDLE,text:f("labels.centerVertically"),icon:fe(tE,{theme:o.theme}),testId:"align-middle"},{value:Qt.BOTTOM,text:f("labels.alignBottom"),icon:fe(eE,{theme:o.theme}),testId:"align-bottom"}],value:Rt(e,o,n=>{if(Z(n)&&n.containerId)return n.verticalAlign;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Qt.MIDDLE),onChange:n=>t(n)})})}),NB=z({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>ee(r)?r:te(r,{roundness:t==="round"?{type:Bi(r.type)?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=uc(Ee(e),o).some(i=>i.roundness?.type===eo.LEGACY);return fo("fieldset",{children:[fe("legend",{children:f("labels.edges")}),fe(Lo,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:_x},{value:"round",text:f("labels.round"),icon:Dx}],value:Rt(e,o,i=>n?null:i.roundness?"round":"sharp",i=>!Re(i)&&i.hasOwnProperty("roundness"),i=>i?null:o.currentItemRoundness),onChange:i=>t(i)})]})}}),My=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Px},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:fe(Rx,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:fe(zx,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:fe(Fx,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:fe(Nx,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:fe(Ox,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:fe(Hx,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:fe(Ux,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:fe(Bx,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:fe(Vx,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:fe(Gx,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:fe(Yx,{flip:e}),keyBinding:"v"}],OB=z({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>{if(ae(r)){let{position:n,type:i}=t;if(n==="start")return te(r,{startArrowhead:i});if(n==="end")return te(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Or().rtl;return fo("fieldset",{children:[fe("legend",{children:f("labels.arrowheads")}),fo("div",{className:"iconSelectList buttonList",children:[fe(lh,{label:"arrowhead_start",options:My(!r),value:Rt(e,o,n=>ae(n)&&Zi(n.type)?n.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:n=>t({position:"start",type:n}),numberOfOptionsToAlwaysShow:4}),fe(lh,{label:"arrowhead_end",group:"arrowheads",options:My(!!r),value:Rt(e,o,n=>ae(n)&&Zi(n.type)?n.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:n=>t({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),BB=z({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Wt(e,o,l=>{if(!Re(l))return l;let s=te(l,{roundness:t===xt.round?{type:eo.PROPORTIONAL_RADIUS}:null,elbowed:t===xt.elbow,points:t===xt.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(ee(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=j.getPointAtIndexGlobalCoordinates(s,0,c),d=j.getPointAtIndexGlobalCoordinates(s,-1,c),p=!s.startBinding&&cn(rn(m),e,c,o.zoom,!1,!0),u=!s.endBinding&&cn(rn(d),e,c,o.zoom,!1,!0),h=p||s.startBinding&&c.get(s.startBinding.elementId),b=u||s.endBinding&&c.get(s.endBinding.elementId),x=p?Sp(s,p,"start"):m,E=u?Sp(s,u,"end"):d;p&&Yo(s,p,"start",c),u&&Yo(s,u,"end",c);let w=h&&s.startBinding?{...s.startBinding,...kp(s,h,"start",c)}:null,y=b&&s.endBinding?{...s.endBinding,...kp(s,b,"end",c)}:null;s={...s,startBinding:w,endBinding:y,...ac(s,c,{points:[x,E].map(v=>M(v[0]-s.x,v[1]-s.y)),startBinding:w,endBinding:y,fixedSegments:null})},j.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Yo(s,m,"start",c)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Yo(s,m,"end",c)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new j(l))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.arrowtypes")}),fe(Lo,{group:"arrowtypes",options:[{value:xt.sharp,text:f("labels.arrowtype_sharp"),icon:ME,testId:"sharp-arrow"},{value:xt.round,text:f("labels.arrowtype_round"),icon:AE,testId:"round-arrow"},{value:xt.elbow,text:f("labels.arrowtype_elbowed"),icon:LE,testId:"elbow-arrow"}],value:Rt(e,o,r=>Re(r)?r.elbowed?xt.elbow:r.roundness?xt.round:xt.sharp:null,r=>Re(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})]})});import{useEffect as m4}from"react";import{jsx as u4}from"react/jsx-runtime";var Ea=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},hh=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},p4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();hh(o,n)},bo=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(m4(()=>()=>Ea().classList.remove("excalidraw-tooltip--visible"),[]),n?null:u4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>p4(i.currentTarget,Ea(),o,t),onPointerLeave:()=>Ea().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import wd from"open-color";var Dy='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',h4='<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"/>',Py='<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"/>',g4=`data:${ue.svg},${encodeURIComponent(`${Dy}${Py}</svg>`)}`,f4=`data:${ue.svg},${encodeURIComponent(`${Dy}${h4}${Py}</svg>`)}`,xo=e=>{e&&(e.style.cursor="")},Me=(e,o)=>{e&&(e.style.cursor=o)},hr,_y,gh=(e,o)=>{let r=()=>{let n=o===de.DARK;hr=document.createElement("canvas"),hr.theme=o,hr.height=20,hr.width=20;let i=hr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(hr.width/2,hr.height/2,5,0,2*Math.PI),i.fillStyle=n?wd.black:wd.white,i.fill(),i.strokeStyle=n?wd.white:wd.black,i.stroke(),_y=hr.toDataURL(ue.svg)};(!hr||hr.theme!==o)&&r(),Me(e,`url(${_y}) ${20/2} ${20/2}, auto`)},Eo=(e,o)=>{if(e)if(o.activeTool.type==="selection")xo(e);else if(Ko(o))e.style.cursor=Se.GRAB;else if(no(o))gh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===de.LIGHT?g4:f4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Se.AUTO):e.style.cursor=Se.CROSSHAIR};var Br=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),c=-(n-n/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as Sd,jsxs as y4}from"react/jsx-runtime";var b4=z({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Sd(Yl,{palette:null,topPicks:As,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),zr=z({name:"clearCanvas",label:"labels.clearCanvas",icon:ho,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>te(n,{isDeleted:!0})),appState:{...dr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:"selection"}:o.activeTool},captureUpdate:A.IMMEDIATELY})}),Td=z({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:hu,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Br({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:cr(o.zoom.value+Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Sd(Q,{type:"button",className:"zoom-in-button zoom-button",icon:hu,title:`${f("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=ap,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.EQUAL||e.code===pe.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),Cd=z({name:"zoomOut",label:"buttons.zoomOut",icon:gu,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Br({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:cr(o.zoom.value-Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Sd(Q,{type:"button",className:"zoom-out-button zoom-button",icon:gu,title:`${f("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=ip,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.MINUS||e.code===pe.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),Id=z({name:"resetZoom",label:"buttons.resetZoom",icon:nx,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Br({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:cr(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Sd(bo,{label:f("buttons.resetZoom"),style:{height:"100%"},children:y4(Q,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===pe.ZERO||e.code===pe.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),x4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,c=a-n,m=o.height/c,p=Math.min(s,m)*wt(t,.1,1);return Math.min(p,1)},Ry=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=wt(n,ip,ap);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,h=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,w=o.height-h-x,y;if(r){let S=c-l,_=m-s;y=Math.min(E/S,w/_)*n}else y=x4(e,{width:E,height:w},n);let v=cr(wt(d1(y,Li,"floor"),i,a)),C=t0({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:A.EVENTUALLY}},Xl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=ye(Ee(o));return Ry({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},Ez=z({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:od,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Xl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),yz=z({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:od,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Xl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),E4=z({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:od,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Xl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===pe.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),fi=z({name:"toggleTheme",label:(e,o)=>o.theme===de.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===de.LIGHT?Pl:Rl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===de.LIGHT?de.DARK:de.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===pe.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),vz=z({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return no(o)?t=Fe(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Fe(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===T.E}),wz=z({name:"toggleLassoTool",label:"toolBar.lasso",icon:_l,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Fe(o,{type:"lasso",fromSelection:!1}),Me(r.interactiveCanvas,Se.CROSSHAIR)):n=Fe(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.NEVER}}}),Ny=z({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Jc,viewMode:!1,perform:(e,o,t,r)=>{let n;return Ko(o)?n=Fe(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Fe(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Me(r.interactiveCanvas,Se.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var v4=z({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Fe(o,{type:"embeddable"});return Eo(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Fe(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as w4}from"react/jsx-runtime";var yo=z({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,l=a.getNonDeletedElementsMap();if(o.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=o.editingLinearElement,b=j.getElement(p,l);if(b)return Ar(b)&&rc(b,u,h,l,a),{elements:b.points.length<2||Qn(b)?e.filter(x=>x.id!==b.id):void 0,appState:{...o,cursorButton:"up",editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let s=e,c=o.pendingImageElementId&&a.getElement(o.pendingImageElementId);c&&B(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let m=o.multiElement?o.multiElement:o.newElement?.type==="freedraw"?o.newElement:null;if(m){if(m.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=m;(!h||u[u.length-1]!==h)&&B(m,{points:m.points.slice(0,-1)})}Qn(m)&&(s=s.filter(u=>u.id!==m.id));let p=yl(m.points,o.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,h=u[0];B(m,{points:u.map((b,x)=>x===u.length-1?M(h[0],h[1]):b)})}if(Ar(m)&&!p&&m.points.length>1){let[u,h]=j.getPointAtIndexGlobalCoordinates(m,-1,re(e));gl(m,o,{x:u,y:h},l,e)}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&xo(n);let d;return o.activeTool.type==="eraser"?d=Fe(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=Fe(o,{type:"selection"}),{elements:s,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&m?o.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[m.id]:!0}:o.selectedElementIds,selectedLinearElement:m&&ae(m)?new j(m):o.selectedLinearElement,pendingImageElementId:null},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===T.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>w4(Q,{type:"button",icon:ux,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import T4 from"clsx";import{jsx as Oy,jsxs as C4}from"react/jsx-runtime";var $l=({children:e,checked:o,onChange:t,className:r})=>C4("div",{className:T4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Oy("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:sx}),Oy("div",{className:"Checkbox-label",children:e})]});import{jsx as jl}from"react/jsx-runtime";var zy=e=>{let o=e.title||(e.value===de.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return jl(Q,{type:"icon",icon:e.value===de.LIGHT?By.MOON:By.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===de.DARK?de.LIGHT:de.DARK),"data-testid":"toggle-dark-mode"})},By={SUN:jl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:jl("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:jl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:jl("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as I4}from"react";import{jsx as Fy,jsxs as S4}from"react/jsx-runtime";var Hy=e=>{let{id:o}=ht(),[t,r]=I4(e.value),n=a=>{e.ignoreFocus||T1(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===T.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return S4("div",{className:"ProjectName",children:[Fy("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Fy("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var $o=32,Ue=12,wn=256,Gy=50,bi="NOT_SPREADSHEET",ya="VALID_SPREADSHEET",ql=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},fh=(e,o)=>e.slice(1).every(t=>ql(t[o])!==null),Uy=e=>{let o=e[0].length;if(o>2)return{type:bi,reason:"More than 2 columns"};if(o===1){if(!fh(e,0))return{type:bi,reason:"Value is not numeric"};let s=ql(e[0][0])===null,c=(s?e.slice(1):e).map(m=>ql(m[0]));return c.length<2?{type:bi,reason:"Less than two rows"}:{type:ya,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=fh(e,0),r=fh(e,1);if(!t&&!r)return{type:bi,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ql(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:bi,reason:"Less than 2 rows"}:{type:ya,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ql(s[i]))}}},k4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Vy=e=>{let o=e.trim().split(`
3
3
  `).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
4
- `).map(i=>i.trim().split(","))),o.length===0)return{type:fi,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:fi,reason:"All rows don't have same number of columns"};let n=Dy(o);if(n.type!==Ea){let i=Dy(b4(o));if(i.type===Ea)return i}return n},Id=Lf(Cf),_o={fillStyle:"hachure",fontFamily:Zr,fontSize:Tr,opacity:100,roughness:1,strokeColor:Io.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Jt.MIDDLE,locked:!1},Ny=e=>{let o=(Xo+He)*e.values.length+He,t=En+He*2;return{chartWidth:o,chartHeight:t}},x4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Gt({groupIds:[r],backgroundColor:n,..._o,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(Xo+He)+He*2,y:t+He/2,width:Xo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],E4=(e,o,t,r,n)=>{let i=Gt({groupIds:[r],backgroundColor:n,..._o,x:o-He,y:t-He,text:"0",textAlign:"right"}),a=Gt({groupIds:[r],backgroundColor:n,..._o,x:o-He,y:t-En-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},y4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Ny(e),l=lr({backgroundColor:n,groupIds:[r],..._o,type:"line",x:o,y:t,width:i,points:[M(0,0),M(i,0)]}),s=lr({backgroundColor:n,groupIds:[r],..._o,type:"line",x:o,y:t,height:a,points:[M(0,0),M(0,-a)]}),c=lr({backgroundColor:n,groupIds:[r],..._o,type:"line",x:o,y:t-En-He,strokeStyle:"dotted",width:i,opacity:Py,points:[M(0,0),M(i,0)]});return[l,s,c]},Oy=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Ny(e),s=e.title?Gt({backgroundColor:n,groupIds:[r],..._o,text:e.title,x:o+a/2,y:t-En-He*2-Tr,roundness:null,textAlign:"center"}):null,c=i?Ut({backgroundColor:n,groupIds:[r],..._o,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Io.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...x4(e,o,t,r,n),...E4(e,o,t,r,n),...y4(e,o,t,r,n)]},v4=(e,o,t)=>{let r=Math.max(...e.values),n=oo(),i=Id[Math.floor(Math.random()*Id.length)];return[...e.values.map((l,s)=>{let c=l/r*En;return Ut({backgroundColor:i,groupIds:[n],..._o,type:"rectangle",x:o+s*(Xo+He)+He,y:t-c-He,width:Xo,height:c})}),...Oy(e,o,t,n,i,Fe())]},w4=(e,o,t)=>{let r=Math.max(...e.values),n=oo(),i=Id[Math.floor(Math.random()*Id.length)],a=0,l=[];for(let b of e.values){let x=a*(Xo+He),E=-(b/r)*En;l.push([x,E]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=lr({backgroundColor:i,groupIds:[n],..._o,type:"line",x:o+He+Xo/2,y:t-He,height:c-d,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let E=x*(Xo+He)+He/2,w=-(b/r)*En+He/2;return Ut({backgroundColor:i,groupIds:[n],..._o,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+E+Xo/2,y:t+w-He*2,width:He,height:He})}),h=e.values.map((b,x)=>{let E=x*(Xo+He)+He/2,w=b/r*En+He/2+He;return lr({backgroundColor:i,groupIds:[n],..._o,type:"line",x:o+E+Xo/2+He/2,y:t-w,height:w,strokeStyle:"dotted",opacity:Py,points:[M(0,0),M(0,w)]})});return[...Oy(e,o,t,n,i,Fe()),p,...h,...u]},By=(e,o,t,r)=>e==="line"?w4(o,t,r):v4(o,t,r);var vF="clipboard"in navigator&&"readText"in navigator.clipboard,Sd="clipboard"in navigator&&"writeText"in navigator.clipboard,ya="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,T4=e=>!!([$r.excalidraw,$r.excalidrawClipboard,$r.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),zy=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n);continue}try{if(t.clipboardData?.setData(r,n),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},C4=({elements:e,files:o})=>{let t=ne(e),r=new Set(e.filter(l=>ie(l))),n=!1,i=e.reduce((l,s)=>(kr(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:$r.excalidrawClipboard,elements:e.map(l=>{if(Qn(l,t)&&!r.has(Qn(l,t))){let s=uo(l);return B(s,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},kd=async(e,o,t)=>{await $o(C4({elements:e,files:o}),t)},I4=e=>{let o=Ry(e);return o.type===Ea?{spreadsheet:o.spreadsheet}:null};function Fy(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(Fy(t));return o}var S4=e=>{let o=e.clipboardData?.getData(ue.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,ue.html),r=Fy(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Hy=async()=>{let e={},o;try{o=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 r=await navigator.clipboard?.readText();if(r)return{[ue.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(Ws(Hf,r))try{if(r===ue.text||r===ue.html)e[r]=await(await t.getType(r)).text();else if(o0(r)){let n=await t.getType(r),i=d0(n,r,void 0);e[r]=i}else throw new Up(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Up?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},k4=async(e,o=!1)=>{try{let t=!o&&e&&S4(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(ue.text)||t.value.map(n=>n.value).join(`
5
- `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(ue.text)||"").trim()}}catch{return{type:"text",value:""}}},Md=async(e,o=!1)=>{let t=await k4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&I4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===$r.excalidrawClipboardWithAPI;if(T4(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Ld=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:e})])}catch(o){if(tn(e))await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:await e})]);else throw o}},$o=async(e,o)=>{if(Sd)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ue.text,e||""),o.clipboardData?.getData(ue.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!M4(e))throw new Error("Error copying to clipboard.")},M4=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n};var bi=(e,{selectedElementIds:o},t)=>{e=Ee(e);let r=t&&ze(e,{selectedElementIds:o}),n=null,i=r?J(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&ie(i[0])?(n=i[0],i=ac(e,n)):i.length>1&&(i=J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:to(i)}},xi=async(e,o,t,r,{exportBackground:n,exportPadding:i=jr,viewBackgroundColor:a,name:l=t.name||e1,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=ea(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return Gp(d.then(p=>new Blob([p.outerHTML],{type:ue.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[tl.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await $o(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let m=Tc(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let d=Dr(m);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-W3GRS73V.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:wl(o,t,r,"local")})))),Gp(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[tl.png],fileHandle:s})}else if(e==="clipboard")try{let d=Dr(m);await Ld(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):wr&&d.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:bi,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:bi,reason:"All rows don't have same number of columns"};let n=Uy(o);if(n.type!==ya){let i=Uy(k4(o));if(i.type===ya)return i}return n},kd=Nf(Af),Do={fillStyle:"hachure",fontFamily:jr,fontSize:Cr,opacity:100,roughness:1,strokeColor:Io.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Qt.MIDDLE,locked:!1},Yy=e=>{let o=($o+Ue)*e.values.length+Ue,t=wn+Ue*2;return{chartWidth:o,chartHeight:t}},M4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Vt({groupIds:[r],backgroundColor:n,...Do,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*($o+Ue)+Ue*2,y:t+Ue/2,width:$o,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],L4=(e,o,t,r,n)=>{let i=Vt({groupIds:[r],backgroundColor:n,...Do,x:o-Ue,y:t-Ue,text:"0",textAlign:"right"}),a=Vt({groupIds:[r],backgroundColor:n,...Do,x:o-Ue,y:t-wn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},A4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Yy(e),l=sr({backgroundColor:n,groupIds:[r],...Do,type:"line",x:o,y:t,width:i,points:[M(0,0),M(i,0)]}),s=sr({backgroundColor:n,groupIds:[r],...Do,type:"line",x:o,y:t,height:a,points:[M(0,0),M(0,-a)]}),c=sr({backgroundColor:n,groupIds:[r],...Do,type:"line",x:o,y:t-wn-Ue,strokeStyle:"dotted",width:i,opacity:Gy,points:[M(0,0),M(i,0)]});return[l,s,c]},Wy=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Yy(e),s=e.title?Vt({backgroundColor:n,groupIds:[r],...Do,text:e.title,x:o+a/2,y:t-wn-Ue*2-Cr,roundness:null,textAlign:"center"}):null,c=i?Gt({backgroundColor:n,groupIds:[r],...Do,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Io.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...M4(e,o,t,r,n),...L4(e,o,t,r,n),...A4(e,o,t,r,n)]},_4=(e,o,t)=>{let r=Math.max(...e.values),n=ro(),i=kd[Math.floor(Math.random()*kd.length)];return[...e.values.map((l,s)=>{let c=l/r*wn;return Gt({backgroundColor:i,groupIds:[n],...Do,type:"rectangle",x:o+s*($o+Ue)+Ue,y:t-c-Ue,width:$o,height:c})}),...Wy(e,o,t,n,i,He())]},D4=(e,o,t)=>{let r=Math.max(...e.values),n=ro(),i=kd[Math.floor(Math.random()*kd.length)],a=0,l=[];for(let b of e.values){let x=a*($o+Ue),E=-(b/r)*wn;l.push([x,E]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=sr({backgroundColor:i,groupIds:[n],...Do,type:"line",x:o+Ue+$o/2,y:t-Ue,height:c-d,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let E=x*($o+Ue)+Ue/2,w=-(b/r)*wn+Ue/2;return Gt({backgroundColor:i,groupIds:[n],...Do,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+E+$o/2,y:t+w-Ue*2,width:Ue,height:Ue})}),h=e.values.map((b,x)=>{let E=x*($o+Ue)+Ue/2,w=b/r*wn+Ue/2+Ue;return sr({backgroundColor:i,groupIds:[n],...Do,type:"line",x:o+E+$o/2+Ue/2,y:t-w,height:w,strokeStyle:"dotted",opacity:Gy,points:[M(0,0),M(0,w)]})});return[...Wy(e,o,t,n,i,He()),p,...h,...u]},Ky=(e,o,t,r)=>e==="line"?D4(o,t,r):_4(o,t,r);var OF="clipboard"in navigator&&"readText"in navigator.clipboard,Md="clipboard"in navigator&&"writeText"in navigator.clipboard,va="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,P4=e=>!!([Jr.excalidraw,Jr.excalidrawClipboard,Jr.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Zy=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n);continue}try{if(t.clipboardData?.setData(r,n),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},R4=({elements:e,files:o})=>{let t=re(e),r=new Set(e.filter(l=>ne(l))),n=!1,i=e.reduce((l,s)=>(Lr(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Jr.excalidrawClipboard,elements:e.map(l=>{if(ei(l,t)&&!r.has(ei(l,t))){let s=uo(l);return B(s,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Ld=async(e,o,t)=>{await jo(R4({elements:e,files:o}),t)},N4=e=>{let o=Vy(e);return o.type===ya?{spreadsheet:o.spreadsheet}:null};function Xy(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(Xy(t));return o}var O4=e=>{let o=e.clipboardData?.getData(ue.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,ue.html),r=Xy(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},$y=async()=>{let e={},o;try{o=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 r=await navigator.clipboard?.readText();if(r)return{[ue.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if($s(Kf,r))try{if(r===ue.text||r===ue.html)e[r]=await(await t.getType(r)).text();else if(u0(r)){let n=await t.getType(r),i=v0(n,r,void 0);e[r]=i}else throw new Kp(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Kp?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},B4=async(e,o=!1)=>{try{let t=!o&&e&&O4(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(ue.text)||t.value.map(n=>n.value).join(`
5
+ `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(ue.text)||"").trim()}}catch{return{type:"text",value:""}}},Ad=async(e,o=!1)=>{let t=await B4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&N4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Jr.excalidrawClipboardWithAPI;if(P4(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},_d=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:e})])}catch(o){if(nn(e))await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:await e})]);else throw o}},jo=async(e,o)=>{if(Md)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ue.text,e||""),o.clipboardData?.getData(ue.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!z4(e))throw new Error("Error copying to clipboard.")},z4=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n};var xi=(e,{selectedElementIds:o},t)=>{e=Ee(e);let r=t&&ze(e,{selectedElementIds:o}),n=null,i=r?J(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&ne(i[0])?(n=i[0],i=dc(e,n)):i.length>1&&(i=J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:oo(i)}},Ei=async(e,o,t,r,{exportBackground:n,exportPadding:i=Qr,viewBackgroundColor:a,name:l=t.name||i1,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=ea(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return Zp(d.then(p=>new Blob([p.outerHTML],{type:ue.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ol.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await jo(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let m=kc(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let d=Rr(m);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-5XD47O4X.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Tl(o,t,r,"local")})))),Zp(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ol.png],fileHandle:s})}else if(e==="clipboard")try{let d=Rr(m);await _d(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Tr&&d.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
6
6
 
7
- ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Uy=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=e0(a);if(!a||!t0(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=bi(e,o,!1);return await xi(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as L4,jsx as Br,jsxs as A4}from"react/jsx-runtime";var mh=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Br(_y,{label:f("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),Gy=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Ee(e),i=ze(r,o)?J(r,o):r;return Br(L4,{children:Ns.map(a=>{let[l,s]=Jb(i,jr,a),c=`${f("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Br(Q,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),ph=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Br(Wl,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),Ad=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>A4(Wl,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[f("imageExportDialog.label.embedScene"),Br(bo,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Br("div",{className:"excalidraw-tooltip-icon",children:nx})})]})}),Ei=F({name:"saveToActiveFile",label:"buttons.save",icon:mi,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Cc(o.fileHandle)?await Uy(e,o,r.files,r.getName()):await Ec(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),Xl=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:mi,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Ec(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:f("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Br(Q,{type:"button",icon:ex,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ce().editor.isMobile,hidden:!Qi,onClick:()=>e(null),"data-testid":"save-as-button"})}),va=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Vp(o,e);return{elements:n,appState:i,files:a,captureUpdate:A.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:A.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),Vy=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Br("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Br(Ly,{value:e.exportWithDarkMode?de.DARK:de.LIGHT,onChange:t=>{o(t===de.DARK)},title:f("imageExportDialog.label.darkMode")})})});var Yy="{}",uh=F({name:"copyStyles",label:"labels.copyStyles",icon:Mu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Tt(i)){let a=ge(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(Yy=JSON.stringify(n)),{appState:{...o,toast:{message:f("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.C}),hh=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Mu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(Yy),i=n[0],a=n[1];if(!S1(i))return{elements:e,captureUpdate:A.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Z(c)&&c.containerId&&(m=a),!m)return c;let d=oe(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?k1(m.roundness.type,c)?m.roundness:M1(c):null});if(Z(d)){let p=m.fontSize||Tr,u=m.fontFamily||Zr;d=oe(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||As,lineHeight:m.lineHeight||Ir(u)});let h=null;d.containerId&&(h=l.find(b=>Z(d)&&b.id===d.containerId)||null),Qe(d,h,r.scene.getNonDeletedElementsMap())}return d.type==="arrow"&&Pe(m)&&(d=oe(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ie(c)&&(d=oe(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V});var wa=(e,o)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||J(o,e).length));import{jsx as Wy}from"react/jsx-runtime";var _4=F({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Wy(Q,{type:"button",icon:Uc,"aria-label":f("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),D4=F({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>Wy(Q,{visible:wa(o,Ee(e)),type:"button",icon:tx,"aria-label":f("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),yi=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:$0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as Ta}from"react/jsx-runtime";var P4=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ki(n,t),!0))return!0}return!1},Ky=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!P4(r)&&!lc(r)},gh=F({name:"group",label:"labels.group",icon:e=>Ta(Cu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=lb(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=Yo(o);if(i.length===1){let x=i[0],E=new Set(Ue(e,x).map(v=>v.id)),w=new Set(n.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&ib(n).forEach((E,w)=>{nc(E,r.scene.getNonDeletedElementsMap())});let s=oo(),c=ne(n);a=a.map(x=>c.get(x.id)?oe(x,{groupIds:Eb(x.groupIds,s,o.editingGroupId)}):x);let m=Ue(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),h=a.slice(0,p).filter(x=>!Ki(x,s)),b=Ht([...h,...m,...u],ne(m));return{appState:{...o,...hb(s,{...o,selectedGroupIds:{}},Ee(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>Ky(e,o,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ta(Q,{hidden:!Ky(e,o,r),type:"button",icon:Ta(Cu,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:ze(Ee(e),o)})}),fh=F({name:"ungroup",label:"labels.ungroup",icon:e=>Ta(Iu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Yo(o),i=ne(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{Be(p)&&l.push(p.id);let u=yb(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:oe(p,{groupIds:u})});let s=ut(o,Ee(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return ab(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=ic(a,Yi(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,o)=>Yo(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ta(Q,{type:"button",hidden:Yo(o).length===0,icon:Ta(Iu,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:ze(Ee(e),o)})});import B4 from"clsx";var _d=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function R4(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var vi=(e,o)=>`hsl(${Math.abs(R4(o?.id||e))%37*10}, 100%, 83%)`,Zy=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},Xy=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,d=14,p=l<0||l>r-m||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-d);let u=vi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=o.remotePointerUserStates.get(i),b=p||h==="idle"||h==="away";b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===de.DARK?"#2f6330":Ff,E=c?.isSpeaking;E&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=el,e.strokeStyle=el,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let w=o.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(E?l+0:l)+m/2,v=(E?s+0:s)+d+2,C=5,I=3,_=e.measureText(w),L=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,N=Math.max(L,12),P=y-1,z=v-1,V=_.width+2+C*2+2,U=N+2+I*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,z,V,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=el,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,z-2,V+4,U+4,8),e.strokeStyle=x,e.stroke())):_d(e,P,z,V,U,8,el),e.fillStyle=zf,e.fillText(w,y+C+1,v+I+_.actualBoundingBoxAscent+Math.floor((N-L)/2)+2),E){e.fillStyle=x;let q=8,H=8,G=5;e.fillRect(P+V+H,z+(U/2-q/2),2,q),e.fillRect(P+V+H+G,z+(U/2-q*2/2),2,q*2),e.fillRect(P+V+H+G*2,z+(U/2-q/2),2,q)}}e.restore(),e.closePath()}};import N4 from"clsx";import{useState as O4}from"react";import{jsx as $y}from"react/jsx-runtime";var bh=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=Zy(t),[a,l]=O4(!1),s=!a&&r,c=s?void 0:{background:e};return $y("div",{className:N4("Avatar",n),style:c,onClick:o,children:s?$y("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as hr,jsxs as Dd}from"react/jsx-runtime";var z4=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:A.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:A.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=vi(r,n),s=B4({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Dd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[hr("div",{}),hr("div",{}),hr("div",{})]}):n.isMuted?hr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:iE}):hr("div",{title:f("userList.hint.inCall"),children:nE}):null;return i?Dd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[hr(bh,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),hr("div",{className:"UserList__collaborator-name",children:n.username}),Dd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&hr("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:ma}),c]})]}):Dd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[hr(bh,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&hr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var xh=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of zs)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:oo(),status:"unpublished",elements:n.map(uo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});var jy=(e,o,t,r)=>{let n=ei(e,o),i=_t(e);return n.flatMap(a=>{let l=F4(a,i,t);return a.map(s=>{let c=B(s,{x:s.x+l.x,y:s.y+l.y});return at(s,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:a}),c})})},F4=(e,o,{axis:t,position:r})=>{let n=_t(e),[i,a]=t==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return r==="start"?{...l,[t]:o[i]-n[i]}:r==="end"?{...l,[t]:o[a]-n[a]}:{...l,[t]:(o[i]+o[a])/2-(n[i]+n[a])/2}};import{jsx as Ia}from"react/jsx-runtime";var io=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ie(r))},Ca=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=ne(e),a=jy(n,i,r,t.scene),l=ne(a);return ir(e.map(s=>l.get(s.id)||s),o,t)},H4=F({name:"alignTop",label:"labels.alignTop",icon:xu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:xu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:ze(Ee(e),o)})}),U4=F({name:"alignBottom",label:"labels.alignBottom",icon:Eu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:Eu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:ze(Ee(e),o)})}),G4=F({name:"alignLeft",label:"labels.alignLeft",icon:yu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:yu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:ze(Ee(e),o)})}),V4=F({name:"alignRight",label:"labels.alignRight",icon:vu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:vu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:ze(Ee(e),o)})}),Y4=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:wu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:wu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:ze(Ee(e),o)})}),W4=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Tu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ca(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ia(Q,{hidden:!io(o,r),type:"button",icon:Tu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:ze(Ee(e),o)})});var qy=(e,o,t)=>{let[r,n,i,a]=t.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=_t(e),s=ei(e,o).map(p=>[p,_t(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let m=(l[a]-c)/(s.length-1);if(m<0){let p=s.findIndex(x=>x[1][r]===l[r]),u=s.findIndex(x=>x[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),b=s[p][1][n];return s.flatMap(([x,E],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(b+=h,y[t.axis]=b-E[n]),x.map(v=>oe(v,{x:v.x+y.x,y:v.y+y.y}))})}let d=l[r];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[t.axis]=d-u[r],d+=m,d+=u[a],p.map(b=>oe(b,{x:b.x+h.x,y:b.y+h.y}))})};import{jsx as e2}from"react/jsx-runtime";var Jy=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ie(r))},Qy=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=qy(n,t.scene.getNonDeletedElementsMap(),r),a=ne(i);return ir(e.map(l=>a.get(l.id)||l),o,t)},K4=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:Qy(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>e2(Q,{hidden:!Jy(o,r),type:"button",icon:sx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:ze(Ee(e),o)})}),Z4=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:Qy(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>e2(Q,{hidden:!Jy(o,r),type:"button",icon:cx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:ze(Ee(e),o)})});var Eh=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:cE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ir(t2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.H}),yh=F({name:"flipVertical",label:"labels.flipVertical",icon:sE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ir(t2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.V&&!e[T.CTRL_OR_CMD]}),t2=(e,o,t,r,n)=>{let i=J(Ee(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=X4(i,o,t,r,n),l=ne(a);return e.map(s=>l.get(s.id)||s)},X4=(e,o,t,r,n)=>{if(e.every(u=>Pe(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let h=u;return oe(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:i,midY:a}=_t(e);tu(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,uo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),qn(e.filter(ce),o,n.scene.getNonDeletedElements(),n.scene,jn(t),[],t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,h)=>ee(h)?{...u,elbowArrows:u.elbowArrows.concat(h)}:{...u,otherElements:u.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=_t(e),[d,p]=[i-c,a-m];return s.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),e};var Sa=F({name:"copy",label:"labels.copy",icon:Al,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await kd(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),vh=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Hy()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),wr?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(zy({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Pd=F({name:"cut",label:"labels.cut",icon:Zx,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Sa.perform(e,o,t,r),Bl.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),Rd=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:dE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=bi(e,o,!0);try{await xi("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>Sd&&e.length>0,keywords:["svg","clipboard","copy"]}),Nd=F({name:"copyAsPng",label:"labels.copyAsPng",icon:mE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=bi(e,o,!0);try{return await xi("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:n.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>ya&&e.length>0,keyTest:e=>e.code===pe.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Od=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{$o(yp(n))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Sd&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(Z),keywords:["text","clipboard","copy"]});var Bd=F({name:"gridMode",icon:fE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===pe.QUOTE});var ka=F({name:"zenMode",label:"buttons.zenMode",icon:uE,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.Z});var wh=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:pE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.S});var Ma=F({name:"stats",label:"stats.fullTitle",icon:lE,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:A.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.SLASH});var Th=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>Tt(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=ge(a,i);if(l){let{width:s,height:c}=Ft(l.originalText,qe(l),l.lineHeight),m=F1(a.id);z1(a.id);let{x:d,y:p}=qs(a,l,i);B(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),B(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),Ch=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=Z(n[0])||Z(n[1]),a;if(Lr(n[0])?a=n[0]:Lr(n[1])&&(a=n[1]),i&&a&&ge(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Z(n[0])&&Lr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),B(i,{containerId:a.id,verticalAlign:Jt.MIDDLE,textAlign:ol.CENTER,autoResize:!0}),B(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Qe(i,a,r.scene.getNonDeletedElementsMap()),pl(a.id,l),{elements:$4(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),$4=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),Ht(r,ne([o,t])),r},j4=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),Ht(r,ne([o,t])),r},o2=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.every(a=>Z(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Z(l)){let s=Ut({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:Bi("rectangle")?Qt.ADAPTIVE_RADIUS:Qt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-ap,y:l.y-ap,width:Ui(l.width,"rectangle"),height:Ui(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>c.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&B(d,{startBinding:p,endBinding:u},!1)})}B(l,{containerId:s.id,verticalAlign:Jt.MIDDLE,boundElements:null,textAlign:ol.CENTER,autoResize:!0},!1),Qe(l,s,r.scene.getNonDeletedElementsMap()),i=j4([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import q4 from"clsx";import{useCallback as r2,useEffect as n2,useLayoutEffect as J4,useRef as Q4,useState as eC}from"react";import{jsx as La,jsxs as i2}from"react/jsx-runtime";var kh=380,tC=42,Ih=5,a2=85,oC=500,Sh=!1,zd=new Map,l2=({element:e,elementsMap:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=mr(),l=pr(),s=Ce(),c=e.link||"",[m,d]=eC(c),p=Q4(null),u=a.showHyperlinkPopup==="editor",h=r2(()=>{if(!p.current)return;let y=Go(p.current.value)||null;if(!e.link&&y&&xe("hyperlink","create"),zt(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!y){B(e,{link:null}),i(e,!1);return}if(!qi(y,l.validateEmbeddable))y&&n({message:f("toast.unableToEmbed"),closable:!0}),e.link&&zd.set(e.id,e.link),B(e,{link:y}),i(e,!1);else{let{width:v,height:C}=e,I=ri(y);I?.error instanceof URIError&&n({message:f("toast.unrecognizedLinkFormat"),closable:!0});let _=I?I.intrinsicSize.w/I.intrinsicSize.h:1,L=zd.get(e.id)!==e.link;B(e,{...L?{width:I?.type==="video"?v>C?v:C*_:v,height:I?.type==="video"&&v>C?v/_:C}:{},link:y}),i(e,!0),zd.has(e.id)&&zd.delete(e.id)}}else B(e,{link:y})},[e,n,l.validateEmbeddable,a.activeEmbeddable,t,i]);J4(()=>()=>{h()},[h]),n2(()=>{u&&p?.current&&!(s.viewport.isMobile||s.isTouchScreen)&&p.current.select()},[u,s.viewport.isMobile,s.isTouchScreen]),n2(()=>{let y=null,v=C=>{if(u)return;y&&clearTimeout(y),nC(e,o,a,M(C.clientX,C.clientY))&&(y=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},oC))};return window.addEventListener("pointermove",v,!1),()=>{window.removeEventListener("pointermove",v,!1),y&&clearTimeout(y)}},[a,e,u,t,o]);let b=r2(()=>{xe("hyperlink","delete"),B(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e]),x=()=>{xe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=s2(e,a,o);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:i2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:kh,padding:Ih},children:[u?La("input",{className:q4("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:p,value:m,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[T.CTRL_OR_CMD]&&y.key===T.K&&y.preventDefault(),(y.key===T.ENTER||y.key===T.ESCAPE)&&(h(),t({showHyperlinkPopup:"info"}))}}):e.link?La("a",{href:Go(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Ks(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&r){let v=Ys("excalidraw-link",y.nativeEvent);r({...e,link:Go(e.link)},v),v.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):La("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),i2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!u&&La(Q,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:pn}),La(Q,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:od}),c&&!zt(e)&&La(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:ho})]})]})},s2=(e,o,t)=>{let[r,n]=Ye(e,t),{x:i,y:a}=Bt({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-kh/2,s=a-o.offsetTop-a2;return{x:l,y:s}},Mh=(e,o)=>{let t=J(e,o);return zt(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},$l=null,c2=(e,o,t)=>{$l&&clearTimeout($l),$l=window.setTimeout(()=>rC(e,o,t),Kf)},rC=(e,o,t)=>{if(!e.link)return;let r=xa();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ni(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=Ye(e,t),[s,c,m,d]=Xb([n,i,a,l],e.angle,o),p=Bt({sceneX:s,sceneY:c},o);sh(r,{left:p.x,top:p.y,width:m,height:d},"top"),xe("hyperlink","tooltip","link-icon"),Sh=!0},Lh=()=>{$l&&clearTimeout($l),Sh&&(Sh=!1,xa().classList.remove("excalidraw-tooltip--visible"))},nC=(e,o,t,[r,n])=>{let{x:i,y:a}=$e({clientX:r,clientY:n},t),l=15/t.zoom.value;if(L1(i,a,e,o))return!1;let[s,c,m]=Ye(e,o);if(i>=s&&i<=m&&a>=c-a2&&a<=c)return!1;let{x:d,y:p}=s2(e,t,o);return!(r>=d-l&&r<=d+kh+Ih*2+l&&n>=p-l&&n<=p+l+Ih*2+tC)};import{jsx as iC}from"react/jsx-runtime";var jl=F({name:"hyperlink",label:(e,o)=>Mh(e,o),icon:Pl,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:A.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return iC(Q,{type:"button",icon:Pl,"aria-label":f(Mh(e,o)),title:`${zt(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var Ah=e=>e.every(o=>!o.locked),_h=F({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!ie(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Ah(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,o)=>{let t=J(o,e);return Ah(t)?aa:di},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Ah(n),a=ne(n);return{elements:e.map(l=>a.has(l.id)?oe(l,{locked:i}):l),appState:{...o,selectedLinearElement:i?null:o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),d2=F({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:di,predicate:(e,o)=>J(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(r=>r.locked);return{elements:e.map(r=>r.locked?oe(r,{locked:!1}):r),appState:{...o,selectedElementIds:Object.fromEntries(t.map(r=>[r.id,!0]))},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import hv from"clsx";import qI from"fuzzy";import{useEffect as nm,useRef as JI,useState as rm}from"react";var Fd=F({name:"copyElementLink",label:"labels.copyElementLink",icon:ca,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=fc(n,o);return i?(await $o(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):gc(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:A.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}},predicate:(e,o)=>bc(J(e,o))}),m2=F({name:"linkToElement",label:"labels.linkToElement",icon:od,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!bc(n)?{elements:e,appState:o,app:r,captureUpdate:A.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&bc(n)},trackEvent:!1});var aC={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[Fo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[Fo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")],searchMenu:[R("CtrlOrCmd+F")],wrapSelectionInFrame:[]},st=(e,o=0)=>{let t=aC[e];return t&&t.length>0?t[o]||t[0]:""};var lC="\\u0300-\\u036f",sC="\\ufe20-\\ufe2f",cC="\\u20d0-\\u20ff",dC=lC+sC+cC,mC=`[${dC}]`,pC=RegExp(mC,"g"),uC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,hC={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Dh=e=>e.replace(uC,o=>hC[o]||o).replace(pC,"");import DI from"clsx";import{useEffect as PI,useState as RI}from"react";import{useCallback as gC,useState as fC}from"react";var p2=()=>{let[e,o]=fC(null),t=gC(r=>o(r),[]);return[e,t]};import{useState as Q2,useCallback as Vh,useMemo as ev,useEffect as j2,memo as tv,useRef as II}from"react";import{useEffect as f2,useRef as b2}from"react";var yn=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ta({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return Tc(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let h=n?.(d,p)||{width:d,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},u2=async e=>{let{mimeType:o=ue.png,quality:t}=e;o===ue.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ue.png}" mimeType`),o==="image/jpg"&&(o=ue.jpg),o===ue.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ue.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await yn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ue.png&&e.appState?.exportEmbedScene&&(a=await Qb({blob:a,metadata:wl(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},Aa=async({elements:e,appState:o=cr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=ta({elements:e,appState:o},null,null),m={...c,exportPadding:r};return ea(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},bC=async e=>{if(e.type==="svg"){let o=await Aa(e);await $o(o.outerHTML)}else if(e.type==="png")await Ld(u2(e));else if(e.type==="json")await kd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as xC,useState as EC}from"react";var Ph=Le(new Map),h2=async e=>await Aa({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Io.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),g2=(e,o,t)=>{let[r,n]=EC();return xC(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await h2(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await h2(o);n(i)})()},[e,o,t,n]),r},Hd=()=>{let[e]=ve(Ph);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var yC=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],E2=new Dt,wi=Le({status:"loaded",isInitialized:!1,libraryItems:[]}),ql=e=>to(e),vC=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),y2=(e,o)=>{let t=[];for(let r of o)vC(e,r)&&t.push(r);return[...t,...e]},v2=(e,o)=>{let t=ne(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=ne(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Rh=class{constructor(o){k(this,"currLibraryItems",[]);k(this,"prevLibraryItems",ql(this.currLibraryItems));k(this,"app");k(this,"updateQueue",[]);k(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);k(this,"notifyListeners",()=>{if(this.updateQueue.length>0)St.set(wi,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{St.set(wi,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ql(this.currLibraryItems);let t=ql(this.currLibraryItems);this.app.props.onLibraryChange?.(t),E2.trigger(v2(o,t),t)}catch(o){console.error(o)}}});k(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],St.set(Ph,new Map)});k(this,"resetLibrary",()=>this.setLibrary([]));k(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(ql(t))}catch{return o(this.currLibraryItems)}}));k(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:At.name,tab:rl}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Zp(s,i):c=Cl(s,i),!t||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?y2(this.currLibraryItems,c):c)):l(new Ji)}catch(s){l(s)}}))));k(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=ql(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},w2=Rh,Vd=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:E}=_t(x.elements);return Math.max(b,E)},0),i=u=>{let h=0,b=0,x=0;for(let E of e){if(h%t===0&&(b=0),b===u){let{width:w}=_t(E.elements);x=Math.max(x,w)}h++,b++}return x},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:h,minY:b,width:x,height:E}=_t(u.elements),w=(c-x)/2,y=(s-E)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+w-h,y:v.y+l+y-b}))),a+=c+50,m++,d++}return r},wC=(e,o=yC)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Nh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Rs.addLibrary)||new URLSearchParams(window.location.search).get(Ps.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},vn=class vn{constructor(o){k(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Cl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?vn.queue.push(n):n()}getLibraryItems(o){return vn.getLibraryItems(this.adapter,o,!1)}};k(vn,"queue",new n1),k(vn,"run",async(o,t)=>{let r=new vn(o);return vn.queue.push(()=>t(r))});var _a=vn,Jl=0,Ud=0,Gd=e=>Sp(e.map(o=>`${o.id}:${Ip(o.elements)}`).sort().join()),x2=async(e,o)=>{try{return Ud++,await _a.run(e,async t=>{let r=ne(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=Gd(i);return a!==Jl&&await e.save({libraryItems:i}),Jl=a,i})}finally{Ud--}},TC=e=>{let{excalidrawAPI:o}=e,t=b2(e);t.current=e;let r=b2(!1);f2(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=Zs(l),wC(l,t.current.validateLibraryUrl);let h=await(await fetch(l)).blob();d(h)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(Rs.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(Rs.addLibrary),window.history.replaceState({},qa,`#${d.toString()}`)}else if(window.location.search.includes(Ps.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(Ps.addLibrary),window.history.replaceState({},qa,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Nh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Nh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=p1();s?c.resolve(xp(s.load).then(async m=>{let d=null;try{if(!m)return _a.getLibraryItems(l,"load");d=Cl(m.libraryItems||[],"published");let p=await x2(l,v2([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(m=>(console.error(`error during library migration: ${m.message}`),_a.getLibraryItems(l,"load")))):c.resolve(xp(_a.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return Jl=Gd(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),f2(()=>{let n=E2.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Jl!==Gd(l)&&await x2(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Ud&&g1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Jl=0,Ud=0}},[])};import SC from"clsx";import{jsx as IC}from"react/jsx-runtime";var CC=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return IC("a",{className:"library-menu-browse-button",href:`${S.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${Os.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},T2=CC;import{jsx as kC,jsxs as MC}from"react/jsx-runtime";var Yd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>MC("div",{className:SC("library-menu-control-buttons",i),style:r,children:[kC(T2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Ra,useEffect as yI,useMemo as X2,useRef as vI,useState as wI}from"react";import LC from"lodash.throttle";import{useEffect as AC}from"react";var _C=Le(0),C2=e=>{let[o,t]=ve(_C);return AC(()=>{let{current:r}=e;if(!r)return;let n=LC(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import nI from"clsx";import{useCallback as iI,useState as zh}from"react";import{flushSync as I2}from"react-dom";import DC from"clsx";import{jsx as Wd,jsxs as RC}from"react/jsx-runtime";var PC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return RC("button",{className:DC("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&Wd("div",{style:a?{visibility:"hidden"}:{},children:r}),Wd("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Wd("div",{style:{position:"absolute",inset:0},children:Wd(Mt,{})})]})},zr=PC;import{jsx as S2,jsxs as k2}from"react/jsx-runtime";var NC=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=Ie(),c=mn(Da),{container:m}=ht();return k2(ct,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,k2("div",{className:"confirm-dialog-buttons",children:[S2(zr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),I2(()=>{t()}),m?.focus()}}),S2(zr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),I2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Kd=NC;import Xd from"open-color";import{useCallback as GC,useEffect as Bh,useRef as M2,useState as Oh}from"react";var Do=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};k(Do,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),k(Do,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Zd from"react";var OC=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,BC=/{{([\w-]+)}}/,zC=/<([\w-]+)>/,FC=/<\/([\w-]+)>/,HC=(e,o)=>{let t=[{name:"",children:[]}];return e.split(OC).filter(Boolean).forEach(r=>{let n=r.match(zC),i=r.match(FC),a=r.match(BC);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=Zd.createElement(Zd.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},UC=({i18nKey:e,children:o,...t})=>{let{t:r}=mt();return Zd.createElement(Zd.Fragment,{},...HC(r(e),t))},Wt=UC;import{jsx as we,jsxs as Rt}from"react/jsx-runtime";var VC=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=m1(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=Xd.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await yn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),h=s%6*(128+r*2);l.drawImage(m,h+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Xd.gray[4],l.strokeRect(h+r/2,u+r/2,128+r,128+r)}return await Il(new File([await Dr(a)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},YC=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=M2(null),a=M2(null);return Bh(()=>{let l=i.current;l&&(async()=>{let s=await Aa({elements:e.elements,appState:{...o,viewBackgroundColor:Xd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),Rt("div",{className:"single-library-item",children:[e.status==="published"&&we("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),we("div",{ref:i,className:"single-library-item__svg"}),we(Q,{"aria-label":f("buttons.remove"),type:"button",icon:ko,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:f("buttons.remove")}),Rt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Rt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Rt("div",{style:{padding:"0.5em 0"},children:[we("span",{style:{fontWeight:500,color:Xd.gray[6]},children:f("publishDialog.itemName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),we("span",{className:"error",children:e.error})]})]})},WC=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Oh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Oh(!1);Bh(()=>{let y=Do.get(qr.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Oh(o.slice());Bh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},h=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(d.forEach(z=>{let V="";z.name||(V=f("publishDialog.errors.required"),C=!0),v.push({...z,error:V})}),C){p(v),m(!1);return}let I=await VC(d),_={type:$r.excalidrawLibrary,version:Os.excalidrawLibrary,source:Uf,libraryItems:d},L=JSON.stringify(_,null,2),N=new Blob([L],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",N),P.append("previewImage",I),P.append("previewImageType",I.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${S.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(z=>z.ok?z.json().then(({url:V})=>{Do.delete(qr.PUBLISH_LIBRARY),r({url:V,authorName:l.authorName,items:d})}):z.json().catch(()=>{throw new Error(z.statusText||"something went wrong")}).then(V=>{throw new Error(V.message||z.statusText||"something went wrong")}),z=>{console.error(z),n(z),m(!1)}).catch(z=>{console.error(z),n(z),m(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(we("div",{className:"single-library-item-wrapper",children:we(YC,{libItem:v,appState:t,index:C,onChange:(I,_)=>{let L=d.slice();L[_].name=I,p(L)},onRemove:a})},C))}),we("div",{className:"selected-library-items",children:y})},x=GC(()=>{i(d),Do.set(qr.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,w=o.some(y=>y.status==="published");return we(ct,{onCloseRequest:x,title:f("publishDialog.title"),className:"publish-library",children:E?Rt("form",{onSubmit:h,children:[we("div",{className:"publish-library-note",children:we(Wt,{i18nKey:"publishDialog.noteDescription",link:y=>we("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("span",{className:"publish-library-note",children:we(Wt,{i18nKey:"publishDialog.noteGuidelines",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),w&&we("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),b(),Rt("div",{className:"publish-library__fields",children:[Rt("label",{children:[Rt("div",{children:[we("span",{children:f("publishDialog.libraryName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),Rt("label",{style:{alignItems:"flex-start"},children:[Rt("div",{children:[we("span",{children:f("publishDialog.libraryDesc")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),Rt("label",{children:[Rt("div",{children:[we("span",{children:f("publishDialog.authorName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),Rt("label",{children:[we("span",{children:f("publishDialog.githubUsername")}),we("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),Rt("label",{children:[we("span",{children:f("publishDialog.twitterUsername")}),we("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),Rt("label",{children:[we("span",{children:f("publishDialog.website")}),we("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),we("span",{className:"publish-library-note",children:we(Wt,{i18nKey:"publishDialog.noteLicense",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),Rt("div",{className:"publish-library__buttons",children:[we(zr,{label:f("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),we(zr,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):we("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},L2=WC;import XC from"clsx";import{useEffect as $C,useRef as jC}from"react";import{forwardRef as A2}from"react";import _2 from"clsx";import{jsx as D2}from"react/jsx-runtime";var KC=A2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>D2("div",{className:_2("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),ZC=A2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>D2("div",{className:_2("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),Ct={Row:KC,Col:ZC};import{jsx as $d}from"react/jsx-runtime";var P2=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=Ce(),a=jC(null),l=un({onClickOutside:o});pa(a,()=>{l.onClickOutside?.()}),$C(()=>{let c=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=XC(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return $d(ju.Provider,{value:{onSelect:r},children:$d("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?$d(Ct.Col,{className:"dropdown-menu-container",children:e}):$d(Et,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};P2.displayName="DropdownMenuContent";var R2=P2;import{jsx as JC}from"react/jsx-runtime";var qC=({children:e,className:o="",selected:t,...r})=>JC("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),N2=qC;import{jsx as O2}from"react/jsx-runtime";var B2=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noreferrer",...s})=>{let c=fd(s.onClick,n);return O2("a",{...s,href:t,target:"_blank",rel:"noreferrer",className:gd(i,a),title:s.title??s["aria-label"],onClick:c,children:O2(hd,{icon:e,shortcut:o,children:r})})},Pa=B2;B2.displayName="DropdownMenuItemLink";import{jsx as QC}from"react/jsx-runtime";var z2=()=>QC("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),F2=z2;z2.displayName="DropdownMenuSeparator";import eI from"clsx";import{jsx as tI}from"react/jsx-runtime";var H2=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=Ce(),a=eI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return tI("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},U2=H2;H2.displayName="DropdownMenuTrigger";import jd from"react";var G2=e=>{let o=jd.Children.toArray(e).find(t=>jd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},V2=e=>{let o=jd.Children.toArray(e).find(t=>jd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as oI,jsxs as rI}from"react/jsx-runtime";var Fr=({children:e,open:o})=>{let t=G2(e),r=V2(e);return rI(oI,{children:[t,o&&r]})};Fr.Trigger=U2;Fr.Content=R2;Fr.Item=Vt;Fr.ItemLink=Pa;Fr.ItemCustom=N2;Fr.Group=Ul;Fr.Separator=F2;var Ne=Fr;Fr.displayName="DropdownMenu";import{jsx as ao,jsxs as qd}from"react/jsx-runtime";var aI=(e,o)=>e.filter(t=>o.includes(t.id)),lI=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ve(wi),[c,m]=ve(Da),d=()=>{let P=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),z=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return ao(Kd,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:z,children:ao("p",{children:P})})},[p,u]=zh(!1),h=!!o.length,b=h?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=h?f("buttons.remove"):f("buttons.resetLibrary"),[E,w]=zh(!1),[y,v]=zh(null),C=iI(()=>qd(ct,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[ao("p",{children:ao(Wt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>ao("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),ao(Q,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),I=(P,z)=>{w(!1),v({url:P.url,authorName:P.authorName});let V=z.slice();V.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(V)},_=async()=>{try{await t.updateLibrary({libraryItems:xc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:f("errors.importLibraryError")})}},L=async()=>{let P=h?b:await t.getLatestLibrary();Zb(P).catch(Vs).catch(z=>{e({errorMessage:z.message})})},N=()=>qd(Ne,{open:c,children:[ao(Ne.Trigger,{onToggle:()=>m(!c),children:P0}),qd(Ne.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!h&&ao(Ne.Item,{onSelect:_,icon:sa,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&ao(Ne.Item,{onSelect:L,icon:mi,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&ao(Ne.Item,{onSelect:()=>u(!0),icon:ho,children:x}),h&&ao(Ne.Item,{icon:Kx,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return qd("div",{className:nI("library-menu-dropdown-container",l),children:[N(),o.length>0&&ao("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&ao(L2,{onClose:()=>w(!1),libraryItems:aI(s.libraryItems,o),appState:a,onSuccess:P=>I(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(z=>z!==P))}),y&&C()]})},Fh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=lt(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Hd(),a=_e(),l=Ie(),[s]=ve(wi),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return ao(lI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as fI,useEffect as bI,useState as xI}from"react";import sI,{useCallback as cI}from"react";function dI(){return[!1,cI(o=>o(),[])]}var Y2=sI.useTransition||dI;import W2 from"clsx";import{memo as mI,useEffect as pI,useRef as uI,useState as hI}from"react";import{jsx as Jd,jsxs as gI}from"react/jsx-runtime";var K2=mI(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=uI(null),c=g2(e,o,l);pI(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[m,d]=hI(!1),p=Ce().editor.isMobile,u=t&&Jd("div",{className:"library-unit__adder",children:D0});return gI("div",{className:W2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[Jd("div",{className:W2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?h=>{e&&h.shiftKey?i(e,h):r(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}d(!1),a(e,h)}}),u,e&&o&&(m||p||n)&&Jd(Wl,{checked:n,onChange:(h,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Z2=()=>Jd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as EI,jsx as Qd}from"react/jsx-runtime";var Hh=({children:e})=>Qd("div",{className:"library-menu-items-container__grid",children:e}),em=fI(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Y2(),[s,c]=xI(0);return bI(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Qd(EI,{children:e.map((m,d)=>d<s?Qd(K2,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??d):Qd(Z2,{},d))})});import{Fragment as $2,jsx as lo,jsxs as Na}from"react/jsx-runtime";var TI=17,CI=64;function Uh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=vI(null),d=C2(m);yI(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Hd(),u=X2(()=>o.filter(P=>P.status!=="published"),[o]),h=X2(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!h.length,[E,w]=wI(null),y=Ra((P,z)=>{let V=!c.includes(P),U=[...u,...h];if(V){if(z.shiftKey&&E){let q=U.findIndex(re=>re.id===E),H=U.findIndex(re=>re.id===P);if(q===-1||H===-1){s([...c,P]);return}let G=ne(c),Y=U.reduce((re,$,le)=>((le>=q&&le<=H||G.has($.id))&&re.push($.id),re),[]);s(Y)}else s([...c,P]);w(P)}else w(null),s(c.filter(q=>q!==P))},[E,s,h,c,u]),v=Ra(P=>{let z;return c.includes(P)?z=o.filter(V=>c.includes(V.id)):z=o.filter(V=>V.id===P),z.map(V=>({...V,elements:ai({type:"everything",elements:V.elements,randomizeSeed:!0}).newElements}))},[o,c]),C=Ra((P,z)=>{z.dataTransfer.setData(ue.excalidrawlib,Yp(v(P)))},[v]),I=Ra(P=>P?c.includes(P):!1,[c]),_=Ra(()=>{t(n)},[n,t]),L=Ra(P=>{P&&r(v(P))},[v,r]),N=p.size>=o.length?CI:TI;return Na("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&lo(Fh,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Na(Ct.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[Na($2,{children:[!x&&lo("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&lo("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:lo(Mt,{})}),!n.length&&!u.length?Na("div",{className:"library-menu-items__no-items",children:[lo("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),lo("div",{className:"library-menu-items__no-items__hint",children:h.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Na(Hh,{children:[n.length>0&&lo(em,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:_,isItemSelected:I,svgCache:p}),lo(em,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:I,svgCache:p})]})]}),Na($2,{children:[(h.length>0||n.length>0||u.length>0)&&lo("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),h.length>0?lo(Hh,{children:lo(em,{itemsRenderedPerBatch:N,items:h,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:I,svgCache:p})}):u.length>0?lo("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&lo(Yd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:lo(Fh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as wn,jsxs as J2}from"react/jsx-runtime";var Da=Le(!1),q2=({children:e})=>wn("div",{className:"layer-ui__library",children:e}),SI=tv(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ve(wi),d=Vh(h=>{(async(x,E)=>{xe("element","addToLibrary","ui");for(let y of zs)if(x.some(v=>v.type===y))return r({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:x,id:oo(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{r({errorMessage:f("alerts.errorAddingToLibrary")})})})(h,m.libraryItems)},[t,i,r,m.libraryItems]),p=ev(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return wn(q2,{children:wn("div",{className:"layer-ui__library-message",children:J2("div",{children:[wn(Mt,{size:"2em"}),wn("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return J2(q2,{children:[wn(Uh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&wn(Yd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Gh=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),kI=(e,o)=>{let t=gn(),[r,n]=Q2(()=>Gh(t,e.selectedElementIds)),i=II(new Map);return j2(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),j2(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!Je(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Gh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Gh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},ov=tv(()=>{let e=lt(),{onInsertElements:o}=e,t=pr(),r=_e(),n=Ie(),[i,a]=Q2([]),l=ev(()=>e.library,[e.library]),s=kI(r,e),c=Vh(d=>{o(Vd(d))},[o]),m=Vh(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return wn(SI,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import MI from"clsx";import{useRef as LI}from"react";import{createPortal as AI}from"react-dom";import{jsx as rv,jsxs as _I}from"react/jsx-runtime";var nv=e=>{let{closeOnClickOutside:o=!0}=e,t=ld({className:"excalidraw-modal-container"}),r=LI(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===T.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return AI(_I("div",{className:MI("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[rv("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),rv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Ql,jsxs as OI}from"react/jsx-runtime";function NI(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ct=e=>{let[o,t]=p2(),[r]=RI(document.activeElement),{id:n}=ht(),i=Ce().viewport.isMobile;PI(()=>{if(!o)return;let c=cl(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===T.TAB){let p=cl(o),{activeElement:u}=document,h=p.findIndex(b=>b===u);h===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):h===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=Ie(),l=mn(Da),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Ql(nv,{className:DI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:NI(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:OI(Et,{ref:t,children:[e.title&&Ql("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Ql("span",{className:"Dialog__titleContent",children:e.title})}),i&&Ql("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:ko}),Ql("div",{className:"Dialog__content",children:e.children})]})})};import Yh from"clsx";import{forwardRef as FI,useRef as HI,useImperativeHandle as UI,useLayoutEffect as GI,useState as VI}from"react";import BI from"clsx";import{jsx as zI}from"react/jsx-runtime";var vo=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>zI("button",{onClick:on(i.onClick,a=>{o()}),type:e,className:BI("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Wh,jsxs as iv}from"react/jsx-runtime";var Oa=FI(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...m},d)=>{let p=HI(null);UI(d,()=>p.current),GI(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,h]=VI(!1);return iv("div",{className:Yh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Wh("div",{className:"ExcTextField__label",children:o}),iv("div",{className:Yh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Wh("input",{className:Yh({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&Wh(vo,{onSelect:()=>h(!u),style:{border:0,userSelect:"none"},children:u?eE:ma})]})]})});var es=[{icon:z0,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:F0,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:H0,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:U0,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:G0,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:V0,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:pn,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:Hc,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:W0,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:K0,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],av=e=>es.find((t,r)=>t.numericKey!=null&&e===t.numericKey.toString()||t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import Xh from"clsx";import{useState as KI}from"react";import{createIsolation as YI}from"jotai-scope";import Kh from"react";import gr from"tunnel-rat";var Zh=Kh.createContext(null),We=()=>Kh.useContext(Zh),WI=YI(),lv=()=>Kh.useMemo(()=>({MainMenuTunnel:gr(),WelcomeScreenMenuHintTunnel:gr(),WelcomeScreenToolbarHintTunnel:gr(),WelcomeScreenHelpHintTunnel:gr(),WelcomeScreenCenterTunnel:gr(),FooterCenterTunnel:gr(),DefaultSidebarTriggerTunnel:gr(),DefaultSidebarTabTriggersTunnel:gr(),OverwriteConfirmDialogTunnel:gr(),TTDDialogTriggerTunnel:gr(),tunnelsJotai:WI}),[]);import{Fragment as Hr,jsx as Ke,jsxs as yt}from"react/jsx-runtime";var $h=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return yl(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>yl(r.type))},jh=(e,o)=>sn(e.activeTool.type)||o.some(t=>sn(t.type)),tm=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=cc(o,e),i=!1;n.length===2&&(Tt(n[0])||Tt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=sn(e.activeTool.type)&&!Vn(e.currentItemBackgroundColor)||n.some(h=>sn(h.type)&&!Vn(h.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&ce(n[0])&&!ee(n[0]),p=!e.croppingElementId&&n.length===1&&he(n[0]),u=!i&&io(e,r);return yt("div",{className:"panelColumn",children:[Ke("div",{children:$h(e,n)&&t("changeStrokeColor")}),jh(e,n)&&Ke("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(_p(e.activeTool.type)||n.some(h=>_p(h.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(h=>h.type==="freedraw"))&&t("changeStrokeShape"),(Dp(e.activeTool.type)||n.some(h=>Dp(h.type)))&&yt(Hr,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Pp(e.activeTool.type)||n.some(h=>Pp(h.type)))&&Ke(Hr,{children:t("changeRoundness")}),(Rp(e.activeTool.type)||n.some(h=>Rp(h.type)))&&Ke(Hr,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(Z))&&yt(Hr,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||W1(n,o))&&t("changeTextAlign")]}),Y1(n,o)&&t("changeVerticalAlign"),(Zi(e.activeTool.type)||n.some(h=>Zi(h.type)))&&Ke(Hr,{children:t("changeArrowhead")}),t("changeOpacity"),yt("fieldset",{children:[Ke("legend",{children:f("labels.layers")}),yt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&yt("fieldset",{children:[Ke("legend",{children:f("labels.align")}),yt("div",{className:"buttonList",children:[s?yt(Hr,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):yt(Hr,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Ke("div",{style:{flexBasis:"100%",height:0}}),yt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&yt("fieldset",{children:[Ke("legend",{children:f("labels.actions")}),yt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},om=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=KI(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=We();return yt(Hr,{children:[es.map(({value:m,icon:d,key:p,numericKey:u,fillable:h},b)=>{if(r.tools?.[m]===!1)return null;let x=f(`toolBar.${m}`),E=p&&Qr(typeof p=="string"?p:p[0]),w=E?`${E} ${f("helpDialog.or")} ${u}`:`${u}`;return Ke(Q,{className:Xh("Shape",{fillable:h}),type:"radio",icon:d,checked:e.type===m,name:"editor-current-shape",title:`${Qr(x)} \u2014 ${w}`,keyBindingLabel:u||E,"aria-label":Qr(x),"aria-keyshortcuts":w,"data-testid":`toolbar-${m}`,onPointerDown:({pointerType:y})=>{!o.penDetected&&y==="pen"&&t.togglePenMode(!0)},onChange:({pointerType:y})=>{o.activeTool.type!==m&&xe("toolbar",m,"ui"),m==="image"?t.setActiveTool({type:m,insertOnCanvasDirectly:y!=="mouse"}):t.setActiveTool({type:m})}},m)}),Ke("div",{className:"App-toolbar__divider"}),yt(Ne,{open:n,children:[Ke(Ne.Trigger,{className:Xh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:f("toolBar.extraTools"),children:Jx}),yt(Ne.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ke(Ne.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:$c,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Ke(Ne.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:X0,"data-testid":"toolbar-embeddable",selected:s,children:f("toolBar.embeddable")}),Ke(Ne.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:qc,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Ke("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Ke(c.Out,{}),Ke(Ne.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:jc,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Ke(Hr,{children:yt(Ne.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Jc,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Ke(Ne.Item.Badge,{children:"AI"})]})})]})]})]})},sv=({renderAction:e,zoom:o})=>Ke(Ct.Col,{gap:1,className:Ho.ZOOM_ACTIONS,children:yt(Ct.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),cv=({renderAction:e,className:o})=>yt("div",{className:`undo-redo-buttons ${o}`,children:[Ke("div",{className:"undo-button-container",children:Ke(bo,{label:f("buttons.undo"),children:e("undo")})}),Ke("div",{className:"redo-button-container",children:yt(bo,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),dv=({actionManager:e,showExitZenModeBtn:o})=>Ke("button",{type:"button",className:Xh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ka),children:f("buttons.exitZenMode")}),mv=({renderAction:e,className:o})=>Ke("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as ZI}from"react";var qh=e=>{let o=ZI({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as $I,jsxs as XI}from"react/jsx-runtime";var Ti=Le(null),pv=()=>{let[e,o]=ve(Ti),t=gt();return e&&e==="clearCanvas"?$I(Kd,{onConfirm:()=>{t.executeAction(Or),o(null)},onCancel:()=>o(null),title:f("clearCanvasDialog.title"),children:XI("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var Jh={};wf(Jh,{toggleTheme:()=>jI});var jI={...gi,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(gi,"commandPalette")}};import{jsx as Kt,jsxs as fr}from"react/jsx-runtime";var QI=Le(null),nt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},eS=e=>{switch(e){case nt.app:return 1;case nt.export:return 2;case nt.editor:return 3;case nt.tools:return 4;case nt.elements:return 5;case nt.links:return 6;default:return 10}},im=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return fr("div",{className:hv("shortcut",o),children:[r.map((n,i)=>Kt("div",{className:"shortcut-wrapper",children:Kt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Kt("div",{className:"shortcut-desc",children:t})]})},gv=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),nq=Object.assign(e=>{let o=_e(),t=Ie();return nm(()=>{let r=n=>{gv(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&xe("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Kt(tS,{...e})},{defaultItems:Jh});function tS({customCommandPaletteItems:e}){let o=lt(),t=_e(),r=Ie(),n=pr(),i=gt(),[a,l]=ve(QI),[s,c]=rm(null),m=JI(null),d=un({uiAppState:t,customCommandPaletteItems:e,appProps:n});nm(()=>{let{uiAppState:I,customCommandPaletteItems:_,appProps:L}=d,N=U=>{let q="";return U.label&&(typeof U.label=="function"?q=f(U.label(o.scene.getNonDeletedElements(),I,o)):q=f(U.label)),q},P=U=>typeof U.icon=="function"?U.icon(I,o.scene.getNonDeletedElements()):U.icon,z=[],V=(U,q,H)=>{let G={label:N(U),icon:P(U),category:q,shortcut:st(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return H?H(G,U):G};if(I&&o.scene&&i){let U=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,jl,Fd,m2].map($=>V($,nt.elements,(le,be)=>({...le,predicate:be.predicate?be.predicate:(Te,ot,$t,zo)=>J(Te,ot).length>0}))),q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map($=>V($,nt.tools)),H=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map($=>V($,nt.editor)),G=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map($=>V($,nt.export));z=[...U,...H,{label:N(Or),icon:P(Or),shortcut:st(Or.name),category:nt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{St.set(Ti,"clearCanvas")}},{label:f("buttons.exportImage"),category:nt.export,icon:Yc,shortcut:st("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...G];let Y=[{label:f("toolBar.library"),category:nt.app,icon:ia,viewMode:!1,perform:()=>{I.openSidebar?r({openSidebar:null}):r({openSidebar:{name:At.name,tab:At.defaultTab}})}},{label:f("search.title"),category:nt.app,icon:go,viewMode:!0,perform:()=>{i.executeAction(ts)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:nt.elements,icon:Vc,viewMode:!1,predicate:($,le)=>{let be=J($,le);return be.length>0&&$h(le,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:Vc,category:nt.elements,viewMode:!1,predicate:($,le)=>{let be=J($,le);return be.length>0&&jh(le,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:Vc,category:nt.editor,viewMode:!1,perform:()=>{r($=>({openMenu:$.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...es.reduce(($,le)=>{let{value:be,icon:Te,key:ot,numericKey:$t}=le;if(L.UIOptions.tools?.[be]===!1)return $;let Qo=ot&&Qr(typeof ot=="string"?ot:ot[0])||$t,jt={label:f(`toolBar.${be}`),category:nt.tools,shortcut:Qo,icon:Te,keywords:["toolbar"],viewMode:!1,perform:({event:er})=>{be==="image"?o.setActiveTool({type:be,insertOnCanvasDirectly:er.type==="keydown"}):o.setActiveTool({type:be})}};return $.push(jt),$},[]),...q,{label:f("toolBar.lock"),category:nt.tools,icon:I.activeTool.locked?aa:di,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:nt.tools,icon:oE,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:nt.tools,icon:jc,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"mermaid"}}))}}],re=[...z,...Y,..._||[]].map($=>({...$,icon:$.icon||Qc,order:$.order??eS($.category),haystack:`${Dh($.label.toLocaleLowerCase())} ${$.keywords?.join(" ")||""}`}));c(re),l(re.find($=>$.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=rm(""),[h,b]=rm(null),[x,E]=rm({}),w=I=>{r({openDialog:null},I),u("")},y=(I,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{I.perform({actionManager:i,event:_}),l(I),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=qh(I=>I.viewMode===!1&&t.viewModeEnabled?!1:typeof I.predicate=="function"?I.predicate(o.scene.getNonDeletedElements(),t,n,o):I.predicate===void 0||I.predicate),C=qh(I=>{let _=or(I.target)||gv(I)||I.key===T.ESCAPE;if(_&&I.key!==T.ARROW_UP&&I.key!==T.ARROW_DOWN&&I.key!==T.ENTER)return;let L=Object.values(x).flat(),N=a&&!p&&v(a);if(I.key===T.ARROW_UP){I.preventDefault();let P=L.findIndex(U=>U.label===h?.label);if(N){if(P===0){b(a);return}if(h===a){let U=L[L.length-1];U&&b(U);return}}let z;P===-1?z=L.length-1:z=P===0?L.length-1:(P-1)%L.length;let V=L[z];V&&b(V);return}if(I.key===T.ARROW_DOWN){I.preventDefault();let P=L.findIndex(U=>U.label===h?.label);if(N){if(!h||P===L.length-1){b(a);return}if(h===a){let U=L[0];U&&b(U);return}}let z=(P+1)%L.length,V=L[z];V&&b(V);return}if(I.key===T.ENTER&&h&&setTimeout(()=>{y(h,I)}),!_){if(I.stopPropagation(),/^[a-zA-Z0-9]$/.test(I.key)){m?.current?.focus();return}I.preventDefault()}});return nm(()=>(window.addEventListener("keydown",C,{capture:!0}),()=>window.removeEventListener("keydown",C,{capture:!0})),[C]),nm(()=>{if(!s)return;let I=P=>{let z={};for(let V of P)z[V.category]?z[V.category].push(V):z[V.category]=[V];return z},_=s.filter(v).sort((P,z)=>P.order-z.order),L=!p&&a&&v(a);if(!p){E(I(L?_.filter(P=>P.label!==a?.label):_)),b(L?a:_[0]||null);return}let N=Dh(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=qI.filter(N,_,{extract:P=>P.haystack}).sort((P,z)=>z.score-P.score).map(P=>P.original),E(I(_)),b(_[0]??null)},[p,s,v,a]),fr(ct,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Kt(Oa,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:I=>{u(I)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&fr("div",{className:"shortcuts-wrapper",children:[Kt(im,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Kt(im,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Kt(im,{shortcut:R("Esc"),children:f("commandPalette.shortcuts.close")})]}),fr("div",{className:"commands",children:[a&&!p&&fr("div",{className:"command-category",children:[fr("div",{className:"command-category-title",children:[f("commandPalette.recents"),Kt("div",{className:"icon",style:{marginLeft:"6px"},children:rE})]}),Kt(uv,{command:a,isSelected:a.label===h?.label,onClick:I=>y(a,I),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((I,_)=>fr("div",{className:"command-category",children:[Kt("div",{className:"command-category-title",children:I}),x[I].map(L=>Kt(uv,{command:L,isSelected:L.label===h?.label,onClick:N=>y(L,N),onMouseMove:()=>b(L),showShortcut:!o.device.viewport.isMobile,appState:t},L.label))]},I)):s?fr("div",{className:"no-match",children:[Kt("div",{className:"icon",children:go})," ",f("commandPalette.search.noMatch")]}):null]})]})}var uv=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return fr("div",{className:hv("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?f("commandPalette.itemNotAvailable"):"",children:[fr("div",{className:"name",children:[e.icon&&Kt(xn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Kt(im,{shortcut:e.shortcut})]})};import{jsx as oS}from"react/jsx-runtime";var Qh=F({name:"toggleLinearEditor",category:nt.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.editingLinearElement&&n.length===1&&ce(n[0])&&!ee(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0],i=o.editingLinearElement?.elementId===n.id?null:new j(n);return{appState:{...o,editingLinearElement:i},captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=f(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return oS(Q,{type:"button",icon:bE,title:n,"aria-label":n,onClick:()=>o(null)})}});var ts=F({name:"searchMenu",icon:go,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openSidebar?.name===At.name&&o.openSidebar.tab===Cr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Ho.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.matches(":focus")?{appState:{...o,openSidebar:null},captureUpdate:A.EVENTUALLY}:(n?.focus(),n?.select(),!1)}return{appState:{...o,openSidebar:{name:At.name,tab:Cr},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as rS}from"react/jsx-runtime";var eg=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Lu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&he(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=f("helpDialog.cropStart");return rS(Q,{type:"button",icon:Lu,title:r,"aria-label":r,onClick:()=>o(null)})}});var fv=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ie(t[0])},bv=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ie(n)){let i=nr(Ee(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:A.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>fv(o,r)}),xv=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ie(n)?{elements:db(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>fv(o,r)}),CJ=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:A.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),IJ=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:$c,viewMode:!1,perform:(e,o,t,r)=>{let n=Ge(o,{type:"frame"});return Eo(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ge(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),Ev=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length>0&&!n.some(i=>ie(i))},perform:(e,o,t,r)=>{let n=J(e,o),[i,a,l,s]=ye(n,r.scene.getNonDeletedElementsMap()),c=16,m=$i({x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2});if(o.editingGroupId){let p=Ue(n,o.editingGroupId);for(let u of p){let h=u.groupIds.indexOf(o.editingGroupId);B(u,{groupIds:u.groupIds.slice(0,h)},!1)}}return{elements:Wi([...r.scene.getElementsIncludingDeleted(),m],n,m,o),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var Ci=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},os=class e{constructor(){k(this,"onHistoryChangedEmitter",new Dt);k(this,"undoStack",[]);k(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o,t){let r=tg.create(t,o);r.isEmpty()||(this.undoStack.push(r.inverse()),r.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Ci(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,o))}redo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,o))}perform(o,t,r,n,i){try{let a=n();if(a===null)return;let l=o,s=t,c=!1;for(;a;){try{[l,s,c]=a.applyTo(l,s,r)}finally{i(a)}if(c)break;a=n()}return[l,s]}finally{this.onHistoryChangedEmitter.trigger(new Ci(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t,r){let n=t.inverse().applyLatestChanges(r);return o.push(n)}},tg=class e{constructor(o,t){this.appStateChange=o;this.elementsChange=t}static create(o,t){return new e(o,t)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(o,t,r){let[n,i]=this.elementsChange.applyTo(o,r.elements),[a,l]=this.appStateChange.applyTo(t,n);return[n,a,i||l]}applyLatestChanges(o){let t=this.elementsChange.applyLatestChanges(o);return e.create(this.appStateChange,t)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};import{useEffect as nS,useState as iS}from"react";var og=(e,o)=>{let[t,r]=iS(o);return nS(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as Tv}from"react/jsx-runtime";var yv=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:A.EVENTUALLY};let[n,i]=r,a=Array.from(n.values());return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},vv=(e,o)=>({name:"undo",label:"buttons.undo",icon:pu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>yv(i,r,()=>e.undo(ne(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&Fs(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>{let{isUndoStackEmpty:n}=og(e.onHistoryChangedEmitter,new Ci(e.isUndoStackEmpty,e.isRedoStackEmpty));return Tv(Q,{type:"button",icon:pu,"aria-label":f("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),wv=(e,o)=>({name:"redo",label:"buttons.redo",icon:uu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>yv(i,r,()=>e.redo(ne(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&t.shiftKey&&Fs(t,T.Z)||Ss&&t.ctrlKey&&!t.shiftKey&&Fs(t,T.Y),PanelComponent:({updateData:t,data:r})=>{let{isRedoStackEmpty:n}=og(e.onHistoryChangedEmitter,new Ci(e.isUndoStackEmpty,e.isRedoStackEmpty));return Tv(Q,{type:"button",icon:uu,"aria-label":f("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-redo"})}});var Cv=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length===1&&Z(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=J(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&Z(i)){let a=Ft(i.originalText,qe(i),i.lineHeight);return oe(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});var rg=F({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:ma,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.R});import{jsx as aS}from"react/jsx-runtime";var ng=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&xe(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},am=class{constructor(o,t,r,n){k(this,"actions",{});k(this,"updater");k(this,"getAppState");k(this,"getElementsIncludingDeleted");k(this,"app");k(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{ng(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return aS(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}return null});k(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(tn(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return ng(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();ng(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var lm=class{constructor(){k(this,"targets",new WeakMap);k(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var ig=e=>{let o=Array.from(e.values());return{x:Iv(o,t=>t.x)/o.length,y:Iv(o,t=>t.y)/o.length}},ag=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Iv=(e,o)=>e.reduce((t,r)=>t+o(r),0);var lS=8,Sv=99999,sm=e=>lS/e,Zt=class Zt{};k(Zt,"referenceSnapPoints",null),k(Zt,"visibleGaps",null),k(Zt,"setReferenceSnapPoints",o=>{Zt.referenceSnapPoints=o}),k(Zt,"getReferenceSnapPoints",()=>Zt.referenceSnapPoints),k(Zt,"setVisibleGaps",o=>{Zt.visibleGaps=o}),k(Zt,"getVisibleGaps",()=>Zt.visibleGaps),k(Zt,"destroy",()=>{Zt.referenceSnapPoints=null,Zt.visibleGaps=null});var Po=Zt,Tn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Ur=({event:e,app:o,selectedElements:t})=>e?o.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!Tn(o):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,sS=(e,o,t=.01)=>Math.abs(e-o)<=t,rs=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=Ye(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,h=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=se(M(l,s+h),M(d,p),a.angle),x=se(M(l+u,s),M(d,p),a.angle),E=se(M(c,s+h),M(d,p),a.angle),w=se(M(l+u,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}else{let b=se(M(l,s),M(d,p),a.angle),x=se(M(c,s),M(d,p),a.angle),E=se(M(l,m),M(d,p),a.angle),w=se(M(c,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}}else if(e.length>1){let[a,l,s,c]=uc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=M(a,l),u=M(s,l),h=M(a,c),b=M(s,c),x=M(a+m/2,l+d/2);i=t?[p,u,h,b]:[p,u,h,b,x]}return i.map(a=>M(et(a[0]),et(a[1])))},Lv=(e,o,t,r)=>{let n=o.filter(i=>ie(i)).map(i=>i.id);return Ap(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},Av=(e,o,t,r)=>{let n=Lv(e,o,t,r),i=ei(n,r).filter(d=>!(d.length===1&&Be(d[0]))).map(d=>ye(d).map(p=>et(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>Sv)break e;let h=a[u],[,b,x,E]=p,[w,y,,v]=h;x<w&&al(po(b,E),po(y,v))&&l.push({startBounds:p,endBounds:h,startSide:[M(x,b),M(x,E)],endSide:[M(w,y),M(w,v)],length:w-x,overlap:ll(po(b,E),po(y,v))})}}let c=i.sort((d,p)=>d[1]-p[1]),m=[];s=0;e:for(let d=0;d<c.length;d++){let p=c[d];for(let u=d+1;u<c.length;u++){if(++s>Sv)break e;let h=c[u],[b,,x,E]=p,[w,y,v]=h;E<y&&al(po(b,x),po(w,v))&&m.push({startBounds:p,endBounds:h,startSide:[M(b,E),M(x,E)],endSide:[M(w,y),M(v,y)],length:y-E,overlap:ll(po(b,x),po(w,v))})}}return{horizontalGaps:l,verticalGaps:m}},kv=(e,o,t,r,n,i,a)=>{if(!Ur({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Po.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=uc(e,o).map(x=>et(x)),h=(m+p)/2,b=(d+u)/2;for(let x of s){if(!al(po(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,w=et(E-h);if(x.length>p-m&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let P={type:"gap",direction:"center_horizontal",gap:x,offset:w};n.push(P);continue}let[,,v]=x.endBounds,C=m-v,I=et(x.length-C);if(Math.abs(I)<=a.x){Math.abs(I)<a.x&&(n.length=0),a.x=Math.abs(I);let P={type:"gap",direction:"side_right",gap:x,offset:I};n.push(P);continue}let[_,,,]=x.startBounds,L=_-p,N=et(L-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let P={type:"gap",direction:"side_left",gap:x,offset:N};n.push(P);continue}}for(let x of c){if(!al(po(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,w=et(E-b);if(x.length>u-d&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let P={type:"gap",direction:"center_vertical",gap:x,offset:w};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,I=et(C-x.length);if(Math.abs(I)<=a.y){Math.abs(I)<a.y&&(i.length=0),a.y=Math.abs(I);let P={type:"gap",direction:"side_top",gap:x,offset:I};i.push(P);continue}let[,,,_]=x.endBounds,L=et(d-_),N=x.length-L;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let P={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(P);continue}}}},_v=(e,o,t,r)=>{let n=Lv(e,o,t,r);return ei(n,r).filter(i=>!(i.length===1&&Be(i[0]))).flatMap(i=>rs(i,r))},Ba=(e,o,t,r,n,i,a)=>{if(!Ur({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Po.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],d=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:d}),a.y=Math.abs(d))}},Dv=(e,o,t,r,n)=>{let i=t.state,a=J(e,i);if(!Ur({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=et(o.x),o.y=et(o.y);let l=[],s=[],c=sm(i.zoom.value),m={x:c,y:c},d=rs(a,n,{dragOffset:o});Ba(a,d,t,r,l,s,m),kv(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:et(o.x+p.x),y:et(o.y+p.y)};Ba(a,rs(a,n,{dragOffset:u}),t,r,l,s,m),kv(a,u,t,r,l,s,m);let h=lg(l,s),b=dS(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...h,...b]}},et=e=>Math.round(e*10**6)/10**6,Mv=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},lg=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=et(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=et(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:Mv(i.map(a=>M(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:Mv(i.map(a=>M(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},cS=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[et(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},dS=(e,o,t)=>{let[r,n,i,a]=uc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,h,b,x]=s.gap.endBounds,E=ll(po(n,a),s.gap.overlap),w=ll(po(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(s.gap.startSide[0][0],y),M(r,y)]},{type:"gap",direction:"horizontal",points:[M(i,y),M(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,s.gap.startSide[0][1]),M(y,n)]},{type:"gap",direction:"vertical",points:[M(y,a),M(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]},{type:"gap",direction:"horizontal",points:[M(b,y),M(r,y)]})}break}case"side_left":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(i,y),M(c,y)]},{type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,a),M(y,m)]},{type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]},{type:"gap",direction:"vertical",points:[M(y,x),M(y,n)]})}break}}}return cS(l.map(s=>({...s,points:s.points.map(c=>M(et(c[0]),et(c[1])))})))},sg=(e,o,t,r,n,i)=>{if(!Ur({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!sS(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=ye(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let m=[];if(i)switch(i){case"e":{m.push(M(s,l),M(s,c));break}case"w":{m.push(M(a,l),M(a,c));break}case"n":{m.push(M(a,l),M(s,l));break}case"s":{m.push(M(a,c),M(s,c));break}case"ne":{m.push(M(s,l));break}case"nw":{m.push(M(a,l));break}case"se":{m.push(M(s,c));break}case"sw":{m.push(M(a,c));break}}let d=sm(t.state.zoom.value),p={x:d,y:d},u=[],h=[];Ba(o,m,t,r,u,h,p);let b={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[x,E,w,y]=ye(e).map(I=>et(I)),v=[M(x,E),M(x,y),M(w,E),M(w,y)];Ba(e,v,t,r,u,h,p);let C=lg(u,h);return{snapOffset:b,snapLines:C}},Pv=(e,o,t,r,n,i)=>{if(!Ur({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[M(r.x+n.x,r.y+n.y)],l=sm(o.state.zoom.value),s={x:l,y:l},c=[],m=[];Ba([e],a,o,t,c,m,s);let d={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let p=rs([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ba([e],p,o,t,c,m,s);let u=lg(c,m);return{snapOffset:d,snapLines:u}},Rv=(e,o,t,r,n)=>{if(!Ur({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Ap(e,[],o.state,n),a=sm(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=rs([m],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,M(p[0],t.y)],direction:"vertical"}),l.x=u);let h=p[1]-t.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,M(t.x,p[1])],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Nv=e=>e===it.rectangle||e===it.ellipse||e===it.diamond||e===it.frame||e===it.magicframe||e===it.image||e===it.text;var cm={width:100,height:0},Cn=100,mS=(e,o,t)=>{let r=Gt({x:0,y:0,textAlign:ol.CENTER,verticalAlign:Jt.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Qe(r,e,t),[e,r]},Ov=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??Cn,d=o?.height??Cn,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,h=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Gt({x:u,y:h,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Ut({x:u,y:h,width:m,height:d,...p,...o,type:b});break}default:Yn(e,`Unhandled element start type "${o.type}"`,!0)}Vo(e,i,"start",n)}}if(t){let m=t?.height??Cn,d=t?.width??Cn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,h=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Gt({x:u,y:h,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Ut({x:u,y:h,width:d,height:m,...p,...t,type:b});break}default:Yn(e,`Unhandled element end type "${b}"`,!0)}Vo(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=to(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},cg=class{constructor(){k(this,"excalidrawElements",new Map);k(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});k(this,"getElements",()=>_r(Array.from(this.excalidrawElements.values())));k(this,"getElementsMap",()=>nn(ne(this.getElements())));k(this,"getElement",o=>this.excalidrawElements.get(o))}},za=(e,o)=>{if(!e)return[];let t=to(e),r=new cg,n=new Map,i=new Map;for(let l of t){let s,c=l.id;switch(o?.regenerateIds!==!1&&Object.assign(l,{id:oo()}),l.type){case"rectangle":case"ellipse":case"diamond":{let d=l?.label?.text&&l.width===void 0?0:l?.width||Cn,p=l?.label?.text&&l.height===void 0?0:l?.height||Cn;s=Ut({...l,width:d,height:p});break}case"line":{let d=l.width||cm.width,p=l.height||cm.height;s=lr({width:d,height:p,points:[M(0,0),M(d,p)],...l});break}case"arrow":{let d=l.width||cm.width,p=l.height||cm.height;s=ji({width:d,height:p,endArrowhead:"arrow",points:[M(0,0),M(d,p)],...l,type:"arrow"}),Object.assign(s,l1(s.points));break}case"text":{let d=l?.fontFamily||Zr,p=l?.fontSize||Tr,u=l?.lineHeight||Ir(d),h=l.text??"",b=$n(h),x=Ft(b,qe({fontFamily:d,fontSize:p}),u);s=Gt({width:x.width,height:x.height,fontFamily:d,fontSize:p,...l});break}case"image":{s=hc({width:l?.width||Cn,height:l?.height||Cn,...l});break}case"frame":{s=$i({x:0,y:0,...l});break}case"magicframe":{s=vl({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Yn(l,`Unhandled element type "${l.type}"`,!0)}r.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(r.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=r.getElementsMap();for(let[l,s]of n){let c=r.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[m,d]=mS(c,s?.label,a);if(r.add(m),r.add(d),Pe(m)){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let E=i.get(p.id);E&&Object.assign(p,{id:E})}if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}let{linearElement:h,startBoundElement:b,endBoundElement:x}=Ov(m,p,u,r,a);m=h,r.add(h),r.add(b),r.add(x)}}else switch(s.type){case"arrow":{let{start:m,end:d}=s;if(m&&m.id){let b=i.get(m.id);Object.assign(m,{id:b})}if(d&&d.id){let b=i.get(d.id);Object.assign(d,{id:b})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=Ov(c,m,d,r,a);r.add(p),r.add(u),r.add(h);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=r.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let m=[];s.children.forEach(v=>{let C=i.get(v);if(!C)throw new Error(`Element with ${v} wasn't mapped correctly`);let I=r.getElement(C);if(!I)throw new Error(`Frame element with id ${C} doesn't exist`);Object.assign(I,{frameId:c.id}),I?.boundElements?.forEach(_=>{let L=r.getElement(_.id);if(!L)throw new Error(`Bound element with id ${_.id} doesn't exist`);Object.assign(L,{frameId:c.id}),m.push(L)}),m.push(I)});let[d,p,u,h]=ye(m),b=10;d=d-b,p=p-b,u=u+b,h=h+b;let x=c?.x||d,E=c?.y||p,w=c?.width||u-d,y=c?.height||h-p;Object.assign(c,{x,y:E,width:w,height:y}),Fe()&&s.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import dm from"open-color";var pS="#ff6b6b",uS="#ff0000",Bv=1,zv=2,Fv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===de.LIGHT||o.zenModeEnabled?pS:uS,r=(o.zenModeEnabled?Bv*1.5:Bv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,gS(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,fS(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,hS(n,e,o));e.restore()},hS=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Ro(r,n,o)}for(let r of e.points)Hv(r,t,o)},gS=(e,o,t)=>{Hv(e.points[0],t,o),t.zenModeEnabled||Ro(e.points[0],e.points[1],o)},Hv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?zv*1.5:zv)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},Ro=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},fS=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||Ro(M(e[0],e[1]-i),M(e[0],e[1]+i),n),Ro(M(s[0]-l,s[1]-a),M(s[0]-l,s[1]+a),n),Ro(M(s[0]+l,s[1]-a),M(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Ro(M(o[0],o[1]-i),M(o[0],o[1]+i),n),Ro(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Ro(M(e[0]-i,e[1]),M(e[0]+i,e[1]),n),Ro(M(s[0]-a,s[1]-l),M(s[0]+a,s[1]-l),n),Ro(M(s[0]-a,s[1]+l),M(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Ro(M(o[0]-i,o[1]),M(o[0]+i,o[1]),n),Ro(e,o,n))}};var jo=4,br=6,Uv="rgba(0,0,0,0.3)",Gv=(e,o,t,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=ye(e),s=o/r.zoom.value,c=t/r.zoom.value,m=o-s,d=t-c,p={top:parseInt(sl("sat"))||0,bottom:parseInt(sl("sab"))||0,left:parseInt(sl("sal"))||0,right:parseInt(sl("sar"))||0},u=Rr().rtl,h=-r.scrollX+m/2+p.left,b=-r.scrollY+d/2+p.top,x=h+s-p.right,E=b+c-p.bottom,w=Math.min(n,h),y=Math.min(i,b),v=Math.max(a,x),C=Math.max(l,E);return{horizontal:h===w&&x===v?null:{x:Math.max(p.left,jo)+(h-w)/(v-w)*o,y:t-br-Math.max(jo,p.bottom),width:(x-h)/(v-w)*o-Math.max(jo*2,p.left+p.right),height:br},vertical:b===y&&E===C?null:{x:u?Math.max(p.left,jo):o-br-Math.max(p.right,jo),y:(b-y)/(C-y)*t+Math.max(p.top,jo),width:br,height:(E-b)/(C-y)*t-Math.max(jo*2,p.top+p.bottom)}}},dg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var bS=(e,o)=>{rn(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;rn(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Yv(t,e,o),e.restore()},xS=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=j.getElement(r,t);if(!i)return;let a=j.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Yv(a,e,o),e.restore()},Yv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Tl(o,e[0],e[1],j.POINT_HANDLE_SIZE/t.zoom.value,!1)},ns=(e,o,t,r,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(o-i,t-a,r,n),c&&e.roundRect?(e.beginPath(),e.roundRect(o-i,t-a,r,n,c),e.stroke(),e.closePath()):e.strokeRect(o-i,t-a,r,n),e.restore()},ES=(e,o,t,r,n,i)=>{e.save(),e.translate(r,n),e.rotate(i),e.beginPath(),e.moveTo(0,t/2),e.lineTo(o/2,0),e.lineTo(0,-t/2),e.lineTo(-o/2,0),e.closePath(),e.stroke(),e.restore()},mg=(e,o,t,r,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Tl(e,t[0],t[1],r/o.zoom.value,!i)},yS=(e,o,t,r,n,i)=>{e.beginPath(),e.ellipse(r,n,o/2,t/2,i,0,Math.PI*2),e.stroke()},vS=(e,o,t,r)=>{let[n,i,a,l]=Ye(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)";let m=r.value<1?r.value:1;e.lineWidth=$1/m;let d=e.lineWidth/2+j1,p=pc(Math.min(o.width,o.height),o);switch(o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":ns(e,n-d,i-d,s+d*2,c+d*2,n+s/2,i+c/2,o.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,c),h=d*u/c,b=d*u/s;ES(e,s+h*2,c+b*2,n+s/2,i+c/2,o.angle);break;case"ellipse":yS(e,s+d*2,c+d*2,n+s/2,i+c/2,o.angle);break}},wS=(e,o,t,r)=>{let[n,i,a]=o,l=Q1(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[m,d]=j.getPointAtIndexGlobalCoordinates(n,c,t);Tl(e,m,d,l)})},Wv=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=t,u=a-n,h=l-i,x=(t.padding??Xr*2)/o.zoom.value,E=8/o.zoom.value,w=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([E,w+(E+w)*(y-1)]),e.lineDashOffset=(E+w)*v,ns(e,n-x,i-x,u+x*2,h+x*2,c,m,r);e.restore()},TS=(e,o,t,r)=>{let n=Array.isArray(t)?wS:vS;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},CS=(e,o,t,r)=>{let[n,i,a,l]=Ye(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Uo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ns(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Uo.radius/o.zoom.value),e.restore()},IS=(e,o,t)=>{let r=t.filter(l=>l.groupIds.length===0),n=t.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,m,d]=ye(l);return{angle:0,x1:s,x2:m,y1:c,y2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(m-s)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},a=l=>{let s=Ue(t,l);return i(s)};Object.entries(fb(n,o)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>Wv(e,o,l))},pg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=j.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=j,a=o.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(ee(t)&&s!==0&&s!==n.length-1)return;let c=!!o.editingLinearElement?.selectedPointsIndices?.includes(s);mg(e,o,l,a,c)}),ee(t)){let l=t.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{j.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||mg(e,o,M((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else j.getEditorMidPoints(t,r,o).filter((s,c,m)=>s!==null&&!(ee(t)&&(c===0||c===m.length-1))).forEach(s=>{(o.editingLinearElement||n.length===2)&&mg(e,o,s,i/2,!1,!0)});e.restore()},Vv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Tl(e,l+c/2,s+m/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):ns(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},SS=(e,o,t,r,n)=>{let[i,a,,,l,s]=Ye(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,h=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,h);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-h],[0,p],[b,p],[p,0],[p,x]],[[u-p,-h],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,h],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,h],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[C,I],[_,L],[N,P],[z,V]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+I),e.lineTo(y+_,v+L),e.stroke(),e.beginPath(),e.moveTo(y+N,v+P),e.lineTo(y+z,v+V),e.stroke(),e.restore()}),e.restore()},kS=(e,o,t,r)=>{o.save();let n=Xr*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,m,i,a),o.restore()},Kv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[c,m]=vc(e,i),d=wc({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:m});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.editingLinearElement?.elementId===b.id&&b&&(p=b)}),p&&pg(d,a,p,o),a.selectionElement&&!a.isCropping)try{Ab(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Z(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&kS(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{TS(d,a,b,o)}),a.frameToHighlight&&CS(d,a,a.frameToHighlight,o),a.elementsToHighlight&&IS(d,a,a.elementsToHighlight);let u=r.some(b=>ie(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&pg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?bS(d,a):(ee(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&xS(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=Ac(r,a),x=r.length===1&&ce(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&pg(d,a,r[0],o);let E=l.selectionColor||dm.black;if(b){let w=ne(r),y=[];for(let C of o.values()){let I=[],_=l.remoteSelectedElementIds.get(C.id);if(x&&ee(C)&&(C.startBinding||C.endBinding)||(w.has(C.id)&&!dc(a,C)&&I.push(E),_&&I.push(..._.map(L=>vi(L,a.collaborators.get(L))))),I.length){let[L,N,P,z,V,U]=Ye(C,o,!0);y.push({angle:C.angle,x1:L,y1:N,x2:P,y2:z,selectionColors:I,dashed:!!_,cx:V,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||he(C)?0:void 0})}}let v=C=>{let I=Ue(o,C),[_,L,N,P]=ye(I);y.push({angle:0,x1:_,x2:N,y1:L,y2:P,selectionColors:[dm.black],dashed:!0,cx:_+(N-_)/2,cy:L+(P-L)/2,activeEmbeddable:!1})};for(let C of Yo(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Wv(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=dm.white;let w=Lc(r[0],a.zoom,o,"mouse",li(s));if(!a.viewModeEnabled&&b&&!Z(a.editingTextElement)&&!a.croppingElementId&&Vv(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&he(y)&&SS(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating){let w=Xr*2/a.zoom.value;d.fillStyle=dm.white;let[y,v,C,I]=ye(r,o),_=d.getLineDash();d.setLineDash([2/a.zoom.value]);let L=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,ns(d,y-w,v-w,C-y+w*2,I-v+w*2,(y+C)/2,(v+I)/2,0),d.lineWidth=L,d.setLineDash(_);let N=Sl([y,v,C,I,(y+C)/2,(v+I)/2],0,a.zoom,"mouse",u?{...li(s),rotation:!0}:li(s));r.some(P=>!P.locked)&&Vv(d,l,a,N,0)}d.restore()}a.searchMatches.forEach(({id:b,focus:x,matchedLines:E})=>{let w=o.get(b);if(w&&Z(w)){let[y,v,,,C,I]=Ye(w,o,!0);d.save(),a.theme===de.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)",d.translate(a.scrollX,a.scrollY),d.translate(C,I),d.rotate(w.angle),E.forEach(_=>{d.fillRect(y+_.offsetX-C,v+_.offsetY-I,_.width,_.height)}),d.restore()}}),Fv(d,a),d.restore(),Xy({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let h;return l.renderScrollbars&&(h=Gv(t,c,m,a),d.save(),d.fillStyle=Uv,d.strokeStyle="rgba(255,255,255,0.8)",[h.horizontal,h.vertical].forEach(b=>{b&&_d(d,b.x,b.y,b.width,b.height,br/2)}),d.restore()),{scrollBars:h,atLeastOneVisibleElement:t.length>0,elementsMap:o}},ug=Pi(e=>{let o=Kv(e);e.callback?.(o)},{trailing:!0}),Zv=(e,o)=>{if(o){ug(e);return}let t=Kv(e);return e.callback(t),t};var is=class{constructor(o){k(this,"scene");k(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())xl(p,m,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i,pendingImageElementId:a})=>{let l=nn(new Map);for(let s of r)he(s)&&a===s.id||i!==s.id&&(!n||n.type!=="text"||s.id!==n.id)&&l.set(s.id,s);return l};return y1(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,pendingImageElementId:p,sceneNonce:u})=>{let h=this.scene.getNonDeletedElements(),b=t({elements:h,editingTextElement:m,newElementId:d,pendingImageElementId:p}),x=o({elementsMap:b,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:b,visibleElements:x}})})());this.scene=o}destroy(){ug.cancel(),jb.cancel(),this.getRenderableElements.clear()}};import{jsx as AS}from"react/jsx-runtime";var MS=5,LS=(e,o,t)=>{let[r,n]=Ye(e,t),{x:i,y:a}=Bt({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},hg=({children:e,element:o,elementsMap:t})=>{let r=mr();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=LS(o,r,t);return AS("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:MS},children:e})};import{LaserPointer as _S}from"@excalidraw/laser-pointer";var Ii=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;k(this,"currentTrail");k(this,"pastTrails",[]);k(this,"container");k(this,"trailElement");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Qf,"path")}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new _S(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([n,i])=>{let a=Bt({sceneX:n,sceneY:i},t);return[a.x,a.y]});return v1(r,!0)}};var mm=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;k(this,"localTrail");k(this,"collabTrails",new Map);k(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Ii(o,t,{...this.getTrailOptions(),fill:()=>Qm})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Un(i),Un(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Ii(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||vi(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as DS}from"react";import{unstable_batchedUpdates as Xv}from"react-dom";var tt=e=>o=>{Xv(e,o)},pm=e=>Pi(o=>{Xv(e,o)}),Fa=(()=>{let e;try{let t=DS.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var PS=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},$v=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,G)=>{if(!G.style.fontFamily||!G.style.fontSize)return!1;let Y=G.style.fontFamily.replace(/"/g,"");return Fn({fontFamily:H.fontFamily})!==Y||`${H.fontSize}px`!==G.style.fontSize},m=()=>{let H=l.state,G=ln.getScene(n)?.getElement(e);if(!G)return;let{textAlign:Y,verticalAlign:re}=G,$=l.scene.getNonDeletedElementsMap();if(G&&Z(G)){let le=G.x,be=G.y,Te=ro(G,l.scene.getNonDeletedElementsMap()),ot=G.width,$t=G.height,zo=G.width,Qo=G.height;if(Te&&G.containerId){if(Pe(Te)){let Kr=j.getBoundTextElementPosition(Te,G,$);le=Kr.x,be=Kr.y}let ws=c(G,d),$a;if(ws?$a=pl(Te.id,Te.height):($a=B1[Te.id],$a||($a=pl(Te.id,Te.height))),zo=Gi(Te,G),Qo=Z1(Te,G),!Pe(Te)&&$t>Qo){let Kr=Ui($t,Te.type);B(Te,{height:Kr});return}else if(!Pe(Te)&&Te.height>$a.height&&$t<Qo){let Kr=Ui($t,Te.type);B(Te,{height:Kr})}else{let{y:Kr}=qs(Te,G,$);be=Kr}}let[jt,er]=r(le,be),Yr=d.selectionStart,qt=d.selectionEnd,Wr=d.value.length;if(Yr===qt&&qt!==Wr){let ws=Wr-qt;d.selectionStart=d.value.length-ws,d.selectionEnd=d.value.length-ws}Te?ot+=.5:(zo=(H.width-8-jt)/H.zoom.value,ot=Math.min(ot,zo)),$t*=1.05;let mo=qe(G),yf=(H.height-er)/H.zoom.value;Object.assign(d.style,{font:mo,lineHeight:G.lineHeight,width:`${ot}px`,height:`${$t}px`,left:`${jt}px`,top:`${er}px`,transform:PS(ot,$t,V1(G,Te),H,zo,yf),textAlign:Y,verticalAlign:re,color:G.strokeColor,opacity:G.opacity/100,filter:"var(--theme-filter)",maxHeight:`${yf}px`}),d.scrollTop=0,dt()&&(d.style.fontFamily=Fn(G)),B(G,{x:le,y:be})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(Be(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,m(),o&&(d.onpaste=async H=>{let G=await Md(H,!0);if(!G.text)return;let Y=$n(G.text);if(!Y)return;let re=ro(n,l.scene.getNonDeletedElementsMap()),$=qe({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(re){let le=ge(re,l.scene.getNonDeletedElementsMap()),be=Hi(`${d.value}${Y}`,$,Gi(re,le)),Te=G1(be,$);d.style.width=`${Te}px`}},d.oninput=()=>{let H=$n(d.value);if(d.value!==H){let G=d.selectionStart;d.value=H,d.selectionStart=G,d.selectionEnd=G}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&vd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(vd),m();else if(!H.shiftKey&&wd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(wd),m();else if(!H.shiftKey&&Td.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Td),m();else if(ah.keyTest(H))l.actionManager.executeAction(ah);else if(lh.keyTest(H))l.actionManager.executeAction(lh);else if(H.key===T.ESCAPE)H.preventDefault(),C=!0,I();else if(Ei.keyTest(H))H.preventDefault(),I(),l.actionManager.executeAction(Ei);else if(H.key===T.ENTER&&H[T.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;C=!0,I()}else if(H.key===T.TAB||H[T.CTRL_OR_CMD]&&(H.code===pe.BRACKET_LEFT||H.code===pe.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===pe.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let h=4,b=" ".repeat(h),x=new RegExp(`^ {1,${h}}`),E=()=>{let{selectionStart:H,selectionEnd:G}=d,Y=y(),re=d.value;Y.forEach($=>{let le=re.slice(0,$),be=re.slice($);re=`${le}${b}${be}`}),d.value=re,d.selectionStart=H+h,d.selectionEnd=G+h*Y.length},w=()=>{let{selectionStart:H,selectionEnd:G}=d,Y=y(),re=[],$=d.value;Y.forEach(le=>{let be=$.slice(le,le+h).match(x);if(be){let Te=$.slice(0,le),ot=$.slice(le+be[0].length);$=`${Te}${ot}`,re.push(le)}}),d.value=$,re.length&&(H>re[re.length-1]?d.selectionStart=Math.max(H-h,re[re.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,G-h*re.length))},y=()=>{let{selectionStart:H,selectionEnd:G,value:Y}=d,re=Y.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-re,Y.slice(H,G).split(`
8
- `).reduce((le,be,Te,ot)=>le.concat(Te?le[Te-1]+ot[Te-1].length+1:H),[]).reverse()},v=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},C=!1,I=()=>{if(U)return;U=!0,_();let H=ln.getScene(n)?.getElement(n.id);if(!H)return;let G=ro(H,l.scene.getNonDeletedElementsMap());if(G){if(d.value.trim()){let Y=Ar(G);!Y||Y!==n.id?B(G,{boundElements:(G.boundElements||[]).concat({type:"text",id:n.id})}):Pe(G)&&bl(G)}else B(G,{boundElements:G.boundElements?.filter(Y=>!Z(Y))});Qe(H,G,l.scene.getNonDeletedElementsMap())}t({viaKeyboard:C,nextOriginalText:d.value})},_=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",L),window.removeEventListener("blur",I),window.removeEventListener("beforeunload",I),z(),V(),d.remove()},L=H=>{window.removeEventListener("pointerup",L);let G=H?.target,Y=G instanceof HTMLElement&&G.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=I,Y||d.focus()})},N=()=>{d.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",I)},P=H=>{let G=H?.target;if(H.button===tr.WHEEL){G instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),N();return}let Y=G instanceof HTMLElement&&G.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Ho.SHAPE_ACTIONS_MENU}, .${Ho.ZOOM_ACTIONS}`)&&!or(H.target)||Y?N():H.target instanceof HTMLCanvasElement&&!dt()&&requestAnimationFrame(()=>{I()})},z=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),V=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&d.select(),L();let q=null;i&&"ResizeObserver"in window?(q=new window.ResizeObserver(()=>{m()}),q.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",I),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};var jv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{jsx as No,jsxs as qv}from"react/jsx-runtime";var RS=()=>qv("div",{"data-testid":"brave-measure-text-error",children:[No("p",{children:No(Wt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>No("span",{style:{fontWeight:600},children:e})})}),No("p",{children:No(Wt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>No("span",{style:{fontWeight:600},children:e})})}),No("p",{children:No(Wt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>No("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),No("p",{children:No(Wt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>No("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>qv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Jv=RS;import zS from"clsx";import FS from"react";import{useLayoutEffect as NS,useRef as Qv,useEffect as ew}from"react";import{unstable_batchedUpdates as OS}from"react-dom";import{jsx as BS}from"react/jsx-runtime";var tw=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Qv(null);ew(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===T.TAB){let h=cl(d),{activeElement:b}=document,x=h.findIndex(E=>E===b);b===d?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=Qv(null);return NS(()=>{if(n&&c.current&&t!=null&&o!=null){let d=c.current,{width:p,height:u}=d.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),ew(()=>{if(r){let d=p=>{c.current?.contains(p.target)||OS(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),BS("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Ha,jsxs as HS}from"react/jsx-runtime";var ft="separator",ow=FS.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=mr(),a=gn(),l=o.reduce((s,c)=>(c&&(c===ft||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Ha(tw,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Ha("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===ft)return!l[c-1]||l[c-1]===ft?null:Ha("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=f(s.label(a,i,e.app)):d=f(s.label)),Ha("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:HS("button",{type:"button",className:zS("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ha("div",{className:"context-menu-item__label",children:d}),Ha("kbd",{className:"context-menu-item__shortcut",children:m?st(m):""})]})},c)})})})});import{jsx as gg,jsxs as rw}from"react/jsx-runtime";var US=({height:e,width:o,userToFollow:t,onDisconnect:r})=>gg("div",{className:"follow-mode",style:{width:o,height:e},children:rw("div",{className:"follow-mode__badge",children:[rw("div",{className:"follow-mode__badge__label",children:["Following"," ",gg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),gg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:ko})]})}),nw=US;import gs from"clsx";import X8 from"react";import GS from"clsx";import{useState as VS,useEffect as YS}from"react";import{jsx as fg,jsxs as WS}from"react/jsx-runtime";var um=({delay:e,theme:o})=>{let[t,r]=VS(!!e);return YS(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:WS("div",{className:GS("LoadingMessage",{"LoadingMessage--dark":o===de.DARK}),children:[fg("div",{children:fg(Mt,{})}),fg("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import KS from"clsx";import{jsx as aw,jsxs as XS}from"react/jsx-runtime";var ZS="medium",iw={CHECKED:aa,UNCHECKED:di},hm=e=>XS("label",{className:KS("ToolIcon ToolIcon__lock",`ToolIcon_size_${ZS}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[aw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),aw("div",{className:"ToolIcon__icon",children:e.checked?iw.CHECKED:iw.UNCHECKED})]});import $S from"clsx";import{jsx as jS}from"react/jsx-runtime";var gm=({children:e,side:o,className:t})=>jS("div",{className:$S("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import qS from"clsx";import{jsx as JS}from"react/jsx-runtime";var fm=e=>JS(Q,{className:qS("Shape",{fillable:!1}),type:"radio",icon:Xc,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as lw}from"react/jsx-runtime";var QS=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===At.name&&e.openSidebar.tab===Cr&&e.searchMatches?.length)return f("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(no(e))return f("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?f("hints.linearElementMulti"):n.type==="arrow"?f("hints.arrowTool",{arrowShortcut:R("A")}):f("hints.linearElement");if(n.type==="freedraw")return f("hints.freeDraw");if(n.type==="text")return f("hints.text");if(n.type==="embeddable")return f("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return f("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return ce(m)&&m.points.length===2?f("hints.lockAngle"):he(m)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&Z(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&he(c[0]))return f("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return f("hints.deepBoxSelect");if(Tn(r)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!o)return f("hints.canvasPanning");if(c.length===1){if(ce(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Lr(c[0]))return Xn(c[0])?x0(c[0],r.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},bm=({appState:e,isMobile:o,device:t,app:r})=>{let n=QS({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>R(a).replace(/\. ?$/,"")).join(". "):R(n);return lw("div",{className:"HintViewer",children:lw("span",{children:i})})};import ek from"clsx";import{jsx as sw,jsxs as ok}from"react/jsx-runtime";var tk="medium",xm=e=>e.penDetected?ok("label",{className:ek("ToolIcon ToolIcon__penMode",`ToolIcon_size_${tk}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[sw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),sw("div",{className:"ToolIcon__icon",children:Y0})]}):null;import{Fragment as rk,jsx as cw,jsxs as nk}from"react/jsx-runtime";var In=({heading:e,children:o,...t})=>{let{id:r}=ht(),n=cw("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:f(`headings.${e}`)});return cw("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):nk(rk,{children:[n,o]})})};import{Fragment as ik,jsx as Lt,jsxs as Gr}from"react/jsx-runtime";var dw=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:m,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=We(),E=()=>Gr(gm,{side:"top",className:"App-top-bar",children:[d&&Lt(h.Out,{}),Lt(In,{heading:"shapes",children:y=>Lt(Ct.Col,{gap:4,align:"center",children:Gr(Ct.Row,{gap:1,className:"App-toolbar-container",children:[Gr(Et,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Lt(Ct.Row,{gap:1,children:Lt(om,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Gr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Lt(x.Out,{}),Lt(xm,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Lt(hm,{checked:e.activeTool.locked,onChange:n,title:f("toolBar.lock"),isMobile:!0}),Lt(fm,{checked:Wo(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]})]})})}),Lt(bm,{appState:e,isMobile:!0,device:m,app:u})]}),w=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Lt("div",{className:"App-toolbar-content",children:Lt(b.Out,{})}):Gr("div",{className:"App-toolbar-content",children:[Lt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Gr("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Gr(ik,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Lt("div",{className:"App-bottom-bar",style:{marginBottom:br+jo*2,marginLeft:br+jo*2,marginRight:br+jo*2},children:Gr(Et,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&wa(e,o)?Lt(In,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Lt(tm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Gr("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Lt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...ii(o,y)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import ak from"open-color";import lk,{useLayoutEffect as sk,useRef as ck,useState as dk}from"react";import{jsx as as,jsxs as mk}from"react/jsx-runtime";var mw=e=>{let o=ck(null),[t,r]=dk(null);return sk(()=>{if(!e.spreadsheet)return;let n=By(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await ea(n,{exportBackground:!1,viewBackgroundColor:ak.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),as("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:as("div",{ref:o})})},pw=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=lt(),n=lk.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),xe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return as(ct,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:mk("div",{className:"container",children:[as(mw,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),as(mw,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Sn from"@radix-ui/react-popover";import uw from"clsx";import Em,{useLayoutEffect as pk}from"react";import{Fragment as bk,jsx as xr,jsxs as ym}from"react/jsx-runtime";var uk=4,hk=8,gk=({shouldWrap:e,children:o,username:t})=>e?xr(bo,{label:t||"Unknown user",children:o}):xr(bk,{children:o}),bg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return xr(gk,{username:o.username,shouldWrap:n,children:l},t)},fk=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],vm=Em.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=gt(),i=new Map;t.forEach((b,x)=>{let E=b.id||x;i.set(E,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Em.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Em.useRef(null);pk(()=>{if(m.current){let b=E=>{let w=Math.max(1,Math.min(8,Math.floor(E/38)));p(w)};if(b(m.current.clientWidth),!ja)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=Em.useState(uk),h=a.slice(0,d-1).map(b=>bg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?xr("div",{className:uw("UserList UserList_mobile",e),children:a.map(b=>bg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):xr("div",{className:"UserList__wrapper",ref:m,children:ym("div",{className:uw("UserList",e),style:{"--max-avatars":d},children:[h,a.length>d-1&&ym(Sn.Root,{children:[ym(Sn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),xr(Sn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:ym(Et,{padding:2,children:[a.length>=hk&&xr(pd,{placeholder:f("quickSearch.placeholder"),onChange:s}),xr(ud,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[xr("div",{className:"hint",children:f("userList.hint.text")}),c.map(b=>bg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),xr(Sn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!Je(n,i,fk))return!1}return!0});import wm from"clsx";import{jsx as xk}from"react/jsx-runtime";var hw=e=>xk("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:la});import{jsx as Er,jsxs as xg}from"react/jsx-runtime";var gw=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=We(),a=Ce(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return xg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Er("div",{className:wm("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Er(Ct.Col,{gap:2,children:xg(In,{heading:"canvasActions",children:[Er(sv,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Er(cv,{renderAction:o.renderAction,className:wm("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&Er(mv,{renderAction:o.renderAction,className:wm("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),Er(n.Out,{}),Er("div",{className:wm("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:xg("div",{style:{position:"relative"},children:[r&&Er(i.Out,{}),Er(hw,{onClick:()=>o.executeAction(yi)})]})}),Er(dv,{actionManager:o,showExitZenModeBtn:t})]})},fw=gw;gw.displayName="Footer";import Sk from"clsx";import{useEffect as Sw,useLayoutEffect as kw,useRef as kg,useState as kk,forwardRef as Mw,useImperativeHandle as Mk,useCallback as Cw}from"react";import yk from"clsx";import{useContext as vk}from"react";import Ek from"react";var Tm=Ek.createContext({});import{jsx as Eg,jsxs as bw}from"react/jsx-runtime";var yg=({children:e,className:o})=>{let t=Ce(),r=vk(Tm),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return bw("div",{className:yk("sidebar__header",o),"data-testid":"sidebar-header",children:[e,bw("div",{className:"sidebar__header__buttons",children:[n&&Eg(bo,{label:f("labels.sidebarLock"),children:Eg(vo,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:R0})}),Eg(vo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":f("buttons.close"),children:ko})]})]})};yg.displayName="SidebarHeader";import*as Ew from"@radix-ui/react-tabs";import{jsx as xw}from"react/jsx-runtime";var vg=({children:e,tab:o,onSelect:t,...r})=>xw(Ew.Trigger,{value:o,asChild:!0,onSelect:t,children:xw("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});vg.displayName="SidebarTabTrigger";import*as yw from"@radix-ui/react-tabs";import{jsx as wk}from"react/jsx-runtime";var wg=({children:e,...o})=>wk(yw.List,{className:"sidebar-triggers",...o,children:e});wg.displayName="SidebarTabTriggers";import Tk from"clsx";import{jsx as Tg,jsxs as vw}from"react/jsx-runtime";var Cg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=Ie(),c=_e();return vw("label",{title:r,className:"sidebar-trigger__label-element",children:[Tg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=m.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),vw("div",{className:Tk("sidebar-trigger",a),style:l,children:[t&&Tg("div",{children:t}),n&&Tg("div",{className:"sidebar-trigger__label",children:n})]})]})};Cg.displayName="SidebarTrigger";import*as ww from"@radix-ui/react-tabs";import{jsx as Ck}from"react/jsx-runtime";var Ig=({children:e,...o})=>{let t=_e(),r=Ie();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Ck(ww.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};Ig.displayName="SidebarTabs";import*as Tw from"@radix-ui/react-tabs";import{jsx as Ik}from"react/jsx-runtime";var Sg=({tab:e,children:o,...t})=>Ik(Tw.Content,{...t,value:e,"data-testid":e,children:o});Sg.displayName="SidebarTab";import{jsx as Iw}from"react/jsx-runtime";import{createElement as Lk}from"react";var ls=Le(!1),Lw=Mw(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{Fe()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=Ie(),s=mn(ls);kw(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=kg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Ri(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=kg(null);Mk(a,()=>m.current);let d=Ce(),p=Cw(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return pa(m,Cw(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),Sw(()=>{let u=h=>{h.key===T.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),Iw(Et,{...i,className:Sk("sidebar",{"sidebar--docked":r},n),ref:m,children:Iw(Tm.Provider,{value:c.current,children:o})})});Lw.displayName="SidebarInner";var Oo=Object.assign(Mw((e,o)=>{let t=_e(),{onStateChange:r}=e,n=kg(t.openSidebar);Sw(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=kk(!1);return kw(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?Lk(Lw,{...e,ref:o,key:e.name}):null}),{Header:yg,TabTriggers:wg,TabTrigger:vg,Tabs:Ig,Tab:Sg,Trigger:Cg});Oo.displayName="Sidebar";import{useLayoutEffect as Ak,useRef as _k}from"react";import{jsx as Dk}from"react/jsx-runtime";var Vr=(e,o)=>{let t=Le(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=We(),[,a]=i(t),l=_k({preferHost:!1,counter:0});return Ak(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:Dk(o,{...n})};return r.displayName=e,r};var Ag={};wf(Ag,{ChangeCanvasBackground:()=>Vw,ClearCanvas:()=>Uw,CommandPalette:()=>zw,Export:()=>Yw,Help:()=>Hw,LiveCollaborationTrigger:()=>Kw,LoadScene:()=>Nw,SaveAsImage:()=>Bw,SaveToActiveFile:()=>Ow,SearchMenu:()=>Fw,Socials:()=>Ww,ToggleTheme:()=>Gw});import Ok from"clsx";var Mg=Le({active:!1});async function Aw({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{St.set(Mg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import Pk from"clsx";import{jsx as _w,jsxs as Rk}from"react/jsx-runtime";var Cm=function({onChange:e,value:o,choices:t,name:r}){return _w("div",{className:"RadioGroup",children:t.map(n=>Rk("div",{className:Pk("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[_w("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as Nk,jsx as Lg,jsxs as Dw}from"react/jsx-runtime";var Pw=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=Ce();return Dw(Nk,{children:[Dw("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Lg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Lg(Cm,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Lg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};Pw.displayName="DropdownMenuItemContentRadio";var Rw=Pw;import{Fragment as Bk,jsx as vt,jsxs as Zw}from"react/jsx-runtime";var Nw=()=>{let{t:e}=mt(),o=gt(),t=gn();return o.isActionEnabled(va)?vt(Vt,{icon:sa,onSelect:async()=>{(!t.length||await Aw({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:vt(Wt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>vt("strong",{children:n}),br:()=>vt("br",{})})}))&&o.executeAction(va)},"data-testid":"load-button",shortcut:st("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};Nw.displayName="LoadScene";var Ow=()=>{let{t:e}=mt(),o=gt();return o.isActionEnabled(Ei)?vt(Vt,{shortcut:st("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Ei),icon:Q0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Ow.displayName="SaveToActiveFile";var Bw=()=>{let e=Ie(),{t:o}=mt();return vt(Vt,{icon:Yc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:st("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Bw.displayName="SaveAsImage";var zw=e=>{let o=Ie(),{t}=mt();return vt(Vt,{icon:Qc,"data-testid":"command-palette-button",onSelect:()=>{xe("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:st("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};zw.displayName="CommandPalette";var Fw=e=>{let{t:o}=mt(),t=gt();return vt(Vt,{icon:go,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ts)},shortcut:st("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};Fw.displayName="SearchMenu";var Hw=()=>{let{t:e}=mt(),o=gt();return vt(Vt,{"data-testid":"help-menu-item",icon:la,onSelect:()=>o.executeAction(yi),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Hw.displayName="Help";var Uw=()=>{let{t:e}=mt(),o=mn(Ti);return gt().isActionEnabled(Or)?vt(Vt,{icon:ho,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};Uw.displayName="ClearCanvas";var Gw=e=>{let{t:o}=mt(),t=_e(),r=gt(),n=st("toggleTheme");return r.isActionEnabled(gi)?e?.allowSystemTheme?vt(Rw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:de.LIGHT,label:Dl,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:de.DARK,label:_l,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:hE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):vt(Vt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===de.DARK?de.LIGHT:de.DARK);else return r.executeAction(gi)},icon:t.theme===de.DARK?Dl:_l,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};Gw.displayName="ToggleTheme";var Vw=()=>{let{t:e}=mt(),o=_e(),t=gt(),r=pr();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:Zw("div",{style:{marginTop:"0.5rem"},children:[vt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),vt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};Vw.displayName="ChangeCanvasBackground";var Yw=()=>{let{t:e}=mt(),o=Ie();return vt(Vt,{icon:mi,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};Yw.displayName="Export";var Ww=()=>{let{t:e}=mt();return Zw(Bk,{children:[vt(Pa,{icon:Gc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),vt(Pa,{icon:q0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),vt(Pa,{icon:j0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};Ww.displayName="Socials";var Kw=({onSelect:e,isCollaborating:o})=>{let{t}=mt();return vt(Vt,{"data-testid":"collab-button",icon:Wc,className:Ok({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};Kw.displayName="LiveCollaborationTrigger";import{jsx as Im,jsxs as _g}from"react/jsx-runtime";var zk=Object.assign(Vr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=We(),r=Ce(),n=_e(),i=Ie(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Im(t.In,{children:_g(Ne,{open:n.openMenu==="canvas",children:[Im(Ne.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Uc}),_g(Ne.Content,{onClickOutside:a,onSelect:on(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&_g("fieldset",{className:"UserList-Wrapper",children:[Im("legend",{children:f("labels.collaborators")}),Im(vm,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ne.Trigger,Item:Ne.Item,ItemLink:Ne.ItemLink,ItemCustom:Ne.ItemCustom,Group:Ne.Group,Separator:Ne.Separator,DefaultItems:Ag}),Nt=zk;import Fk from"clsx";import{forwardRef as Hk,useState as Uk}from"react";import{jsx as Sm,jsxs as Gk}from"react/jsx-runtime";var kn=Hk(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=Uk(!1),u=async b=>{let x=t?.(b);if(tn(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(w){if(w instanceof Ji)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},h=d?"loading":c;return i=h==="success"?"success":i,Sm("button",{className:Fk("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:h==="loading"||h==="success",children:Gk("div",{className:"ExcButton__contents",children:[h==="loading"?Sm(Mt,{className:"ExcButton__statusIcon"}):h==="success"&&Sm("div",{className:"ExcButton__statusIcon",children:$x}),o&&Sm("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Ua,jsxs as Wk}from"react/jsx-runtime";var km=({title:e,children:o,actionLabel:t,onClick:r})=>Wk("div",{className:"OverwriteConfirm__Actions__Action",children:[Ua("h4",{children:e}),Ua("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Ua(kn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),Vk=()=>{let{t:e}=mt(),o=gt(),t=Ie();return Ua(km,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ad,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},Yk=()=>{let{t:e}=mt(),o=gt();return Ua(km,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Xl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Dg=Object.assign(({children:e})=>Ua("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Vk,SaveToDisk:Yk});import{jsx as Mn,jsxs as Xw}from"react/jsx-runtime";var Mm=Object.assign(Vr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=We(),[t,r]=ve(Mg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Mn(o.In,{children:Mn(ct,{onCloseRequest:n,title:!1,size:916,children:Xw("div",{className:"OverwriteConfirm",children:[Mn("h3",{children:t.title}),Xw("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Mn("div",{className:"OverwriteConfirm__Description__icon",children:jx}),Mn("div",{children:t.description}),Mn("div",{className:"OverwriteConfirm__Description__spacer"}),Mn(kn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Mn(Dg,{children:e})]})})})}),{Actions:Dg,Action:km});import lM from"clsx";import Kk from"clsx";import Zk from"lodash.debounce";import{Fragment as Xk,memo as $k,useEffect as ss,useRef as Pg,useState as $w}from"react";import{Fragment as aM,jsx as wo,jsxs as cs}from"react/jsx-runtime";var jk=Le(""),Rg=Le(null),qk=350,qw=()=>{let e=lt(),o=Ie(),t=Pg(null),[r,n]=ve(jk),i=r.trim(),[a,l]=$w(!1),[s,c]=$w({nonce:null,items:[]}),m=Pg(null),d=Pg(void 0),[p,u]=ve(Rg),h=e.scene.getNonDeletedElementsMap();ss(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,jw(i,e,(y,v)=>{c({nonce:Wn(),items:y}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.map(C=>({id:C.textElement.id,focus:!1,matchedLines:C.matchedLines}))})}))},[a,i,h,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};ss(()=>{o(y=>({searchMatches:y.searchMatches.map((v,C)=>C===p?{...v,focus:!0}:{...v,focus:!1})}))},[p,o]),ss(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=Gt({text:y.searchQuery,x:y.textElement.x+(y.matchedLines[0]?.offsetX??0),y:y.textElement.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:y.textElement.fontSize,fontFamily:y.textElement.fontFamily}),I=14,_=y.textElement.fontSize,L=_*v<I;if(!Vi([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||L){let N;L?_>=I?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:So(I/_,1)}:N={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),ss(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:[]}),l(!1)},[o,u]);let E=un({goToNextItem:b,goToPreviousItem:x,searchMatches:s});ss(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),t.current?.matches(":focus")?o({openSidebar:null}):(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return Ve(window,"keydown",y,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return cs("div",{className:"layer-ui__search",children:[wo("div",{className:"layer-ui__search-header",children:wo(Oa,{className:Ho.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:f("search.placeholder"),icon:go,onChange:y=>{n(y),l(!0);let v=y.trim();jw(v,e,(C,I)=>{c({nonce:Wn(),items:C}),u(I),m.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.map(_=>({id:_.textElement.id,focus:!1,matchedLines:_.matchedLines}))}),l(!1)})},selectOnRender:!0})}),cs("div",{className:"layer-ui__search-count",children:[s.items.length>0&&cs(aM,{children:[p!==null&&p>-1?cs("div",{children:[p+1," / ",w]}):wo("div",{children:w}),cs("div",{className:"result-nav",children:[wo(vo,{onSelect:()=>{b()},className:"result-nav-btn",children:td}),wo(vo,{onSelect:()=>{x()},className:"result-nav-btn",children:wE})]})]}),s.items.length===0&&i&&m.current&&wo("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),wo(tM,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},Jk=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return wo("div",{tabIndex:-1,className:Kk("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:wo("div",{className:"preview-text",children:o.flatMap((t,r)=>wo(Xk,{children:r===2?wo("b",{children:t}):t},r))})})},Qk=e=>wo("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((o,t)=>wo(Jk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:t===e.focusIndex,onClick:()=>e.onItemClick(t)},o.textElement.id+o.index))}),eM=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,tM=$k(Qk,eM),oM=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),h=u?6:5,b=(u?"":" ")+p.slice(0,h).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>h}},rM=(e,o)=>{let t=e.split(`
7
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var jy=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=m0(a);if(!a||!p0(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=xi(e,o,!1);return await Ei(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as F4,jsx as Fr,jsxs as H4}from"react/jsx-runtime";var bh=z({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Fr(Hy,{label:f("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),qy=z({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Ee(e),i=ze(r,o)?J(r,o):r;return Fr(F4,{children:Hs.map(a=>{let[l,s]=c0(i,Qr,a),c=`${f("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Fr(Q,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),xh=z({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Fr($l,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),Dd=z({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>H4($l,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[f("imageExportDialog.label.embedScene"),Fr(bo,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Fr("div",{className:"excalidraw-tooltip-icon",children:hx})})]})}),yi=z({name:"saveToActiveFile",label:"buttons.save",icon:pi,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=Mc(o.fileHandle)?await jy(e,o,r.files,r.getName()):await Tc(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),Jl=z({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:pi,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Tc(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:f("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Fr(Q,{type:"button",icon:dx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ce().editor.isMobile,hidden:!Qi,onClick:()=>e(null),"data-testid":"save-as-button"})}),wa=z({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Xp(o,e);return{elements:n,appState:i,files:a,captureUpdate:A.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:A.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),Jy=z({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Fr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Fr(zy,{value:e.exportWithDarkMode?de.DARK:de.LIGHT,onChange:t=>{o(t===de.DARK)},title:f("imageExportDialog.label.darkMode")})})});var Qy="{}",Eh=z({name:"copyStyles",label:"labels.copyStyles",icon:Ru,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Tt(i)){let a=ge(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(Qy=JSON.stringify(n)),{appState:{...o,toast:{message:f("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.C}),yh=z({name:"pasteStyles",label:"labels.pasteStyles",icon:Ru,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(Qy),i=n[0],a=n[1];if(!N1(i))return{elements:e,captureUpdate:A.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Z(c)&&c.containerId&&(m=a),!m)return c;let d=te(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?O1(m.roundness.type,c)?m.roundness:B1(c):null});if(Z(d)){let p=m.fontSize||Cr,u=m.fontFamily||jr;d=te(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||Ns,lineHeight:m.lineHeight||Sr(u)});let h=null;d.containerId&&(h=l.find(b=>Z(d)&&b.id===d.containerId)||null),Qe(d,h,r.scene.getNonDeletedElementsMap())}return d.type==="arrow"&&Re(m)&&(d=te(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ne(c)&&(d=te(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V});var Ta=(e,o)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||J(o,e).length));import{jsx as e2}from"react/jsx-runtime";var U4=z({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>e2(Q,{type:"button",icon:Wc,"aria-label":f("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),G4=z({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>e2(Q,{visible:Ta(o,Ee(e)),type:"button",icon:mx,"aria-label":f("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),vi=z({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:ix,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as Ca}from"react/jsx-runtime";var V4=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ki(n,t),!0))return!0}return!1},t2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!V4(r)&&!mc(r)},vh=z({name:"group",label:"labels.group",icon:e=>Ca(Au,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=bb(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=Wo(o);if(i.length===1){let x=i[0],E=new Set(Ge(e,x).map(v=>v.id)),w=new Set(n.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&gb(n).forEach((E,w)=>{sc(E,r.scene.getNonDeletedElementsMap())});let s=ro(),c=re(n);a=a.map(x=>c.get(x.id)?te(x,{groupIds:Lb(x.groupIds,s,o.editingGroupId)}):x);let m=Ge(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),h=a.slice(0,p).filter(x=>!Ki(x,s)),b=Ut([...h,...m,...u],re(m));return{appState:{...o,...Cb(s,{...o,selectedGroupIds:{}},Ee(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>t2(e,o,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ca(Q,{hidden:!t2(e,o,r),type:"button",icon:Ca(Au,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:ze(Ee(e),o)})}),wh=z({name:"ungroup",label:"labels.ungroup",icon:e=>Ca(_u,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Wo(o),i=re(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{Be(p)&&l.push(p.id);let u=Ab(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:te(p,{groupIds:u})});let s=lt(o,Ee(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return fb(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=cc(a,Yi(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,o)=>Wo(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ca(Q,{type:"button",hidden:Wo(o).length===0,icon:Ca(_u,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:ze(Ee(e),o)})});import Z4 from"clsx";var Pd=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function Y4(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var wi=(e,o)=>`hsl(${Math.abs(Y4(o?.id||e))%37*10}, 100%, 83%)`,o2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},r2=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,d=14,p=l<0||l>r-m||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-d);let u=wi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=o.remotePointerUserStates.get(i),b=p||h==="idle"||h==="away";b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===de.DARK?"#2f6330":Wf,E=c?.isSpeaking;E&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=tl,e.strokeStyle=tl,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let w=o.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(E?l+0:l)+m/2,v=(E?s+0:s)+d+2,C=5,S=3,_=e.measureText(w),L=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,N=Math.max(L,12),P=y-1,F=v-1,K=_.width+2+C*2+2,U=N+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,F,K,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=tl,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,F-2,K+4,U+4,8),e.strokeStyle=x,e.stroke())):Pd(e,P,F,K,U,8,tl),e.fillStyle=Yf,e.fillText(w,y+C+1,v+S+_.actualBoundingBoxAscent+Math.floor((N-L)/2)+2),E){e.fillStyle=x;let q=8,H=8,G=5;e.fillRect(P+K+H,F+(U/2-q/2),2,q),e.fillRect(P+K+H+G,F+(U/2-q*2/2),2,q*2),e.fillRect(P+K+H+G*2,F+(U/2-q/2),2,q)}}e.restore(),e.closePath()}};import W4 from"clsx";import{useState as K4}from"react";import{jsx as n2}from"react/jsx-runtime";var Th=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=o2(t),[a,l]=K4(!1),s=!a&&r,c=s?void 0:{background:e};return n2("div",{className:W4("Avatar",n),style:c,onClick:o,children:s?n2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as gr,jsxs as Rd}from"react/jsx-runtime";var X4=z({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:A.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:A.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=wi(r,n),s=Z4({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Rd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[gr("div",{}),gr("div",{}),gr("div",{})]}):n.isMuted?gr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:gE}):gr("div",{title:f("userList.hint.inCall"),children:hE}):null;return i?Rd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[gr(Th,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),gr("div",{className:"UserList__collaborator-name",children:n.username}),Rd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&gr("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:ma}),c]})]}):Rd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[gr(Th,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&gr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var Ch=z({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of Vs)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:ro(),status:"unpublished",elements:n.map(uo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});var i2=(e,o,t,r)=>{let n=ti(e,o),i=Dt(e);return n.flatMap(a=>{let l=$4(a,i,t);return a.map(s=>{let c=B(s,{x:s.x+l.x,y:s.y+l.y});return at(s,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:a}),c})})},$4=(e,o,{axis:t,position:r})=>{let n=Dt(e),[i,a]=t==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return r==="start"?{...l,[t]:o[i]-n[i]}:r==="end"?{...l,[t]:o[a]-n[a]}:{...l,[t]:(o[i]+o[a])/2-(n[i]+n[a])/2}};import{jsx as Sa}from"react/jsx-runtime";var io=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ne(r))},Ia=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=re(e),a=i2(n,i,r,t.scene),l=re(a);return ar(e.map(s=>l.get(s.id)||s),o,t)},j4=z({name:"alignTop",label:"labels.alignTop",icon:Cu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Cu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:ze(Ee(e),o)})}),q4=z({name:"alignBottom",label:"labels.alignBottom",icon:Iu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Iu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:ze(Ee(e),o)})}),J4=z({name:"alignLeft",label:"labels.alignLeft",icon:Su,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Su,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:ze(Ee(e),o)})}),Q4=z({name:"alignRight",label:"labels.alignRight",icon:ku,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:ku,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:ze(Ee(e),o)})}),eC=z({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Mu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Mu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:ze(Ee(e),o)})}),tC=z({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Lu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Lu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:ze(Ee(e),o)})});var a2=(e,o,t)=>{let[r,n,i,a]=t.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Dt(e),s=ti(e,o).map(p=>[p,Dt(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let m=(l[a]-c)/(s.length-1);if(m<0){let p=s.findIndex(x=>x[1][r]===l[r]),u=s.findIndex(x=>x[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),b=s[p][1][n];return s.flatMap(([x,E],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(b+=h,y[t.axis]=b-E[n]),x.map(v=>te(v,{x:v.x+y.x,y:v.y+y.y}))})}let d=l[r];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[t.axis]=d-u[r],d+=m,d+=u[a],p.map(b=>te(b,{x:b.x+h.x,y:b.y+h.y}))})};import{jsx as c2}from"react/jsx-runtime";var l2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ne(r))},s2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=a2(n,t.scene.getNonDeletedElementsMap(),r),a=re(i);return ar(e.map(l=>a.get(l.id)||l),o,t)},oC=z({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:s2(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>c2(Q,{hidden:!l2(o,r),type:"button",icon:xx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:ze(Ee(e),o)})}),rC=z({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:s2(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>c2(Q,{hidden:!l2(o,r),type:"button",icon:Ex,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:ze(Ee(e),o)})});var Ih=z({name:"flipHorizontal",label:"labels.flipHorizontal",icon:EE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ar(d2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.H}),Sh=z({name:"flipVertical",label:"labels.flipVertical",icon:xE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ar(d2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.V&&!e[T.CTRL_OR_CMD]}),d2=(e,o,t,r,n)=>{let i=J(Ee(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=nC(i,o,t,r,n),l=re(a);return e.map(s=>l.get(s.id)||s)},nC=(e,o,t,r,n)=>{if(e.every(u=>Re(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let h=u;return te(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:i,midY:a}=Dt(e);au(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,uo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Jn(e.filter(ae),o,n.scene.getNonDeletedElements(),n.scene,qn(t),[],t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,h)=>ee(h)?{...u,elbowArrows:u.elbowArrows.concat(h)}:{...u,otherElements:u.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=Dt(e),[d,p]=[i-c,a-m];return s.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),e};var ka=z({name:"copy",label:"labels.copy",icon:Dl,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ld(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),kh=z({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await $y()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Tr?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(Zy({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Nd=z({name:"cut",label:"labels.cut",icon:rE,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ka.perform(e,o,t,r),Ul.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),Od=z({name:"copyAsSvg",label:"labels.copyAsSvg",icon:yE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=xi(e,o,!0);try{await Ei("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>Md&&e.length>0,keywords:["svg","clipboard","copy"]}),Bd=z({name:"copyAsPng",label:"labels.copyAsPng",icon:vE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=xi(e,o,!0);try{return await Ei("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:n.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>va&&e.length>0,keyTest:e=>e.code===pe.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),zd=z({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{jo(Ip(n))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Md&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(Z),keywords:["text","clipboard","copy"]});var Fd=z({name:"gridMode",icon:SE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===pe.QUOTE});var Ma=z({name:"zenMode",label:"buttons.zenMode",icon:TE,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.Z});var Mh=z({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:wE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.S});var La=z({name:"stats",label:"stats.fullTitle",icon:bE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:A.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.SLASH});var Lh=z({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>Tt(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=ge(a,i);if(l){let{width:s,height:c}=Ht(l.originalText,qe(l),l.lineHeight),m=X1(a.id);Z1(a.id);let{x:d,y:p}=tc(a,l,i);B(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),B(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),Ah=z({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=Z(n[0])||Z(n[1]),a;if(_r(n[0])?a=n[0]:_r(n[1])&&(a=n[1]),i&&a&&ge(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Z(n[0])&&_r(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),B(i,{containerId:a.id,verticalAlign:Qt.MIDDLE,textAlign:rl.CENTER,autoResize:!0}),B(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Qe(i,a,r.scene.getNonDeletedElementsMap()),ul(a.id,l),{elements:iC(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),iC=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),Ut(r,re([o,t])),r},aC=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),Ut(r,re([o,t])),r},m2=z({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Z(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Z(l)){let s=Gt({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:Bi("rectangle")?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-dp,y:l.y-dp,width:Ui(l.width,"rectangle"),height:Ui(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>c.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&B(d,{startBinding:p,endBinding:u},!1)})}B(l,{containerId:s.id,verticalAlign:Qt.MIDDLE,boundElements:null,textAlign:rl.CENTER,autoResize:!0},!1),Qe(l,s,r.scene.getNonDeletedElementsMap()),i=aC([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import lC from"clsx";import{useCallback as p2,useEffect as u2,useLayoutEffect as sC,useRef as cC,useState as dC}from"react";import{jsx as Aa,jsxs as h2}from"react/jsx-runtime";var Ph=380,mC=42,_h=5,g2=85,pC=500,Dh=!1,Hd=new Map,f2=({element:e,elementsMap:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=pr(),l=ur(),s=Ce(),c=e.link||"",[m,d]=dC(c),p=cC(null),u=a.showHyperlinkPopup==="editor",h=p2(()=>{if(!p.current)return;let y=Vo(p.current.value)||null;if(!e.link&&y&&xe("hyperlink","create"),Ft(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!y){B(e,{link:null}),i(e,!1);return}if(!qi(y,l.validateEmbeddable))y&&n({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Hd.set(e.id,e.link),B(e,{link:y}),i(e,!1);else{let{width:v,height:C}=e,S=ni(y);S?.error instanceof URIError&&n({message:f("toast.unrecognizedLinkFormat"),closable:!0});let _=S?S.intrinsicSize.w/S.intrinsicSize.h:1,L=Hd.get(e.id)!==e.link;B(e,{...L?{width:S?.type==="video"?v>C?v:C*_:v,height:S?.type==="video"&&v>C?v/_:C}:{},link:y}),i(e,!0),Hd.has(e.id)&&Hd.delete(e.id)}}else B(e,{link:y})},[e,n,l.validateEmbeddable,a.activeEmbeddable,t,i]);sC(()=>()=>{h()},[h]),u2(()=>{u&&p?.current&&!(s.viewport.isMobile||s.isTouchScreen)&&p.current.select()},[u,s.viewport.isMobile,s.isTouchScreen]),u2(()=>{let y=null,v=C=>{if(u)return;y&&clearTimeout(y),hC(e,o,a,M(C.clientX,C.clientY))&&(y=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},pC))};return window.addEventListener("pointermove",v,!1),()=>{window.removeEventListener("pointermove",v,!1),y&&clearTimeout(y)}},[a,e,u,t,o]);let b=p2(()=>{xe("hyperlink","delete"),B(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e]),x=()=>{xe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=b2(e,a,o);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:h2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:Ph,padding:_h},children:[u?Aa("input",{className:lC("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:p,value:m,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[T.CTRL_OR_CMD]&&y.key===T.K&&y.preventDefault(),(y.key===T.ENTER||y.key===T.ESCAPE)&&(h(),t({showHyperlinkPopup:"info"}))}}):e.link?Aa("a",{href:Vo(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:js(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&r){let v=Xs("excalidraw-link",y.nativeEvent);r({...e,link:Vo(e.link)},v),v.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Aa("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),h2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!u&&Aa(Q,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:gn}),Aa(Q,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:nd}),c&&!Ft(e)&&Aa(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:ho})]})]})},b2=(e,o,t)=>{let[r,n]=We(e,t),{x:i,y:a}=zt({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-Ph/2,s=a-o.offsetTop-g2;return{x:l,y:s}},Rh=(e,o)=>{let t=J(e,o);return Ft(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ql=null,x2=(e,o,t)=>{Ql&&clearTimeout(Ql),Ql=window.setTimeout(()=>uC(e,o,t),Jf)},uC=(e,o,t)=>{if(!e.link)return;let r=Ea();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ii(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=We(e,t),[s,c,m,d]=i0([n,i,a,l],e.angle,o),p=zt({sceneX:s,sceneY:c},o);hh(r,{left:p.x,top:p.y,width:m,height:d},"top"),xe("hyperlink","tooltip","link-icon"),Dh=!0},Nh=()=>{Ql&&clearTimeout(Ql),Dh&&(Dh=!1,Ea().classList.remove("excalidraw-tooltip--visible"))},hC=(e,o,t,[r,n])=>{let{x:i,y:a}=$e({clientX:r,clientY:n},t),l=15/t.zoom.value;if(z1(i,a,e,o))return!1;let[s,c,m]=We(e,o);if(i>=s&&i<=m&&a>=c-g2&&a<=c)return!1;let{x:d,y:p}=b2(e,t,o);return!(r>=d-l&&r<=d+Ph+_h*2+l&&n>=p-l&&n<=p+l+_h*2+mC)};import{jsx as gC}from"react/jsx-runtime";var es=z({name:"hyperlink",label:(e,o)=>Rh(e,o),icon:Nl,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:A.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return gC(Q,{type:"button",icon:Nl,"aria-label":f(Rh(e,o)),title:`${Ft(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var Oh=e=>e.every(o=>!o.locked),Bh=z({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!ne(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Oh(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,o)=>{let t=J(o,e);return Oh(t)?aa:mi},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Oh(n),a=re(n);return{elements:e.map(l=>a.has(l.id)?te(l,{locked:i}):l),appState:{...o,selectedLinearElement:i?null:o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),E2=z({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:mi,predicate:(e,o)=>J(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(r=>r.locked);return{elements:e.map(r=>r.locked?te(r,{locked:!1}):r),appState:{...o,selectedElementIds:Object.fromEntries(t.map(r=>[r.id,!0]))},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import Tv from"clsx";import lS from"fuzzy";import{useEffect as am,useRef as sS,useState as im}from"react";var Ud=z({name:"copyElementLink",label:"labels.copyElementLink",icon:ca,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=yc(n,o);return i?(await jo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):Ec(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:A.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}},predicate:(e,o)=>vc(J(e,o))}),y2=z({name:"linkToElement",label:"labels.linkToElement",icon:nd,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!vc(n)?{elements:e,appState:o,app:r,captureUpdate:A.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&vc(n)},trackEvent:!1});var fC={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[Ho?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[Ho?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")],searchMenu:[R("CtrlOrCmd+F")],wrapSelectionInFrame:[]},ct=(e,o=0)=>{let t=fC[e];return t&&t.length>0?t[o]||t[0]:""};var bC="\\u0300-\\u036f",xC="\\ufe20-\\ufe2f",EC="\\u20d0-\\u20ff",yC=bC+xC+EC,vC=`[${yC}]`,wC=RegExp(vC,"g"),TC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,CC={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},zh=e=>e.replace(TC,o=>CC[o]||o).replace(wC,"");import GI from"clsx";import{useEffect as VI,useState as YI}from"react";import{useCallback as IC,useState as SC}from"react";var v2=()=>{let[e,o]=SC(null),t=IC(r=>o(r),[]);return[e,t]};import{useState as sv,useCallback as $h,useMemo as cv,useEffect as iv,memo as dv,useRef as NI}from"react";import{useEffect as I2,useRef as S2}from"react";var Tn=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ta({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return kc(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let h=n?.(d,p)||{width:d,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},w2=async e=>{let{mimeType:o=ue.png,quality:t}=e;o===ue.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ue.png}" mimeType`),o==="image/jpg"&&(o=ue.jpg),o===ue.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ue.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Tn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ue.png&&e.appState?.exportEmbedScene&&(a=await d0({blob:a,metadata:Tl(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},_a=async({elements:e,appState:o=dr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=ta({elements:e,appState:o},null,null),m={...c,exportPadding:r};return ea(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},kC=async e=>{if(e.type==="svg"){let o=await _a(e);await jo(o.outerHTML)}else if(e.type==="png")await _d(w2(e));else if(e.type==="json")await Ld(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as MC,useState as LC}from"react";var Fh=Ae(new Map),T2=async e=>await _a({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Io.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),C2=(e,o,t)=>{let[r,n]=LC();return MC(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await T2(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await T2(o);n(i)})()},[e,o,t,n]),r},Gd=()=>{let[e]=ve(Fh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var AC=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],M2=new Pt,Ti=Ae({status:"loaded",isInitialized:!1,libraryItems:[]}),ts=e=>oo(e),_C=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),L2=(e,o)=>{let t=[];for(let r of o)_C(e,r)&&t.push(r);return[...t,...e]},A2=(e,o)=>{let t=re(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=re(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Hh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",ts(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)St.set(Ti,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{St.set(Ti,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ts(this.currLibraryItems);let t=ts(this.currLibraryItems);this.app.props.onLibraryChange?.(t),M2.trigger(A2(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],St.set(Fh,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(ts(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:At.name,tab:nl}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Jp(s,i):c=Il(s,i),!t||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?L2(this.currLibraryItems,c):c)):l(new Ji)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=ts(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},_2=Hh,Wd=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:E}=Dt(x.elements);return Math.max(b,E)},0),i=u=>{let h=0,b=0,x=0;for(let E of e){if(h%t===0&&(b=0),b===u){let{width:w}=Dt(E.elements);x=Math.max(x,w)}h++,b++}return x},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:h,minY:b,width:x,height:E}=Dt(u.elements),w=(c-x)/2,y=(s-E)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+w-h,y:v.y+l+y-b}))),a+=c+50,m++,d++}return r},DC=(e,o=AC)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Uh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Fs.addLibrary)||new URLSearchParams(window.location.search).get(zs.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Cn=class Cn{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Il(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Cn.queue.push(n):n()}getLibraryItems(o){return Cn.getLibraryItems(this.adapter,o,!1)}};I(Cn,"queue",new c1),I(Cn,"run",async(o,t)=>{let r=new Cn(o);return Cn.queue.push(()=>t(r))});var Da=Cn,os=0,Vd=0,Yd=e=>_p(e.map(o=>`${o.id}:${Ap(o.elements)}`).sort().join()),k2=async(e,o)=>{try{return Vd++,await Da.run(e,async t=>{let r=re(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=Yd(i);return a!==os&&await e.save({libraryItems:i}),os=a,i})}finally{Vd--}},PC=e=>{let{excalidrawAPI:o}=e,t=S2(e);t.current=e;let r=S2(!1);I2(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=qs(l),DC(l,t.current.validateLibraryUrl);let h=await(await fetch(l)).blob();d(h)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(Fs.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(Fs.addLibrary),window.history.replaceState({},Ja,`#${d.toString()}`)}else if(window.location.search.includes(zs.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(zs.addLibrary),window.history.replaceState({},Ja,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Uh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Uh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=v1();s?c.resolve(Tp(s.load).then(async m=>{let d=null;try{if(!m)return Da.getLibraryItems(l,"load");d=Il(m.libraryItems||[],"published");let p=await k2(l,A2([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Da.getLibraryItems(l,"load")))):c.resolve(Tp(Da.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return os=Yd(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),I2(()=>{let n=M2.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&os!==Yd(l)&&await k2(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Vd&&C1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),os=0,Vd=0}},[])};import OC from"clsx";import{jsx as NC}from"react/jsx-runtime";var RC=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return NC("a",{className:"library-menu-browse-button",href:`${k.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${Us.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},D2=RC;import{jsx as BC,jsxs as zC}from"react/jsx-runtime";var Kd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>zC("div",{className:OC("library-menu-control-buttons",i),style:r,children:[BC(D2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Na,useEffect as AI,useMemo as rv,useRef as _I,useState as DI}from"react";import FC from"lodash.throttle";import{useEffect as HC}from"react";var UC=Ae(0),P2=e=>{let[o,t]=ve(UC);return HC(()=>{let{current:r}=e;if(!r)return;let n=FC(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import hI from"clsx";import{useCallback as gI,useState as Yh}from"react";import{flushSync as R2}from"react-dom";import GC from"clsx";import{jsx as Zd,jsxs as YC}from"react/jsx-runtime";var VC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return YC("button",{className:GC("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&Zd("div",{style:a?{visibility:"hidden"}:{},children:r}),Zd("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Zd("div",{style:{position:"absolute",inset:0},children:Zd(Mt,{})})]})},Hr=VC;import{jsx as N2,jsxs as O2}from"react/jsx-runtime";var WC=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=Ie(),c=hn(Pa),{container:m}=ht();return O2(dt,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,O2("div",{className:"confirm-dialog-buttons",children:[N2(Hr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),R2(()=>{t()}),m?.focus()}}),N2(Hr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),R2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Xd=WC;import jd from"open-color";import{useCallback as JC,useEffect as Vh,useRef as B2,useState as Gh}from"react";var Po=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(Po,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(Po,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import $d from"react";var KC=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,ZC=/{{([\w-]+)}}/,XC=/<([\w-]+)>/,$C=/<\/([\w-]+)>/,jC=(e,o)=>{let t=[{name:"",children:[]}];return e.split(KC).filter(Boolean).forEach(r=>{let n=r.match(XC),i=r.match($C),a=r.match(ZC);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=$d.createElement($d.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},qC=({i18nKey:e,children:o,...t})=>{let{t:r}=pt();return $d.createElement($d.Fragment,{},...jC(r(e),t))},Kt=qC;import{jsx as we,jsxs as Nt}from"react/jsx-runtime";var QC=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=y1(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=jd.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Tn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),h=s%6*(128+r*2);l.drawImage(m,h+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=jd.gray[4],l.strokeRect(h+r/2,u+r/2,128+r,128+r)}return await Sl(new File([await Rr(a)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},eI=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=B2(null),a=B2(null);return Vh(()=>{let l=i.current;l&&(async()=>{let s=await _a({elements:e.elements,appState:{...o,viewBackgroundColor:jd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),Nt("div",{className:"single-library-item",children:[e.status==="published"&&we("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),we("div",{ref:i,className:"single-library-item__svg"}),we(Q,{"aria-label":f("buttons.remove"),type:"button",icon:Mo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:f("buttons.remove")}),Nt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Nt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Nt("div",{style:{padding:"0.5em 0"},children:[we("span",{style:{fontWeight:500,color:jd.gray[6]},children:f("publishDialog.itemName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),we("span",{className:"error",children:e.error})]})]})},tI=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Gh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Gh(!1);Vh(()=>{let y=Po.get(en.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Gh(o.slice());Vh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},h=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(d.forEach(F=>{let K="";F.name||(K=f("publishDialog.errors.required"),C=!0),v.push({...F,error:K})}),C){p(v),m(!1);return}let S=await QC(d),_={type:Jr.excalidrawLibrary,version:Us.excalidrawLibrary,source:Zf,libraryItems:d},L=JSON.stringify(_,null,2),N=new Blob([L],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",N),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${k.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(F=>F.ok?F.json().then(({url:K})=>{Po.delete(en.PUBLISH_LIBRARY),r({url:K,authorName:l.authorName,items:d})}):F.json().catch(()=>{throw new Error(F.statusText||"something went wrong")}).then(K=>{throw new Error(K.message||F.statusText||"something went wrong")}),F=>{console.error(F),n(F),m(!1)}).catch(F=>{console.error(F),n(F),m(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(we("div",{className:"single-library-item-wrapper",children:we(eI,{libItem:v,appState:t,index:C,onChange:(S,_)=>{let L=d.slice();L[_].name=S,p(L)},onRemove:a})},C))}),we("div",{className:"selected-library-items",children:y})},x=JC(()=>{i(d),Po.set(en.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,w=o.some(y=>y.status==="published");return we(dt,{onCloseRequest:x,title:f("publishDialog.title"),className:"publish-library",children:E?Nt("form",{onSubmit:h,children:[we("div",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteDescription",link:y=>we("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("span",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteGuidelines",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),w&&we("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),b(),Nt("div",{className:"publish-library__fields",children:[Nt("label",{children:[Nt("div",{children:[we("span",{children:f("publishDialog.libraryName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),Nt("label",{style:{alignItems:"flex-start"},children:[Nt("div",{children:[we("span",{children:f("publishDialog.libraryDesc")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),Nt("label",{children:[Nt("div",{children:[we("span",{children:f("publishDialog.authorName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.githubUsername")}),we("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.twitterUsername")}),we("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.website")}),we("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),we("span",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteLicense",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),Nt("div",{className:"publish-library__buttons",children:[we(Hr,{label:f("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),we(Hr,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):we("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},z2=tI;import nI from"clsx";import{useEffect as iI,useRef as aI}from"react";import{forwardRef as F2}from"react";import H2 from"clsx";import{jsx as U2}from"react/jsx-runtime";var oI=F2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>U2("div",{className:H2("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),rI=F2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>U2("div",{className:H2("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),Ct={Row:oI,Col:rI};import{jsx as qd}from"react/jsx-runtime";var G2=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=Ce(),a=aI(null),l=fn({onClickOutside:o});pa(a,()=>{l.onClickOutside?.()}),iI(()=>{let c=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=nI(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return qd(oh.Provider,{value:{onSelect:r},children:qd("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?qd(Ct.Col,{className:"dropdown-menu-container",children:e}):qd(Et,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};G2.displayName="DropdownMenuContent";var V2=G2;import{jsx as sI}from"react/jsx-runtime";var lI=({children:e,className:o="",selected:t,...r})=>sI("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Y2=lI;import{jsx as W2}from"react/jsx-runtime";var K2=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noreferrer",...s})=>{let c=xd(s.onClick,n);return W2("a",{...s,href:t,target:"_blank",rel:"noreferrer",className:bd(i,a),title:s.title??s["aria-label"],onClick:c,children:W2(fd,{icon:e,shortcut:o,children:r})})},Ra=K2;K2.displayName="DropdownMenuItemLink";import{jsx as cI}from"react/jsx-runtime";var Z2=()=>cI("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),X2=Z2;Z2.displayName="DropdownMenuSeparator";import dI from"clsx";import{jsx as mI}from"react/jsx-runtime";var $2=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=Ce(),a=dI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return mI("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},j2=$2;$2.displayName="DropdownMenuTrigger";import Jd from"react";var q2=e=>{let o=Jd.Children.toArray(e).find(t=>Jd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},J2=e=>{let o=Jd.Children.toArray(e).find(t=>Jd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as pI,jsxs as uI}from"react/jsx-runtime";var Ur=({children:e,open:o})=>{let t=q2(e),r=J2(e);return uI(pI,{children:[t,o&&r]})};Ur.Trigger=j2;Ur.Content=V2;Ur.Item=Yt;Ur.ItemLink=Ra;Ur.ItemCustom=Y2;Ur.Group=Wl;Ur.Separator=X2;var Pe=Ur;Ur.displayName="DropdownMenu";import{jsx as ao,jsxs as Qd}from"react/jsx-runtime";var fI=(e,o)=>e.filter(t=>o.includes(t.id)),bI=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ve(Ti),[c,m]=ve(Pa),d=()=>{let P=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),F=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return ao(Xd,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:F,children:ao("p",{children:P})})},[p,u]=Yh(!1),h=!!o.length,b=h?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=h?f("buttons.remove"):f("buttons.resetLibrary"),[E,w]=Yh(!1),[y,v]=Yh(null),C=gI(()=>Qd(dt,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[ao("p",{children:ao(Kt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>ao("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),ao(Q,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,F)=>{w(!1),v({url:P.url,authorName:P.authorName});let K=F.slice();K.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(K)},_=async()=>{try{await t.updateLibrary({libraryItems:wc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:f("errors.importLibraryError")})}},L=async()=>{let P=h?b:await t.getLatestLibrary();n0(P).catch(Zs).catch(F=>{e({errorMessage:F.message})})},N=()=>Qd(Pe,{open:c,children:[ao(Pe.Trigger,{onToggle:()=>m(!c),children:Y0}),Qd(Pe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!h&&ao(Pe.Item,{onSelect:_,icon:sa,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&ao(Pe.Item,{onSelect:L,icon:pi,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&ao(Pe.Item,{onSelect:()=>u(!0),icon:ho,children:x}),h&&ao(Pe.Item,{icon:oE,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return Qd("div",{className:hI("library-menu-dropdown-container",l),children:[N(),o.length>0&&ao("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&ao(z2,{onClose:()=>w(!1),libraryItems:fI(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(F=>F!==P))}),y&&C()]})},Wh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=st(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Gd(),a=De(),l=Ie(),[s]=ve(Ti),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return ao(bI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as SI,useEffect as kI,useState as MI}from"react";import xI,{useCallback as EI}from"react";function yI(){return[!1,EI(o=>o(),[])]}var Q2=xI.useTransition||yI;import ev from"clsx";import{memo as vI,useEffect as wI,useRef as TI,useState as CI}from"react";import{jsx as em,jsxs as II}from"react/jsx-runtime";var tv=vI(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=TI(null),c=C2(e,o,l);wI(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[m,d]=CI(!1),p=Ce().editor.isMobile,u=t&&em("div",{className:"library-unit__adder",children:V0});return II("div",{className:ev("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[em("div",{className:ev("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?h=>{e&&h.shiftKey?i(e,h):r(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}d(!1),a(e,h)}}),u,e&&o&&(m||p||n)&&em($l,{checked:n,onChange:(h,b)=>i(e,b),className:"library-unit__checkbox"})]})}),ov=()=>em("div",{className:"library-unit library-unit--skeleton"});import{Fragment as LI,jsx as tm}from"react/jsx-runtime";var Kh=({children:e})=>tm("div",{className:"library-menu-items-container__grid",children:e}),om=SI(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Q2(),[s,c]=MI(0);return kI(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),tm(LI,{children:e.map((m,d)=>d<s?tm(tv,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??d):tm(ov,{},d))})});import{Fragment as nv,jsx as lo,jsxs as Oa}from"react/jsx-runtime";var PI=17,RI=64;function Zh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=_I(null),d=P2(m);AI(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Gd(),u=rv(()=>o.filter(P=>P.status!=="published"),[o]),h=rv(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!h.length,[E,w]=DI(null),y=Na((P,F)=>{let K=!c.includes(P),U=[...u,...h];if(K){if(F.shiftKey&&E){let q=U.findIndex(ie=>ie.id===E),H=U.findIndex(ie=>ie.id===P);if(q===-1||H===-1){s([...c,P]);return}let G=re(c),V=U.reduce((ie,$,se)=>((se>=q&&se<=H||G.has($.id))&&ie.push($.id),ie),[]);s(V)}else s([...c,P]);w(P)}else w(null),s(c.filter(q=>q!==P))},[E,s,h,c,u]),v=Na(P=>{let F;return c.includes(P)?F=o.filter(K=>c.includes(K.id)):F=o.filter(K=>K.id===P),F.map(K=>({...K,elements:li({type:"everything",elements:K.elements,randomizeSeed:!0}).newElements}))},[o,c]),C=Na((P,F)=>{F.dataTransfer.setData(ue.excalidrawlib,$p(v(P)))},[v]),S=Na(P=>P?c.includes(P):!1,[c]),_=Na(()=>{t(n)},[n,t]),L=Na(P=>{P&&r(v(P))},[v,r]),N=p.size>=o.length?RI:PI;return Oa("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&lo(Wh,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Oa(Ct.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[Oa(nv,{children:[!x&&lo("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&lo("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:lo(Mt,{})}),!n.length&&!u.length?Oa("div",{className:"library-menu-items__no-items",children:[lo("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),lo("div",{className:"library-menu-items__no-items__hint",children:h.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Oa(Kh,{children:[n.length>0&&lo(om,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:_,isItemSelected:S,svgCache:p}),lo(om,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})]})]}),Oa(nv,{children:[(h.length>0||n.length>0||u.length>0)&&lo("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),h.length>0?lo(Kh,{children:lo(om,{itemsRenderedPerBatch:N,items:h,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})}):u.length>0?lo("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&lo(Kd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:lo(Wh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as In,jsxs as lv}from"react/jsx-runtime";var Pa=Ae(!1),av=({children:e})=>In("div",{className:"layer-ui__library",children:e}),OI=dv(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ve(Ti),d=$h(h=>{(async(x,E)=>{xe("element","addToLibrary","ui");for(let y of Vs)if(x.some(v=>v.type===y))return r({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:x,id:ro(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{r({errorMessage:f("alerts.errorAddingToLibrary")})})})(h,m.libraryItems)},[t,i,r,m.libraryItems]),p=cv(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return In(av,{children:In("div",{className:"layer-ui__library-message",children:lv("div",{children:[In(Mt,{size:"2em"}),In("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return lv(av,{children:[In(Zh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&In(Kd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Xh=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),BI=(e,o)=>{let t=xn(),[r,n]=sv(()=>Xh(t,e.selectedElementIds)),i=NI(new Map);return iv(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),iv(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!Je(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Xh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Xh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},mv=dv(()=>{let e=st(),{onInsertElements:o}=e,t=ur(),r=De(),n=Ie(),[i,a]=sv([]),l=cv(()=>e.library,[e.library]),s=BI(r,e),c=$h(d=>{o(Wd(d))},[o]),m=$h(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return In(OI,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import zI from"clsx";import{useRef as FI}from"react";import{createPortal as HI}from"react-dom";import{jsx as pv,jsxs as UI}from"react/jsx-runtime";var uv=e=>{let{closeOnClickOutside:o=!0}=e,t=cd({className:"excalidraw-modal-container"}),r=FI(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===T.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return HI(UI("div",{className:zI("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[pv("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),pv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as rs,jsxs as KI}from"react/jsx-runtime";function WI(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var dt=e=>{let[o,t]=v2(),[r]=YI(document.activeElement),{id:n}=ht(),i=Ce().viewport.isMobile;VI(()=>{if(!o)return;let c=dl(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===T.TAB){let p=dl(o),{activeElement:u}=document,h=p.findIndex(b=>b===u);h===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):h===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=Ie(),l=hn(Pa),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return rs(uv,{className:GI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:WI(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:KI(Et,{ref:t,children:[e.title&&rs("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:rs("span",{className:"Dialog__titleContent",children:e.title})}),i&&rs("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Mo}),rs("div",{className:"Dialog__content",children:e.children})]})})};import jh from"clsx";import{forwardRef as $I,useRef as jI,useImperativeHandle as qI,useLayoutEffect as JI,useState as QI}from"react";import ZI from"clsx";import{jsx as XI}from"react/jsx-runtime";var vo=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>XI("button",{onClick:an(i.onClick,a=>{o()}),type:e,className:ZI("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as qh,jsxs as hv}from"react/jsx-runtime";var Ba=$I(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...m},d)=>{let p=jI(null);qI(d,()=>p.current),JI(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,h]=QI(!1);return hv("div",{className:jh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&qh("div",{className:"ExcTextField__label",children:o}),hv("div",{className:jh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[qh("input",{className:jh({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&qh(vo,{onSelect:()=>h(!u),style:{border:0,userSelect:"none"},children:u?dE:ma})]})]})});var ns=[{icon:$0,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:j0,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:q0,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:J0,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:Q0,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:ex,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:gn,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:Yc,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:ox,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:rx,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],gv=e=>ns.find((t,r)=>t.numericKey!=null&&e===t.numericKey.toString()||t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import eg from"clsx";import{useState as oS}from"react";import{createIsolation as eS}from"jotai-scope";import Jh from"react";import fr from"tunnel-rat";var Qh=Jh.createContext(null),Ke=()=>Jh.useContext(Qh),tS=eS(),fv=()=>Jh.useMemo(()=>({MainMenuTunnel:fr(),WelcomeScreenMenuHintTunnel:fr(),WelcomeScreenToolbarHintTunnel:fr(),WelcomeScreenHelpHintTunnel:fr(),WelcomeScreenCenterTunnel:fr(),FooterCenterTunnel:fr(),DefaultSidebarTriggerTunnel:fr(),DefaultSidebarTabTriggersTunnel:fr(),OverwriteConfirmDialogTunnel:fr(),TTDDialogTriggerTunnel:fr(),tunnelsJotai:tS}),[]);import{Fragment as Gr,jsx as Ve,jsxs as yt}from"react/jsx-runtime";var tg=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return vl(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>vl(r.type))},og=(e,o)=>mn(e.activeTool.type)||o.some(t=>mn(t.type)),rm=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=uc(o,e),i=!1;n.length===2&&(Tt(n[0])||Tt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=mn(e.activeTool.type)&&!Wn(e.currentItemBackgroundColor)||n.some(h=>mn(h.type)&&!Wn(h.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&ae(n[0])&&!ee(n[0]),p=!e.croppingElementId&&n.length===1&&he(n[0]),u=!i&&io(e,r);return yt("div",{className:"panelColumn",children:[Ve("div",{children:tg(e,n)&&t("changeStrokeColor")}),og(e,n)&&Ve("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Op(e.activeTool.type)||n.some(h=>Op(h.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(h=>h.type==="freedraw"))&&t("changeStrokeShape"),(Bp(e.activeTool.type)||n.some(h=>Bp(h.type)))&&yt(Gr,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(zp(e.activeTool.type)||n.some(h=>zp(h.type)))&&Ve(Gr,{children:t("changeRoundness")}),(Fp(e.activeTool.type)||n.some(h=>Fp(h.type)))&&Ve(Gr,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(Z))&&yt(Gr,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||eb(n,o))&&t("changeTextAlign")]}),Q1(n,o)&&t("changeVerticalAlign"),(Zi(e.activeTool.type)||n.some(h=>Zi(h.type)))&&Ve(Gr,{children:t("changeArrowhead")}),t("changeOpacity"),yt("fieldset",{children:[Ve("legend",{children:f("labels.layers")}),yt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&yt("fieldset",{children:[Ve("legend",{children:f("labels.align")}),yt("div",{className:"buttonList",children:[s?yt(Gr,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):yt(Gr,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Ve("div",{style:{flexBasis:"100%",height:0}}),yt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&yt("fieldset",{children:[Ve("legend",{children:f("labels.actions")}),yt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},nm=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=oS(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Ke();return yt(Gr,{children:[ns.map(({value:d,icon:p,key:u,numericKey:h,fillable:b},x)=>{if(r.tools?.[d]===!1)return null;let E=f(`toolBar.${d}`),w=u&&on(typeof u=="string"?u:u[0]),y=w?`${w} ${f("helpDialog.or")} ${h}`:`${h}`;return Ve(Q,{className:eg("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${on(E)} \u2014 ${y}`,keyBindingLabel:h||w,"aria-label":on(E),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==d&&xe("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d,insertOnCanvasDirectly:v!=="mouse"}):t.setActiveTool({type:d})}},d)}),Ve("div",{className:"App-toolbar__divider"}),yt(Pe,{open:n,children:[Ve(Pe.Trigger,{className:eg("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:f("toolBar.extraTools"),children:a?Bl:c?fu:l&&!t.props.isCollaborating?zl:s?_l:sE}),yt(Pe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ve(Pe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Bl,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Ve(Pe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:fu,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),Ve(Pe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:zl,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Ve(Pe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:_l,"data-testid":"toolbar-lasso",selected:s,children:f("toolBar.lasso")}),Ve("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Ve(m.Out,{}),Ve(Pe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Qc,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Ve(Gr,{children:yt(Pe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:ed,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Ve(Pe.Item.Badge,{children:"AI"})]})})]})]})]})},bv=({renderAction:e,zoom:o})=>Ve(Ct.Col,{gap:1,className:Uo.ZOOM_ACTIONS,children:yt(Ct.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),xv=({renderAction:e,className:o})=>yt("div",{className:`undo-redo-buttons ${o}`,children:[Ve("div",{className:"undo-button-container",children:Ve(bo,{label:f("buttons.undo"),children:e("undo")})}),Ve("div",{className:"redo-button-container",children:yt(bo,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),Ev=({actionManager:e,showExitZenModeBtn:o})=>Ve("button",{type:"button",className:eg("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Ma),children:f("buttons.exitZenMode")}),yv=({renderAction:e,className:o})=>Ve("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as rS}from"react";var rg=e=>{let o=rS({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as iS,jsxs as nS}from"react/jsx-runtime";var Ci=Ae(null),vv=()=>{let[e,o]=ve(Ci),t=gt();return e&&e==="clearCanvas"?iS(Xd,{onConfirm:()=>{t.executeAction(zr),o(null)},onCancel:()=>o(null),title:f("clearCanvasDialog.title"),children:nS("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var ng={};Mf(ng,{toggleTheme:()=>aS});var aS={...fi,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(fi,"commandPalette")}};import{jsx as Zt,jsxs as br}from"react/jsx-runtime";var cS=Ae(null),nt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},dS=e=>{switch(e){case nt.app:return 1;case nt.export:return 2;case nt.editor:return 3;case nt.tools:return 4;case nt.elements:return 5;case nt.links:return 6;default:return 10}},lm=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return br("div",{className:Tv("shortcut",o),children:[r.map((n,i)=>Zt("div",{className:"shortcut-wrapper",children:Zt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Zt("div",{className:"shortcut-desc",children:t})]})},Cv=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),Eq=Object.assign(e=>{let o=De(),t=Ie();return am(()=>{let r=n=>{Cv(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&xe("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Zt(mS,{...e})},{defaultItems:ng});function mS({customCommandPaletteItems:e}){let o=st(),t=De(),r=Ie(),n=ur(),i=gt(),[a,l]=ve(cS),[s,c]=im(null),m=sS(null),d=fn({uiAppState:t,customCommandPaletteItems:e,appProps:n});am(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:L}=d,N=U=>{let q="";return U.label&&(typeof U.label=="function"?q=f(U.label(o.scene.getNonDeletedElements(),S,o)):q=f(U.label)),q},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,F=[],K=(U,q,H)=>{let G={label:N(U),icon:P(U),category:q,shortcut:ct(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return H?H(G,U):G};if(S&&o.scene&&i){let U=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,es,Ud,y2].map($=>K($,nt.elements,(se,be)=>({...se,predicate:be.predicate?be.predicate:(Te,ot,jt,Fo)=>J(Te,ot).length>0}))),q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map($=>K($,nt.tools)),H=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map($=>K($,nt.editor)),G=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map($=>K($,nt.export));F=[...U,...H,{label:N(zr),icon:P(zr),shortcut:ct(zr.name),category:nt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{St.set(Ci,"clearCanvas")}},{label:f("buttons.exportImage"),category:nt.export,icon:Xc,shortcut:ct("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...G];let V=[{label:f("toolBar.library"),category:nt.app,icon:ia,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:At.name,tab:At.defaultTab}})}},{label:f("search.title"),category:nt.app,icon:go,viewMode:!0,perform:()=>{i.executeAction(is)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:nt.elements,icon:Zc,viewMode:!1,predicate:($,se)=>{let be=J($,se);return be.length>0&&tg(se,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:Zc,category:nt.elements,viewMode:!1,predicate:($,se)=>{let be=J($,se);return be.length>0&&og(se,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:Zc,category:nt.editor,viewMode:!1,perform:()=>{r($=>({openMenu:$.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...ns.reduce(($,se)=>{let{value:be,icon:Te,key:ot,numericKey:jt}=se;if(L.UIOptions.tools?.[be]===!1)return $;let er=ot&&on(typeof ot=="string"?ot:ot[0])||jt,qt={label:f(`toolBar.${be}`),category:nt.tools,shortcut:er,icon:Te,keywords:["toolbar"],viewMode:!1,perform:({event:tr})=>{be==="image"?o.setActiveTool({type:be,insertOnCanvasDirectly:tr.type==="keydown"}):o.setActiveTool({type:be})}};return $.push(qt),$},[]),...q,{label:f("toolBar.lock"),category:nt.tools,icon:S.activeTool.locked?aa:mi,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:nt.tools,icon:pE,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:nt.tools,icon:Qc,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ie=[...F,...V,..._||[]].map($=>({...$,icon:$.icon||td,order:$.order??dS($.category),haystack:`${zh($.label.toLocaleLowerCase())} ${$.keywords?.join(" ")||""}`}));c(ie),l(ie.find($=>$.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=im(""),[h,b]=im(null),[x,E]=im({}),w=S=>{r({openDialog:null},S),u("")},y=(S,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{S.perform({actionManager:i,event:_}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=rg(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=rg(S=>{let _=rr(S.target)||Cv(S)||S.key===T.ESCAPE;if(_&&S.key!==T.ARROW_UP&&S.key!==T.ARROW_DOWN&&S.key!==T.ENTER)return;let L=Object.values(x).flat(),N=a&&!p&&v(a);if(S.key===T.ARROW_UP){S.preventDefault();let P=L.findIndex(U=>U.label===h?.label);if(N){if(P===0){b(a);return}if(h===a){let U=L[L.length-1];U&&b(U);return}}let F;P===-1?F=L.length-1:F=P===0?L.length-1:(P-1)%L.length;let K=L[F];K&&b(K);return}if(S.key===T.ARROW_DOWN){S.preventDefault();let P=L.findIndex(U=>U.label===h?.label);if(N){if(!h||P===L.length-1){b(a);return}if(h===a){let U=L[0];U&&b(U);return}}let F=(P+1)%L.length,K=L[F];K&&b(K);return}if(S.key===T.ENTER&&h&&setTimeout(()=>{y(h,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return am(()=>(window.addEventListener("keydown",C,{capture:!0}),()=>window.removeEventListener("keydown",C,{capture:!0})),[C]),am(()=>{if(!s)return;let S=P=>{let F={};for(let K of P)F[K.category]?F[K.category].push(K):F[K.category]=[K];return F},_=s.filter(v).sort((P,F)=>P.order-F.order),L=!p&&a&&v(a);if(!p){E(S(L?_.filter(P=>P.label!==a?.label):_)),b(L?a:_[0]||null);return}let N=zh(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=lS.filter(N,_,{extract:P=>P.haystack}).sort((P,F)=>F.score-P.score).map(P=>P.original),E(S(_)),b(_[0]??null)},[p,s,v,a]),br(dt,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Zt(Ba,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&br("div",{className:"shortcuts-wrapper",children:[Zt(lm,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Zt(lm,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Zt(lm,{shortcut:R("Esc"),children:f("commandPalette.shortcuts.close")})]}),br("div",{className:"commands",children:[a&&!p&&br("div",{className:"command-category",children:[br("div",{className:"command-category-title",children:[f("commandPalette.recents"),Zt("div",{className:"icon",style:{marginLeft:"6px"},children:uE})]}),Zt(wv,{command:a,isSelected:a.label===h?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,_)=>br("div",{className:"command-category",children:[Zt("div",{className:"command-category-title",children:S}),x[S].map(L=>Zt(wv,{command:L,isSelected:L.label===h?.label,onClick:N=>y(L,N),onMouseMove:()=>b(L),showShortcut:!o.device.viewport.isMobile,appState:t},L.label))]},S)):s?br("div",{className:"no-match",children:[Zt("div",{className:"icon",children:go})," ",f("commandPalette.search.noMatch")]}):null]})]})}var wv=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return br("div",{className:Tv("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?f("commandPalette.itemNotAvailable"):"",children:[br("div",{className:"name",children:[e.icon&&Zt(vn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Zt(lm,{shortcut:e.shortcut})]})};import{jsx as pS}from"react/jsx-runtime";var ig=z({name:"toggleLinearEditor",category:nt.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.editingLinearElement&&n.length===1&&ae(n[0])&&!ee(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0],i=o.editingLinearElement?.elementId===n.id?null:new j(n);return{appState:{...o,editingLinearElement:i},captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=f(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return pS(Q,{type:"button",icon:kE,title:n,"aria-label":n,onClick:()=>o(null)})}});var is=z({name:"searchMenu",icon:go,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openSidebar?.name===At.name&&o.openSidebar.tab===Ir){let n=r.excalidrawContainerValue.container?.querySelector(`.${Uo.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.matches(":focus")?{appState:{...o,openSidebar:null},captureUpdate:A.EVENTUALLY}:(n?.focus(),n?.select(),!1)}return{appState:{...o,openSidebar:{name:At.name,tab:Ir},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as uS}from"react/jsx-runtime";var ag=z({name:"cropEditor",label:"helpDialog.cropStart",icon:Nu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&he(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=f("helpDialog.cropStart");return uS(Q,{type:"button",icon:Nu,title:r,"aria-label":r,onClick:()=>o(null)})}});var Iv=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ne(t[0])},Sv=z({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ne(n)){let i=ko(Ee(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:A.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Iv(o,r)}),kv=z({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ne(n)?{elements:yb(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Iv(o,r)}),FJ=z({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:A.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),HJ=z({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Bl,viewMode:!1,perform:(e,o,t,r)=>{let n=Fe(o,{type:"frame"});return Eo(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Fe(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),Mv=z({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length>0&&!n.some(i=>ne(i))},perform:(e,o,t,r)=>{let n=J(e,o),[i,a,l,s]=ye(n,r.scene.getNonDeletedElementsMap()),c=16,m=$i({x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2});if(o.editingGroupId){let p=Ge(n,o.editingGroupId);for(let u of p){let h=u.groupIds.indexOf(o.editingGroupId);B(u,{groupIds:u.groupIds.slice(0,h)},!1)}}return{elements:Wi([...r.scene.getElementsIncludingDeleted(),m],n,m,o),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var Ii=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},as=class e{constructor(){I(this,"onHistoryChangedEmitter",new Pt);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o,t){let r=lg.create(t,o);r.isEmpty()||(this.undoStack.push(r.inverse()),r.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Ii(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,o))}redo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,o))}perform(o,t,r,n,i){try{let a=n();if(a===null)return;let l=o,s=t,c=!1;for(;a;){try{[l,s,c]=a.applyTo(l,s,r)}finally{i(a)}if(c)break;a=n()}return[l,s]}finally{this.onHistoryChangedEmitter.trigger(new Ii(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t,r){let n=t.inverse().applyLatestChanges(r);return o.push(n)}},lg=class e{constructor(o,t){this.appStateChange=o;this.elementsChange=t}static create(o,t){return new e(o,t)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(o,t,r){let[n,i]=this.elementsChange.applyTo(o,r.elements),[a,l]=this.appStateChange.applyTo(t,n);return[n,a,i||l]}applyLatestChanges(o){let t=this.elementsChange.applyLatestChanges(o);return e.create(this.appStateChange,t)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};import{useEffect as hS,useState as gS}from"react";var sg=(e,o)=>{let[t,r]=gS(o);return hS(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as Dv}from"react/jsx-runtime";var Lv=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:A.EVENTUALLY};let[n,i]=r,a=Array.from(n.values());return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},Av=(e,o)=>({name:"undo",label:"buttons.undo",icon:xu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>Lv(i,r,()=>e.undo(re(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&Ys(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>{let{isUndoStackEmpty:n}=sg(e.onHistoryChangedEmitter,new Ii(e.isUndoStackEmpty,e.isRedoStackEmpty));return Dv(Q,{type:"button",icon:xu,"aria-label":f("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),_v=(e,o)=>({name:"redo",label:"buttons.redo",icon:Eu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>Lv(i,r,()=>e.redo(re(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&t.shiftKey&&Ys(t,T.Z)||_s&&t.ctrlKey&&!t.shiftKey&&Ys(t,T.Y),PanelComponent:({updateData:t,data:r})=>{let{isRedoStackEmpty:n}=sg(e.onHistoryChangedEmitter,new Ii(e.isUndoStackEmpty,e.isRedoStackEmpty));return Dv(Q,{type:"button",icon:Eu,"aria-label":f("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-redo"})}});var Pv=z({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length===1&&Z(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=J(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&Z(i)){let a=Ht(i.originalText,qe(i),i.lineHeight);return te(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});var cg=z({name:"viewMode",label:"labels.viewMode",icon:ma,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.R});import{jsx as fS}from"react/jsx-runtime";var dg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&xe(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},sm=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{dg(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return fS(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(nn(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return dg(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();dg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var cm=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var mg=e=>{let o=Array.from(e.values());return{x:Rv(o,t=>t.x)/o.length,y:Rv(o,t=>t.y)/o.length}},pg=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Rv=(e,o)=>e.reduce((t,r)=>t+o(r),0);var bS=8,Nv=99999,dm=e=>bS/e,Xt=class Xt{};I(Xt,"referenceSnapPoints",null),I(Xt,"visibleGaps",null),I(Xt,"setReferenceSnapPoints",o=>{Xt.referenceSnapPoints=o}),I(Xt,"getReferenceSnapPoints",()=>Xt.referenceSnapPoints),I(Xt,"setVisibleGaps",o=>{Xt.visibleGaps=o}),I(Xt,"getVisibleGaps",()=>Xt.visibleGaps),I(Xt,"destroy",()=>{Xt.referenceSnapPoints=null,Xt.visibleGaps=null});var Ro=Xt,Sn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Vr=({event:e,app:o,selectedElements:t})=>e?o.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!Sn(o):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,xS=(e,o,t=.01)=>Math.abs(e-o)<=t,ls=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=We(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,h=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=ce(M(l,s+h),M(d,p),a.angle),x=ce(M(l+u,s),M(d,p),a.angle),E=ce(M(c,s+h),M(d,p),a.angle),w=ce(M(l+u,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}else{let b=ce(M(l,s),M(d,p),a.angle),x=ce(M(c,s),M(d,p),a.angle),E=ce(M(l,m),M(d,p),a.angle),w=ce(M(c,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}}else if(e.length>1){let[a,l,s,c]=bc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=M(a,l),u=M(s,l),h=M(a,c),b=M(s,c),x=M(a+m/2,l+d/2);i=t?[p,u,h,b]:[p,u,h,b,x]}return i.map(a=>M(et(a[0]),et(a[1])))},zv=(e,o,t,r)=>{let n=o.filter(i=>ne(i)).map(i=>i.id);return Np(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},Fv=(e,o,t,r)=>{let n=zv(e,o,t,r),i=ti(n,r).filter(d=>!(d.length===1&&Be(d[0]))).map(d=>ye(d).map(p=>et(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>Nv)break e;let h=a[u],[,b,x,E]=p,[w,y,,v]=h;x<w&&ll(po(b,E),po(y,v))&&l.push({startBounds:p,endBounds:h,startSide:[M(x,b),M(x,E)],endSide:[M(w,y),M(w,v)],length:w-x,overlap:sl(po(b,E),po(y,v))})}}let c=i.sort((d,p)=>d[1]-p[1]),m=[];s=0;e:for(let d=0;d<c.length;d++){let p=c[d];for(let u=d+1;u<c.length;u++){if(++s>Nv)break e;let h=c[u],[b,,x,E]=p,[w,y,v]=h;E<y&&ll(po(b,x),po(w,v))&&m.push({startBounds:p,endBounds:h,startSide:[M(b,E),M(x,E)],endSide:[M(w,y),M(v,y)],length:y-E,overlap:sl(po(b,x),po(w,v))})}}return{horizontalGaps:l,verticalGaps:m}},Ov=(e,o,t,r,n,i,a)=>{if(!Vr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Ro.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=bc(e,o).map(x=>et(x)),h=(m+p)/2,b=(d+u)/2;for(let x of s){if(!ll(po(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,w=et(E-h);if(x.length>p-m&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let P={type:"gap",direction:"center_horizontal",gap:x,offset:w};n.push(P);continue}let[,,v]=x.endBounds,C=m-v,S=et(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[_,,,]=x.startBounds,L=_-p,N=et(L-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let P={type:"gap",direction:"side_left",gap:x,offset:N};n.push(P);continue}}for(let x of c){if(!ll(po(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,w=et(E-b);if(x.length>u-d&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let P={type:"gap",direction:"center_vertical",gap:x,offset:w};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=et(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,_]=x.endBounds,L=et(d-_),N=x.length-L;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let P={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(P);continue}}}},Hv=(e,o,t,r)=>{let n=zv(e,o,t,r);return ti(n,r).filter(i=>!(i.length===1&&Be(i[0]))).flatMap(i=>ls(i,r))},za=(e,o,t,r,n,i,a)=>{if(!Vr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Ro.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],d=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:d}),a.y=Math.abs(d))}},Uv=(e,o,t,r,n)=>{let i=t.state,a=J(e,i);if(!Vr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=et(o.x),o.y=et(o.y);let l=[],s=[],c=dm(i.zoom.value),m={x:c,y:c},d=ls(a,n,{dragOffset:o});za(a,d,t,r,l,s,m),Ov(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:et(o.x+p.x),y:et(o.y+p.y)};za(a,ls(a,n,{dragOffset:u}),t,r,l,s,m),Ov(a,u,t,r,l,s,m);let h=ug(l,s),b=yS(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...h,...b]}},et=e=>Math.round(e*10**6)/10**6,Bv=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ug=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=et(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=et(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:Bv(i.map(a=>M(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:Bv(i.map(a=>M(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},ES=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[et(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},yS=(e,o,t)=>{let[r,n,i,a]=bc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,h,b,x]=s.gap.endBounds,E=sl(po(n,a),s.gap.overlap),w=sl(po(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(s.gap.startSide[0][0],y),M(r,y)]},{type:"gap",direction:"horizontal",points:[M(i,y),M(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,s.gap.startSide[0][1]),M(y,n)]},{type:"gap",direction:"vertical",points:[M(y,a),M(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]},{type:"gap",direction:"horizontal",points:[M(b,y),M(r,y)]})}break}case"side_left":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(i,y),M(c,y)]},{type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,a),M(y,m)]},{type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,p),M(y,h)]},{type:"gap",direction:"vertical",points:[M(y,x),M(y,n)]})}break}}}return ES(l.map(s=>({...s,points:s.points.map(c=>M(et(c[0]),et(c[1])))})))},hg=(e,o,t,r,n,i)=>{if(!Vr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!xS(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=ye(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let m=[];if(i)switch(i){case"e":{m.push(M(s,l),M(s,c));break}case"w":{m.push(M(a,l),M(a,c));break}case"n":{m.push(M(a,l),M(s,l));break}case"s":{m.push(M(a,c),M(s,c));break}case"ne":{m.push(M(s,l));break}case"nw":{m.push(M(a,l));break}case"se":{m.push(M(s,c));break}case"sw":{m.push(M(a,c));break}}let d=dm(t.state.zoom.value),p={x:d,y:d},u=[],h=[];za(o,m,t,r,u,h,p);let b={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[x,E,w,y]=ye(e).map(S=>et(S)),v=[M(x,E),M(x,y),M(w,E),M(w,y)];za(e,v,t,r,u,h,p);let C=ug(u,h);return{snapOffset:b,snapLines:C}},Gv=(e,o,t,r,n,i)=>{if(!Vr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[M(r.x+n.x,r.y+n.y)],l=dm(o.state.zoom.value),s={x:l,y:l},c=[],m=[];za([e],a,o,t,c,m,s);let d={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let p=ls([e],i,{boundingBoxCorners:!0,omitCenter:!0});za([e],p,o,t,c,m,s);let u=ug(c,m);return{snapOffset:d,snapLines:u}},Vv=(e,o,t,r,n)=>{if(!Vr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Np(e,[],o.state,n),a=dm(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=ls([m],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,M(p[0],t.y)],direction:"vertical"}),l.x=u);let h=p[1]-t.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,M(t.x,p[1])],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Yv=e=>e===it.rectangle||e===it.ellipse||e===it.diamond||e===it.frame||e===it.magicframe||e===it.image||e===it.text;var mm={width:100,height:0},kn=100,vS=(e,o,t)=>{let r=Vt({x:0,y:0,textAlign:rl.CENTER,verticalAlign:Qt.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Qe(r,e,t),[e,r]},Wv=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??kn,d=o?.height??kn,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,h=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Vt({x:u,y:h,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Gt({x:u,y:h,width:m,height:d,...p,...o,type:b});break}default:Kn(e,`Unhandled element start type "${o.type}"`,!0)}Yo(e,i,"start",n)}}if(t){let m=t?.height??kn,d=t?.width??kn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,h=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Vt({x:u,y:h,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Gt({x:u,y:h,width:d,height:m,...p,...t,type:b});break}default:Kn(e,`Unhandled element end type "${b}"`,!0)}Yo(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=oo(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,j.getNormalizedPoints({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},gg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>Pr(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>sn(re(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Fa=(e,o)=>{if(!e)return[];let t=oo(e),r=new gg,n=new Map,i=new Map;for(let l of t){let s,c=l.id;switch(o?.regenerateIds!==!1&&Object.assign(l,{id:ro()}),l.type){case"rectangle":case"ellipse":case"diamond":{let d=l?.label?.text&&l.width===void 0?0:l?.width||kn,p=l?.label?.text&&l.height===void 0?0:l?.height||kn;s=Gt({...l,width:d,height:p});break}case"line":{let d=l.width||mm.width,p=l.height||mm.height;s=sr({width:d,height:p,points:[M(0,0),M(d,p)],...l});break}case"arrow":{let d=l.width||mm.width,p=l.height||mm.height;s=ji({width:d,height:p,endArrowhead:"arrow",points:[M(0,0),M(d,p)],...l,type:"arrow"}),Object.assign(s,f1(s.points));break}case"text":{let d=l?.fontFamily||jr,p=l?.fontSize||Cr,u=l?.lineHeight||Sr(d),h=l.text??"",b=jn(h),x=Ht(b,qe({fontFamily:d,fontSize:p}),u);s=Vt({width:x.width,height:x.height,fontFamily:d,fontSize:p,...l});break}case"image":{s=xc({width:l?.width||kn,height:l?.height||kn,...l});break}case"frame":{s=$i({x:0,y:0,...l});break}case"magicframe":{s=wl({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Kn(l,`Unhandled element type "${l.type}"`,!0)}r.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(r.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=r.getElementsMap();for(let[l,s]of n){let c=r.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[m,d]=vS(c,s?.label,a);if(r.add(m),r.add(d),Re(m)){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let E=i.get(p.id);E&&Object.assign(p,{id:E})}if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}let{linearElement:h,startBoundElement:b,endBoundElement:x}=Wv(m,p,u,r,a);m=h,r.add(h),r.add(b),r.add(x)}}else switch(s.type){case"arrow":{let{start:m,end:d}=s;if(m&&m.id){let b=i.get(m.id);Object.assign(m,{id:b})}if(d&&d.id){let b=i.get(d.id);Object.assign(d,{id:b})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=Wv(c,m,d,r,a);r.add(p),r.add(u),r.add(h);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=r.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let m=[];s.children.forEach(v=>{let C=i.get(v);if(!C)throw new Error(`Element with ${v} wasn't mapped correctly`);let S=r.getElement(C);if(!S)throw new Error(`Frame element with id ${C} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(_=>{let L=r.getElement(_.id);if(!L)throw new Error(`Bound element with id ${_.id} doesn't exist`);Object.assign(L,{frameId:c.id}),m.push(L)}),m.push(S)});let[d,p,u,h]=ye(m),b=10;d=d-b,p=p-b,u=u+b,h=h+b;let x=c?.x||d,E=c?.y||p,w=c?.width||u-d,y=c?.height||h-p;Object.assign(c,{x,y:E,width:w,height:y}),He()&&s.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import pm from"open-color";var wS="#ff6b6b",TS="#ff0000",Kv=1,Zv=2,Xv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===de.LIGHT||o.zenModeEnabled?wS:TS,r=(o.zenModeEnabled?Kv*1.5:Kv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,IS(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,SS(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,CS(n,e,o));e.restore()},CS=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];No(r,n,o)}for(let r of e.points)$v(r,t,o)},IS=(e,o,t)=>{$v(e.points[0],t,o),t.zenModeEnabled||No(e.points[0],e.points[1],o)},$v=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?Zv*1.5:Zv)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},No=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},SS=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||No(M(e[0],e[1]-i),M(e[0],e[1]+i),n),No(M(s[0]-l,s[1]-a),M(s[0]-l,s[1]+a),n),No(M(s[0]+l,s[1]-a),M(s[0]+l,s[1]+a),n),r.zenModeEnabled||(No(M(o[0],o[1]-i),M(o[0],o[1]+i),n),No(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||No(M(e[0]-i,e[1]),M(e[0]+i,e[1]),n),No(M(s[0]-a,s[1]-l),M(s[0]+a,s[1]-l),n),No(M(s[0]-a,s[1]+l),M(s[0]+a,s[1]+l),n),r.zenModeEnabled||(No(M(o[0]-i,o[1]),M(o[0]+i,o[1]),n),No(e,o,n))}};var qo=4,xr=6,jv="rgba(0,0,0,0.3)",qv=(e,o,t,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=ye(e),s=o/r.zoom.value,c=t/r.zoom.value,m=o-s,d=t-c,p={top:parseInt(cl("sat"))||0,bottom:parseInt(cl("sab"))||0,left:parseInt(cl("sal"))||0,right:parseInt(cl("sar"))||0},u=Or().rtl,h=-r.scrollX+m/2+p.left,b=-r.scrollY+d/2+p.top,x=h+s-p.right,E=b+c-p.bottom,w=Math.min(n,h),y=Math.min(i,b),v=Math.max(a,x),C=Math.max(l,E);return{horizontal:h===w&&x===v?null:{x:Math.max(p.left,qo)+(h-w)/(v-w)*o,y:t-xr-Math.max(qo,p.bottom),width:(x-h)/(v-w)*o-Math.max(qo*2,p.left+p.right),height:xr},vertical:b===y&&E===C?null:{x:u?Math.max(p.left,qo):o-xr-Math.max(p.right,qo),y:(b-y)/(C-y)*t+Math.max(p.top,qo),width:xr,height:(E-b)/(C-y)*t-Math.max(qo*2,p.top+p.bottom)}}},fg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var kS=(e,o)=>{ln(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;ln(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Qv(t,e,o),e.restore()},MS=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=j.getElement(r,t);if(!i)return;let a=j.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Qv(a,e,o),e.restore()},Qv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Cl(o,e[0],e[1],j.POINT_HANDLE_SIZE/t.zoom.value,!1)},ss=(e,o,t,r,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(o-i,t-a,r,n),c&&e.roundRect?(e.beginPath(),e.roundRect(o-i,t-a,r,n,c),e.stroke(),e.closePath()):e.strokeRect(o-i,t-a,r,n),e.restore()},LS=(e,o,t,r,n,i)=>{e.save(),e.translate(r,n),e.rotate(i),e.beginPath(),e.moveTo(0,t/2),e.lineTo(o/2,0),e.lineTo(0,-t/2),e.lineTo(-o/2,0),e.closePath(),e.stroke(),e.restore()},bg=(e,o,t,r,n,i=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Cl(e,t[0],t[1],r/o.zoom.value,!i)},AS=(e,o,t,r,n,i)=>{e.beginPath(),e.ellipse(r,n,o/2,t/2,i,0,Math.PI*2),e.stroke()},_S=(e,o,t,r)=>{let[n,i,a,l]=We(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)";let m=r.value<1?r.value:1;e.lineWidth=nb/m;let d=e.lineWidth/2+ib,p=fc(Math.min(o.width,o.height),o);switch(o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":ss(e,n-d,i-d,s+d*2,c+d*2,n+s/2,i+c/2,o.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,c),h=d*u/c,b=d*u/s;LS(e,s+h*2,c+b*2,n+s/2,i+c/2,o.angle);break;case"ellipse":AS(e,s+d*2,c+d*2,n+s/2,i+c/2,o.angle);break}},DS=(e,o,t,r)=>{let[n,i,a]=o,l=cb(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[m,d]=j.getPointAtIndexGlobalCoordinates(n,c,t);Cl(e,m,d,l)})},ew=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=t,u=a-n,h=l-i,x=(t.padding??qr*2)/o.zoom.value,E=8/o.zoom.value,w=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([E,w+(E+w)*(y-1)]),e.lineDashOffset=(E+w)*v,ss(e,n-x,i-x,u+x*2,h+x*2,c,m,r);e.restore()},PS=(e,o,t,r)=>{let n=Array.isArray(t)?DS:_S;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},RS=(e,o,t,r)=>{let[n,i,a,l]=We(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Go.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ss(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Go.radius/o.zoom.value),e.restore()},NS=(e,o,t)=>{let r=t.filter(l=>l.groupIds.length===0),n=t.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,m,d]=ye(l);return{angle:0,x1:s,x2:m,y1:c,y2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(m-s)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},a=l=>{let s=Ge(t,l);return i(s)};Object.entries(Sb(n,o)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>ew(e,o,l))},xg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=j.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=j,a=o.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(ee(t)&&s!==0&&s!==n.length-1)return;let c=!!o.editingLinearElement?.selectedPointsIndices?.includes(s);bg(e,o,l,a,c)}),ee(t)){let l=t.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{j.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||bg(e,o,M((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else j.getEditorMidPoints(t,r,o).filter((s,c,m)=>s!==null&&!(ee(t)&&(c===0||c===m.length-1))).forEach(s=>{(o.editingLinearElement||n.length===2)&&bg(e,o,s,i/2,!1,!0)});e.restore()},Jv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Cl(e,l+c/2,s+m/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):ss(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},OS=(e,o,t,r,n)=>{let[i,a,,,l,s]=We(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,h=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,h);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-h],[0,p],[b,p],[p,0],[p,x]],[[u-p,-h],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,h],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,h],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[C,S],[_,L],[N,P],[F,K]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+_,v+L),e.stroke(),e.beginPath(),e.moveTo(y+N,v+P),e.lineTo(y+F,v+K),e.stroke(),e.restore()}),e.restore()},BS=(e,o,t,r)=>{o.save();let n=qr*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,m,i,a),o.restore()},tw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[c,m]=Ic(e,i),d=Sc({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:m});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.editingLinearElement?.elementId===b.id&&b&&(p=b)}),p&&xg(d,a,p,o),a.selectionElement&&!a.isCropping)try{Hb(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Z(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&BS(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{PS(d,a,b,o)}),a.frameToHighlight&&RS(d,a,a.frameToHighlight,o),a.elementsToHighlight&&NS(d,a,a.elementsToHighlight);let u=r.some(b=>ne(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&xg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?kS(d,a):(ee(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&MS(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=Rc(r,a),x=r.length===1&&ae(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&xg(d,a,r[0],o);let E=l.selectionColor||pm.black;if(b){let w=re(r),y=[];for(let C of o.values()){let S=[],_=l.remoteSelectedElementIds.get(C.id);if(x&&ee(C)&&(C.startBinding||C.endBinding)||(w.has(C.id)&&!hc(a,C)&&S.push(E),_&&S.push(..._.map(L=>wi(L,a.collaborators.get(L))))),S.length){let[L,N,P,F,K,U]=We(C,o,!0);y.push({angle:C.angle,x1:L,y1:N,x2:P,y2:F,selectionColors:S,dashed:!!_,cx:K,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||he(C)?0:void 0})}}let v=C=>{let S=Ge(o,C),[_,L,N,P]=ye(S);y.push({angle:0,x1:_,x2:N,y1:L,y2:P,selectionColors:[pm.black],dashed:!0,cx:_+(N-_)/2,cy:L+(P-L)/2,activeEmbeddable:!1})};for(let C of Wo(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>ew(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=pm.white;let w=Pc(r[0],a.zoom,o,"mouse",si(s));if(!a.viewModeEnabled&&b&&!Z(a.editingTextElement)&&!a.croppingElementId&&Jv(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&he(y)&&OS(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating){let w=qr*2/a.zoom.value;d.fillStyle=pm.white;let[y,v,C,S]=ye(r,o),_=d.getLineDash();d.setLineDash([2/a.zoom.value]);let L=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,ss(d,y-w,v-w,C-y+w*2,S-v+w*2,(y+C)/2,(v+S)/2,0),d.lineWidth=L,d.setLineDash(_);let N=kl([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...si(s),rotation:!0}:si(s));r.some(P=>!P.locked)&&Jv(d,l,a,N,0)}d.restore()}a.searchMatches.forEach(({id:b,focus:x,matchedLines:E})=>{let w=o.get(b);if(w&&Z(w)){let[y,v,,,C,S]=We(w,o,!0);d.save(),a.theme===de.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)",d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(w.angle),E.forEach(_=>{d.fillRect(y+_.offsetX-C,v+_.offsetY-S,_.width,_.height)}),d.restore()}}),Xv(d,a),d.restore(),r2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let h;return l.renderScrollbars&&(h=qv(t,c,m,a),d.save(),d.fillStyle=jv,d.strokeStyle="rgba(255,255,255,0.8)",[h.horizontal,h.vertical].forEach(b=>{b&&Pd(d,b.x,b.y,b.width,b.height,xr/2)}),d.restore()),{scrollBars:h,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Eg=Pi(e=>{let o=tw(e);e.callback?.(o)},{trailing:!0}),ow=(e,o)=>{if(o){Eg(e);return}let t=tw(e);return e.callback(t),t};var cs=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())El(p,m,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i,pendingImageElementId:a})=>{let l=sn(new Map);for(let s of r)he(s)&&a===s.id||i!==s.id&&(!n||n.type!=="text"||s.id!==n.id)&&l.set(s.id,s);return l};return L1(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,pendingImageElementId:p,sceneNonce:u})=>{let h=this.scene.getNonDeletedElements(),b=t({elements:h,editingTextElement:m,newElementId:d,pendingImageElementId:p}),x=o({elementsMap:b,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:b,visibleElements:x}})})());this.scene=o}destroy(){Eg.cancel(),l0.cancel(),this.getRenderableElements.clear()}};import{jsx as HS}from"react/jsx-runtime";var zS=5,FS=(e,o,t)=>{let[r,n]=We(e,t),{x:i,y:a}=zt({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},yg=({children:e,element:o,elementsMap:t})=>{let r=pr();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=FS(o,r,t);return HS("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:zS},children:e})};import{LaserPointer as US}from"@excalidraw/laser-pointer";var Yr=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(cp,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(cp,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new US(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.pastTrails=[],this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=zt({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return A1(n,!0)}};var um=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Yr(o,t,{...this.getTrailOptions(),fill:()=>op})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(nr(i),nr(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new Yr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||wi(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as GS}from"react";import{unstable_batchedUpdates as rw}from"react-dom";var tt=e=>o=>{rw(e,o)},hm=e=>Pi(o=>{rw(e,o)}),Ha=(()=>{let e;try{let t=GS.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var VS=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},nw=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,G)=>{if(!G.style.fontFamily||!G.style.fontSize)return!1;let V=G.style.fontFamily.replace(/"/g,"");return Gn({fontFamily:H.fontFamily})!==V||`${H.fontSize}px`!==G.style.fontSize},m=()=>{let H=l.state,G=dn.getScene(n)?.getElement(e);if(!G)return;let{textAlign:V,verticalAlign:ie}=G,$=l.scene.getNonDeletedElementsMap();if(G&&Z(G)){let se=G.x,be=G.y,Te=_t(G,l.scene.getNonDeletedElementsMap()),ot=G.width,jt=G.height,Fo=G.width,er=G.height;if(Te&&G.containerId){if(Re(Te)){let $r=j.getBoundTextElementPosition(Te,G,$);se=$r.x,be=$r.y}let Ss=c(G,d),ja;if(Ss?ja=ul(Te.id,Te.height):(ja=K1[Te.id],ja||(ja=ul(Te.id,Te.height))),Fo=Gi(Te,G),er=ob(Te,G),!Re(Te)&&jt>er){let $r=Ui(jt,Te.type);B(Te,{height:$r});return}else if(!Re(Te)&&Te.height>ja.height&&jt<er){let $r=Ui(jt,Te.type);B(Te,{height:$r})}else{let{y:$r}=tc(Te,G,$);be=$r}}let[qt,tr]=r(se,be),Zr=d.selectionStart,Jt=d.selectionEnd,Xr=d.value.length;if(Zr===Jt&&Jt!==Xr){let Ss=Xr-Jt;d.selectionStart=d.value.length-Ss,d.selectionEnd=d.value.length-Ss}Te?ot+=.5:(Fo=(H.width-8-qt)/H.zoom.value,ot=Math.min(ot,Fo)),jt*=1.05;let mo=qe(G),Sf=(H.height-tr)/H.zoom.value;Object.assign(d.style,{font:mo,lineHeight:G.lineHeight,width:`${ot}px`,height:`${jt}px`,left:`${qt}px`,top:`${tr}px`,transform:VS(ot,jt,J1(G,Te),H,Fo,Sf),textAlign:V,verticalAlign:ie,color:G.strokeColor,opacity:G.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Sf}px`}),d.scrollTop=0,mt()&&(d.style.fontFamily=Gn(G)),B(G,{x:se,y:be})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(Be(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,m(),o&&(d.onpaste=async H=>{let G=await Ad(H,!0);if(!G.text)return;let V=jn(G.text);if(!V)return;let ie=_t(n,l.scene.getNonDeletedElementsMap()),$=qe({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ie){let se=ge(ie,l.scene.getNonDeletedElementsMap()),be=Hi(`${d.value}${V}`,$,Gi(ie,se)),Te=q1(be,$);d.style.width=`${Te}px`}},d.oninput=()=>{let H=jn(d.value);if(d.value!==H){let G=d.selectionStart;d.value=H,d.selectionStart=G,d.selectionEnd=G}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&Td.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Td),m();else if(!H.shiftKey&&Cd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Cd),m();else if(!H.shiftKey&&Id.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Id),m();else if(ph.keyTest(H))l.actionManager.executeAction(ph);else if(uh.keyTest(H))l.actionManager.executeAction(uh);else if(H.key===T.ESCAPE)H.preventDefault(),C=!0,S();else if(yi.keyTest(H))H.preventDefault(),S(),l.actionManager.executeAction(yi);else if(H.key===T.ENTER&&H[T.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;C=!0,S()}else if(H.key===T.TAB||H[T.CTRL_OR_CMD]&&(H.code===pe.BRACKET_LEFT||H.code===pe.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===pe.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let h=4,b=" ".repeat(h),x=new RegExp(`^ {1,${h}}`),E=()=>{let{selectionStart:H,selectionEnd:G}=d,V=y(),ie=d.value;V.forEach($=>{let se=ie.slice(0,$),be=ie.slice($);ie=`${se}${b}${be}`}),d.value=ie,d.selectionStart=H+h,d.selectionEnd=G+h*V.length},w=()=>{let{selectionStart:H,selectionEnd:G}=d,V=y(),ie=[],$=d.value;V.forEach(se=>{let be=$.slice(se,se+h).match(x);if(be){let Te=$.slice(0,se),ot=$.slice(se+be[0].length);$=`${Te}${ot}`,ie.push(se)}}),d.value=$,ie.length&&(H>ie[ie.length-1]?d.selectionStart=Math.max(H-h,ie[ie.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,G-h*ie.length))},y=()=>{let{selectionStart:H,selectionEnd:G,value:V}=d,ie=V.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-ie,V.slice(H,G).split(`
8
+ `).reduce((se,be,Te,ot)=>se.concat(Te?se[Te-1]+ot[Te-1].length+1:H),[]).reverse()},v=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,_();let H=dn.getScene(n)?.getElement(n.id);if(!H)return;let G=_t(H,l.scene.getNonDeletedElementsMap());if(G){if(d.value.trim()){let V=Dr(G);!V||V!==n.id?B(G,{boundElements:(G.boundElements||[]).concat({type:"text",id:n.id})}):Re(G)&&xl(G)}else B(G,{boundElements:G.boundElements?.filter(V=>!Z(V))});Qe(H,G,l.scene.getNonDeletedElementsMap())}t({viaKeyboard:C,nextOriginalText:d.value})},_=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",L),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),F(),K(),d.remove()},L=H=>{window.removeEventListener("pointerup",L);let G=H?.target,V=G instanceof HTMLElement&&G.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,V||d.focus()})},N=()=>{d.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",S)},P=H=>{let G=H?.target;if(H.button===or.WHEEL){G instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),N();return}let V=G instanceof HTMLElement&&G.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Uo.SHAPE_ACTIONS_MENU}, .${Uo.ZOOM_ACTIONS}`)&&!rr(H.target)||V?N():H.target instanceof HTMLCanvasElement&&!mt()&&requestAnimationFrame(()=>{S()})},F=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),K=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&d.select(),L();let q=null;i&&"ResizeObserver"in window?(q=new window.ResizeObserver(()=>{m()}),q.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};var iw=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{simplify as YS}from"points-on-curve";var aw=e=>{let{lassoPath:o,elements:t,elementsSegments:r,intersectedElements:n,enclosedElements:i,simplifyDistance:a}=e,l=o;a&&(l=YS(o,a)),i.clear();for(let c of t)!n.has(c.id)&&!i.has(c.id)&&(WS(l,c,r)?i.add(c.id):KS(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},WS=(e,o,t)=>{let r=h1(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>g1(a,r))):!1},KS=(e,o,t)=>{let r=t.get(o.id);return r?e.reduce((i,a,l)=>(l===0||i.push(p1(e[l-1],a)),i),[]).some(i=>r.some(a=>u1(i,a,1)!==null)):!1};var gm=class extends Yr{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(nr(s),nr(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&Z(c)){let m=_t(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&ne(c)){let m=ko(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=lt({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&ae(this.app.scene.getNonDeletedElement(a[0]))?new j(this.app.scene.getNonDeletedElement(a[0])):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>M(r[0],r[1]));if(!this.elementsSegments){this.elementsSegments=new Map;let r=re(this.app.visibleElements);for(let n of this.app.visibleElements){let i=Gb(n,r);this.elementsSegments.set(n.id,i)}}if(t){let{selectedElementIds:r}=aw({lassoPath:t,elements:this.app.visibleElements,elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{jsx as Oo,jsxs as lw}from"react/jsx-runtime";var ZS=()=>lw("div",{"data-testid":"brave-measure-text-error",children:[Oo("p",{children:Oo(Kt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Oo("span",{style:{fontWeight:600},children:e})})}),Oo("p",{children:Oo(Kt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Oo("span",{style:{fontWeight:600},children:e})})}),Oo("p",{children:Oo(Kt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Oo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Oo("p",{children:Oo(Kt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Oo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>lw("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),sw=ZS;import qS from"clsx";import JS from"react";import{useLayoutEffect as XS,useRef as cw,useEffect as dw}from"react";import{unstable_batchedUpdates as $S}from"react-dom";import{jsx as jS}from"react/jsx-runtime";var mw=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=cw(null);dw(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===T.TAB){let h=dl(d),{activeElement:b}=document,x=h.findIndex(E=>E===b);b===d?(u.shiftKey?h[h.length-1]?.focus():h[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(h[h.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===h.length-1&&!u.shiftKey&&(h[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=cw(null);return XS(()=>{if(n&&c.current&&t!=null&&o!=null){let d=c.current,{width:p,height:u}=d.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),dw(()=>{if(r){let d=p=>{c.current?.contains(p.target)||$S(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),jS("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Ua,jsxs as QS}from"react/jsx-runtime";var ft="separator",pw=JS.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=pr(),a=xn(),l=o.reduce((s,c)=>(c&&(c===ft||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Ua(mw,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Ua("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===ft)return!l[c-1]||l[c-1]===ft?null:Ua("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=f(s.label(a,i,e.app)):d=f(s.label)),Ua("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:QS("button",{type:"button",className:qS("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ua("div",{className:"context-menu-item__label",children:d}),Ua("kbd",{className:"context-menu-item__shortcut",children:m?ct(m):""})]})},c)})})})});import{jsx as vg,jsxs as uw}from"react/jsx-runtime";var ek=({height:e,width:o,userToFollow:t,onDisconnect:r})=>vg("div",{className:"follow-mode",style:{width:o,height:e},children:uw("div",{className:"follow-mode__badge",children:[uw("div",{className:"follow-mode__badge__label",children:["Following"," ",vg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),vg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Mo})]})}),hw=ek;import Es from"clsx";import l8 from"react";import tk from"clsx";import{useState as ok,useEffect as rk}from"react";import{jsx as wg,jsxs as nk}from"react/jsx-runtime";var fm=({delay:e,theme:o})=>{let[t,r]=ok(!!e);return rk(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:nk("div",{className:tk("LoadingMessage",{"LoadingMessage--dark":o===de.DARK}),children:[wg("div",{children:wg(Mt,{})}),wg("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import ik from"clsx";import{jsx as fw,jsxs as lk}from"react/jsx-runtime";var ak="medium",gw={CHECKED:aa,UNCHECKED:mi},bm=e=>lk("label",{className:ik("ToolIcon ToolIcon__lock",`ToolIcon_size_${ak}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[fw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),fw("div",{className:"ToolIcon__icon",children:e.checked?gw.CHECKED:gw.UNCHECKED})]});import sk from"clsx";import{jsx as ck}from"react/jsx-runtime";var xm=({children:e,side:o,className:t})=>ck("div",{className:sk("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import dk from"clsx";import{jsx as mk}from"react/jsx-runtime";var Em=e=>mk(Q,{className:dk("Shape",{fillable:!1}),type:"radio",icon:Jc,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as bw}from"react/jsx-runtime";var pk=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===At.name&&e.openSidebar.tab===Ir&&e.searchMatches?.length)return f("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(no(e))return f("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?f("hints.linearElementMulti"):n.type==="arrow"?f("hints.arrowTool",{arrowShortcut:R("A")}):f("hints.linearElement");if(n.type==="freedraw")return f("hints.freeDraw");if(n.type==="text")return f("hints.text");if(n.type==="embeddable")return f("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return f("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return ae(m)&&m.points.length===2?f("hints.lockAngle"):he(m)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&Z(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&he(c[0]))return f("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[f("hints.deepBoxSelect")];if(Sn(r)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!o)return[f("hints.canvasPanning")];if(c.length===1){if(ae(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&_r(c[0]))return $n(c[0])?L0(c[0],r.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},ym=({appState:e,isMobile:o,device:t,app:r})=>{let n=pk({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>R(a).replace(/\. ?$/,"")).join(". "):R(n);return bw("div",{className:"HintViewer",children:bw("span",{children:i})})};import uk from"clsx";import{jsx as xw,jsxs as gk}from"react/jsx-runtime";var hk="medium",vm=e=>e.penDetected?gk("label",{className:uk("ToolIcon ToolIcon__penMode",`ToolIcon_size_${hk}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[xw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),xw("div",{className:"ToolIcon__icon",children:tx})]}):null;import{Fragment as fk,jsx as Ew,jsxs as bk}from"react/jsx-runtime";var Mn=({heading:e,children:o,...t})=>{let{id:r}=ht(),n=Ew("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:f(`headings.${e}`)});return Ew("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):bk(fk,{children:[n,o]})})};import{Fragment as xk,jsx as Lt,jsxs as Wr}from"react/jsx-runtime";var yw=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:m,renderWelcomeScreen:d,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ke(),E=()=>Wr(xm,{side:"top",className:"App-top-bar",children:[d&&Lt(h.Out,{}),Lt(Mn,{heading:"shapes",children:y=>Lt(Ct.Col,{gap:4,align:"center",children:Wr(Ct.Row,{gap:1,className:"App-toolbar-container",children:[Wr(Et,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Lt(Ct.Row,{gap:1,children:Lt(nm,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Wr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Lt(x.Out,{}),Lt(vm,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Lt(bm,{checked:e.activeTool.locked,onChange:n,title:f("toolBar.lock"),isMobile:!0}),Lt(Em,{checked:Ko(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]})]})})}),Lt(ym,{appState:e,isMobile:!0,device:m,app:u})]}),w=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Lt("div",{className:"App-toolbar-content",children:Lt(b.Out,{})}):Wr("div",{className:"App-toolbar-content",children:[Lt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Wr("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Wr(xk,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Lt("div",{className:"App-bottom-bar",style:{marginBottom:xr+qo*2,marginLeft:xr+qo*2,marginRight:xr+qo*2},children:Wr(Et,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Ta(e,o)?Lt(Mn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Lt(rm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Wr("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Lt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...ai(o,y)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import Ek from"open-color";import yk,{useLayoutEffect as vk,useRef as wk,useState as Tk}from"react";import{jsx as ds,jsxs as Ck}from"react/jsx-runtime";var vw=e=>{let o=wk(null),[t,r]=Tk(null);return vk(()=>{if(!e.spreadsheet)return;let n=Ky(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await ea(n,{exportBackground:!1,viewBackgroundColor:Ek.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),ds("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:ds("div",{ref:o})})},ww=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=st(),n=yk.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),xe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return ds(dt,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:Ck("div",{className:"container",children:[ds(vw,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),ds(vw,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Ln from"@radix-ui/react-popover";import Tw from"clsx";import wm,{useLayoutEffect as Ik}from"react";import{Fragment as Ak,jsx as Er,jsxs as Tm}from"react/jsx-runtime";var Sk=4,kk=8,Mk=({shouldWrap:e,children:o,username:t})=>e?Er(bo,{label:t||"Unknown user",children:o}):Er(Ak,{children:o}),Tg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Er(Mk,{username:o.username,shouldWrap:n,children:l},t)},Lk=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Cm=wm.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=gt(),i=new Map;t.forEach((b,x)=>{let E=b.id||x;i.set(E,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=wm.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=wm.useRef(null);Ik(()=>{if(m.current){let b=E=>{let w=Math.max(1,Math.min(8,Math.floor(E/38)));p(w)};if(b(m.current.clientWidth),!qa)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=wm.useState(Sk),h=a.slice(0,d-1).map(b=>Tg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?Er("div",{className:Tw("UserList UserList_mobile",e),children:a.map(b=>Tg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):Er("div",{className:"UserList__wrapper",ref:m,children:Tm("div",{className:Tw("UserList",e),style:{"--max-avatars":d},children:[h,a.length>d-1&&Tm(Ln.Root,{children:[Tm(Ln.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Er(Ln.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Tm(Et,{padding:2,children:[a.length>=kk&&Er(hd,{placeholder:f("quickSearch.placeholder"),onChange:s}),Er(gd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[Er("div",{className:"hint",children:f("userList.hint.text")}),c.map(b=>Tg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),Er(Ln.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!Je(n,i,Lk))return!1}return!0});import Im from"clsx";import{jsx as _k}from"react/jsx-runtime";var Cw=e=>_k("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:la});import{jsx as yr,jsxs as Cg}from"react/jsx-runtime";var Iw=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ke(),a=Ce(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return Cg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[yr("div",{className:Im("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:yr(Ct.Col,{gap:2,children:Cg(Mn,{heading:"canvasActions",children:[yr(bv,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&yr(xv,{renderAction:o.renderAction,className:Im("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&yr(yv,{renderAction:o.renderAction,className:Im("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),yr(n.Out,{}),yr("div",{className:Im("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Cg("div",{style:{position:"relative"},children:[r&&yr(i.Out,{}),yr(Cw,{onClick:()=>o.executeAction(vi)})]})}),yr(Ev,{actionManager:o,showExitZenModeBtn:t})]})},Sw=Iw;Iw.displayName="Footer";import Fk from"clsx";import{useEffect as Ow,useLayoutEffect as Bw,useRef as Pg,useState as Hk,forwardRef as zw,useImperativeHandle as Uk,useCallback as Rw}from"react";import Pk from"clsx";import{useContext as Rk}from"react";import Dk from"react";var Sm=Dk.createContext({});import{jsx as Ig,jsxs as kw}from"react/jsx-runtime";var Sg=({children:e,className:o})=>{let t=Ce(),r=Rk(Sm),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return kw("div",{className:Pk("sidebar__header",o),"data-testid":"sidebar-header",children:[e,kw("div",{className:"sidebar__header__buttons",children:[n&&Ig(bo,{label:f("labels.sidebarLock"),children:Ig(vo,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:W0})}),Ig(vo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":f("buttons.close"),children:Mo})]})]})};Sg.displayName="SidebarHeader";import*as Lw from"@radix-ui/react-tabs";import{jsx as Mw}from"react/jsx-runtime";var kg=({children:e,tab:o,onSelect:t,...r})=>Mw(Lw.Trigger,{value:o,asChild:!0,onSelect:t,children:Mw("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});kg.displayName="SidebarTabTrigger";import*as Aw from"@radix-ui/react-tabs";import{jsx as Nk}from"react/jsx-runtime";var Mg=({children:e,...o})=>Nk(Aw.List,{className:"sidebar-triggers",...o,children:e});Mg.displayName="SidebarTabTriggers";import Ok from"clsx";import{jsx as Lg,jsxs as _w}from"react/jsx-runtime";var Ag=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=Ie(),c=De();return _w("label",{title:r,className:"sidebar-trigger__label-element",children:[Lg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=m.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),_w("div",{className:Ok("sidebar-trigger",a),style:l,children:[t&&Lg("div",{children:t}),n&&Lg("div",{className:"sidebar-trigger__label",children:n})]})]})};Ag.displayName="SidebarTrigger";import*as Dw from"@radix-ui/react-tabs";import{jsx as Bk}from"react/jsx-runtime";var _g=({children:e,...o})=>{let t=De(),r=Ie();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Bk(Dw.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};_g.displayName="SidebarTabs";import*as Pw from"@radix-ui/react-tabs";import{jsx as zk}from"react/jsx-runtime";var Dg=({tab:e,children:o,...t})=>zk(Pw.Content,{...t,value:e,"data-testid":e,children:o});Dg.displayName="SidebarTab";import{jsx as Nw}from"react/jsx-runtime";import{createElement as Gk}from"react";var ms=Ae(!1),Fw=zw(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{He()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=Ie(),s=hn(ms);Bw(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Pg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Ri(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=Pg(null);Uk(a,()=>m.current);let d=Ce(),p=Rw(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return pa(m,Rw(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),Ow(()=>{let u=h=>{h.key===T.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),Nw(Et,{...i,className:Fk("sidebar",{"sidebar--docked":r},n),ref:m,children:Nw(Sm.Provider,{value:c.current,children:o})})});Fw.displayName="SidebarInner";var Bo=Object.assign(zw((e,o)=>{let t=De(),{onStateChange:r}=e,n=Pg(t.openSidebar);Ow(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=Hk(!1);return Bw(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?Gk(Fw,{...e,ref:o,key:e.name}):null}),{Header:Sg,TabTriggers:Mg,TabTrigger:kg,Tabs:_g,Tab:Dg,Trigger:Ag});Bo.displayName="Sidebar";import{useLayoutEffect as Vk,useRef as Yk}from"react";import{jsx as Wk}from"react/jsx-runtime";var Kr=(e,o)=>{let t=Ae(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ke(),[,a]=i(t),l=Yk({preferHost:!1,counter:0});return Vk(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:Wk(o,{...n})};return r.displayName=e,r};var Og={};Mf(Og,{ChangeCanvasBackground:()=>Qw,ClearCanvas:()=>qw,CommandPalette:()=>Xw,Export:()=>e3,Help:()=>jw,LiveCollaborationTrigger:()=>o3,LoadScene:()=>Ww,SaveAsImage:()=>Zw,SaveToActiveFile:()=>Kw,SearchMenu:()=>$w,Socials:()=>t3,ToggleTheme:()=>Jw});import $k from"clsx";var Rg=Ae({active:!1});async function Hw({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{St.set(Rg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import Kk from"clsx";import{jsx as Uw,jsxs as Zk}from"react/jsx-runtime";var km=function({onChange:e,value:o,choices:t,name:r}){return Uw("div",{className:"RadioGroup",children:t.map(n=>Zk("div",{className:Kk("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[Uw("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as Xk,jsx as Ng,jsxs as Gw}from"react/jsx-runtime";var Vw=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=Ce();return Gw(Xk,{children:[Gw("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Ng("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Ng(km,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Ng("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};Vw.displayName="DropdownMenuItemContentRadio";var Yw=Vw;import{Fragment as jk,jsx as vt,jsxs as r3}from"react/jsx-runtime";var Ww=()=>{let{t:e}=pt(),o=gt(),t=xn();return o.isActionEnabled(wa)?vt(Yt,{icon:sa,onSelect:async()=>{(!t.length||await Hw({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:vt(Kt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>vt("strong",{children:n}),br:()=>vt("br",{})})}))&&o.executeAction(wa)},"data-testid":"load-button",shortcut:ct("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};Ww.displayName="LoadScene";var Kw=()=>{let{t:e}=pt(),o=gt();return o.isActionEnabled(yi)?vt(Yt,{shortcut:ct("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(yi),icon:cx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Kw.displayName="SaveToActiveFile";var Zw=()=>{let e=Ie(),{t:o}=pt();return vt(Yt,{icon:Xc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ct("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Zw.displayName="SaveAsImage";var Xw=e=>{let o=Ie(),{t}=pt();return vt(Yt,{icon:td,"data-testid":"command-palette-button",onSelect:()=>{xe("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:ct("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Xw.displayName="CommandPalette";var $w=e=>{let{t:o}=pt(),t=gt();return vt(Yt,{icon:go,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(is)},shortcut:ct("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};$w.displayName="SearchMenu";var jw=()=>{let{t:e}=pt(),o=gt();return vt(Yt,{"data-testid":"help-menu-item",icon:la,onSelect:()=>o.executeAction(vi),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};jw.displayName="Help";var qw=()=>{let{t:e}=pt(),o=hn(Ci);return gt().isActionEnabled(zr)?vt(Yt,{icon:ho,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};qw.displayName="ClearCanvas";var Jw=e=>{let{t:o}=pt(),t=De(),r=gt(),n=ct("toggleTheme");return r.isActionEnabled(fi)?e?.allowSystemTheme?vt(Yw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:de.LIGHT,label:Rl,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:de.DARK,label:Pl,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:CE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):vt(Yt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===de.DARK?de.LIGHT:de.DARK);else return r.executeAction(fi)},icon:t.theme===de.DARK?Rl:Pl,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};Jw.displayName="ToggleTheme";var Qw=()=>{let{t:e}=pt(),o=De(),t=gt(),r=ur();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:r3("div",{style:{marginTop:"0.5rem"},children:[vt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),vt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};Qw.displayName="ChangeCanvasBackground";var e3=()=>{let{t:e}=pt(),o=Ie();return vt(Yt,{icon:pi,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};e3.displayName="Export";var t3=()=>{let{t:e}=pt();return r3(jk,{children:[vt(Ra,{icon:Kc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),vt(Ra,{icon:lx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),vt(Ra,{icon:ax,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};t3.displayName="Socials";var o3=({onSelect:e,isCollaborating:o})=>{let{t}=pt();return vt(Yt,{"data-testid":"collab-button",icon:$c,className:$k({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};o3.displayName="LiveCollaborationTrigger";import{jsx as Mm,jsxs as Bg}from"react/jsx-runtime";var qk=Object.assign(Kr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ke(),r=Ce(),n=De(),i=Ie(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Mm(t.In,{children:Bg(Pe,{open:n.openMenu==="canvas",children:[Mm(Pe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Wc}),Bg(Pe.Content,{onClickOutside:a,onSelect:an(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Bg("fieldset",{className:"UserList-Wrapper",children:[Mm("legend",{children:f("labels.collaborators")}),Mm(Cm,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Pe.Trigger,Item:Pe.Item,ItemLink:Pe.ItemLink,ItemCustom:Pe.ItemCustom,Group:Pe.Group,Separator:Pe.Separator,DefaultItems:Og}),Ot=qk;import Jk from"clsx";import{forwardRef as Qk,useState as eM}from"react";import{jsx as Lm,jsxs as tM}from"react/jsx-runtime";var An=Qk(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=eM(!1),u=async b=>{let x=t?.(b);if(nn(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(w){if(w instanceof Ji)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},h=d?"loading":c;return i=h==="success"?"success":i,Lm("button",{className:Jk("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:h==="loading"||h==="success",children:tM("div",{className:"ExcButton__contents",children:[h==="loading"?Lm(Mt,{className:"ExcButton__statusIcon"}):h==="success"&&Lm("div",{className:"ExcButton__statusIcon",children:iE}),o&&Lm("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Ga,jsxs as nM}from"react/jsx-runtime";var Am=({title:e,children:o,actionLabel:t,onClick:r})=>nM("div",{className:"OverwriteConfirm__Actions__Action",children:[Ga("h4",{children:e}),Ga("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Ga(An,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),oM=()=>{let{t:e}=pt(),o=gt(),t=Ie();return Ga(Am,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Dd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},rM=()=>{let{t:e}=pt(),o=gt();return Ga(Am,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Jl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},zg=Object.assign(({children:e})=>Ga("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:oM,SaveToDisk:rM});import{jsx as _n,jsxs as n3}from"react/jsx-runtime";var _m=Object.assign(Kr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ke(),[t,r]=ve(Rg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return _n(o.In,{children:_n(dt,{onCloseRequest:n,title:!1,size:916,children:n3("div",{className:"OverwriteConfirm",children:[_n("h3",{children:t.title}),n3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[_n("div",{className:"OverwriteConfirm__Description__icon",children:aE}),_n("div",{children:t.description}),_n("div",{className:"OverwriteConfirm__Description__spacer"}),_n(An,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),_n(zg,{children:e})]})})})}),{Actions:zg,Action:Am});import yM from"clsx";import iM from"clsx";import aM from"lodash.debounce";import{Fragment as lM,memo as sM,useEffect as ps,useRef as Fg,useState as i3}from"react";import{Fragment as EM,jsx as wo,jsxs as us}from"react/jsx-runtime";var cM=Ae(""),Hg=Ae(null),dM=350,l3=()=>{let e=st(),o=Ie(),t=Fg(null),[r,n]=ve(cM),i=r.trim(),[a,l]=i3(!1),[s,c]=i3({nonce:null,items:[]}),m=Fg(null),d=Fg(void 0),[p,u]=ve(Hg),h=e.scene.getNonDeletedElementsMap();ps(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,a3(i,e,(y,v)=>{c({nonce:Mr(),items:y}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.map(C=>({id:C.textElement.id,focus:!1,matchedLines:C.matchedLines}))})}))},[a,i,h,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};ps(()=>{o(y=>({searchMatches:y.searchMatches.map((v,C)=>C===p?{...v,focus:!0}:{...v,focus:!1})}))},[p,o]),ps(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=Vt({text:y.searchQuery,x:y.textElement.x+(y.matchedLines[0]?.offsetX??0),y:y.textElement.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:y.textElement.fontSize,fontFamily:y.textElement.fontFamily}),S=14,_=y.textElement.fontSize,L=_*v<S;if(!Vi([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||L){let N;L?_>=S?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:So(S/_,1)}:N={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),ps(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:[]}),l(!1)},[o,u]);let E=fn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});ps(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),t.current?.matches(":focus")?o({openSidebar:null}):(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return Ye(window,"keydown",y,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return us("div",{className:"layer-ui__search",children:[wo("div",{className:"layer-ui__search-header",children:wo(Ba,{className:Uo.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:f("search.placeholder"),icon:go,onChange:y=>{n(y),l(!0);let v=y.trim();a3(v,e,(C,S)=>{c({nonce:Mr(),items:C}),u(S),m.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.map(_=>({id:_.textElement.id,focus:!1,matchedLines:_.matchedLines}))}),l(!1)})},selectOnRender:!0})}),us("div",{className:"layer-ui__search-count",children:[s.items.length>0&&us(EM,{children:[p!==null&&p>-1?us("div",{children:[p+1," / ",w]}):wo("div",{children:w}),us("div",{className:"result-nav",children:[wo(vo,{onSelect:()=>{b()},className:"result-nav-btn",children:rd}),wo(vo,{onSelect:()=>{x()},className:"result-nav-btn",children:DE})]})]}),s.items.length===0&&i&&m.current&&wo("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),wo(hM,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},mM=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return wo("div",{tabIndex:-1,className:iM("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:wo("div",{className:"preview-text",children:o.flatMap((t,r)=>wo(lM,{children:r===2?wo("b",{children:t}):t},r))})})},pM=e=>wo("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((o,t)=>wo(mM,{searchQuery:e.searchQuery,preview:o.preview,highlighted:t===e.focusIndex,onClick:()=>e.onItemClick(t)},o.textElement.id+o.index))}),uM=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,hM=sM(pM,uM),gM=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),h=u?6:5,b=(u?"":" ")+p.slice(0,h).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>h}},fM=(e,o)=>{let t=e.split(`
9
9
  `),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let c=s-(a.length+n);for(;c>0;)a+=" ",c--}}r.push(a),n=n+a.length}return r.join(`
10
- `)},nM=(e,o,t)=>{let n=rM(e.text,e.originalText).split(`
11
- `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let d of i){if(c==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),h=c.slice(0,p);c=c.slice(p);let b=Ft(u,qe(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Ft(d.line,qe(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:E}=Ft(h,qe(e),e.lineHeight),w=b.width,y=d.lineNumber*b.height;m.push({offsetX:w,offsetY:y,width:x,height:E}),s+=p}}return m},iM=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),jw=Zk((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements().filter(c=>Z(c));n.sort((c,m)=>c.y-m.y);let i=[],a=new RegExp(iM(e),"gi");for(let c of n){let m=null,d=c.originalText;for(;(m=a.exec(d))!==null;){let p=oM(d,m.index,e),u=nM(c,e,m.index);u.length>0&&i.push({textElement:c,searchQuery:e,preview:p,index:m.index,matchedLines:u})}}let l=new Set(o.visibleElements.map(c=>c.id)),s=i.findIndex(c=>l.has(c.textElement.id))??null;t(i,s)},qk);import{jsx as qo,jsxs as Jw}from"react/jsx-runtime";import{createElement as sM}from"react";var Qw=Vr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=We();return qo(o.In,{children:qo(Oo.Trigger,{...e,className:"default-sidebar-trigger",name:At.name})})});Qw.displayName="DefaultSidebarTrigger";var e3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=We();return qo(o.In,{children:e})};e3.displayName="DefaultTabTriggers";var Lm=Object.assign(Vr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=_e(),a=Ie(),{DefaultSidebarTabTriggersTunnel:l}=We(),s=i.openSidebar?.tab===Cr;return sM(Oo,{...n,name:"default",key:"default",className:lM("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:on(t,c=>{a({defaultSidebarDockedPreference:c})})},Jw(Oo.Tabs,{children:[qo(Oo.Header,{children:Jw(Oo.TabTriggers,{children:[qo(Oo.TabTrigger,{tab:Cr,children:go}),qo(Oo.TabTrigger,{tab:rl,children:ia}),qo(l.Out,{})]})}),qo(Oo.Tab,{tab:rl,children:qo(ov,{})}),qo(Oo.Tab,{tab:Cr,children:qo(qw,{})}),e]}))}),{Trigger:Qw,TabTriggers:e3});import{useEffect as wM,useRef as Bg,useState as Fm}from"react";import{useState as i3,useRef as a3,useEffect as l3,useDeferredValue as gM}from"react";import{useEffect as cM,useRef as t3}from"react";import{jsx as dM}from"react/jsx-runtime";var Am=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=t3(null),i=t3(r);return i.current=r,cM(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[T.CTRL_OR_CMD]&&s.key===T.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),dM("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,autoFocus:!0,ref:n})};import{jsx as _m,jsxs as o3}from"react/jsx-runtime";var mM=({error:e})=>o3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",_m("p",{children:e})]}),Dm=({error:e,canvasRef:o,loaded:t})=>o3("div",{className:"ttd-dialog-output-wrapper",children:[e&&_m(mM,{error:e.message}),t?_m("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):_m(Mt,{size:"2rem"})]});import r3 from"clsx";import{jsx as Ng,jsxs as ds}from"react/jsx-runtime";var Ga=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>ds("div",{className:"ttd-dialog-panel",children:[ds("div",{className:"ttd-dialog-panel__header",children:[Ng("label",{children:e}),i?.()]}),o,ds("div",{className:r3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[ds(vo,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[ds("div",{className:r3({invisible:n}),children:[t?.label,t?.icon&&Ng("span",{children:t.icon})]}),n&&Ng(Mt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as pM}from"react/jsx-runtime";var Pm=({children:e})=>pM("div",{className:"ttd-dialog-panels",children:e});import{jsx as n3,jsxs as uM}from"react/jsx-runtime";var Rm=()=>uM("div",{className:"ttd-dialog-submit-shortcut",children:[n3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),n3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});var hM=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Nm=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){hM({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:c,files:m}=s;r(null),n.current={elements:za(c,{regenerateIds:!0}),files:m};let d=await yn({elements:n.current.elements,files:n.current.files,exportPadding:jr,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Dr(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},ms=e=>{Do.set(qr.MERMAID_TO_EXCALIDRAW,e)},Om=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&ms(t))};import{Fragment as xM,jsx as yr,jsxs as c3}from"react/jsx-runtime";var fM=`flowchart TD
10
+ `)},bM=(e,o,t)=>{let n=fM(e.text,e.originalText).split(`
11
+ `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let d of i){if(c==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),h=c.slice(0,p);c=c.slice(p);let b=Ht(u,qe(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Ht(d.line,qe(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:E}=Ht(h,qe(e),e.lineHeight),w=b.width,y=d.lineNumber*b.height;m.push({offsetX:w,offsetY:y,width:x,height:E}),s+=p}}return m},xM=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),a3=aM((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements().filter(c=>Z(c));n.sort((c,m)=>c.y-m.y);let i=[],a=new RegExp(xM(e),"gi");for(let c of n){let m=null,d=c.originalText;for(;(m=a.exec(d))!==null;){let p=gM(d,m.index,e),u=bM(c,e,m.index);u.length>0&&i.push({textElement:c,searchQuery:e,preview:p,index:m.index,matchedLines:u})}}let l=new Set(o.visibleElements.map(c=>c.id)),s=i.findIndex(c=>l.has(c.textElement.id))??null;t(i,s)},dM);import{jsx as Jo,jsxs as s3}from"react/jsx-runtime";import{createElement as vM}from"react";var c3=Kr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ke();return Jo(o.In,{children:Jo(Bo.Trigger,{...e,className:"default-sidebar-trigger",name:At.name})})});c3.displayName="DefaultSidebarTrigger";var d3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ke();return Jo(o.In,{children:e})};d3.displayName="DefaultTabTriggers";var Dm=Object.assign(Kr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=De(),a=Ie(),{DefaultSidebarTabTriggersTunnel:l}=Ke(),s=i.openSidebar?.tab===Ir;return vM(Bo,{...n,name:"default",key:"default",className:yM("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:an(t,c=>{a({defaultSidebarDockedPreference:c})})},s3(Bo.Tabs,{children:[Jo(Bo.Header,{children:s3(Bo.TabTriggers,{children:[Jo(Bo.TabTrigger,{tab:Ir,children:go}),Jo(Bo.TabTrigger,{tab:nl,children:ia}),Jo(l.Out,{})]})}),Jo(Bo.Tab,{tab:nl,children:Jo(mv,{})}),Jo(Bo.Tab,{tab:Ir,children:Jo(l3,{})}),e]}))}),{Trigger:c3,TabTriggers:d3});import{useEffect as NM,useRef as Vg,useState as Gm}from"react";import{useState as g3,useRef as f3,useEffect as b3,useDeferredValue as MM}from"react";import{useEffect as wM,useRef as m3}from"react";import{jsx as TM}from"react/jsx-runtime";var Pm=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=m3(null),i=m3(r);return i.current=r,wM(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[T.CTRL_OR_CMD]&&s.key===T.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),TM("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,autoFocus:!0,ref:n})};import{jsx as Rm,jsxs as p3}from"react/jsx-runtime";var CM=({error:e})=>p3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Rm("p",{children:e})]}),Nm=({error:e,canvasRef:o,loaded:t})=>p3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Rm(CM,{error:e.message}),t?Rm("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Rm(Mt,{size:"2rem"})]});import u3 from"clsx";import{jsx as Ug,jsxs as hs}from"react/jsx-runtime";var Va=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>hs("div",{className:"ttd-dialog-panel",children:[hs("div",{className:"ttd-dialog-panel__header",children:[Ug("label",{children:e}),i?.()]}),o,hs("div",{className:u3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[hs(vo,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[hs("div",{className:u3({invisible:n}),children:[t?.label,t?.icon&&Ug("span",{children:t.icon})]}),n&&Ug(Mt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as IM}from"react/jsx-runtime";var Om=({children:e})=>IM("div",{className:"ttd-dialog-panels",children:e});import{jsx as h3,jsxs as SM}from"react/jsx-runtime";var Bm=()=>SM("div",{className:"ttd-dialog-submit-shortcut",children:[h3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),h3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});var kM=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},zm=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){kM({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:c,files:m}=s;r(null),n.current={elements:Fa(c,{regenerateIds:!0}),files:m};let d=await Tn({elements:n.current.elements,files:n.current.files,exportPadding:Qr,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Rr(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},gs=e=>{Po.set(en.MERMAID_TO_EXCALIDRAW,e)},Fm=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&gs(t))};import{Fragment as _M,jsx as vr,jsxs as E3}from"react/jsx-runtime";var LM=`flowchart TD
12
12
  A[Christmas] -->|Get money| B(Go shopping)
13
13
  B --> C{Let me think}
14
14
  C -->|One| D[Laptop]
15
15
  C -->|Two| E[iPhone]
16
- C -->|Three| F[Car]`,s3=Hn(ms,300),bM=({mermaidToExcalidrawLib:e})=>{let[o,t]=i3(()=>Do.get(qr.MERMAID_TO_EXCALIDRAW)||fM),r=gM(o.trim()),[n,i]=i3(null),a=a3(null),l=a3({elements:[],files:null}),s=lt();l3(()=>{Nm({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{Fe()&&console.error("Failed to parse mermaid definition",m)}),s3(r)},[r,e]),l3(()=>()=>{s3.flush()},[]);let c=()=>{Om({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return c3(xM,{children:[yr("div",{className:"ttd-dialog-desc",children:yr(Wt,{i18nKey:"mermaid.description",flowchartLink:m=>yr("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>yr("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>yr("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),c3(Pm,{children:[yr(Ga,{label:f("mermaid.syntax"),children:yr(Am,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{c()}})}),yr(Ga,{label:f("mermaid.preview"),panelAction:{action:()=>{c()},label:f("mermaid.button"),icon:da},renderSubmitShortcut:()=>yr(Rm,{}),children:yr(Dm,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},d3=bM;import*as p3 from"@radix-ui/react-tabs";import{useRef as m3}from"react";import{jsx as EM}from"react/jsx-runtime";var u3=e=>{let o=Ie(),t=m3(null),r=m3(0);return EM(p3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&Ws(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};u3.displayName="TTDDialogTabs";var h3=u3;import*as g3 from"@radix-ui/react-tabs";import{jsx as yM}from"react/jsx-runtime";var Og=({children:e,...o})=>yM(g3.List,{className:"ttd-dialog-triggers",...o,children:e});Og.displayName="TTDDialogTabTriggers";import*as b3 from"@radix-ui/react-tabs";import{jsx as f3}from"react/jsx-runtime";var Bm=({children:e,tab:o,onSelect:t,...r})=>f3(b3.Trigger,{value:o,asChild:!0,onSelect:t,children:f3("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Bm.displayName="TTDDialogTabTrigger";import*as x3 from"@radix-ui/react-tabs";import{jsx as vM}from"react/jsx-runtime";var zm=({tab:e,children:o,...t})=>vM(x3.Content,{...t,value:e,children:o});zm.displayName="TTDDialogTab";import{jsx as Xt,jsxs as Ln}from"react/jsx-runtime";var zg=3,Va=1e3,TM=Le(null),CM=Le(null),Fg=e=>{let o=_e();return o.openDialog?.name!=="ttd"?null:Xt(IM,{...e,tab:o.openDialog.tab})},IM=Vr("TTDDialogBase",({tab:e,...o})=>{let t=lt(),r=Ie(),n=Bg(null),[i,a]=ve(CM),[l,s]=Fm(i?.prompt??""),c=l.trim(),m=I=>{s(I.target.value),a(_=>({generatedResponse:_?.generatedResponse??null,prompt:I.target.value}))},[d,p]=Fm(!1),[u,h]=ve(TM),b=async()=>{if(c.length>Va||c.length<zg||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<zg&&C(new Error(`Prompt is too short (min ${zg} characters)`)),c.length>Va&&C(new Error(`Prompt is too long (max ${Va} characters)`));return}try{p(!0),xe("ai","generate","ttd");let{generatedResponse:I,error:_,rateLimit:L,rateLimitRemaining:N}=await o.onTextSubmit(c);if(typeof I=="string"&&a(P=>({generatedResponse:I,prompt:P?.prompt??null})),lp(L)&&lp(N)&&h({rateLimit:L,rateLimitRemaining:N}),_){C(_);return}if(!I){C(new Error("Generation failed"));return}try{await Nm({canvasRef:n,data:y,mermaidToExcalidrawLib:E,setError:C,mermaidDefinition:I}),xe("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
17
- TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(I){let _=I.message;(!_||_==="Failed to fetch")&&(_="Request failed"),C(new Error(_))}finally{p(!1)}},x=Bg(b);x.current=b;let[E,w]=Fm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});wM(()=>{(async()=>{await E.api,w(_=>({..._,loaded:!0}))})()},[E.api]);let y=Bg({elements:[],files:null}),[v,C]=Fm(null);return Xt(ct,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Ln(h3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?Xt("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Ln(Og,{children:[Xt(Bm,{tab:"text-to-diagram",children:Ln("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),Xt("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),Xt(Bm,{tab:"mermaid",children:"Mermaid"})]}),Xt(zm,{className:"ttd-dialog-content",tab:"mermaid",children:Xt(d3,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&Ln(zm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Xt("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Ln(Pm,{children:[Xt(Ga,{label:f("labels.prompt"),panelAction:{action:b,label:"Generate",icon:da},onTextSubmitInProgess:d,panelActionDisabled:c.length>Va||u?.rateLimitRemaining===0,renderTopRight:()=>u?Ln("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>Xt(Rm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Ln("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(ms(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Xt(xn,{icon:da})]});let I=c.length/Va;return I>.8?Ln("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:I>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Va]}):null},children:Xt(Am,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Xt(Ga,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Om({app:t,data:y})},label:"Insert",icon:da},children:Xt(Dm,{canvasRef:n,error:v,loaded:E.loaded})})]})]})]})})});import g8 from"clsx";import f8 from"lodash.throttle";import{useEffect as D3,useMemo as Wg,useState as b8,memo as x8}from"react";import SM from"clsx";import{useEffect as y3,useRef as Um,useState as kM}from"react";var E3=.01,so=(e,o)=>!(o==="height"&&Z(e)||o==="width"&&Z(e)||o==="angle"&&ie(e)),je=(e,o)=>{let t=e+o/2;return t-t%o},Ya=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Si=(e,o,t,r,n,i,a,l=!0)=>{let s=r.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[d,p]=se(M(t.x,t.y),M(c,m),t.angle),u=e-d,h=o-p,[b,x]=se(M(e,o),M(c+u,m+h),-t.angle);B(s,{x:b,y:x},l),Hm(s,r,n,i);let E=ge(t,a);if(E){let w=r.get(E.id);w&&B(w,{x:E.x+u,y:E.y+h},l)}},Wa=(e,o)=>{let r=Yo(o).map(n=>Ue(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!ar(n)).forEach(n=>{r.push({[n.id]:!0})}),r},Hm=(e,o,t,r,n)=>{ce(e)?qn([e],o,t,r,!0,[],n?.zoom):at(e,o,n)};import{jsx as Hg,jsxs as LM}from"react/jsx-runtime";var MM=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=lt(),p=Um(null),u=Um(null),[h,b]=kM(r.toString()),x=Um(null);x.current||(x.current={originalAppState:to(c),originalElements:n,lastUpdatedValue:h,updatePending:!1}),y3(()=>{let y=r.toString();b(y),x.current.lastUpdatedValue=y},[r]);let E=(y,v,C)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let I=Number(y);if(isNaN(I)){b(r.toString());return}let _=Number(I.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(_-L)>=E3)&&(x.current.lastUpdatedValue=y,t({accumulatedChange:0,instantChange:0,originalElements:v,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:l,originalAppState:C,setInputValue:N=>b(String(N))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},w=Um({});return w.current.handleInputValue=E,y3(()=>{let y=p.current,v=w.current;return()=>{let C=y?.value;C&&v.handleInputValue?.(C,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?LM("div",{className:SM("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Hg("div",{className:"drag-input-label",ref:u,onPointerDown:y=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let v=Number(p.current.value);isNaN(v)&&(v=0);let C=null,I=d.scene.getNonDeletedElements().reduce((U,q)=>(U.set(q.id,uo(q)),U),new Map),_=n.map(U=>I.get(U.id)),L=to(c),N=0,P=0,z=U=>{if(C&&I!==null&&_!==null){let q=U.clientX-C.x;q!==0&&(P+=q,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),N+=P,t({accumulatedChange:N,instantChange:P,originalElements:_,originalElementsMap:I,shouldKeepAspectRatio:a,shouldChangeByStepSize:U.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:H=>b(String(H))}),P=0))}C={x:U.clientX,y:U.clientY}},V=()=>{window.removeEventListener("pointermove",z,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),C=null,N=0,P=0,_=null,I=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",V,!1)};w.current.onPointerMove=z,w.current.onPointerUp=V,window.addEventListener("pointermove",z,!1),window.addEventListener("pointerup",V,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:o?Hg(xn,{icon:o}):e}),Hg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let v=y.target;v instanceof HTMLInputElement&&y.key===T.ENTER&&(E(v.value,n,c),d.focusContainer())}},ref:p,value:h,onChange:y=>{x.current.updatePending=!0,b(y.target.value)},onFocus:y=>{y.target.select(),x.current.originalElements=n,x.current.originalAppState=to(c)},onBlur:y=>{h?i&&E(y.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},It=MM;import{jsx as PM}from"react/jsx-runtime";var AM=15,_M=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),l=o[0];if(l&&!ee(l)){let s=i.get(l.id);if(!s)return;if(r!==void 0){let h=_i(r);B(s,{angle:h}),Hm(s,i,a,n);let b=ge(s,i);b&&!Pe(s)&&B(b,{angle:h});return}let c=Math.round(Di(l.angle)*100)/100,m=Math.round(e),d=(c+m)%360;t&&(d=je(d,AM)),d=d<0?d+360:d;let p=_i(d);B(s,{angle:p}),Hm(s,i,a,n);let u=ge(s,i);u&&!Pe(s)&&B(u,{angle:p})}},DM=({element:e,scene:o,appState:t,property:r})=>PM(It,{label:"A",icon:Zc,value:Math.round(Di(e.angle)%360*100)/100,elements:[e],dragInputCallback:_M,editable:so(e,"angle"),scene:o,appState:t,property:r}),v3=DM;import{jsx as NM}from"react/jsx-runtime";var w3=5,RM=({property:e,scene:o,appState:t,setAppState:r})=>NM(It,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let c;return n?c=n:i&&(c=a?je(s.gridStep+w3*Math.sign(i),w3):s.gridStep+i),c?(c=Wb(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),T3=RM;import{jsx as FM}from"react/jsx-runtime";var C3=10,OM=e=>e.type==="image",BM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c})=>{let m=c.getNonDeletedElementsMap(),d=o[0],p=m.get(d.id);if(d&&p){let u=r||OM(d),h=d.width/d.height;if(l.croppingElementId===d.id){let y=m.get(d.id);if(!y||!he(y)||!y.crop)return;let v=y.crop,C={...v},I=y.scale[0]===-1,_=y.scale[1]===-1,{width:L,height:N}=oi(y),P=v.naturalWidth/L,z=v.naturalHeight/N,V=I?v.width+v.x:v.naturalWidth-v.x,U=_?v.height+v.y:v.naturalHeight-v.y,q=Np*P,H=Np*z;if(i!==void 0){if(a==="width"){let le=i*P,be=wt(le,q,V);C={...C,width:be,x:I?v.x+v.width-be:v.x}}else if(a==="height"){let le=i*z,be=wt(le,H,U);C={...C,height:be,y:_?v.y+v.height-be:v.y}}B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}let G=a==="width"?s:0,Y=a==="height"?s:0,re=wt(v.width+G,q,V),$=wt(v.height+Y,q,U);C={...v,x:I?v.x+v.width-re:v.x,y:_?v.y+v.height-$:v.y,width:re,height:$},B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*h:d.width,eo),v=Math.max(a==="height"?i:u?i/h:d.height,eo);ci(y,v,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let b=a==="width"?e:0,x=a==="height"?e:0,E=Math.max(0,d.width+b);a==="width"&&(n?E=je(E,C3):E=Math.round(E));let w=Math.max(0,d.height+x);a==="height"&&(n?w=je(w,C3):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/h*100)/100:E=Math.round(w*h*100)/100),w=Math.max(eo,w),E=Math.max(eo,E),ci(E,w,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},zM=({property:e,element:o,scene:t,appState:r})=>{let n=So(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&he(o)&&o.crop){let{width:i,height:a}=oi(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=So(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=So(o.crop.height*l,2)}}return FM(It,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:BM,value:n,editable:so(o,e),scene:t,appState:r,property:e})},Ug=zM;import{jsx as VM}from"react/jsx-runtime";var I3=4,HM=4,UM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!Z(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),I3);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,I3),t&&(s=je(s,HM))}s&&(B(l,{fontSize:s}),Qe(l,n.getContainerElement(l),n.getNonDeletedElementsMap()))}},GM=({element:e,scene:o,appState:t,property:r})=>{let n=Z(e)?e:Tt(e)?ge(e,o.getNonDeletedElementsMap()):null;return n?VM(It,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:UM,icon:pi,appState:t,scene:o,property:r}):null},S3=GM;import{jsx as ZM}from"react/jsx-runtime";var YM=15,WM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!ar(c)&&so(c,n)),s=o.filter(c=>!ar(c)&&so(c,n));if(r!==void 0){let c=_i(r);for(let m of l){if(!m)continue;B(m,{angle:c},!1);let d=ge(m,a);d&&!Pe(m)&&B(d,{angle:c},!1)}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let d=s[c],p=Math.round(Di(d.angle)*100)/100,u=Math.round(e),h=(p+u)%360;t&&(h=je(h,YM)),h=h<0?h+360:h;let b=_i(h);B(m,{angle:b},!1);let x=ge(m,a);x&&!Pe(m)&&B(x,{angle:b},!1)}i.triggerUpdate()},KM=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!ar(s)&&so(s,"angle")),i=n.map(s=>Math.round(Di(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>so(s,"angle"));return ZM(It,{label:"A",icon:Zc,value:a,elements:e,dragInputCallback:WM,editable:l,appState:t,scene:o,property:r})},k3=KM;import{useMemo as XM}from"react";import{jsx as QM}from"react/jsx-runtime";var Ka=10,$M=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...Pc(r,a,l,!1),...Z(r)?{fontSize:r.fontSize*t}:{}}},jM=(e,o,t,r,n,i,a,l)=>{let s=$M(e,o,r,i);B(n,s,!1);let c=ge(i,l);if(c){let m=c.fontSize*r;at(n,a,{newSize:{width:s.width,height:s.height}});let d=a.get(c.id);d&&Z(d)&&(B(d,{fontSize:m},!1),ul(n,a,t==="width"?"e":"s",!0))}},M3=(e,o,t,r,n,i,a,l,s,c)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];jM(n[0],n[1],i,m,u,p,s,c)}},qM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=Wa(o,r);if(i!==void 0){for(let p of c){let u=Ya(p,s,t);if(u.length>1){let h=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,C=y-E,I=v/C,_=Math.max(eo,l==="width"?Math.max(0,i):v),L=Math.max(eo,l==="height"?Math.max(0,i):C);M3(_,L,C,I,M(x,E),l,h,b,s,t)}else{let[h]=u,b=h?.latest,x=h?.original;if(b&&x&&so(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=je(E,Ka):E=Math.round(E));let w=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?w=je(w,Ka):w=Math.round(w)),E=Math.max(eo,E),w=Math.max(eo,w),ci(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate();return}let m=l==="width"?e:0,d=l==="height"?e:0;for(let p of c){let u=Ya(p,s,t);if(u.length>1){let h=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,C=y-E,I=v/C,_=Math.max(0,v+m);l==="width"&&(n?_=je(_,Ka):_=Math.round(_));let L=Math.max(0,C+d);l==="height"&&(n?L=je(L,Ka):L=Math.round(L)),_=Math.max(eo,_),L=Math.max(eo,L),M3(_,L,C,I,M(x,E),l,h,b,s,t)}else{let[h]=u,b=h?.latest,x=h?.original;if(b&&x&&so(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=je(E,Ka):E=Math.round(E));let w=Math.max(0,x.height+d);l==="height"&&(n?w=je(w,Ka):w=Math.round(w)),E=Math.max(eo,E),w=Math.max(eo,w),ci(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},JM=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=XM(()=>r.map(c=>{let m=Ya(c,t);if(m.length>1){let[p,u,h,b]=ye(m.map(x=>x.latest));return Math.round((e==="width"?h-p:b-u)*100)/100}let[d]=m;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return QM(It,{label:e==="width"?"W":"H",elements:o,dragInputCallback:qM,value:l,editable:s,appState:i,property:e,scene:n})},Gg=JM;import{jsx as n8}from"react/jsx-runtime";var L3=4,e8=4,t8=(e,o)=>e.reduce((t,r)=>{if(!r||ar(r))return t;if(Z(r))return t.push(r),t;if(Tt(r)){let n=ge(r,o);if(n)return t.push(n),t}return t},[]),o8=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),L3);for(let s of a)B(s,{fontSize:l},!1),Qe(s,n.getContainerElement(s),i,!1);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),h=Math.max(p+u,L3);t&&(h=je(h,e8)),B(m,{fontSize:h},!1),Qe(m,n.getContainerElement(m),i,!1)}n.triggerUpdate()}},r8=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=t8(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return n8(It,{label:"F",icon:pi,elements:i,dragInputCallback:o8,value:l,editable:s,scene:o,property:r,appState:t})},A3=r8;import{useMemo as i8}from"react";import{jsx as m8}from"react/jsx-runtime";var a8=10,l8=(e,o,t,r,n,i,a,l)=>{for(let s=0;s<r.length;s++){let c=n[s],[m,d]=[c.x+c.width/2,c.y+c.height/2],[p,u]=se(M(c.x,c.y),M(m,d),c.angle),h=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(u+t):u;Si(h,b,c,i,r,l,a,!1)}},s8=(e,o,t,r,n,i,a)=>{let[l,s,,]=ye(t),c=e-l,m=o-s;for(let d=0;d<t.length;d++){let p=t[d],u=r.get(p.id);if(u&&(!Z(u)||!u.containerId)){let[h,b]=[u.x+u.width/2,u.y+u.height/2],[x,E]=se(M(u.x,u.y),M(h,b),u.angle);Si(x+c,E+m,p,r,n,a,i,!1)}}},c8=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of Wa(o,l)){let h=Ya(u,s,t);if(h.length>1){let[b,x,,]=ye(h.map(y=>y.latest));s8(i==="x"?n:b,i==="y"?n:x,h.map(y=>y.original),s,c,t,a)}else{let b=h[0]?.original,x=h[0]?.latest;if(b&&x&&so(x,i)){let[E,w]=[b.x+b.width/2,b.y+b.height/2],[y,v]=se(M(b.x,b.y),M(E,w),b.angle);Si(i==="x"?n:y,i==="y"?n:v,b,s,c,a,t,!1)}}}a.triggerUpdate();return}let m=r?je(e,a8):e;l8(i,i==="x"?m:0,i==="y"?m:0,o,o,s,t,a),a.triggerUpdate()},d8=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=i8(()=>r.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=ye(c);return Math.round((e==="x"?b:x)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,h]=se(M(m.x,m.y),M(d,p),m.angle);return Math.round((e==="x"?u:h)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return m8(It,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:c8,value:l,property:e,scene:n,appState:i})},Vg=d8;import{jsx as h8}from"react/jsx-runtime";var _3=10,p8=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=l.getNonDeletedElements(),d=t[0],[p,u]=[d.x+d.width/2,d.y+d.height/2],[h,b]=se(M(d.x,d.y),M(p,u),d.angle);if(s.croppingElementId===d.id){let v=c.get(d.id);if(!v||!he(v)||!v.crop)return;let C=v.crop,I=C,_=v.scale[0]===-1,L=v.scale[1]===-1,{width:N,height:P}=oi(v);if(i!==void 0){if(a==="x"){let U=i*(C.naturalWidth/N);_?I={...C,x:wt(C.naturalWidth-U-C.width,0,C.naturalWidth-C.width)}:I={...C,x:wt(i*(C.naturalWidth/N),0,C.naturalWidth-C.width)}}a==="y"&&(I={...C,y:wt(i*(C.naturalHeight/P),0,C.naturalHeight-C.height)}),B(v,{crop:I});return}let z=(a==="x"?o:0)*(_?-1:1),V=(a==="y"?o:0)*(L?-1:1);I={...C,x:wt(C.x+z,0,C.naturalWidth-C.width),y:wt(C.y+V,0,C.naturalHeight-C.height)},B(v,{crop:I});return}if(i!==void 0){Si(a==="x"?i:h,a==="y"?i:b,d,c,m,l,r);return}let x=a==="x"?e:0,E=a==="y"?e:0,w=a==="x"?Math.round(n?je(d.x+x,_3):h+x):h,y=a==="y"?Math.round(n?je(d.y+E,_3):b+E):b;Si(w,y,d,c,m,l,r)},u8=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=se(M(o.x,o.y),M(o.x+o.width/2,o.y+o.height/2),o.angle),l=So(e==="x"?i:a,2);if(n.croppingElementId===o.id&&he(o)&&o.crop){let s=Mb(o);s&&(l=So(e==="x"?s.x:s.y,2))}return h8(It,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:p8,scene:r,value:l,property:e,appState:n})},Yg=u8;import{Fragment as Kg,jsx as ae,jsxs as co}from"react/jsx-runtime";var E8=50,ps=e=>{let o=mr(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Tn(e.app);return ae(y8,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ze=({children:e,columns:o=1,heading:t,style:r,...n})=>ae("div",{className:g8("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ze.displayName="StatsRow";var Gm=({children:e,order:o,style:t,...r})=>ae("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Gm.displayName="StatsRows";ps.StatsRow=Ze;ps.StatsRows=Gm;var y8=x8(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=Ie(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&he(d),h=u?oi(d):null,[b,x]=b8({width:0,height:0}),E=Wg(()=>f8(v=>{let C=ye(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},E8),[]);D3(()=>{E(s)},[i,s,E]),D3(()=>()=>E.cancel(),[E]);let w=Wg(()=>Wa(r,n),[r,n]),y=Wg(()=>lc(r),[r]);return ae("div",{className:"exc-stats",children:co(Et,{padding:3,children:[co("div",{className:"title",children:[ae("h2",{children:f("stats.title")}),ae("div",{className:"close",onClick:o,children:ko})]}),co(Vl,{label:ae("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&nl.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^nl.generalStats}})),children:[co(Gm,{children:[ae(Ze,{heading:!0,children:f("stats.scene")}),co(Ze,{columns:2,children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:s.length})]}),co(Ze,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:b.width})]}),co(Ze,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:b.height})]}),a&&co(Kg,{children:[ae(Ze,{heading:!0,children:"Canvas"}),ae(Ze,{children:ae(T3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&ae("div",{id:"elementStats",style:{marginTop:12},children:ae(Vl,{label:ae("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&nl.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^nl.elementProperties}})),children:co(Gm,{children:[d&&co(Kg,{children:[u&&ae(Ze,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&he(d)&&h&&co(Ze,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:So(h.width,2)})]}),n.croppingElementId&&he(d)&&h&&co(Ze,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:So(h.height,2)})]}),ae(Ze,{heading:!0,"data-testid":"stats-element-type",children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),ae(Ze,{children:ae(Yg,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),ae(Ze,{children:ae(Yg,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),ae(Ze,{children:ae(Ug,{property:"width",element:d,scene:l,appState:n})}),ae(Ze,{children:ae(Ug,{property:"height",element:d,scene:l,appState:n})}),!ee(d)&&ae(Ze,{children:ae(v3,{property:"angle",element:d,scene:l,appState:n})}),ae(Ze,{children:ae(S3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&co(Kg,{children:[wb(p)&&ae(Ze,{heading:!0,children:f("element.group")}),co(Ze,{columns:2,style:{margin:"0.3125rem 0"},children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:r.length})]}),ae(Ze,{children:ae(Vg,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Ze,{children:ae(Vg,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Ze,{children:ae(Gg,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Ze,{children:ae(Gg,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Ze,{children:ae(k3,{property:"angle",elements:p,scene:l,appState:n})}),ae(Ze,{children:ae(A3,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as v8,useEffect as P3,useState as R3}from"react";import{jsx as Za,jsxs as Vm}from"react/jsx-runtime";var w8=({sourceElementId:e,onClose:o,elementsMap:t,appState:r,generateLinkForSelection:n=gc})=>{let i=t.get(e)?.link??null,[a,l]=R3(i),[s,c]=R3(!1);P3(()=>{let d=J(t,r),p=i;if(d.length>0&&n){let u=fc(d,r);u&&(p=Go(n(u.id,u.type)))}l(p)},[t,r,r.selectedElementIds,i,n]);let m=v8(()=>{if(a&&a!==t.get(e)?.link){let d=t.get(e);d&&B(d,{link:a})}if(!a&&s&&e){let d=t.get(e);d&&B(d,{link:null})}o?.()},[e,a,t,s,o]);return P3(()=>{let d=p=>{r.openDialog?.name==="elementLinkSelector"&&p.key===T.ENTER&&m(),r.openDialog?.name==="elementLinkSelector"&&p.key===T.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[r,o,m]),Vm("div",{className:"ElementLinkDialog",children:[Vm("div",{className:"ElementLinkDialog__header",children:[Za("h2",{children:f("elementLink.title")}),Za("p",{children:f("elementLink.desc")})]}),Vm("div",{className:"ElementLinkDialog__input",children:[Za(Oa,{value:a??"",onChange:d=>{s||c(!0),l(d)},onKeyDown:d=>{d.key===T.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),i&&a&&Za(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),c(!0)},className:"ElementLinkDialog__remove",icon:ho})]}),Vm("div",{className:"ElementLinkDialog__actions",children:[Za(zr,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Za(zr,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},N3=w8;import T8,{useState as C8}from"react";import{Fragment as I8,jsx as Zg}from"react/jsx-runtime";var O3=({children:e,onClose:o})=>{let[t,r]=C8(!!e),{container:n}=ht(),i=T8.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Zg(I8,{children:t&&Zg(ct,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:Zg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import S8 from"react";import{Fragment as z3,jsx as W,jsxs as To}from"react/jsx-runtime";var k8=()=>To("div",{className:"HelpDialog__header",children:[To("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:mu}),f("helpDialog.documentation")]}),To("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:mu}),f("helpDialog.blog")]}),To("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Gc}),f("helpDialog.github")]}),To("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:gE}),"YouTube"]})]}),M8=e=>To(z3,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),Xg=e=>To("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*L8(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var A8=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),X=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>W(_8,{children:A8(a)},a)));return To("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...L8(r,t?f("helpDialog.or"):null)]})]})},_8=e=>W("kbd",{className:"HelpDialog__key",...e}),B3=({onClose:e})=>{let o=S8.useCallback(()=>{e&&e()},[e]);return W(z3,{children:To(ct,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",children:[W(k8,{}),To(M8,{title:f("helpDialog.shortcuts"),children:[To(Xg,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[W(X,{label:f("toolBar.hand"),shortcuts:[T.H]}),W(X,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),W(X,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),W(X,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),W(X,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),W(X,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),W(X,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),W(X,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),W(X,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),W(X,{label:f("toolBar.image"),shortcuts:[T[9]]}),W(X,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),W(X,{label:f("toolBar.frame"),shortcuts:[T.F]}),W(X,{label:f("toolBar.laser"),shortcuts:[T.K]}),W(X,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),W(X,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),W(X,{label:f("helpDialog.editText"),shortcuts:[R("Enter")]}),W(X,{label:f("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),W(X,{label:f("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),W(X,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),W(X,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),W(X,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),R("Enter")],isOr:!0}),W(X,{label:f("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),W(X,{label:f("toolBar.lock"),shortcuts:[T.Q]}),W(X,{label:f("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),W(X,{label:f("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),To(Xg,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[W(X,{label:f("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),W(X,{label:f("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),W(X,{label:f("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),W(X,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),W(X,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W(X,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W(X,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W(X,{label:f("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),W(X,{label:f("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),W(X,{label:f("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),W(X,{label:f("labels.viewMode"),shortcuts:[R("Alt+R")]}),W(X,{label:f("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),W(X,{label:f("stats.fullTitle"),shortcuts:[R("Alt+/")]}),W(X,{label:f("search.title"),shortcuts:[st("searchMenu")]}),W(X,{label:f("commandPalette.title"),shortcuts:wr?[st("commandPalette")]:[st("commandPalette"),st("commandPalette",1)]})]}),To(Xg,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[W(X,{label:f("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),W(X,{label:f("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),W(X,{label:f("labels.moveCanvas"),shortcuts:[R(`Space+${f("helpDialog.drag")}`),R(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),W(X,{label:f("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),W(X,{label:f("labels.delete"),shortcuts:[R("Delete")]}),W(X,{label:f("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),W(X,{label:f("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),W(X,{label:f("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),W(X,{label:f("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),W(X,{label:f("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),W(X,{label:f("labels.multiSelect"),shortcuts:[R(`Shift+${f("helpDialog.click")}`)]}),W(X,{label:f("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.click")}`)]}),W(X,{label:f("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(ya||wr)&&W(X,{label:f("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),W(X,{label:f("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),W(X,{label:f("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),W(X,{label:f("labels.sendToBack"),shortcuts:[Fo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),W(X,{label:f("labels.bringToFront"),shortcuts:[Fo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),W(X,{label:f("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),W(X,{label:f("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),W(X,{label:f("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),W(X,{label:f("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),W(X,{label:f("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),W(X,{label:f("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),W(X,{label:f("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)]}),W(X,{label:f("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),W(X,{label:f("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),W(X,{label:f("buttons.redo"),shortcuts:Ss?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),W(X,{label:f("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),W(X,{label:f("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),W(X,{label:f("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),W(X,{label:f("labels.flipVertical"),shortcuts:[R("Shift+V")]}),W(X,{label:f("labels.showStroke"),shortcuts:[R("S")]}),W(X,{label:f("labels.showBackground"),shortcuts:[R("G")]}),W(X,{label:f("labels.showFonts"),shortcuts:[R("Shift+F")]}),W(X,{label:f("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),W(X,{label:f("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as U3,useRef as B8,useState as An}from"react";import{useCallback as D8,useRef as P8,useState as R8}from"react";var N8=2e3,F3=()=>{let[e,o]=R8(null),t=P8(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},N8)},n=D8(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import O8 from"clsx";import{jsx as H3}from"react/jsx-runtime";var us=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>H3("div",{className:O8("Switch",{toggled:t,disabled:n}),children:H3("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Xe,jsxs as _n}from"react/jsx-runtime";var z8="filter"in document.createElement("canvas").getContext("2d"),F8=()=>_n("div",{children:[Xe("h3",{children:f("canvasError.cannotShowPreview")}),Xe("p",{children:Xe("span",{children:f("canvasError.canvasTooBig")})}),_n("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),H8=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=ze(o,e),[l,s]=An(i),[c,m]=An(a),[d,p]=An(e.exportBackground),[u,h]=An(e.exportWithDarkMode),[b,x]=An(e.exportEmbedScene),[E,w]=An(e.exportScale),y=B8(null),[v,C]=An(null),{onCopy:I,copyStatus:_,resetCopyStatus:L}=F3();U3(()=>{L()},[l,d,u,E,b,L]);let{exportedElements:N,exportingFrame:P}=bi(o,e,c);return U3(()=>{let z=y.current;if(!z)return;let V=z.offsetWidth,U=z.offsetHeight;V&&yn({elements:N,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:jr,maxWidthOrHeight:Math.max(V,U),exportingFrame:P}).then(q=>(C(null),Dr(q).then(()=>{z.replaceChildren(q)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}))).catch(q=>{console.error(q),C(q)})},[e,t,N,P,l,d,u,E,b]),_n("div",{className:"ImageExportModal",children:[Xe("h3",{children:f("imageExportDialog.header")}),_n("div",{className:"ImageExportModal__preview",children:[Xe("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Xe(F8,{})}),Xe("div",{className:"ImageExportModal__preview__filename",children:!Qi&&Xe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:z=>{s(z.target.value),r.executeAction(mh,"ui",z.target.value)}})})]}),_n("div",{className:"ImageExportModal__settings",children:[Xe("h3",{children:f("imageExportDialog.header")}),a&&Xe(hs,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Xe(us,{name:"exportOnlySelected",checked:c,onChange:z=>{m(z)}})}),Xe(hs,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Xe(us,{name:"exportBackgroundSwitch",checked:d,onChange:z=>{p(z),r.executeAction(ph,"ui",z)}})}),z8&&Xe(hs,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Xe(us,{name:"exportDarkModeSwitch",checked:u,onChange:z=>{h(z),r.executeAction(Vy,"ui",z)}})}),Xe(hs,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Xe(us,{name:"exportEmbedSwitch",checked:b,onChange:z=>{x(z),r.executeAction(Ad,"ui",z)}})}),Xe(hs,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Xe(Cm,{name:"exportScale",value:E,onChange:z=>{w(z),r.executeAction(Gy,"ui",z)},choices:Ns.map(z=>({value:z,label:`${z}\xD7`}))})}),_n("div",{className:"ImageExportModal__settings__buttons",children:[Xe(kn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(Ds.png,N,{exportingFrame:P}),icon:ku,children:f("imageExportDialog.button.exportToPng")}),Xe(kn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(Ds.svg,N,{exportingFrame:P}),icon:ku,children:f("imageExportDialog.button.exportToSvg")}),(ya||wr)&&Xe(kn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:_,onClick:async()=>{await n(Ds.clipboard,N,{exportingFrame:P}),I()},icon:ca,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},hs=({label:e,children:o,tooltip:t,name:r})=>_n("div",{className:"ImageExportModal__settings__setting",title:e,children:[_n("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Xe(bo,{label:t,long:!0,children:Xx})]}),Xe("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),G3=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=An(()=>({appStateSnapshot:to(o),elementsSnapshot:to(e)}));return Xe(ct,{onCloseRequest:i,size:"wide",title:!1,children:Xe(H8,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import G8 from"react";import $g from"open-color";import{jsx as U8}from"react/jsx-runtime";var jg=({children:e,color:o})=>U8("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":$g[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":$g[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":$g[o][9]},children:e});import{Fragment as Y8,jsx as Jo,jsxs as Ym}from"react/jsx-runtime";var V8=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Jo("div",{className:"ExportDialog ExportDialog--json",children:Ym("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Ym(jg,{color:"lime",children:[Jo("div",{className:"Card-icon",children:ox}),Jo("h2",{children:f("exportDialog.disk_title")}),Ym("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Qi&&n.renderAction("changeProjectName")]}),Jo(Q,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Xl,"ui")}})]}),s&&Ym(jg,{color:"pink",children:[Jo("div",{className:"Card-icon",children:Pl}),Jo("h2",{children:f("exportDialog.link_title")}),Jo("div",{className:"Card-details",children:f("exportDialog.link_details")}),Jo(Q,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{xe("export","link",`ui (${E1()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},V3=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=G8.useCallback(()=>{a({openDialog:null})},[a]);return Jo(Y8,{children:o.openDialog?.name==="jsonExport"&&Jo(ct,{onCloseRequest:l,title:f("buttons.export"),children:Jo(V8,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import W8 from"clsx";import{jsx as Y3,jsxs as Z8}from"react/jsx-runtime";var K8="small",W3=e=>Z8("label",{className:W8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${K8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Y3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),Y3("div",{className:"ToolIcon__icon",children:qc})]});import{Fragment as Z3,jsx as te,jsxs as Co}from"react/jsx-runtime";var $8=({UIOptions:e})=>Co(Nt,{__fallback:!0,children:[te(Nt.DefaultItems.LoadScene,{}),te(Nt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Nt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Nt.DefaultItems.SaveAsImage,{}),te(Nt.DefaultItems.SearchMenu,{}),te(Nt.DefaultItems.Help,{}),te(Nt.DefaultItems.ClearCanvas,{}),te(Nt.Separator,{}),te(Nt.Group,{title:"Excalidraw links",children:te(Nt.DefaultItems.Socials,{})}),te(Nt.Separator,{}),te(Nt.DefaultItems.ToggleTheme,{}),te(Nt.DefaultItems.ChangeCanvasBackground,{})]}),j8=()=>Co(Mm,{__fallback:!0,children:[te(Mm.Actions.SaveToDisk,{}),te(Mm.Actions.ExportToImage,{})]}),q8=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:b,app:x,isCollaborating:E,generateLinkForSelection:w})=>{let y=Ce(),v=lv(),C=v.tunnelsJotai.Provider,[I,_]=ve(hn),L=()=>p.canvasActions.export?te(V3,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,N=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:te(G3,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Co("div",{style:{position:"relative"},children:[te(v.MainMenuTunnel.Out,{}),h&&te(v.WelcomeScreenMenuHintTunnel.Out,{})]}),z=()=>te(In,{heading:"selectedShapeActions",className:gs("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:te(Et,{className:Ho.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:te(tm,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),V=()=>{let G=wa(o,n),Y=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return te(gm,{side:"top",children:Co("div",{className:"App-menu App-menu_top",children:[Co(Ct.Col,{gap:6,className:gs("App-menu_top__left"),children:[P(),G&&z()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&te(In,{heading:"shapes",className:"shapes-section",children:re=>Co("div",{style:{position:"relative"},children:[h&&te(v.WelcomeScreenToolbarHintTunnel.Out,{}),te(Ct.Col,{gap:4,align:"start",children:Co(Ct.Row,{gap:1,className:gs("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Co(Et,{padding:1,className:gs("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[te(bm,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),re,Co(Ct.Row,{gap:1,children:[te(xm,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),te(hm,{checked:o.activeTool.locked,onChange:a,title:f("toolBar.lock")}),te("div",{className:"App-toolbar__divider"}),te(fm,{checked:Wo(o),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),te(om,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),E&&te(Et,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:te(W3,{title:f("toolBar.laser"),checked:o.activeTool.type===it.laser,onChange:()=>x.setActiveTool({type:it.laser}),isMobile:!0})})]})})]})}),Co("div",{className:gs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&te(vm,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!q||o.openSidebar?.name!==At.name)&&te(v.DefaultSidebarTriggerTunnel.Out,{}),Y&&te(ps,{app:x,onClose:()=>{e.executeAction(Ma)},renderCustomStats:d})]})]})})},U=()=>te(Lm,{__fallback:!0,onDock:G=>{xe("sidebar",`toggleDock (${G?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),q=Rc(ls),H=Co(Z3,{children:[b,te($8,{UIOptions:p}),te(Lm.Trigger,{__fallback:!0,icon:ia,title:Qr(f("toolBar.library")),onToggle:G=>{G&&xe("sidebar",`${At.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:At.defaultTab,children:f("toolBar.library")}),te(j8,{}),o.openDialog?.name==="ttd"&&te(Fg,{__fallback:!0}),o.isLoading&&te(um,{delay:250}),o.errorMessage&&te(O3,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),I&&!y.editor.isMobile&&te(zE,{colorPickerType:I.colorPickerType,onCancel:()=>{_(null)},onChange:(G,Y,re,{altKey:$})=>{if(!(G!=="elementBackground"&&G!=="elementStroke"))if(re.length){for(let le of re)B(le,{[$&&I.swapPreviewOnAlt?G==="elementBackground"?"strokeColor":"backgroundColor":G==="elementBackground"?"backgroundColor":"strokeColor"]:Y},!1),cn.delete(le);ln.getScene(re[0])?.triggerUpdate()}else r(G==="elementBackground"?{currentItemBackgroundColor:Y}:{currentItemStrokeColor:Y})},onSelect:(G,Y)=>{_(re=>re?.keepOpenOnAlt&&Y.altKey?re:null),I?.onSelect?.(G,Y)}}),o.openDialog?.name==="help"&&te(B3,{onClose:()=>{r({openDialog:null})}}),te(pv,{}),o.openDialog?.name==="elementLinkSelector"&&te(N3,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:x.scene.getNonDeletedElementsMap(),appState:o,generateLinkForSelection:w}),te(v.OverwriteConfirmDialogTunnel.Out,{}),N(),L(),o.pasteDialog.shown&&te(pw,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&te(dw,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:L,renderImageExportDialog:N,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:U,device:y,renderWelcomeScreen:h,UIOptions:p}),!y.editor.isMobile&&Co(Z3,{children:[Co("div",{className:"layer-ui__wrapper",style:o.openSidebar&&q&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[h&&te(v.WelcomeScreenCenterTunnel.Out,{}),V(),te(fw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),o.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(G=>({...ii(n,G)}))},children:f("buttons.scrollBackToContent")})]}),U()]})]});return te(Hu.Provider,{value:o,children:te(C,{children:te(Zh.Provider,{value:v,children:H})})})},K3=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},J8=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Je(K3(r),K3(a),{selectedElementIds:Je,selectedGroupIds:Je})&&Je(n,l)},X3=X8.memo(q8,J8);import Q8 from"clsx";import{jsx as $3,jsxs as tL}from"react/jsx-runtime";var eL="small",Wm=e=>tL("label",{className:Q8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${eL}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[$3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),$3("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as oL,useRef as rL}from"react";import{jsx as j3}from"react/jsx-runtime";var q3=({trails:e})=>{let o=rL(null);return oL(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),j3("div",{className:"SVGLayer",children:j3("svg",{ref:o})})};import nL,{useEffect as iL,useRef as aL}from"react";import{jsx as cL}from"react/jsx-runtime";var lL=e=>{let o=aL(!1);return iL(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),r.set(c,Bt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Zv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},Fa())}),cL("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Se.GRAB:Se.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},J3=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches}),sL=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements?!1:Je(J3(e.appState),J3(o.appState)),qg=nL.memo(lL,sL);import dL,{useEffect as mL,useRef as Q3}from"react";import{jsx as hL}from"react/jsx-runtime";var pL=e=>{let o=Q3(null),t=Q3(!1);return mL(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),qb({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Fa())}),hL("div",{className:"excalidraw__canvas-wrapper",ref:o})},e5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),uL=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:Je(e5(e.appState),e5(o.appState))&&Je(e.renderConfig,o.renderConfig),Jg=dL.memo(pL,uL);import{useEffect as fL,useRef as bL}from"react";var t5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=vc(e,i),m=wc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?_b(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},gL=Pi(e=>{t5(e)},{trailing:!0}),o5=(e,o)=>{if(o){gL(e);return}t5(e)};import{jsx as EL}from"react/jsx-runtime";var xL=e=>{let o=bL(null);return fL(()=>{o.current&&o5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Fa())}),EL("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},r5=xL;import{useCallback as yL,useEffect as vL,useRef as wL}from"react";import{jsx as n5,jsxs as CL}from"react/jsx-runtime";var TL=5e3,i5=({message:e,onClose:o,closable:t=!1,duration:r=TL,style:n})=>{let i=wL(0),a=r!==1/0,l=yL(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return vL(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),CL("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[n5("p",{className:"Toast__message",children:e}),t&&n5(Q,{icon:ko,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{Fragment as LL,jsx as Oe,jsxs as Zm}from"react/jsx-runtime";var c5=vr.createContext(null),d5=vr.createContext(null),m5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},nf=vr.createContext(m5);nf.displayName="DeviceContext";var af=vr.createContext({container:null,id:null});af.displayName="ExcalidrawContainerContext";var lf=vr.createContext([]);lf.displayName="ExcalidrawElementsContext";var sf=vr.createContext({...cr(),width:0,height:0,offsetLeft:0,offsetTop:0});sf.displayName="ExcalidrawAppStateContext";var cf=vr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});cf.displayName="ExcalidrawSetAppStateContext";var df=vr.createContext(null);df.displayName="ExcalidrawActionManagerContext";var lt=()=>Pn(c5),pr=()=>Pn(d5),Ce=()=>Pn(nf),ht=()=>Pn(af),gn=()=>Pn(lf),mr=()=>Pn(sf),Ie=()=>Pn(cf),gt=()=>Pn(df),fs=!1,Qg=0,Mi=!1,bs=!1,ef=!1,tf={horizontal:null,vertical:null},Dn=0,xs=!1,of=new Map,Km=!1,l5=0,s5=!1,Es=null,ke={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},rf=class e extends vr.Component{constructor(t){super(t);k(this,"canvas");k(this,"interactiveCanvas",null);k(this,"rc");k(this,"unmounted",!1);k(this,"actionManager");k(this,"device",m5);k(this,"excalidrawContainerRef",vr.createRef());k(this,"scene");k(this,"fonts");k(this,"renderer");k(this,"visibleElements");k(this,"resizeObserver");k(this,"nearestScrollableContainer");k(this,"library");k(this,"libraryItemsFromStorage");k(this,"id");k(this,"store");k(this,"history");k(this,"excalidrawContainerValue");k(this,"files",{});k(this,"imageCache",new Map);k(this,"iFrameRefs",new Map);k(this,"embedsValidationStatus",new Map);k(this,"initializedEmbeds",new Set);k(this,"elementsPendingErasure",new Set);k(this,"flowChartCreator",new Dc);k(this,"flowChartNavigator",new _c);k(this,"hitLinkElement");k(this,"lastPointerDownEvent",null);k(this,"lastPointerUpEvent",null);k(this,"lastPointerMoveEvent",null);k(this,"lastPointerMoveCoords",null);k(this,"lastViewportPosition",{x:0,y:0});k(this,"animationFrameHandler",new lm);k(this,"laserTrails",new mm(this.animationFrameHandler,this));k(this,"eraserTrail",new Ii(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let i=Math.max(0,1-(performance.now()-t.pressure)/200),a=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(Un(a),Un(i))},fill:()=>this.state.theme===de.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"}));k(this,"onChangeEmitter",new Dt);k(this,"onPointerDownEmitter",new Dt);k(this,"onPointerUpEmitter",new Dt);k(this,"onUserFollowEmitter",new Dt);k(this,"onScrollChangeEmitter",new Dt);k(this,"missingPointerEventCleanupEmitter",new Dt);k(this,"onRemoveEventListenersEmitter",new Dt);k(this,"getEffectiveGridSize",()=>Tn(this)?this.state.gridSize:null);k(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),cn.delete(t)});k(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(zt(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=qi(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Kn(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});k(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);k(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=$e({clientX:i.x,clientY:i.y},this.state),l=$e({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});k(this,"resetEditingFrame",t=>{t&&B(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});k(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===de.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!xl(r,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===r.id&&this.resetEditingFrame(r),null;let{x:n,y:i}=Bt({sceneX:r.x,sceneY:r.y},this.state),a=6,l,s=mb(r);if(r.id===this.state.editingFrame){let c=s;l=Oe("input",{autoFocus:!0,value:c,onChange:m=>{B(r,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(r),onKeyDown:m=>{(m.key===T.ESCAPE||m.key===T.ENTER)&&this.resetEditingFrame(r)},style:{background:this.state.viewBackgroundColor,filter:t?Zf:"none",zIndex:2,border:"none",display:"block",padding:`${a}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${a}px, ${a}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-n-a}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else l=s;return Oe("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+Uo.nameOffsetY-i+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:Uo.nameFontSize,color:t?Uo.nameColorDarkTheme:Uo.nameColorLightTheme,lineHeight:Uo.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Se.MOVE,pointerEvents:this.state.viewModeEnabled?Bn.disabled:Bn.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:l},r.id)})});k(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});k(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());k(this,"getSceneElements",()=>this.scene.getNonDeletedElements());k(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});k(this,"onExportImage",async(t,r,n)=>{xe("export",t,"ui");let i=await xi(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Vs).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Cc(i)&&this.setState({fileHandle:i})});k(this,"magicGenerations",new Map);k(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?B(t,{customData:{generationData:void 0}},!1):B(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()});k(this,"plugins",{});k(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:it.magicframe}),xe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Xs(t[0])&&t[0];if(!r&&t.some(i=>ie(i)||i.frameId)){this.setActiveTool({type:it.magicframe});return}xe("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ye(t),c=50;n=vl({...Uo,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)B(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});k(this,"openEyeDropper",({type:t})=>{St.set(hn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:A.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:A.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?oe(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});k(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});k(this,"syncActionResult",tt(t=>{if(this.unmounted||t===!1)return;t.captureUpdate===A.NEVER?this.store.shouldUpdateSnapshot():t.captureUpdate===A.IMMEDIATELY&&this.store.shouldCaptureIncrement();let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||de.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&kp(m)&&Z(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=t.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}!r&&t.captureUpdate!==A.EVENTUALLY&&this.scene.triggerUpdate()}));k(this,"onBlur",tt(()=>{Mi=!1,this.setState({isBindingEnabled:!0})}));k(this,"onUnload",()=>{this.onBlur()});k(this,"disableEvent",t=>{t.preventDefault()});k(this,"resetHistory",()=>{this.history.clear()});k(this,"resetStore",()=>{this.store.clear()});k(this,"resetScene",tt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...cr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));k(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=ta(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...ii(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:A.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),ni(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});k(this,"isMobileBreakpoint",(t,r)=>t<Xf||r<jf&&t<$f);k(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Ri(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});k(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:qf,a=this.device.editor,l=Ri(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});k(this,"onResize",tt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>cn.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),ja||this.refreshEditorBreakpoints(),this.setState({})}));k(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});k(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(tf=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});k(this,"onScroll",Hn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Wf));k(this,"onCut",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||or(t.target)||(this.actionManager.executeAction(Pd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onCopy",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||or(t.target)||(this.actionManager.executeAction(Sa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onTouchStart",t=>{if(ks&&t.preventDefault(),!fs){fs=!0,clearTimeout(Qg),Qg=window.setTimeout(e.resetTapTwice,Vf);return}if(fs&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),fs=!1,clearTimeout(Qg)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});k(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):ke.pointers.clear()});k(this,"pasteFromClipboard",tt(async t=>{let r=!!Km,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||or(n)))return;let{x:l,y:s}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t?.clipboardData?.files[0],m=await Md(t,r);if(!c&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let d=m.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(c=Xp(d))}}if(Ic(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:Me({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let d=m.programmaticAPI?za(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&jv(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:h,files:b}=await u.parseMermaidToExcalidraw(m.text),x=za(h,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(h){console.warn(`parsing pasted text as mermaid definition failed: ${h.message}`)}}let d=w1(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>zb(u)).filter(u=>qi(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||ri(u)?.type==="video"));if(!Km&&p.length>0&&p.length===d.length){let u=[];for(let h of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Go(h)});x&&u.push(x)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(h=>[h.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));k(this,"addElementsFromPasteOrLibrary",t=>{let r=Wp(t.elements,null,void 0),[n,i,a,l]=ye(r),s=Gn(n,a)/2,c=Gn(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=$e({clientX:m,clientY:d},this.state),h=p-s,b=u-c,[x,E]=pt(h,b,this.getEffectiveGridSize()),{newElements:w}=ai({type:"everything",elements:r.map(L=>oe(L,{x:L.x+x-n,y:L.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,Ht(v,ne(w));let I=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(I){let L=cb(w,I);Wi(v,L,I,this.state)}this.scene.replaceAllElements(v),w.forEach(L=>{if(Z(L)&&Be(L)){let N=ro(L,this.scene.getElementsMapIncludingDeleted());Qe(L,N,this.scene.getElementsMapIncludingDeleted())}}),Df&&dn.loadElementsFonts(w).then(L=>{this.fonts.onLoaded(L)}),t.files&&this.addMissingFiles(t.files),this.store.shouldCaptureIncrement();let _=sc(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&St.get(ls)?this.state.openSidebar:null,...ut({editingGroupId:null,selectedElementIds:_.reduce((L,N)=>(Be(N)||(L[N.id]=!0),L),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});k(this,"setAppState",(t,r)=>{this.setState(t,r)});k(this,"removePointer",t=>{Dn&&this.resetContextMenuTimer(),ke.pointers.delete(t.pointerId)});k(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||xe("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Ge(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});k(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});k(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});k(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Sy)});k(this,"zoomCanvas",t=>{this.setState({...Nr({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:sr(t)},this.state)})});k(this,"cancelInProgressAnimation",null);k(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(ni(t)?s=Gb(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):ni(t)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Yl({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=ii(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,d=d1({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,h,b)=>{if(b==="zoom")return p*Math.pow(u/p,Un(h))},onStep:({scrollX:p,scrollY:u,zoom:h})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:h}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});k(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});k(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});k(this,"setToast",t=>{this.setState({toast:t})});k(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,qa,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});k(this,"addFiles",tt(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));k(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ue.svg))try{let s=i0(Fp(l0(l.dataURL)),ue.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});k(this,"updateScene",tt(t=>{let r=_r(t.elements??[]);if(t.captureUpdate&&t.captureUpdate!==A.EVENTUALLY){let n=this.store.snapshot.appState,i=this.store.snapshot.elements,a=t.appState?Object.assign({},n,t.appState):n,l=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),ne(r)):i;t.captureUpdate===A.IMMEDIATELY?this.store.captureIncrement(l,a):t.captureUpdate===A.NEVER&&this.store.updateSnapshot(l,a)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})}));k(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});k(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});k(this,"updateCurrentCursorPosition",tt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));k(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Rr().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});k(this,"onKeyDown",tt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!fp(t.target)){if((t.key===T.ESCAPE||t.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&he(a[0])&&t.key===T.ENTER){this.startImageCropping(a[0]);return}if(t.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=zn(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&Xn(s[0])&&this.flowChartCreator.createNodes(s[0],this.scene.getNonDeletedElementsMap(),this.state,Qp(t.key)),this.flowChartCreator.pendingNodes?.length&&!Vi(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=J(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),Qp(t.key));if(c){this.setState(d=>({selectedElementIds:Me({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Vi([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[T.CTRL_OR_CMD]&&t.key===T.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:st("commandPalette")})}),t.preventDefault();return}if(t[T.CTRL_OR_CMD]&&t.key.toLowerCase()===T.V&&(Km=t.shiftKey,clearTimeout(l5),l5=window.setTimeout(()=>{Km=!1},100)),t[T.CTRL_OR_CMD]&&or(t.target)&&(t.code===pe.MINUS||t.code===pe.EQUAL)){t.preventDefault();return}if(or(t.target)&&t.key!==T.ESCAPE||zn(t.key)&&fp(t.target))return;if(t.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===T.E&&t.shiftKey&&t[T.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===T.PAGE_UP||t.key===T.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===T.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),zn(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(ee),s=new Set;a.filter(ee).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),h=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||h}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?Jm:this.getEffectiveGridSize())||(t.shiftKey?Nf:Jm),m=0,d=0;t.key===T.ARROW_LEFT?m=-c:t.key===T.ARROW_RIGHT?m=c:t.key===T.ARROW_UP?d=-c:t.key===T.ARROW_DOWN&&(d=c),a.forEach(p=>{B(p,{x:p.x+m,y:p.y+d},!1),at(p,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:ec(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===T.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[T.CTRL_OR_CMD])ce(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.shouldCaptureIncrement(),ee(l)||this.setState({editingLinearElement:new j(l)}));else if(Z(l)||K1(l)){let s;Z(l)||(s=l);let c=Js(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),t.preventDefault();return}else ie(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=av(t.key);a?(this.state.activeTool.type!==a&&xe("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===xt.sharp?xt.round:l.currentItemArrowType===xt.round?xt.elbow:xt.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===T.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===T.SPACE&&ke.pointers.size===0&&(Mi=!0,De(this.interactiveCanvas,Se.GRAB),t.preventDefault()),(t.key===T.G||t.key===T.S)&&!t.altKey&&!t[T.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===T.G&&(sn(this.state.activeTool.type)||a.some(l=>sn(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===T.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[T.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===T.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>Z(l)||ge(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===T.K&&!t.altKey&&!t[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[T.CTRL_OR_CMD]&&(t.key===T.BACKSPACE||t.key===T.DELETE)&&St.set(Ti,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,i=t.key===T.I||r===T.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));k(this,"onKeyUp",tt(t=>{if(t.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?De(this.interactiveCanvas,Se.GRAB):this.state.activeTool.type==="selection"?xo(this.interactiveCanvas):(Eo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Mi=!1),!t[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),zn(t.key)&&(qn(this.scene.getSelectedElements(this.state).filter(ce),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,jn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[T.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:Me({[r.id]:!0},n)})),Vi([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})}}));k(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);k(this,"setActiveTool",t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Ge(this.state,t);r.type==="hand"?De(this.interactiveCanvas,Se.GRAB):Mi||Eo(this.interactiveCanvas,{...this.state,activeTool:r}),s1(document.activeElement)&&this.focusContainer(),C1(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(n=>{let i={snapLines:n.snapLines.length?[]:n.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.shouldCaptureIncrement(),r.type!=="selection"?{...n,activeTool:r,selectedElementIds:Me({},n),selectedGroupIds:Me({},n),editingGroupId:null,multiElement:null,...i}:{...n,activeTool:r,...i}})});k(this,"setOpenDialog",t=>{this.setState({openDialog:t})});k(this,"setCursor",t=>{De(this.interactiveCanvas,t)});k(this,"resetCursor",()=>{xo(this.interactiveCanvas)});k(this,"isTouchScreenMultiTouchGesture",()=>ke.pointers.size>=2);k(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${gp()}`);k(this,"onGestureStart",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),ke.initialScale=this.state.zoom.value}));k(this,"onGestureChange",tt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=ke.initialScale;r&&this.setState(n=>({...Nr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:sr(r*t.scale)},n)}))}));k(this,"onGestureEnd",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),ke.initialScale=null}));k(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(ge(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Z(m[0])?c=m[0]:i?c=ge(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let d=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||Ir(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!Pe(i)){let E=$s(qe({fontSize:u,fontFamily:d}),p),w=js(u,p),y=Math.max(i.height,w),v=Math.max(i.width,E);B(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let h=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Gt({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Jt.MIDDLE:ep,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?.angle??0,frameId:h?h.id:null});if(!c&&l&&i&&B(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});k(this,"startImageCropping",t=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:t.id})});k(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))});k(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=$e(t,this.state);if(r.length===1&&ce(r[0])){if(t[T.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!ee(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(r[0])});return}else if(this.state.selectedLinearElement&&ee(r[0])){let l=j.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.shouldCaptureIncrement(),j.deleteFixedSegment(r[0],s);let c=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}}if(r.length===1&&he(r[0])){this.startImageCropping(r[0]);return}if(xo(this.interactiveCanvas),Yo(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&xb(l,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(c=>({...c,...ut({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(xo(this.interactiveCanvas),!t[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Oi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(Tt(s)||!Vn(s.backgroundColor)||zi({x:n,y:i,element:s,shape:ti(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=Js(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}});k(this,"getElementLinkAtPosition",(t,r)=>{let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&yc(l,this.scene.getNonDeletedElementsMap(),this.state,M(t.x,t.y),this.device.editor.isMobile))return l}});k(this,"redirectToLink",(t,r)=>{let n=Jr(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>On)return;let i=$e(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=yc(this.hitLinkElement,a,this.state,M(i.x,i.y),this.device.editor.isMobile),s=$e(this.lastPointerUpEvent,this.state),c=yc(this.hitLinkElement,a,this.state,M(s.x,s.y),this.device.editor.isMobile);if(l&&c){Lh();let m=this.hitLinkElement.link;if(m){m=Go(m);let d;if(this.props.onLinkOpen&&(d=Ys("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=Ks(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});k(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>Mp(t,i,r));return n.length?n[n.length-1]:null});k(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ke.pointers.has(t.pointerId)&&ke.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=ke.initialScale;if(ke.pointers.size===2&&ke.lastCenter&&r&&ke.initialDistance){let u=ig(ke.pointers),h=u.x-ke.lastCenter.x,b=u.y-ke.lastCenter.y;ke.lastCenter=u;let x=ag(Array.from(ke.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/ke.initialDistance,w=E?sr(r*E):this.state.zoom.value;this.setState(y=>{let v=Nr({viewportX:u.x,viewportY:u.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(h/w),scrollY:v.scrollY+2*(b/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ke.lastCenter=ke.initialDistance=ke.initialScale=null;if(Mi||bs||ef||Wo(this.state))return;let i=dg(tf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?xo(this.interactiveCanvas):Eo(this.interactiveCanvas,this.state));let a=$e(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Nv(this.state.activeTool.type)){let{originOffset:u,snapLines:h}=Rv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(b=>{let x=Ni(b.snapLines,h),E=b.originSnapOffset?Ni(b.originSnapOffset,u):u;return b.snapLines===x&&b.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(u=>u.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let u=j.handlePointerMove(t,l,s,this,this.scene.getNonDeletedElementsMap());u&&u!==this.state.editingLinearElement&&ki(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):ki(()=>{this.setState({suggestedBindings:[]})})}if(I1(this.state.activeTool.type)){let{newElement:u}=this.state;Mr(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:h,y:b}=u,{points:x,lastCommittedPoint:E}=u,w=x[x.length-1];if(Eo(this.interactiveCanvas,this.state),w===E)Jr(M(l-h,s-b),w)>=Ms?B(u,{points:[...x,M(l-h,s-b)]},!1):De(this.interactiveCanvas,Se.POINTER);else if(x.length>2&&E&&Jr(M(l-h,s-b),E)<Ms)De(this.interactiveCanvas,Se.POINTER),B(u,{points:x.slice(0,-1)},!1);else{let[y,v]=pt(l,s,t[T.CTRL_OR_CMD]||ee(u)?null:this.getEffectiveGridSize()),[C,I]=u?.lastCommittedPoint??[0,0],_=y-h-C,L=v-b-I;Us(t)&&({width:_,height:L}=Cp(C+h,I+b,y,v)),El(x,this.state.zoom.value)&&De(this.interactiveCanvas,Se.POINTER),B(u,{points:[...x.slice(0,-1),M(C+_,I+L)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&ee(d[0]))){let u=nu(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){De(this.interactiveCanvas,au(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=iu(ye(d),l,s,this.state.zoom,t.pointerType,this.device);if(u){De(this.interactiveCanvas,au({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!no(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(De(this.interactiveCanvas,Se.POINTER),c2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Lh(),p&&(p.link||zt(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?De(this.interactiveCanvas,Z(p)?Se.TEXT:Se.CROSSHAIR):this.state.viewModeEnabled?De(this.interactiveCanvas,Se.GRAB):this.state.openDialog?.name==="elementLinkSelector"?De(this.interactiveCanvas,Se.AUTO):i?De(this.interactiveCanvas,Se.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[T.CTRL_OR_CMD]?De(this.interactiveCanvas,Se.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&Oi(p)&&this.isIframeLikeElementCenter(p,t,l,s)?(De(this.interactiveCanvas,Se.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!ee(p)||!(p.startBinding||p.endBinding))&&(De(this.interactiveCanvas,Se.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,ut({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,{})})))});k(this,"handleEraser",(t,r,n)=>{this.eraserTrail.addPointToPath(n.x,n.y);let i=!1,a=new Set,l=this.scene.getNonDeletedElements(),s=u=>{for(let h of u){if(h.locked)return;if(t.altKey?this.elementsPendingErasure.delete(h.id)&&(i=!0):this.elementsPendingErasure.has(h.id)||(i=!0,this.elementsPendingErasure.add(h.id)),i&&h.groupIds?.length){let b=h.groupIds.at(-1);if(!a.has(b)){a.add(b);let x=Ue(l,b);for(let E of x)t.altKey?this.elementsPendingErasure.delete(E.id):this.elementsPendingErasure.add(E.id)}}}},c=Jr(M(r.lastCoords.x,r.lastCoords.y),M(n.x,n.y)),m=this.getElementHitThreshold(),d={...r.lastCoords},p=0;for(;p<=c;){let u=this.getElementsAtPosition(d.x,d.y);if(s(u),p===c)break;p=Math.min(p+m,c);let h=p/c,b=(1-h)*d.x+h*n.x,x=(1-h)*d.y+h*n.y;d.x=b,d.y=x}if(r.lastCoords.x=n.x,r.lastCoords.y=n.y,i){for(let u of this.scene.getNonDeletedElements())Be(u)&&(this.elementsPendingErasure.has(u.id)||this.elementsPendingErasure.has(u.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(u.id),this.elementsPendingErasure.delete(u.containerId)):(this.elementsPendingErasure.add(u.id),this.elementsPendingErasure.add(u.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}});k(this,"handleTouchMove",t=>{xs=!0});k(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches.map(p=>({...p,focus:!1}))})),St.set(Rg,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Me(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?A.EVENTUALLY:A.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Ri(this.device,{isTouchScreen:!0})),bs||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===tr.ERASER&&this.state.activeTool.type!==it.eraser){this.setState({activeTool:Ge(this.state,{type:it.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),no(this.state)&&this.setState({activeTool:Ge(this.state,{...this.state.activeTool.lastActiveTool||{type:it.selection},lastActiveToolBeforeEraser:null})})},p=Ve(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==tr.MAIN&&t.button!==tr.TOUCH&&t.button!==tr.ERASER||ke.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(t,i);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i);else if(this.state.activeTool.type==="image"){De(this.interactiveCanvas,Se.CROSSHAIR);let d=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!d)return;this.setState({newElement:d,pendingImageElementId:null,multiElement:null});let{x:p,y:u}=$e(t,this.state),h=this.getTopLayerFrameAtSceneCoords({x:p,y:u});B(d,{x:p,y:u,frameId:h?h.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Eo(this.interactiveCanvas,this.state):this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",c),window.addEventListener("keyup",m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=c)});k(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=$e({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Oi(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Oi(this.hitLinkElement)&&!$b(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,M(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});k(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(xs=!1,Dn?xs=!0:Dn=window.setTimeout(()=>{Dn=0,xs||this.handleCanvasContextMenu(t)},Yf))});k(this,"resetContextMenuTimer",()=>{clearTimeout(Dn),Dn=0,xs=!1});k(this,"maybeCleanupAfterMissingPointerUp",t=>{Es?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});k(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ke.pointers.size<=1&&(t.button===tr.WHEEL||t.button===tr.MAIN&&Mi||Wo(this.state)||this.state.viewModeEnabled)))return!1;bs=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);De(this.interactiveCanvas,Se.GRABBING);let{clientX:i,clientY:a}=t,l=pm(c=>{let m=i-c.clientX,d=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(d)>1)){r=!0;let p=h=>{document.body.removeEventListener("paste",p),h.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=tt(Es=()=>{Es=null,bs=!1,Mi||(this.state.viewModeEnabled?De(this.interactiveCanvas,Se.GRAB):Eo(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),l.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerup",s),!0});k(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});k(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!ee(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=nu(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=iu(ye(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=en(y0(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ce(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=v0(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=j.handlePointerDown(t,this,this.store,r.origin,c,this.scene);if(m.hitElement&&(r.hit.element=m.hitElement),m.linearElementEditor&&(this.setState({selectedLinearElement:m.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:m.linearElementEditor})),m.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,r.hit.element),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let l=r.hit.element,s=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((l===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(l),this.state.editingLinearElement)this.setState({selectedElementIds:Me({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(t[T.CTRL_OR_CMD])return this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...bb(c,l),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!Ki(l,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{let m={...c.selectedElementIds,[l.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(p=>{let u=this.scene.getElement(p);u&&d.push(u)}),ie(l))nr(d,l.id).forEach(p=>{delete m[p.id]});else if(l.frameId)m[l.frameId]&&delete m[l.id];else{let p=l.groupIds,u=new Set(p.flatMap(h=>Ue(this.scene.getNonDeletedElements(),h)).filter(h=>ie(h)).map(h=>h.id));u.size>0&&d.forEach(h=>{h.frameId&&u.has(h.frameId)&&(delete m[h.id],h.groupIds.flatMap(b=>Ue(this.scene.getNonDeletedElements(),b)).forEach(b=>{delete m[b.id]}))})}return c.openDialog?.name==="elementLinkSelector"&&(l.groupIds.some(p=>c.selectedGroupIds[p])||(m={[l.id]:!0})),{...ut({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||zt(l)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});k(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);Tt(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),xo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Ge(this.state,{type:"selection"})})});k(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=pt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=Bb({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[M(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Me(p,d)}});let m=an(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});k(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=pt(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Nb({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});k(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=pt(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ri(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=Bp({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});k(this,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=pt(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return hc({type:"image",x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null})});k(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&El(i.points,this.state.zoom.value)){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}if(ee(i)&&i.points.length>1){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Jr(M(n.origin.x-a,n.origin.y-l),s)<Ms){this.actionManager.executeAction(yo);return}this.setState(c=>({selectedElementIds:Me({...c.selectedElementIds,[i.id]:!0},c)})),B(i,{lastCommittedPoint:i.points[i.points.length-1]}),De(this.interactiveCanvas,Se.POINTER)}else{let[i,a]=pt(n.origin.x,n.origin.y,t[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,d]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?ji({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===xt.round?{type:Qt.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===xt.elbow,fixedSegments:this.state.currentItemArrowType===xt.elbow?[]:null}):lr({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Qt.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(h=>{let b={...h.selectedElementIds};return delete b[p.id],{selectedElementIds:Me(b,h)}}),B(p,{points:[...p.points,M(0,0)]});let u=an(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(p),ee(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});k(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=pt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=Bp({type:"embeddable",...l}):s=Ut({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});k(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=pt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Uo},l=r===it.magicframe?vl(a):$i(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});k(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});k(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||Be(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,oe(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))});k(this,"initializeImage",async({imageFile:t,imageElement:r,showCursorImagePreview:n=!1})=>{if(!Ic(t))throw new Error(f("errors.unsupportedFileType"));let i=t.type;if(De(this.interactiveCanvas,"wait"),i===ue.svg)try{t=Xp(Fp(await t.text()),t.name)}catch(m){throw console.warn(m),new Error(f("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(t)||n0(t));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{t=await Il(t,{maxWidthOrHeight:Jf})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(t.size>ip)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(ip/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&a0(m);this.setImagePreviewCursor(d||t)}let s=this.files[a]?.dataURL||await kc(t),c=B(r,{fileId:a},!1);return new Promise(async(m,d)=>{try{this.addMissingFiles([{mimeType:i,id:a,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let p=this.imageCache.get(a);p||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),p?.image instanceof Promise&&await p.image,this.state.pendingImageElementId!==c.id&&this.state.newElement?.id!==c.id&&this.initializeImageDimensions(c,!0),m(c)}catch(p){console.error(p),d(new Error(f("errors.imageInsertError")))}finally{n||xo(this.interactiveCanvas)}})});k(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return B(t,{isDeleted:!0}),this.actionManager.executeAction(yo),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});k(this,"setImagePreviewCursor",async t=>{let n;try{n=await Il(t,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(f("errors.unsupportedFileType")):a}let i=await kc(n);if(t.type===ue.svg){let a=await Fb(i),l=Math.min(a.height,96),s=l*(a.width/a.height);s>96&&(s=96,l=s*(a.height/a.width));let c=document.createElement("canvas");c.height=l,c.width=s,c.getContext("2d").drawImage(a,0,0,s,l),i=c.toDataURL(ue.svg)}this.state.pendingImageElementId&&De(this.interactiveCanvas,`url(${i}) 4 4, auto`)});k(this,"onImageAction",async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:i,y:a}=$e({clientX:r,clientY:n},this.state),l=await xc({description:"Image",extensions:Object.keys(tl)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,l,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,newElement:null,activeTool:Ge(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(yo)})}});k(this,"initializeImageDimensions",(t,r=!1)=>{let n=kr(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<On/this.state.zoom.value&&t.height<On/this.state.zoom.value){let i=100/this.state.zoom.value;B(t,{x:t.x-i/2,y:t.y-i/2,width:i,height:i})}return}if(r||t.width<On/this.state.zoom.value&&t.height<On/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=t.x+t.width/2-s/2,m=t.y+t.height/2-l/2;B(t,{x:c,y:m,width:s,height:l,crop:null})}});k(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await Hb({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});if(n.size||i.size)for(let a of t)n.has(a.fileId)&&cn.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>kr(a)&&i.has(a.fileId)?oe(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});k(this,"addNewImagesToImageCache",async(t=Ub(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);i.size&&this.scene.triggerUpdate()}});k(this,"scheduleImageRefresh",IL(()=>{this.addNewImagesToImageCache()},Gf));k(this,"updateBindingEnabledOnPointerMove",t=>{let r=X1(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});k(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=an(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});k(this,"maybeSuggestBindingsForLinearElementAtCoords",(t,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=an(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(t),ee(t));return s!=null&&!q1(t,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});k(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});k(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await c0(t),{x:i,y:a}=$e(t,this.state);try{if(Ic(r)&&this.isToolSupported("image")){if(r?.type===ue.png||r?.type===ue.svg)try{let c=await Sc(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(ue.excalidrawlib);if(l&&typeof l=="string"){try{let s=r0(l);this.addElementsFromPasteOrLibrary({elements:Vd(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,n),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&qi(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||ri(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Go(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});k(this,"loadFileToCanvas",async(t,r)=>{t=await m0(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Kp(t,this.state,n,r)}catch(a){let l=a instanceof Kb;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ue.excalidraw?(_r(n.concat(i.data.elements)),this.store.updateSnapshot(ne(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ue.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});k(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==tr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=$e(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:d}=c.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-m;xe("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ut({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ce(i)?new j(i):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});k(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){lu({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Gn(t.origin.x,a.x),height:Gn(t.origin.y,a.y),shouldMaintainAspectRatio:Ai(r),shouldResizeFromCenter:Hs(r),zoom:this.state.zoom.value,informMutation:n});return}let l=this.state.newElement;if(!l)return;let[s,c]=pt(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=kr(l)&&this.imageCache.get(l.fileId)?.image,d=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Pv(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),lu({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Gn(t.originInGrid.x,s),height:Gn(t.originInGrid.y,c),shouldMaintainAspectRatio:he(l)?!Ai(r):Ai(r),shouldResizeFromCenter:Hs(r),zoom:this.state.zoom.value,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe)&&this.setState({elementsToHighlight:Yi(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});k(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=pt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&he(s)){let c=t.originalElements.get(s.id),m=kr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&he(c)&&m&&!(m instanceof Promise)){let[d,p]=pt(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:h,snapLines:b}=sg([s],[c],this,r,u,n);B(s,kb(s,n,m.naturalWidth,m.naturalHeight,a+h.x,l+h.y,r.shiftKey?c.width/c.height:void 0)),at(s,this.scene.getNonDeletedElementsMap(),{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});k(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ie(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&ee(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=pt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{nr(this.scene.getNonDeletedElements(),d.id).forEach(u=>{m.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=pt(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},h=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=sg(n,J(h,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(E0(t.originalElements,a,n,this.scene.getElementsMapIncludingDeleted(),this.scene,Us(r),Hs(r),n.some(d=>he(d))?!Ai(r):Ai(r),s,c,t.resize.center.x,t.resize.center.y)){let d=ec(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Yi(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});k(this,"getContextMenuItems",t=>{let r=[];return r.push(Nd,Rd),t==="canvas"?this.state.viewModeEnabled?[...r,Bd,ka,rg,Ma]:[vh,ft,Nd,Rd,Od,ft,Bu,d2,ft,Bd,wh,ka,rg,Ma]:(r.push(Od),this.state.viewModeEnabled?[Sa,...r]:[ft,Pd,Sa,vh,ft,bv,xv,Ev,ft,eg,ft,...r,ft,uh,hh,ft,gh,Cv,Th,Ch,o2,fh,ft,xh,ft,Pu,Ru,Nu,Ou,ft,Eh,yh,ft,Qh,ft,jl,Fd,ft,zu,_h,ft,Bl])});k(this,"handleWheel",tt(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[T.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),bs)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Li*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Nr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:sr(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));k(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=$e({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:ke.pointers})});k(this,"resetShouldCacheIgnoreZoomDebounced",Hn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));k(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:d}=this.state;if(n===s&&i===c&&a===d&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});k(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=cr(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${f("labels.untitled")}-${gp()}`}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=kL(),this.library=new w2(this),this.actionManager=new am(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new ln,this.canvas=document.createElement("canvas"),this.rc=SL.canvas(this.canvas),this.renderer=new is(this.scene),this.visibleElements=[],this.store=new zc,this.history=new os,n){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new dn(this.scene),this.history=new os,this.actionManager.registerAll(rd),this.actionManager.registerAction(vv(this.history,this.store)),this.actionManager.registerAction(wv(this.history,this.store))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(Qa).includes(i)&&of.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Kn(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=of.get(t.id);switch(n||(of.set(t.id,Qa.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case Qa.PLAYING:case Qa.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>zt(a)&&this.embedsValidationStatus.get(a.id)===!0||Kn(a));return Oe(LL,{children:i.map(a=>{let{x:l,y:s}=Bt({sceneX:a.x,sceneY:a.y},this.state),c=xl(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let p;if(Kn(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>zp(`
16
+ C -->|Three| F[Car]`,x3=Vn(gs,300),AM=({mermaidToExcalidrawLib:e})=>{let[o,t]=g3(()=>Po.get(en.MERMAID_TO_EXCALIDRAW)||LM),r=MM(o.trim()),[n,i]=g3(null),a=f3(null),l=f3({elements:[],files:null}),s=st();b3(()=>{zm({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{He()&&console.error("Failed to parse mermaid definition",m)}),x3(r)},[r,e]),b3(()=>()=>{x3.flush()},[]);let c=()=>{Fm({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return E3(_M,{children:[vr("div",{className:"ttd-dialog-desc",children:vr(Kt,{i18nKey:"mermaid.description",flowchartLink:m=>vr("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>vr("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>vr("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),E3(Om,{children:[vr(Va,{label:f("mermaid.syntax"),children:vr(Pm,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{c()}})}),vr(Va,{label:f("mermaid.preview"),panelAction:{action:()=>{c()},label:f("mermaid.button"),icon:da},renderSubmitShortcut:()=>vr(Bm,{}),children:vr(Nm,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},y3=AM;import*as w3 from"@radix-ui/react-tabs";import{useRef as v3}from"react";import{jsx as DM}from"react/jsx-runtime";var T3=e=>{let o=Ie(),t=v3(null),r=v3(0);return DM(w3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&$s(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};T3.displayName="TTDDialogTabs";var C3=T3;import*as I3 from"@radix-ui/react-tabs";import{jsx as PM}from"react/jsx-runtime";var Gg=({children:e,...o})=>PM(I3.List,{className:"ttd-dialog-triggers",...o,children:e});Gg.displayName="TTDDialogTabTriggers";import*as k3 from"@radix-ui/react-tabs";import{jsx as S3}from"react/jsx-runtime";var Hm=({children:e,tab:o,onSelect:t,...r})=>S3(k3.Trigger,{value:o,asChild:!0,onSelect:t,children:S3("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Hm.displayName="TTDDialogTabTrigger";import*as M3 from"@radix-ui/react-tabs";import{jsx as RM}from"react/jsx-runtime";var Um=({tab:e,children:o,...t})=>RM(M3.Content,{...t,value:e,children:o});Um.displayName="TTDDialogTab";import{jsx as $t,jsxs as Dn}from"react/jsx-runtime";var Yg=3,Ya=1e3,OM=Ae(null),BM=Ae(null),Wg=e=>{let o=De();return o.openDialog?.name!=="ttd"?null:$t(zM,{...e,tab:o.openDialog.tab})},zM=Kr("TTDDialogBase",({tab:e,...o})=>{let t=st(),r=Ie(),n=Vg(null),[i,a]=ve(BM),[l,s]=Gm(i?.prompt??""),c=l.trim(),m=S=>{s(S.target.value),a(_=>({generatedResponse:_?.generatedResponse??null,prompt:S.target.value}))},[d,p]=Gm(!1),[u,h]=ve(OM),b=async()=>{if(c.length>Ya||c.length<Yg||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<Yg&&C(new Error(`Prompt is too short (min ${Yg} characters)`)),c.length>Ya&&C(new Error(`Prompt is too long (max ${Ya} characters)`));return}try{p(!0),xe("ai","generate","ttd");let{generatedResponse:S,error:_,rateLimit:L,rateLimitRemaining:N}=await o.onTextSubmit(c);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),pp(L)&&pp(N)&&h({rateLimit:L,rateLimitRemaining:N}),_){C(_);return}if(!S){C(new Error("Generation failed"));return}try{await zm({canvasRef:n,data:y,mermaidToExcalidrawLib:E,setError:C,mermaidDefinition:S}),xe("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
17
+ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let _=S.message;(!_||_==="Failed to fetch")&&(_="Request failed"),C(new Error(_))}finally{p(!1)}},x=Vg(b);x.current=b;let[E,w]=Gm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});NM(()=>{(async()=>{await E.api,w(_=>({..._,loaded:!0}))})()},[E.api]);let y=Vg({elements:[],files:null}),[v,C]=Gm(null);return $t(dt,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Dn(C3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?$t("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Dn(Gg,{children:[$t(Hm,{tab:"text-to-diagram",children:Dn("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),$t("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),$t(Hm,{tab:"mermaid",children:"Mermaid"})]}),$t(Um,{className:"ttd-dialog-content",tab:"mermaid",children:$t(y3,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&Dn(Um,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[$t("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Dn(Om,{children:[$t(Va,{label:f("labels.prompt"),panelAction:{action:b,label:"Generate",icon:da},onTextSubmitInProgess:d,panelActionDisabled:c.length>Ya||u?.rateLimitRemaining===0,renderTopRight:()=>u?Dn("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>$t(Bm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Dn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(gs(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",$t(vn,{icon:da})]});let S=c.length/Ya;return S>.8?Dn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Ya]}):null},children:$t(Pm,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),$t(Va,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Fm({app:t,data:y})},label:"Insert",icon:da},children:$t(Nm,{canvasRef:n,error:v,loaded:E.loaded})})]})]})]})})});import ML from"clsx";import LL from"lodash.throttle";import{useEffect as G3,useMemo as qg,useState as AL,memo as _L}from"react";import FM from"clsx";import{useEffect as A3,useRef as Ym,useState as HM}from"react";var L3=.01,so=(e,o)=>!(o==="height"&&Z(e)||o==="width"&&Z(e)||o==="angle"&&ne(e)),je=(e,o)=>{let t=e+o/2;return t-t%o},Wa=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Si=(e,o,t,r,n,i,a,l=!0)=>{let s=r.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[d,p]=ce(M(t.x,t.y),M(c,m),t.angle),u=e-d,h=o-p,[b,x]=ce(M(e,o),M(c+u,m+h),-t.angle);B(s,{x:b,y:x},l),Vm(s,r,n,i);let E=ge(t,a);if(E){let w=r.get(E.id);w&&B(w,{x:E.x+u,y:E.y+h},l)}},Ka=(e,o)=>{let r=Wo(o).map(n=>Ge(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!lr(n)).forEach(n=>{r.push({[n.id]:!0})}),r},Vm=(e,o,t,r,n)=>{ae(e)?Jn([e],o,t,r,!0,[],n?.zoom):at(e,o,n)};import{jsx as Kg,jsxs as GM}from"react/jsx-runtime";var UM=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=st(),p=Ym(null),u=Ym(null),[h,b]=HM(r.toString()),x=Ym(null);x.current||(x.current={originalAppState:oo(c),originalElements:n,lastUpdatedValue:h,updatePending:!1}),A3(()=>{let y=r.toString();b(y),x.current.lastUpdatedValue=y},[r]);let E=(y,v,C)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let S=Number(y);if(isNaN(S)){b(r.toString());return}let _=Number(S.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(_-L)>=L3)&&(x.current.lastUpdatedValue=y,t({accumulatedChange:0,instantChange:0,originalElements:v,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:l,originalAppState:C,setInputValue:N=>b(String(N))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},w=Ym({});return w.current.handleInputValue=E,A3(()=>{let y=p.current,v=w.current;return()=>{let C=y?.value;C&&v.handleInputValue?.(C,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?GM("div",{className:FM("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Kg("div",{className:"drag-input-label",ref:u,onPointerDown:y=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let v=Number(p.current.value);isNaN(v)&&(v=0);let C=null,S=d.scene.getNonDeletedElements().reduce((U,q)=>(U.set(q.id,uo(q)),U),new Map),_=n.map(U=>S.get(U.id)),L=oo(c),N=0,P=0,F=U=>{if(C&&S!==null&&_!==null){let q=U.clientX-C.x;q!==0&&(P+=q,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),N+=P,t({accumulatedChange:N,instantChange:P,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:U.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:H=>b(String(H))}),P=0))}C={x:U.clientX,y:U.clientY}},K=()=>{window.removeEventListener("pointermove",F,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),C=null,N=0,P=0,_=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",K,!1)};w.current.onPointerMove=F,w.current.onPointerUp=K,window.addEventListener("pointermove",F,!1),window.addEventListener("pointerup",K,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:o?Kg(vn,{icon:o}):e}),Kg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let v=y.target;v instanceof HTMLInputElement&&y.key===T.ENTER&&(E(v.value,n,c),d.focusContainer())}},ref:p,value:h,onChange:y=>{x.current.updatePending=!0,b(y.target.value)},onFocus:y=>{y.target.select(),x.current.originalElements=n,x.current.originalAppState=oo(c)},onBlur:y=>{h?i&&E(y.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},It=UM;import{jsx as KM}from"react/jsx-runtime";var VM=15,YM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),l=o[0];if(l&&!ee(l)){let s=i.get(l.id);if(!s)return;if(r!==void 0){let h=_i(r);B(s,{angle:h}),Vm(s,i,a,n);let b=ge(s,i);b&&!Re(s)&&B(b,{angle:h});return}let c=Math.round(Di(l.angle)*100)/100,m=Math.round(e),d=(c+m)%360;t&&(d=je(d,VM)),d=d<0?d+360:d;let p=_i(d);B(s,{angle:p}),Vm(s,i,a,n);let u=ge(s,i);u&&!Re(s)&&B(u,{angle:p})}},WM=({element:e,scene:o,appState:t,property:r})=>KM(It,{label:"A",icon:qc,value:Math.round(Di(e.angle)%360*100)/100,elements:[e],dragInputCallback:YM,editable:so(e,"angle"),scene:o,appState:t,property:r}),_3=WM;import{jsx as XM}from"react/jsx-runtime";var D3=5,ZM=({property:e,scene:o,appState:t,setAppState:r})=>XM(It,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let c;return n?c=n:i&&(c=a?je(s.gridStep+D3*Math.sign(i),D3):s.gridStep+i),c?(c=o0(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),P3=ZM;import{jsx as JM}from"react/jsx-runtime";var R3=10,$M=e=>e.type==="image",jM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c})=>{let m=c.getNonDeletedElementsMap(),d=o[0],p=m.get(d.id);if(d&&p){let u=r||$M(d),h=d.width/d.height;if(l.croppingElementId===d.id){let y=m.get(d.id);if(!y||!he(y)||!y.crop)return;let v=y.crop,C={...v},S=y.scale[0]===-1,_=y.scale[1]===-1,{width:L,height:N}=ri(y),P=v.naturalWidth/L,F=v.naturalHeight/N,K=S?v.width+v.x:v.naturalWidth-v.x,U=_?v.height+v.y:v.naturalHeight-v.y,q=Hp*P,H=Hp*F;if(i!==void 0){if(a==="width"){let se=i*P,be=wt(se,q,K);C={...C,width:be,x:S?v.x+v.width-be:v.x}}else if(a==="height"){let se=i*F,be=wt(se,H,U);C={...C,height:be,y:_?v.y+v.height-be:v.y}}B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}let G=a==="width"?s:0,V=a==="height"?s:0,ie=wt(v.width+G,q,K),$=wt(v.height+V,q,U);C={...v,x:S?v.x+v.width-ie:v.x,y:_?v.y+v.height-$:v.y,width:ie,height:$},B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*h:d.width,to),v=Math.max(a==="height"?i:u?i/h:d.height,to);di(y,v,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let b=a==="width"?e:0,x=a==="height"?e:0,E=Math.max(0,d.width+b);a==="width"&&(n?E=je(E,R3):E=Math.round(E));let w=Math.max(0,d.height+x);a==="height"&&(n?w=je(w,R3):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/h*100)/100:E=Math.round(w*h*100)/100),w=Math.max(to,w),E=Math.max(to,E),di(E,w,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},qM=({property:e,element:o,scene:t,appState:r})=>{let n=So(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&he(o)&&o.crop){let{width:i,height:a}=ri(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=So(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=So(o.crop.height*l,2)}}return JM(It,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:jM,value:n,editable:so(o,e),scene:t,appState:r,property:e})},Zg=qM;import{jsx as oL}from"react/jsx-runtime";var N3=4,QM=4,eL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!Z(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),N3);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,N3),t&&(s=je(s,QM))}s&&(B(l,{fontSize:s}),Qe(l,n.getContainerElement(l),n.getNonDeletedElementsMap()))}},tL=({element:e,scene:o,appState:t,property:r})=>{let n=Z(e)?e:Tt(e)?ge(e,o.getNonDeletedElementsMap()):null;return n?oL(It,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:eL,icon:ui,appState:t,scene:o,property:r}):null},O3=tL;import{jsx as aL}from"react/jsx-runtime";var rL=15,nL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!lr(c)&&so(c,n)),s=o.filter(c=>!lr(c)&&so(c,n));if(r!==void 0){let c=_i(r);for(let m of l){if(!m)continue;B(m,{angle:c},!1);let d=ge(m,a);d&&!Re(m)&&B(d,{angle:c},!1)}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let d=s[c],p=Math.round(Di(d.angle)*100)/100,u=Math.round(e),h=(p+u)%360;t&&(h=je(h,rL)),h=h<0?h+360:h;let b=_i(h);B(m,{angle:b},!1);let x=ge(m,a);x&&!Re(m)&&B(x,{angle:b},!1)}i.triggerUpdate()},iL=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!lr(s)&&so(s,"angle")),i=n.map(s=>Math.round(Di(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>so(s,"angle"));return aL(It,{label:"A",icon:qc,value:a,elements:e,dragInputCallback:nL,editable:l,appState:t,scene:o,property:r})},B3=iL;import{useMemo as lL}from"react";import{jsx as pL}from"react/jsx-runtime";var Za=10,sL=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...Bc(r,a,l,!1),...Z(r)?{fontSize:r.fontSize*t}:{}}},cL=(e,o,t,r,n,i,a,l)=>{let s=sL(e,o,r,i);B(n,s,!1);let c=ge(i,l);if(c){let m=c.fontSize*r;at(n,a,{newSize:{width:s.width,height:s.height}});let d=a.get(c.id);d&&Z(d)&&(B(d,{fontSize:m},!1),hl(n,a,t==="width"?"e":"s",!0))}},z3=(e,o,t,r,n,i,a,l,s,c)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];cL(n[0],n[1],i,m,u,p,s,c)}},dL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=Ka(o,r);if(i!==void 0){for(let p of c){let u=Wa(p,s,t);if(u.length>1){let h=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,C=y-E,S=v/C,_=Math.max(to,l==="width"?Math.max(0,i):v),L=Math.max(to,l==="height"?Math.max(0,i):C);z3(_,L,C,S,M(x,E),l,h,b,s,t)}else{let[h]=u,b=h?.latest,x=h?.original;if(b&&x&&so(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=je(E,Za):E=Math.round(E));let w=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?w=je(w,Za):w=Math.round(w)),E=Math.max(to,E),w=Math.max(to,w),di(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate();return}let m=l==="width"?e:0,d=l==="height"?e:0;for(let p of c){let u=Wa(p,s,t);if(u.length>1){let h=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,C=y-E,S=v/C,_=Math.max(0,v+m);l==="width"&&(n?_=je(_,Za):_=Math.round(_));let L=Math.max(0,C+d);l==="height"&&(n?L=je(L,Za):L=Math.round(L)),_=Math.max(to,_),L=Math.max(to,L),z3(_,L,C,S,M(x,E),l,h,b,s,t)}else{let[h]=u,b=h?.latest,x=h?.original;if(b&&x&&so(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=je(E,Za):E=Math.round(E));let w=Math.max(0,x.height+d);l==="height"&&(n?w=je(w,Za):w=Math.round(w)),E=Math.max(to,E),w=Math.max(to,w),di(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},mL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=lL(()=>r.map(c=>{let m=Wa(c,t);if(m.length>1){let[p,u,h,b]=ye(m.map(x=>x.latest));return Math.round((e==="width"?h-p:b-u)*100)/100}let[d]=m;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return pL(It,{label:e==="width"?"W":"H",elements:o,dragInputCallback:dL,value:l,editable:s,appState:i,property:e,scene:n})},Xg=mL;import{jsx as bL}from"react/jsx-runtime";var F3=4,uL=4,hL=(e,o)=>e.reduce((t,r)=>{if(!r||lr(r))return t;if(Z(r))return t.push(r),t;if(Tt(r)){let n=ge(r,o);if(n)return t.push(n),t}return t},[]),gL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),F3);for(let s of a)B(s,{fontSize:l},!1),Qe(s,n.getContainerElement(s),i,!1);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),h=Math.max(p+u,F3);t&&(h=je(h,uL)),B(m,{fontSize:h},!1),Qe(m,n.getContainerElement(m),i,!1)}n.triggerUpdate()}},fL=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=hL(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return bL(It,{label:"F",icon:ui,elements:i,dragInputCallback:gL,value:l,editable:s,scene:o,property:r,appState:t})},H3=fL;import{useMemo as xL}from"react";import{jsx as CL}from"react/jsx-runtime";var EL=10,yL=(e,o,t,r,n,i,a,l)=>{for(let s=0;s<r.length;s++){let c=n[s],[m,d]=[c.x+c.width/2,c.y+c.height/2],[p,u]=ce(M(c.x,c.y),M(m,d),c.angle),h=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(u+t):u;Si(h,b,c,i,r,l,a,!1)}},vL=(e,o,t,r,n,i,a)=>{let[l,s,,]=ye(t),c=e-l,m=o-s;for(let d=0;d<t.length;d++){let p=t[d],u=r.get(p.id);if(u&&(!Z(u)||!u.containerId)){let[h,b]=[u.x+u.width/2,u.y+u.height/2],[x,E]=ce(M(u.x,u.y),M(h,b),u.angle);Si(x+c,E+m,p,r,n,a,i,!1)}}},wL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of Ka(o,l)){let h=Wa(u,s,t);if(h.length>1){let[b,x,,]=ye(h.map(y=>y.latest));vL(i==="x"?n:b,i==="y"?n:x,h.map(y=>y.original),s,c,t,a)}else{let b=h[0]?.original,x=h[0]?.latest;if(b&&x&&so(x,i)){let[E,w]=[b.x+b.width/2,b.y+b.height/2],[y,v]=ce(M(b.x,b.y),M(E,w),b.angle);Si(i==="x"?n:y,i==="y"?n:v,b,s,c,a,t,!1)}}}a.triggerUpdate();return}let m=r?je(e,EL):e;yL(i,i==="x"?m:0,i==="y"?m:0,o,o,s,t,a),a.triggerUpdate()},TL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=xL(()=>r.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=ye(c);return Math.round((e==="x"?b:x)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,h]=ce(M(m.x,m.y),M(d,p),m.angle);return Math.round((e==="x"?u:h)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return CL(It,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:wL,value:l,property:e,scene:n,appState:i})},$g=TL;import{jsx as kL}from"react/jsx-runtime";var U3=10,IL=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=l.getNonDeletedElements(),d=t[0],[p,u]=[d.x+d.width/2,d.y+d.height/2],[h,b]=ce(M(d.x,d.y),M(p,u),d.angle);if(s.croppingElementId===d.id){let v=c.get(d.id);if(!v||!he(v)||!v.crop)return;let C=v.crop,S=C,_=v.scale[0]===-1,L=v.scale[1]===-1,{width:N,height:P}=ri(v);if(i!==void 0){if(a==="x"){let U=i*(C.naturalWidth/N);_?S={...C,x:wt(C.naturalWidth-U-C.width,0,C.naturalWidth-C.width)}:S={...C,x:wt(i*(C.naturalWidth/N),0,C.naturalWidth-C.width)}}a==="y"&&(S={...C,y:wt(i*(C.naturalHeight/P),0,C.naturalHeight-C.height)}),B(v,{crop:S});return}let F=(a==="x"?o:0)*(_?-1:1),K=(a==="y"?o:0)*(L?-1:1);S={...C,x:wt(C.x+F,0,C.naturalWidth-C.width),y:wt(C.y+K,0,C.naturalHeight-C.height)},B(v,{crop:S});return}if(i!==void 0){Si(a==="x"?i:h,a==="y"?i:b,d,c,m,l,r);return}let x=a==="x"?e:0,E=a==="y"?e:0,w=a==="x"?Math.round(n?je(d.x+x,U3):h+x):h,y=a==="y"?Math.round(n?je(d.y+E,U3):b+E):b;Si(w,y,d,c,m,l,r)},SL=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=ce(M(o.x,o.y),M(o.x+o.width/2,o.y+o.height/2),o.angle),l=So(e==="x"?i:a,2);if(n.croppingElementId===o.id&&he(o)&&o.crop){let s=zb(o);s&&(l=So(e==="x"?s.x:s.y,2))}return kL(It,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:IL,scene:r,value:l,property:e,appState:n})},jg=SL;import{Fragment as Jg,jsx as le,jsxs as co}from"react/jsx-runtime";var DL=50,fs=e=>{let o=pr(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Sn(e.app);return le(PL,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ze=({children:e,columns:o=1,heading:t,style:r,...n})=>le("div",{className:ML("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ze.displayName="StatsRow";var Wm=({children:e,order:o,style:t,...r})=>le("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Wm.displayName="StatsRows";fs.StatsRow=Ze;fs.StatsRows=Wm;var PL=_L(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=Ie(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&he(d),h=u?ri(d):null,[b,x]=AL({width:0,height:0}),E=qg(()=>LL(v=>{let C=ye(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},DL),[]);G3(()=>{E(s)},[i,s,E]),G3(()=>()=>E.cancel(),[E]);let w=qg(()=>Ka(r,n),[r,n]),y=qg(()=>mc(r),[r]);return le("div",{className:"exc-stats",children:co(Et,{padding:3,children:[co("div",{className:"title",children:[le("h2",{children:f("stats.title")}),le("div",{className:"close",onClick:o,children:Mo})]}),co(Zl,{label:le("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&il.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.generalStats}})),children:[co(Wm,{children:[le(Ze,{heading:!0,children:f("stats.scene")}),co(Ze,{columns:2,children:[le("div",{children:f("stats.shapes")}),le("div",{children:s.length})]}),co(Ze,{columns:2,children:[le("div",{children:f("stats.width")}),le("div",{children:b.width})]}),co(Ze,{columns:2,children:[le("div",{children:f("stats.height")}),le("div",{children:b.height})]}),a&&co(Jg,{children:[le(Ze,{heading:!0,children:"Canvas"}),le(Ze,{children:le(P3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&le("div",{id:"elementStats",style:{marginTop:12},children:le(Zl,{label:le("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&il.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.elementProperties}})),children:co(Wm,{children:[d&&co(Jg,{children:[u&&le(Ze,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&he(d)&&h&&co(Ze,{columns:2,children:[le("div",{children:f("stats.width")}),le("div",{children:So(h.width,2)})]}),n.croppingElementId&&he(d)&&h&&co(Ze,{columns:2,children:[le("div",{children:f("stats.height")}),le("div",{children:So(h.height,2)})]}),le(Ze,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),le(Ze,{children:le(jg,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),le(Ze,{children:le(jg,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),le(Ze,{children:le(Zg,{property:"width",element:d,scene:l,appState:n})}),le(Ze,{children:le(Zg,{property:"height",element:d,scene:l,appState:n})}),!ee(d)&&le(Ze,{children:le(_3,{property:"angle",element:d,scene:l,appState:n})}),le(Ze,{children:le(O3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&co(Jg,{children:[Db(p)&&le(Ze,{heading:!0,children:f("element.group")}),co(Ze,{columns:2,style:{margin:"0.3125rem 0"},children:[le("div",{children:f("stats.shapes")}),le("div",{children:r.length})]}),le(Ze,{children:le($g,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le($g,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(Xg,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(Xg,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(B3,{property:"angle",elements:p,scene:l,appState:n})}),le(Ze,{children:le(H3,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as RL,useEffect as V3,useState as Y3}from"react";import{jsx as Xa,jsxs as Km}from"react/jsx-runtime";var NL=({sourceElementId:e,onClose:o,elementsMap:t,appState:r,generateLinkForSelection:n=Ec})=>{let i=t.get(e)?.link??null,[a,l]=Y3(i),[s,c]=Y3(!1);V3(()=>{let d=J(t,r),p=i;if(d.length>0&&n){let u=yc(d,r);u&&(p=Vo(n(u.id,u.type)))}l(p)},[t,r,r.selectedElementIds,i,n]);let m=RL(()=>{if(a&&a!==t.get(e)?.link){let d=t.get(e);d&&B(d,{link:a})}if(!a&&s&&e){let d=t.get(e);d&&B(d,{link:null})}o?.()},[e,a,t,s,o]);return V3(()=>{let d=p=>{r.openDialog?.name==="elementLinkSelector"&&p.key===T.ENTER&&m(),r.openDialog?.name==="elementLinkSelector"&&p.key===T.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[r,o,m]),Km("div",{className:"ElementLinkDialog",children:[Km("div",{className:"ElementLinkDialog__header",children:[Xa("h2",{children:f("elementLink.title")}),Xa("p",{children:f("elementLink.desc")})]}),Km("div",{className:"ElementLinkDialog__input",children:[Xa(Ba,{value:a??"",onChange:d=>{s||c(!0),l(d)},onKeyDown:d=>{d.key===T.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),i&&a&&Xa(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),c(!0)},className:"ElementLinkDialog__remove",icon:ho})]}),Km("div",{className:"ElementLinkDialog__actions",children:[Xa(Hr,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Xa(Hr,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},W3=NL;import OL,{useState as BL}from"react";import{Fragment as zL,jsx as Qg}from"react/jsx-runtime";var K3=({children:e,onClose:o})=>{let[t,r]=BL(!!e),{container:n}=ht(),i=OL.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Qg(zL,{children:t&&Qg(dt,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:Qg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import FL from"react";import{Fragment as X3,jsx as Y,jsxs as To}from"react/jsx-runtime";var HL=()=>To("div",{className:"HelpDialog__header",children:[To("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:bu}),f("helpDialog.documentation")]}),To("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:bu}),f("helpDialog.blog")]}),To("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:Kc}),f("helpDialog.github")]}),To("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:IE}),"YouTube"]})]}),UL=e=>To(X3,{children:[Y("h3",{children:e.title}),Y("div",{className:"HelpDialog__islands-container",children:e.children})]}),ef=e=>To("div",{className:`HelpDialog__island ${e.className}`,children:[Y("h4",{className:"HelpDialog__island-title",children:e.caption}),Y("div",{className:"HelpDialog__island-content",children:e.children})]});function*GL(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var VL=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),X=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>Y(YL,{children:VL(a)},a)));return To("div",{className:"HelpDialog__shortcut",children:[Y("div",{children:e}),Y("div",{className:"HelpDialog__key-container",children:[...GL(r,t?f("helpDialog.or"):null)]})]})},YL=e=>Y("kbd",{className:"HelpDialog__key",...e}),Z3=({onClose:e})=>{let o=FL.useCallback(()=>{e&&e()},[e]);return Y(X3,{children:To(dt,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",children:[Y(HL,{}),To(UL,{title:f("helpDialog.shortcuts"),children:[To(ef,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Y(X,{label:f("toolBar.hand"),shortcuts:[T.H]}),Y(X,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),Y(X,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),Y(X,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),Y(X,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),Y(X,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),Y(X,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),Y(X,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),Y(X,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),Y(X,{label:f("toolBar.image"),shortcuts:[T[9]]}),Y(X,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),Y(X,{label:f("toolBar.frame"),shortcuts:[T.F]}),Y(X,{label:f("toolBar.laser"),shortcuts:[T.K]}),Y(X,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),Y(X,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),Y(X,{label:f("helpDialog.editText"),shortcuts:[R("Enter")]}),Y(X,{label:f("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),Y(X,{label:f("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),Y(X,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(X,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(X,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),R("Enter")],isOr:!0}),Y(X,{label:f("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),Y(X,{label:f("toolBar.lock"),shortcuts:[T.Q]}),Y(X,{label:f("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),Y(X,{label:f("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),To(ef,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Y(X,{label:f("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),Y(X,{label:f("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),Y(X,{label:f("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),Y(X,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),Y(X,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),Y(X,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Y(X,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Y(X,{label:f("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),Y(X,{label:f("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),Y(X,{label:f("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),Y(X,{label:f("labels.viewMode"),shortcuts:[R("Alt+R")]}),Y(X,{label:f("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),Y(X,{label:f("stats.fullTitle"),shortcuts:[R("Alt+/")]}),Y(X,{label:f("search.title"),shortcuts:[ct("searchMenu")]}),Y(X,{label:f("commandPalette.title"),shortcuts:Tr?[ct("commandPalette")]:[ct("commandPalette"),ct("commandPalette",1)]})]}),To(ef,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Y(X,{label:f("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),Y(X,{label:f("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),Y(X,{label:f("labels.moveCanvas"),shortcuts:[R(`Space+${f("helpDialog.drag")}`),R(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Y(X,{label:f("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),Y(X,{label:f("labels.delete"),shortcuts:[R("Delete")]}),Y(X,{label:f("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),Y(X,{label:f("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),Y(X,{label:f("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),Y(X,{label:f("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),Y(X,{label:f("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),Y(X,{label:f("labels.multiSelect"),shortcuts:[R(`Shift+${f("helpDialog.click")}`)]}),Y(X,{label:f("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Y(X,{label:f("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(va||Tr)&&Y(X,{label:f("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),Y(X,{label:f("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),Y(X,{label:f("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),Y(X,{label:f("labels.sendToBack"),shortcuts:[Ho?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),Y(X,{label:f("labels.bringToFront"),shortcuts:[Ho?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),Y(X,{label:f("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),Y(X,{label:f("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),Y(X,{label:f("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),Y(X,{label:f("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),Y(X,{label:f("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),Y(X,{label:f("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),Y(X,{label:f("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)]}),Y(X,{label:f("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),Y(X,{label:f("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),Y(X,{label:f("buttons.redo"),shortcuts:_s?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),Y(X,{label:f("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),Y(X,{label:f("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),Y(X,{label:f("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),Y(X,{label:f("labels.flipVertical"),shortcuts:[R("Shift+V")]}),Y(X,{label:f("labels.showStroke"),shortcuts:[R("S")]}),Y(X,{label:f("labels.showBackground"),shortcuts:[R("G")]}),Y(X,{label:f("labels.showFonts"),shortcuts:[R("Shift+F")]}),Y(X,{label:f("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),Y(X,{label:f("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as q3,useRef as jL,useState as Pn}from"react";import{useCallback as WL,useRef as KL,useState as ZL}from"react";var XL=2e3,$3=()=>{let[e,o]=ZL(null),t=KL(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},XL)},n=WL(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import $L from"clsx";import{jsx as j3}from"react/jsx-runtime";var bs=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>j3("div",{className:$L("Switch",{toggled:t,disabled:n}),children:j3("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Xe,jsxs as Rn}from"react/jsx-runtime";var qL="filter"in document.createElement("canvas").getContext("2d"),JL=()=>Rn("div",{children:[Xe("h3",{children:f("canvasError.cannotShowPreview")}),Xe("p",{children:Xe("span",{children:f("canvasError.canvasTooBig")})}),Rn("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),QL=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=ze(o,e),[l,s]=Pn(i),[c,m]=Pn(a),[d,p]=Pn(e.exportBackground),[u,h]=Pn(e.exportWithDarkMode),[b,x]=Pn(e.exportEmbedScene),[E,w]=Pn(e.exportScale),y=jL(null),[v,C]=Pn(null),{onCopy:S,copyStatus:_,resetCopyStatus:L}=$3();q3(()=>{L()},[l,d,u,E,b,L]);let{exportedElements:N,exportingFrame:P}=xi(o,e,c);return q3(()=>{let F=y.current;if(!F)return;let K=F.offsetWidth,U=F.offsetHeight;K&&Tn({elements:N,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:Qr,maxWidthOrHeight:Math.max(K,U),exportingFrame:P}).then(q=>(C(null),Rr(q).then(()=>{F.replaceChildren(q)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}))).catch(q=>{console.error(q),C(q)})},[e,t,N,P,l,d,u,E,b]),Rn("div",{className:"ImageExportModal",children:[Xe("h3",{children:f("imageExportDialog.header")}),Rn("div",{className:"ImageExportModal__preview",children:[Xe("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Xe(JL,{})}),Xe("div",{className:"ImageExportModal__preview__filename",children:!Qi&&Xe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:F=>{s(F.target.value),r.executeAction(bh,"ui",F.target.value)}})})]}),Rn("div",{className:"ImageExportModal__settings",children:[Xe("h3",{children:f("imageExportDialog.header")}),a&&Xe(xs,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Xe(bs,{name:"exportOnlySelected",checked:c,onChange:F=>{m(F)}})}),Xe(xs,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Xe(bs,{name:"exportBackgroundSwitch",checked:d,onChange:F=>{p(F),r.executeAction(xh,"ui",F)}})}),qL&&Xe(xs,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Xe(bs,{name:"exportDarkModeSwitch",checked:u,onChange:F=>{h(F),r.executeAction(Jy,"ui",F)}})}),Xe(xs,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Xe(bs,{name:"exportEmbedSwitch",checked:b,onChange:F=>{x(F),r.executeAction(Dd,"ui",F)}})}),Xe(xs,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Xe(km,{name:"exportScale",value:E,onChange:F=>{w(F),r.executeAction(qy,"ui",F)},choices:Hs.map(F=>({value:F,label:`${F}\xD7`}))})}),Rn("div",{className:"ImageExportModal__settings__buttons",children:[Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(Bs.png,N,{exportingFrame:P}),icon:Pu,children:f("imageExportDialog.button.exportToPng")}),Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(Bs.svg,N,{exportingFrame:P}),icon:Pu,children:f("imageExportDialog.button.exportToSvg")}),(va||Tr)&&Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:_,onClick:async()=>{await n(Bs.clipboard,N,{exportingFrame:P}),S()},icon:ca,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},xs=({label:e,children:o,tooltip:t,name:r})=>Rn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Rn("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Xe(bo,{label:t,long:!0,children:nE})]}),Xe("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),J3=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Pn(()=>({appStateSnapshot:oo(o),elementsSnapshot:oo(e)}));return Xe(dt,{onCloseRequest:i,size:"wide",title:!1,children:Xe(QL,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import t8 from"react";import tf from"open-color";import{jsx as e8}from"react/jsx-runtime";var of=({children:e,color:o})=>e8("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":tf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":tf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":tf[o][9]},children:e});import{Fragment as r8,jsx as Qo,jsxs as Zm}from"react/jsx-runtime";var o8=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Qo("div",{className:"ExportDialog ExportDialog--json",children:Zm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Zm(of,{color:"lime",children:[Qo("div",{className:"Card-icon",children:px}),Qo("h2",{children:f("exportDialog.disk_title")}),Zm("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Qi&&n.renderAction("changeProjectName")]}),Qo(Q,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Jl,"ui")}})]}),s&&Zm(of,{color:"pink",children:[Qo("div",{className:"Card-icon",children:Nl}),Qo("h2",{children:f("exportDialog.link_title")}),Qo("div",{className:"Card-details",children:f("exportDialog.link_details")}),Qo(Q,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{xe("export","link",`ui (${M1()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},Q3=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=t8.useCallback(()=>{a({openDialog:null})},[a]);return Qo(r8,{children:o.openDialog?.name==="jsonExport"&&Qo(dt,{onCloseRequest:l,title:f("buttons.export"),children:Qo(o8,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import n8 from"clsx";import{jsx as e5,jsxs as a8}from"react/jsx-runtime";var i8="small",t5=e=>a8("label",{className:n8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${i8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[e5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),e5("div",{className:"ToolIcon__icon",children:zl})]});import{Fragment as r5,jsx as oe,jsxs as Co}from"react/jsx-runtime";var s8=({UIOptions:e})=>Co(Ot,{__fallback:!0,children:[oe(Ot.DefaultItems.LoadScene,{}),oe(Ot.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&oe(Ot.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&oe(Ot.DefaultItems.SaveAsImage,{}),oe(Ot.DefaultItems.SearchMenu,{}),oe(Ot.DefaultItems.Help,{}),oe(Ot.DefaultItems.ClearCanvas,{}),oe(Ot.Separator,{}),oe(Ot.Group,{title:"Excalidraw links",children:oe(Ot.DefaultItems.Socials,{})}),oe(Ot.Separator,{}),oe(Ot.DefaultItems.ToggleTheme,{}),oe(Ot.DefaultItems.ChangeCanvasBackground,{})]}),c8=()=>Co(_m,{__fallback:!0,children:[oe(_m.Actions.SaveToDisk,{}),oe(_m.Actions.ExportToImage,{})]}),d8=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:b,app:x,isCollaborating:E,generateLinkForSelection:w})=>{let y=Ce(),v=fv(),C=v.tunnelsJotai.Provider,[S,_]=ve(bn),L=()=>p.canvasActions.export?oe(Q3,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,N=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:oe(J3,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Co("div",{style:{position:"relative"},children:[oe(v.MainMenuTunnel.Out,{}),h&&oe(v.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>oe(Mn,{heading:"selectedShapeActions",className:Es("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:oe(Et,{className:Uo.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:oe(rm,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),K=()=>{let G=Ta(o,n),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return oe(xm,{side:"top",children:Co("div",{className:"App-menu App-menu_top",children:[Co(Ct.Col,{gap:6,className:Es("App-menu_top__left"),children:[P(),G&&F()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&oe(Mn,{heading:"shapes",className:"shapes-section",children:ie=>Co("div",{style:{position:"relative"},children:[h&&oe(v.WelcomeScreenToolbarHintTunnel.Out,{}),oe(Ct.Col,{gap:4,align:"start",children:Co(Ct.Row,{gap:1,className:Es("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Co(Et,{padding:1,className:Es("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[oe(ym,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),ie,Co(Ct.Row,{gap:1,children:[oe(vm,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),oe(bm,{checked:o.activeTool.locked,onChange:a,title:f("toolBar.lock")}),oe("div",{className:"App-toolbar__divider"}),oe(Em,{checked:Ko(o),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),oe(nm,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),E&&oe(Et,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:oe(t5,{title:f("toolBar.laser"),checked:o.activeTool.type===it.laser,onChange:()=>x.setActiveTool({type:it.laser}),isMobile:!0})})]})})]})}),Co("div",{className:Es("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&oe(Cm,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!q||o.openSidebar?.name!==At.name)&&oe(v.DefaultSidebarTriggerTunnel.Out,{}),V&&oe(fs,{app:x,onClose:()=>{e.executeAction(La)},renderCustomStats:d})]})]})})},U=()=>oe(Dm,{__fallback:!0,onDock:G=>{xe("sidebar",`toggleDock (${G?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),q=zc(ms),H=Co(r5,{children:[b,oe(s8,{UIOptions:p}),oe(Dm.Trigger,{__fallback:!0,icon:ia,title:on(f("toolBar.library")),onToggle:G=>{G&&xe("sidebar",`${At.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:At.defaultTab,children:f("toolBar.library")}),oe(c8,{}),o.openDialog?.name==="ttd"&&oe(Wg,{__fallback:!0}),o.isLoading&&oe(fm,{delay:250}),o.errorMessage&&oe(K3,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&oe(XE,{colorPickerType:S.colorPickerType,onCancel:()=>{_(null)},onChange:(G,V,ie,{altKey:$})=>{if(!(G!=="elementBackground"&&G!=="elementStroke"))if(ie.length){for(let se of ie)B(se,{[$&&S.swapPreviewOnAlt?G==="elementBackground"?"strokeColor":"backgroundColor":G==="elementBackground"?"backgroundColor":"strokeColor"]:V},!1),pn.delete(se);dn.getScene(ie[0])?.triggerUpdate()}else r(G==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(G,V)=>{_(ie=>ie?.keepOpenOnAlt&&V.altKey?ie:null),S?.onSelect?.(G,V)}}),o.openDialog?.name==="help"&&oe(Z3,{onClose:()=>{r({openDialog:null})}}),oe(vv,{}),o.openDialog?.name==="elementLinkSelector"&&oe(W3,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:x.scene.getNonDeletedElementsMap(),appState:o,generateLinkForSelection:w}),oe(v.OverwriteConfirmDialogTunnel.Out,{}),N(),L(),o.pasteDialog.shown&&oe(ww,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&oe(yw,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:L,renderImageExportDialog:N,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:U,device:y,renderWelcomeScreen:h,UIOptions:p}),!y.editor.isMobile&&Co(r5,{children:[Co("div",{className:"layer-ui__wrapper",style:o.openSidebar&&q&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[h&&oe(v.WelcomeScreenCenterTunnel.Out,{}),K(),oe(Sw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),o.scrolledOutside&&oe("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(G=>({...ai(n,G)}))},children:f("buttons.scrollBackToContent")})]}),U()]})]});return oe(Ku.Provider,{value:o,children:oe(C,{children:oe(Qh.Provider,{value:v,children:H})})})},o5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},m8=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Je(o5(r),o5(a),{selectedElementIds:Je,selectedGroupIds:Je})&&Je(n,l)},n5=l8.memo(d8,m8);import p8 from"clsx";import{jsx as i5,jsxs as h8}from"react/jsx-runtime";var u8="small",Xm=e=>h8("label",{className:p8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${u8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[i5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),i5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as g8,useRef as f8}from"react";import{jsx as a5}from"react/jsx-runtime";var l5=({trails:e})=>{let o=f8(null);return g8(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),a5("div",{className:"SVGLayer",children:a5("svg",{ref:o})})};import b8,{useEffect as x8,useRef as E8}from"react";import{jsx as w8}from"react/jsx-runtime";var y8=e=>{let o=E8(!1);return x8(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),r.set(c,zt({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";ow({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},Ha())}),w8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Se.GRAB:Se.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},s5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches}),v8=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements?!1:Je(s5(e.appState),s5(o.appState)),rf=b8.memo(y8,v8);import T8,{useEffect as C8,useRef as c5}from"react";import{jsx as k8}from"react/jsx-runtime";var I8=e=>{let o=c5(null),t=c5(!1);return C8(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),s0({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ha())}),k8("div",{className:"excalidraw__canvas-wrapper",ref:o})},d5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),S8=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:Je(d5(e.appState),d5(o.appState))&&Je(e.renderConfig,o.renderConfig),nf=T8.memo(I8,S8);import{useEffect as L8,useRef as A8}from"react";var m5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Ic(e,i),m=Sc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?Ub(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},M8=Pi(e=>{m5(e)},{trailing:!0}),p5=(e,o)=>{if(o){M8(e);return}m5(e)};import{jsx as D8}from"react/jsx-runtime";var _8=e=>{let o=A8(null);return L8(()=>{o.current&&p5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ha())}),D8("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},u5=_8;import{useCallback as P8,useEffect as R8,useRef as N8}from"react";import{jsx as h5,jsxs as B8}from"react/jsx-runtime";var O8=5e3,g5=({message:e,onClose:o,closable:t=!1,duration:r=O8,style:n})=>{let i=N8(0),a=r!==1/0,l=P8(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return R8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),B8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[h5("p",{className:"Toast__message",children:e}),t&&h5(Q,{icon:Mo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{Fragment as G8,jsx as Oe,jsxs as jm}from"react/jsx-runtime";var E5=wr.createContext(null),y5=wr.createContext(null),v5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},mf=wr.createContext(v5);mf.displayName="DeviceContext";var pf=wr.createContext({container:null,id:null});pf.displayName="ExcalidrawContainerContext";var uf=wr.createContext([]);uf.displayName="ExcalidrawElementsContext";var hf=wr.createContext({...dr(),width:0,height:0,offsetLeft:0,offsetTop:0});hf.displayName="ExcalidrawAppStateContext";var gf=wr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});gf.displayName="ExcalidrawSetAppStateContext";var ff=wr.createContext(null);ff.displayName="ExcalidrawActionManagerContext";var st=()=>On(E5),ur=()=>On(y5),Ce=()=>On(mf),ht=()=>On(pf),xn=()=>On(uf),pr=()=>On(hf),Ie=()=>On(gf),gt=()=>On(ff),ys=!1,af=0,Mi=!1,vs=!1,lf=!1,sf={horizontal:null,vertical:null},Nn=0,ws=!1,cf=new Map,$m=!1,b5=0,x5=!1,Ts=null,Le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},df=class e extends wr.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",v5);I(this,"excalidrawContainerRef",wr.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new Oc);I(this,"flowChartNavigator",new Nc);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new cm);I(this,"laserTrails",new um(this.animationFrameHandler,this));I(this,"eraserTrail",new Yr(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let i=Math.max(0,1-(performance.now()-t.pressure)/200),a=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(nr(a),nr(i))},fill:()=>this.state.theme===de.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"}));I(this,"lassoTrail",new gm(this.animationFrameHandler,this));I(this,"onChangeEmitter",new Pt);I(this,"onPointerDownEmitter",new Pt);I(this,"onPointerUpEmitter",new Pt);I(this,"onUserFollowEmitter",new Pt);I(this,"onScrollChangeEmitter",new Pt);I(this,"missingPointerEventCleanupEmitter",new Pt);I(this,"onRemoveEventListenersEmitter",new Pt);I(this,"getEffectiveGridSize",()=>Sn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),pn.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ft(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=qi(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Zn(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=$e({clientX:i.x,clientY:i.y},this.state),l=$e({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&B(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===de.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!El(r,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===r.id&&this.resetEditingFrame(r),null;let{x:n,y:i}=zt({sceneX:r.x,sceneY:r.y},this.state),a=6,l,s=vb(r);if(r.id===this.state.editingFrame){let c=s;l=Oe("input",{autoFocus:!0,value:c,onChange:m=>{B(r,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(r),onKeyDown:m=>{(m.key===T.ESCAPE||m.key===T.ENTER)&&this.resetEditingFrame(r)},style:{background:this.state.viewBackgroundColor,filter:t?Qf:"none",zIndex:2,border:"none",display:"block",padding:`${a}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${a}px, ${a}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-n-a}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else l=s;return Oe("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+Go.nameOffsetY-i+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:Go.nameFontSize,color:t?Go.nameColorDarkTheme:Go.nameColorLightTheme,lineHeight:Go.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Se.MOVE,pointerEvents:this.state.viewModeEnabled?Hn.disabled:Hn.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:l},r.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{xe("export",t,"ui");let i=await Ei(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Zs).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Mc(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?B(t,{customData:{generationData:void 0}},!1):B(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:it.magicframe}),xe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Js(t[0])&&t[0];if(!r&&t.some(i=>ne(i)||i.frameId)){this.setActiveTool({type:it.magicframe});return}xe("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ye(t),c=50;n=wl({...Go,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)B(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{St.set(bn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:A.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:A.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?te(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});I(this,"syncActionResult",tt(t=>{if(this.unmounted||t===!1)return;t.captureUpdate===A.NEVER?this.store.shouldUpdateSnapshot():t.captureUpdate===A.IMMEDIATELY&&this.store.shouldCaptureIncrement();let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||de.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&Dp(m)&&Z(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=t.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}!r&&t.captureUpdate!==A.EVENTUALLY&&this.scene.triggerUpdate()}));I(this,"onBlur",tt(()=>{Mi=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",tt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...dr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=ta(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...ai(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:A.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),ii(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<e1||r<o1&&t<t1);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Ri(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:r1,a=this.device.editor,l=Ri(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",tt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>pn.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),qa||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(sf=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",Vn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},qf));I(this,"onCut",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||rr(t.target)||(this.actionManager.executeAction(Nd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||rr(t.target)||(this.actionManager.executeAction(ka,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(Ds&&t.preventDefault(),!ys){ys=!0,clearTimeout(af),af=window.setTimeout(e.resetTapTwice,$f);return}if(ys&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),ys=!1,clearTimeout(af)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):Le.pointers.clear()});I(this,"pasteFromClipboard",tt(async t=>{let r=!!$m,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||rr(n)))return;let{x:l,y:s}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t?.clipboardData?.files[0],m=await Ad(t,r);if(!c&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let d=m.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(c=Qp(d))}}if(Lc(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:ke({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let d=m.programmaticAPI?Fa(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&iw(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:h,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Fa(h,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(h){console.warn(`parsing pasted text as mermaid definition failed: ${h.message}`)}}let d=_1(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>$b(u)).filter(u=>qi(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||ni(u)?.type==="video"));if(!$m&&p.length>0&&p.length===d.length){let u=[];for(let h of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Vo(h)});x&&u.push(x)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(h=>[h.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=jp(t.elements,null,void 0),[n,i,a,l]=ye(r),s=Yn(n,a)/2,c=Yn(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=$e({clientX:m,clientY:d},this.state),h=p-s,b=u-c,[x,E]=ut(h,b,this.getEffectiveGridSize()),{newElements:w}=li({type:"everything",elements:r.map(L=>te(L,{x:L.x+x-n,y:L.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,Ut(v,re(w));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let L=Eb(w,S);Wi(v,L,S,this.state)}this.scene.replaceAllElements(v),w.forEach(L=>{if(Z(L)&&Be(L)){let N=_t(L,this.scene.getElementsMapIncludingDeleted());Qe(L,N,this.scene.getElementsMapIncludingDeleted())}}),zf&&un.loadElementsFonts(w).then(L=>{this.fonts.onLoaded(L)}),t.files&&this.addMissingFiles(t.files),this.store.shouldCaptureIncrement();let _=pc(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&St.get(ms)?this.state.openSidebar:null,...lt({editingGroupId:null,selectedElementIds:_.reduce((L,N)=>(Be(N)||(L[N.id]=!0),L),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Nn&&this.resetContextMenuTimer(),Le.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||xe("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Fe(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Ny)});I(this,"zoomCanvas",t=>{this.setState({...Br({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:cr(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(ii(t)?s=Qb(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):ii(t)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Xl({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=ai(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,d=E1({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,h,b)=>{if(b==="zoom")return p*Math.pow(u/p,nr(h))},onStep:({scrollX:p,scrollY:u,zoom:h})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:h}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,Ja,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",tt(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ue.svg))try{let s=f0(Yp(x0(l.dataURL)),ue.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",tt(t=>{let r=Pr(t.elements??[]);if(t.captureUpdate&&t.captureUpdate!==A.EVENTUALLY){let n=this.store.snapshot.appState,i=this.store.snapshot.elements,a=t.appState?Object.assign({},n,t.appState):n,l=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),re(r)):i;t.captureUpdate===A.IMMEDIATELY?this.store.captureIncrement(l,a):t.captureUpdate===A.NEVER&&this.store.updateSnapshot(l,a)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",tt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Or().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"onKeyDown",tt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!vp(t.target)){if((t.key===T.ESCAPE||t.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&he(a[0])&&t.key===T.ENTER){this.startImageCropping(a[0]);return}if(t.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Un(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&$n(s[0])&&this.flowChartCreator.createNodes(s[0],this.scene.getNonDeletedElementsMap(),this.state,nu(t.key)),this.flowChartCreator.pendingNodes?.length&&!Vi(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=J(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),nu(t.key));if(c){this.setState(d=>({selectedElementIds:ke({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Vi([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[T.CTRL_OR_CMD]&&t.key===T.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:ct("commandPalette")})}),t.preventDefault();return}if(t[T.CTRL_OR_CMD]&&t.key.toLowerCase()===T.V&&($m=t.shiftKey,clearTimeout(b5),b5=window.setTimeout(()=>{$m=!1},100)),t[T.CTRL_OR_CMD]&&rr(t.target)&&(t.code===pe.MINUS||t.code===pe.EQUAL)){t.preventDefault();return}if(rr(t.target)&&t.key!==T.ESCAPE||Un(t.key)&&vp(t.target))return;if(t.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===T.E&&t.shiftKey&&t[T.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===T.PAGE_UP||t.key===T.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===T.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Un(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(ee),s=new Set;a.filter(ee).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),h=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||h}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?tp:this.getEffectiveGridSize())||(t.shiftKey?Uf:tp),m=0,d=0;t.key===T.ARROW_LEFT?m=-c:t.key===T.ARROW_RIGHT?m=c:t.key===T.ARROW_UP?d=-c:t.key===T.ARROW_DOWN&&(d=c),a.forEach(p=>{B(p,{x:p.x+m,y:p.y+d},!1),at(p,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:nc(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===T.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[T.CTRL_OR_CMD])ae(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.shouldCaptureIncrement(),ee(l)||this.setState({editingLinearElement:new j(l)}));else if(Z(l)||tb(l)){let s;Z(l)||(s=l);let c=oc(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),t.preventDefault();return}else ne(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=gv(t.key);a?(this.state.activeTool.type!==a&&xe("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===xt.sharp?xt.round:l.currentItemArrowType===xt.round?xt.elbow:xt.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===T.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===T.SPACE&&Le.pointers.size===0&&(Mi=!0,Me(this.interactiveCanvas,Se.GRAB),t.preventDefault()),(t.key===T.G||t.key===T.S)&&!t.altKey&&!t[T.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===T.G&&(mn(this.state.activeTool.type)||a.some(l=>mn(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===T.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[T.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===T.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>Z(l)||ge(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===T.K&&!t.altKey&&!t[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[T.CTRL_OR_CMD]&&(t.key===T.BACKSPACE||t.key===T.DELETE)&&St.set(Ci,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,i=t.key===T.I||r===T.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",tt(t=>{if(t.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Me(this.interactiveCanvas,Se.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?xo(this.interactiveCanvas):(Eo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Mi=!1),!t[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Un(t.key)&&(Jn(this.scene.getSelectedElements(this.state).filter(ae),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,qn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[T.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ke({[r.id]:!0},n)})),Vi([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Fe(this.state,t);n.type==="hand"?Me(this.interactiveCanvas,Se.GRAB):Mi||Eo(this.interactiveCanvas,{...this.state,activeTool:n}),b1(document.activeElement)&&this.focusContainer(),P1(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.shouldCaptureIncrement(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{Me(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{xo(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>Le.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${yp()}`);I(this,"onGestureStart",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),Le.initialScale=this.state.zoom.value}));I(this,"onGestureChange",tt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Le.initialScale;r&&this.setState(n=>({...Br({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:cr(r*t.scale)},n)}))}));I(this,"onGestureEnd",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),Le.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(ge(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Z(m[0])?c=m[0]:i?c=ge(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let d=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||Sr(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!Re(i)){let E=Qs(qe({fontSize:u,fontFamily:d}),p),w=ec(u,p),y=Math.max(i.height,w),v=Math.max(i.width,E);B(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let h=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Vt({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Qt.MIDDLE:rp,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?.angle??0,frameId:h?h.id:null});if(!c&&l&&i&&B(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=$e(t,this.state);if(r.length===1&&ae(r[0])){if(t[T.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!ee(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(r[0])});return}else if(this.state.selectedLinearElement&&ee(r[0])){let l=j.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.shouldCaptureIncrement(),j.deleteFixedSegment(r[0],s);let c=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}}if(r.length===1&&he(r[0])){this.startImageCropping(r[0]);return}if(xo(this.interactiveCanvas),Wo(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&Mb(l,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(c=>({...c,...lt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(xo(this.interactiveCanvas),!t[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Oi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(Tt(s)||!Wn(s.backgroundColor)||zi({x:n,y:i,element:s,shape:oi(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=oc(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}});I(this,"getElementLinkAtPosition",(t,r)=>{let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Cc(l,this.scene.getNonDeletedElementsMap(),this.state,M(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=tn(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Fn)return;let i=$e(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Cc(this.hitLinkElement,a,this.state,M(i.x,i.y),this.device.editor.isMobile),s=$e(this.lastPointerUpEvent,this.state),c=Cc(this.hitLinkElement,a,this.state,M(s.x,s.y),this.device.editor.isMobile);if(l&&c){Nh();let m=this.hitLinkElement.link;if(m){m=Vo(m);let d;if(this.props.onLinkOpen&&(d=Xs("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=js(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>Pp(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Le.pointers.has(t.pointerId)&&Le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Le.initialScale;if(Le.pointers.size===2&&Le.lastCenter&&r&&Le.initialDistance){let u=mg(Le.pointers),h=u.x-Le.lastCenter.x,b=u.y-Le.lastCenter.y;Le.lastCenter=u;let x=pg(Array.from(Le.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/Le.initialDistance,w=E?cr(r*E):this.state.zoom.value;this.setState(y=>{let v=Br({viewportX:u.x,viewportY:u.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(h/w),scrollY:v.scrollY+2*(b/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Le.lastCenter=Le.initialDistance=Le.initialScale=null;if(Mi||vs||lf||Ko(this.state))return;let i=fg(sf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?xo(this.interactiveCanvas):Eo(this.interactiveCanvas,this.state));let a=$e(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Yv(this.state.activeTool.type)){let{originOffset:u,snapLines:h}=Vv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(b=>{let x=Ni(b.snapLines,h),E=b.originSnapOffset?Ni(b.originSnapOffset,u):u;return b.snapLines===x&&b.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(u=>u.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let u=j.handlePointerMove(t,l,s,this,this.scene.getNonDeletedElementsMap());u&&u!==this.state.editingLinearElement&&ki(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):ki(()=>{this.setState({suggestedBindings:[]})})}if(R1(this.state.activeTool.type)){let{newElement:u}=this.state;Ar(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:h,y:b}=u,{points:x,lastCommittedPoint:E}=u,w=x[x.length-1];if(Eo(this.interactiveCanvas,this.state),w===E)tn(M(l-h,s-b),w)>=Ps?B(u,{points:[...x,M(l-h,s-b)]},!1):Me(this.interactiveCanvas,Se.POINTER);else if(x.length>2&&E&&tn(M(l-h,s-b),E)<Ps)Me(this.interactiveCanvas,Se.POINTER),B(u,{points:x.slice(0,-1)},!1);else{let[y,v]=ut(l,s,t[T.CTRL_OR_CMD]||ee(u)?null:this.getEffectiveGridSize()),[C,S]=u?.lastCommittedPoint??[0,0],_=y-h-C,L=v-b-S;Ws(t)&&({width:_,height:L}=Lp(C+h,S+b,y,v)),yl(x,this.state.zoom.value)&&Me(this.interactiveCanvas,Se.POINTER),B(u,{points:[...x.slice(0,-1),M(C+_,S+L)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&ee(d[0]))){let u=cu(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){Me(this.interactiveCanvas,mu(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=du(ye(d),l,s,this.state.zoom,t.pointerType,this.device);if(u){Me(this.interactiveCanvas,mu({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!no(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Me(this.interactiveCanvas,Se.POINTER),x2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Nh(),p&&(p.link||Ft(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Me(this.interactiveCanvas,Z(p)?Se.TEXT:Se.CROSSHAIR):this.state.viewModeEnabled?Me(this.interactiveCanvas,Se.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Me(this.interactiveCanvas,Se.AUTO):i?Me(this.interactiveCanvas,Se.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[T.CTRL_OR_CMD]?Me(this.interactiveCanvas,Se.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&Oi(p)&&this.isIframeLikeElementCenter(p,t,l,s)?(Me(this.interactiveCanvas,Se.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!ee(p)||!(p.startBinding||p.endBinding))&&(Me(this.interactiveCanvas,Se.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,lt({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r,n)=>{this.eraserTrail.addPointToPath(n.x,n.y);let i=!1,a=new Set,l=this.scene.getNonDeletedElements(),s=u=>{for(let h of u){if(h.locked)return;if(t.altKey?this.elementsPendingErasure.delete(h.id)&&(i=!0):this.elementsPendingErasure.has(h.id)||(i=!0,this.elementsPendingErasure.add(h.id)),i&&h.groupIds?.length){let b=h.groupIds.at(-1);if(!a.has(b)){a.add(b);let x=Ge(l,b);for(let E of x)t.altKey?this.elementsPendingErasure.delete(E.id):this.elementsPendingErasure.add(E.id)}}}},c=tn(M(r.lastCoords.x,r.lastCoords.y),M(n.x,n.y)),m=this.getElementHitThreshold(),d={...r.lastCoords},p=0;for(;p<=c;){let u=this.getElementsAtPosition(d.x,d.y);if(s(u),p===c)break;p=Math.min(p+m,c);let h=p/c,b=(1-h)*d.x+h*n.x,x=(1-h)*d.y+h*n.y;d.x=b,d.y=x}if(r.lastCoords.x=n.x,r.lastCoords.y=n.y,i){for(let u of this.scene.getNonDeletedElements())Be(u)&&(this.elementsPendingErasure.has(u.id)||this.elementsPendingErasure.has(u.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(u.id),this.elementsPendingErasure.delete(u.containerId)):(this.elementsPendingErasure.add(u.id),this.elementsPendingErasure.add(u.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}});I(this,"handleTouchMove",t=>{ws=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches.map(p=>({...p,focus:!1}))})),St.set(Hg,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ke(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?A.EVENTUALLY:A.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Ri(this.device,{isTouchScreen:!0})),vs||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===or.ERASER&&this.state.activeTool.type!==it.eraser){this.setState({activeTool:Fe(this.state,{type:it.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),no(this.state)&&this.setState({activeTool:Fe(this.state,{...this.state.activeTool.lastActiveTool||{type:it.selection},lastActiveToolBeforeEraser:null})})},p=Ye(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==or.MAIN&&t.button!==or.TOUCH&&t.button!==or.ERASER||Le.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso")this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey);else if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(t,i);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i);else if(this.state.activeTool.type==="image"){Me(this.interactiveCanvas,Se.CROSSHAIR);let d=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!d)return;this.setState({newElement:d,pendingImageElementId:null,multiElement:null});let{x:p,y:u}=$e(t,this.state),h=this.getTopLayerFrameAtSceneCoords({x:p,y:u});B(d,{x:p,y:u,frameId:h?h.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Eo(this.interactiveCanvas,this.state):this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",c),window.addEventListener("keyup",m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=c)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=$e({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Oi(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Oi(this.hitLinkElement)&&!a0(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,M(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ws=!1,Nn?ws=!0:Nn=window.setTimeout(()=>{Nn=0,ws||this.handleCanvasContextMenu(t)},jf))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Nn),Nn=0,ws=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Ts?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Le.pointers.size<=1&&(t.button===or.WHEEL||t.button===or.MAIN&&Mi||Ko(this.state)||this.state.viewModeEnabled)))return!1;vs=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Me(this.interactiveCanvas,Se.GRABBING);let{clientX:i,clientY:a}=t,l=hm(c=>{let m=i-c.clientX,d=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(d)>1)){r=!0;let p=h=>{document.body.removeEventListener("paste",p),h.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=tt(Ts=()=>{Ts=null,vs=!1,Mi||(this.state.viewModeEnabled?Me(this.interactiveCanvas,Se.GRAB):Eo(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),l.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerup",s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!ee(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=cu(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=du(ye(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=rn(_0(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ae(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=D0(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=j.handlePointerDown(t,this,this.store,r.origin,c,this.scene);if(m.hitElement&&(r.hit.element=m.hitElement),m.linearElementEditor&&(this.setState({selectedLinearElement:m.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:m.linearElementEditor})),m.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,r.hit.element),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let l=r.hit.element,s=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((l===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(l),this.state.editingLinearElement)this.setState({selectedElementIds:ke({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(t[T.CTRL_OR_CMD])return this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...kb(c,l),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!Ki(l,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{let m={...c.selectedElementIds,[l.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(p=>{let u=this.scene.getElement(p);u&&d.push(u)}),ne(l))ko(d,l.id).forEach(p=>{delete m[p.id]});else if(l.frameId)m[l.frameId]&&delete m[l.id];else{let p=l.groupIds,u=new Set(p.flatMap(h=>Ge(this.scene.getNonDeletedElements(),h)).filter(h=>ne(h)).map(h=>h.id));u.size>0&&d.forEach(h=>{h.frameId&&u.has(h.frameId)&&(delete m[h.id],h.groupIds.flatMap(b=>Ge(this.scene.getNonDeletedElements(),b)).forEach(b=>{delete m[b.id]}))})}return c.openDialog?.name==="elementLinkSelector"&&(l.groupIds.some(p=>c.selectedGroupIds[p])||(m={[l.id]:!0})),{...lt({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||Ft(l)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);Tt(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),xo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Fe(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=ut(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=Xb({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[M(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:ke(p,d)}});let m=cn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=ut(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Kb({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=ut(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ni(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=Gp({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=ut(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return xc({type:"image",x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&yl(i.points,this.state.zoom.value)){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}if(ee(i)&&i.points.length>1){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&tn(M(n.origin.x-a,n.origin.y-l),s)<Ps){this.actionManager.executeAction(yo);return}this.setState(c=>({selectedElementIds:ke({...c.selectedElementIds,[i.id]:!0},c)})),B(i,{lastCommittedPoint:i.points[i.points.length-1]}),Me(this.interactiveCanvas,Se.POINTER)}else{let[i,a]=ut(n.origin.x,n.origin.y,t[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,d]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?ji({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===xt.round?{type:eo.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===xt.elbow,fixedSegments:this.state.currentItemArrowType===xt.elbow?[]:null}):sr({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:eo.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(h=>{let b={...h.selectedElementIds};return delete b[p.id],{selectedElementIds:ke(b,h)}}),B(p,{points:[...p.points,M(0,0)]});let u=cn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(p),ee(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=ut(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=Gp({type:"embeddable",...l}):s=Gt({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=ut(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Go},l=r===it.magicframe?wl(a):$i(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||Be(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,te(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async({imageFile:t,imageElement:r,showCursorImagePreview:n=!1})=>{if(!Lc(t))throw new Error(f("errors.unsupportedFileType"));let i=t.type;if(Me(this.interactiveCanvas,"wait"),i===ue.svg)try{t=Qp(Yp(await t.text()),t.name)}catch(m){throw console.warn(m),new Error(f("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(t)||g0(t));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{t=await Sl(t,{maxWidthOrHeight:n1})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(t.size>sp)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(sp/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&b0(m);this.setImagePreviewCursor(d||t)}let s=this.files[a]?.dataURL||await _c(t),c=B(r,{fileId:a},!1);return new Promise(async(m,d)=>{try{this.addMissingFiles([{mimeType:i,id:a,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let p=this.imageCache.get(a);p||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),p?.image instanceof Promise&&await p.image,this.state.pendingImageElementId!==c.id&&this.state.newElement?.id!==c.id&&this.initializeImageDimensions(c,!0),m(c)}catch(p){console.error(p),d(new Error(f("errors.imageInsertError")))}finally{n||xo(this.interactiveCanvas)}})});I(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return B(t,{isDeleted:!0}),this.actionManager.executeAction(yo),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});I(this,"setImagePreviewCursor",async t=>{let n;try{n=await Sl(t,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(f("errors.unsupportedFileType")):a}let i=await _c(n);if(t.type===ue.svg){let a=await jb(i),l=Math.min(a.height,96),s=l*(a.width/a.height);s>96&&(s=96,l=s*(a.height/a.width));let c=document.createElement("canvas");c.height=l,c.width=s,c.getContext("2d").drawImage(a,0,0,s,l),i=c.toDataURL(ue.svg)}this.state.pendingImageElementId&&Me(this.interactiveCanvas,`url(${i}) 4 4, auto`)});I(this,"onImageAction",async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:i,y:a}=$e({clientX:r,clientY:n},this.state),l=await wc({description:"Image",extensions:Object.keys(ol)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:ke({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,l,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,newElement:null,activeTool:Fe(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(yo)})}});I(this,"initializeImageDimensions",(t,r=!1)=>{let n=Lr(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<Fn/this.state.zoom.value&&t.height<Fn/this.state.zoom.value){let i=100/this.state.zoom.value;B(t,{x:t.x-i/2,y:t.y-i/2,width:i,height:i})}return}if(r||t.width<Fn/this.state.zoom.value&&t.height<Fn/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=t.x+t.width/2-s/2,m=t.y+t.height/2-l/2;B(t,{x:c,y:m,width:s,height:l,crop:null})}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await qb({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});if(n.size||i.size)for(let a of t)n.has(a.fileId)&&pn.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Lr(a)&&i.has(a.fileId)?te(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=Jb(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",z8(()=>{this.addNewImagesToImageCache()},Xf));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=rb(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=cn(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"maybeSuggestBindingsForLinearElementAtCoords",(t,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=cn(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,ee(t),ee(t));return s!=null&&!ab(t,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await y0(t),{x:i,y:a}=$e(t,this.state);try{if(Lc(r)&&this.isToolSupported("image")){if(r?.type===ue.png||r?.type===ue.svg)try{let c=await Ac(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:ke({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(ue.excalidrawlib);if(l&&typeof l=="string"){try{let s=h0(l);this.addElementsFromPasteOrLibrary({elements:Wd(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,n),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&qi(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||ni(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Vo(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await w0(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await qp(t,this.state,n,r)}catch(a){let l=a instanceof r0;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ue.excalidraw?(Pr(n.concat(i.data.elements)),this.store.updateSnapshot(re(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ue.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==or.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=$e(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:d}=c.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-m;xe("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...lt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ae(i)?new j(i):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){pu({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Yn(t.origin.x,a.x),height:Yn(t.origin.y,a.y),shouldMaintainAspectRatio:Ai(r),shouldResizeFromCenter:!1,zoom:this.state.zoom.value,informMutation:n});return}let l=this.state.newElement;if(!l)return;let[s,c]=ut(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Lr(l)&&this.imageCache.get(l.fileId)?.image,d=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Gv(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),pu({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Yn(t.originInGrid.x,s),height:Yn(t.originInGrid.y,c),shouldMaintainAspectRatio:he(l)?!Ai(r):Ai(r),shouldResizeFromCenter:mp(r),zoom:this.state.zoom.value,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe)&&this.setState({elementsToHighlight:Yi(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=ut(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&he(s)){let c=t.originalElements.get(s.id),m=Lr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&he(c)&&m&&!(m instanceof Promise)){let[d,p]=ut(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:h,snapLines:b}=hg([s],[c],this,r,u,n);B(s,Bb(s,n,m.naturalWidth,m.naturalHeight,a+h.x,l+h.y,r.shiftKey?c.width/c.height:void 0)),at(s,this.scene.getNonDeletedElementsMap(),{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ne(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&ee(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=ut(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{ko(this.scene.getNonDeletedElements(),d.id).forEach(u=>{m.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=ut(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},h=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=hg(n,J(h,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(A0(t.originalElements,a,n,this.scene.getElementsMapIncludingDeleted(),this.scene,Ws(r),mp(r),n.some(d=>he(d))?!Ai(r):Ai(r),s,c,t.resize.center.x,t.resize.center.y)){let d=nc(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Yi(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(Bd,Od),t==="canvas"?this.state.viewModeEnabled?[...r,Fd,Ma,cg,La]:[kh,ft,Bd,Od,zd,ft,Vu,E2,ft,Fd,Mh,Ma,cg,La]:(r.push(zd),this.state.viewModeEnabled?[ka,...r]:[ft,Nd,ka,kh,ft,Sv,kv,Mv,ft,ag,ft,...r,ft,Eh,yh,ft,vh,Pv,Lh,Ah,m2,wh,ft,Ch,ft,Fu,Hu,Uu,Gu,ft,Ih,Sh,ft,ig,ft,es,Ud,ft,Yu,Bh,ft,Ul])});I(this,"handleWheel",tt(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[T.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),vs)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Li*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Br({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:cr(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=$e({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:Le.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Vn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:d}=this.state;if(n===s&&i===c&&a===d&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=dr(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${f("labels.untitled")}-${yp()}`}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=H8(),this.library=new _2(this),this.actionManager=new sm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new dn,this.canvas=document.createElement("canvas"),this.rc=F8.canvas(this.canvas),this.renderer=new cs(this.scene),this.visibleElements=[],this.store=new Gc,this.history=new as,n){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new un(this.scene),this.history=new as,this.actionManager.registerAll(id),this.actionManager.registerAction(Av(this.history,this.store)),this.actionManager.registerAction(_v(this.history,this.store))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(el).includes(i)&&cf.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Zn(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=cf.get(t.id);switch(n||(cf.set(t.id,el.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case el.PLAYING:case el.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Ft(a)&&this.embedsValidationStatus.get(a.id)===!0||Zn(a));return Oe(G8,{children:i.map(a=>{let{x:l,y:s}=zt({sceneX:a.x,sceneY:a.y},this.state),c=El(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let p;if(Zn(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Vp(`
18
18
  <style>
19
19
  html, body {
20
20
  width: 100%;
@@ -86,7 +86,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","me
86
86
  </svg>
87
87
  </div>
88
88
  <div>Generating...</div>
89
- `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>zp(`
89
+ `)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Vp(`
90
90
  <style>
91
91
  html, body {
92
92
  height: 100%;
@@ -105,7 +105,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","me
105
105
  </style>
106
106
  <h1>Error!</h1>
107
107
  <h3>${x}</h3>
108
- `)}}}else p=ri(Zs(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",h=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Oe("div",{className:a5("excalidraw__embeddable-container",{"is-hovered":h}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:Lb(a,Qn(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?t1:1),"--embeddable-radius":`${pc(Math.min(a.width,a.height),a)}px`},children:Zm("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Bn.enabled:Bn.disabled},children:[h&&Oe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Oe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(zt(a)?this.props.renderEmbeddable?.(a,this.state):null)??Oe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0];return Oe("div",{className:a5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Bn.disabled:Bn.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Oe(c5.Provider,{value:this,children:Oe(d5.Provider,{value:this.props,children:Oe(af.Provider,{value:this.excalidrawContainerValue,children:Oe(nf.Provider,{value:this.device,children:Oe(cf.Provider,{value:this.setAppState,children:Oe(sf.Provider,{value:this.state,children:Zm(lf.Provider,{value:this.scene.getNonDeletedElements(),children:[Zm(df.Provider,{value:this.actionManager,children:[Oe(X3,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Rr().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),Oe("div",{className:"excalidraw-textEditorContainer"}),Oe("div",{className:"excalidraw-contextMenuContainer"}),Oe("div",{className:"excalidraw-eye-dropper-container"}),Oe(q3,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Oe(l2,{element:m,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&Xs(m)&&Oe(hg,{element:m,elementsMap:a,children:Oe(Wm,{title:f("labels.convertToCode"),icon:Jc,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Kn(m)&&m.customData?.generationData?.status==="done"&&Zm(hg,{element:m,elementsMap:a,children:[Oe(Wm,{title:f("labels.copySource"),icon:ca,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Oe(Wm,{title:"Enter fullscreen",icon:Qx,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(m);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(p){console.warn(p),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Oe(i5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Oe(ow,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Oe(Jg,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Tn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Oe(r5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),Oe(qg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Oe(nw,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=ac(this.scene.getNonDeletedElements(),t).filter(l=>!Xs(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),xe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),xe("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(xe("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){xe("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&($o(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{kr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),cn.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,dt()||Fe()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...n)=>this.setState(...n)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),dt()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),ja&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Pf()&&!H1()&&this.setState({errorMessage:Oe(Jv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new ln,this.fonts=new dn(this.scene),this.renderer=new is(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),cn.destroy(),Po.destroy(),clearTimeout(Dn),ze.clearCache(),ut.clearCache(),Dn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ve(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ve(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ve(window,"message",this.onWindowMessage,!1),Ve(document,"pointerup",this.removePointer,{passive:!1}),Ve(document,"copy",this.onCopy,{passive:!1}),Ve(document,"keyup",this.onKeyUp,{passive:!0}),Ve(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Ve(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Ve(document,"gesturestart",this.onGestureStart,!1),Ve(document,"gesturechange",this.onGestureChange,!1),Ve(document,"gestureend",this.onGestureEnd,!1),Ve(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ve(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Ve(document,"paste",this.pasteFromClipboard,{passive:!1}),Ve(document,"cut",this.onCut,{passive:!1}),Ve(window,"resize",this.onResize,!1),Ve(window,"unload",this.onUnload,!1),Ve(window,"blur",this.onBlur,!1),Ve(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ve(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Ve(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ve(u1(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&no(this.state)&&this.setState({activeTool:Ge(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&ch(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),no(r)&&!no(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===de.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(yo)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&jn(this.state)&&Mr(s,!1)&&hl(s,this.state,en(j.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){fs=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await s0(p)}}catch(u){let h=u.message;return u.cause==="FETCH_ERROR"?h=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(h=f("errors.unsupportedFileType")),{errorMessage:h}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),h=await this.insertImageElement(u,p.file);h&&(c||(c=!0,s-=h.height/2),B(h,{y:s},!1),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Me(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
108
+ `)}}}else p=ni(qs(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",h=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Oe("div",{className:f5("excalidraw__embeddable-container",{"is-hovered":h}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:Fb(a,ei(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?a1:1),"--embeddable-radius":`${fc(Math.min(a.width,a.height),a)}px`},children:jm("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Hn.enabled:Hn.disabled},children:[h&&Oe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Oe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ft(a)?this.props.renderEmbeddable?.(a,this.state):null)??Oe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0];return Oe("div",{className:f5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Hn.disabled:Hn.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Oe(E5.Provider,{value:this,children:Oe(y5.Provider,{value:this.props,children:Oe(pf.Provider,{value:this.excalidrawContainerValue,children:Oe(mf.Provider,{value:this.device,children:Oe(gf.Provider,{value:this.setAppState,children:Oe(hf.Provider,{value:this.state,children:jm(uf.Provider,{value:this.scene.getNonDeletedElements(),children:[jm(ff.Provider,{value:this.actionManager,children:[Oe(n5,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Or().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),Oe("div",{className:"excalidraw-textEditorContainer"}),Oe("div",{className:"excalidraw-contextMenuContainer"}),Oe("div",{className:"excalidraw-eye-dropper-container"}),Oe(l5,{trails:[this.laserTrails,this.eraserTrail,this.lassoTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Oe(f2,{element:m,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&Js(m)&&Oe(yg,{element:m,elementsMap:a,children:Oe(Xm,{title:f("labels.convertToCode"),icon:ed,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Zn(m)&&m.customData?.generationData?.status==="done"&&jm(yg,{element:m,elementsMap:a,children:[Oe(Xm,{title:f("labels.copySource"),icon:ca,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Oe(Xm,{title:"Enter fullscreen",icon:cE,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(m);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(p){console.warn(p),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Oe(g5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Oe(pw,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Oe(nf,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Sn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Oe(u5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),Oe(rf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Oe(hw,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=dc(this.scene.getNonDeletedElements(),t).filter(l=>!Js(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),xe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),xe("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(xe("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){xe("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(jo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{Lr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),pn.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,mt()||He()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...n)=>this.setState(...n)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),mt()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),qa&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Ff()&&!$1()&&this.setState({errorMessage:Oe(sw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new dn,this.fonts=new un(this.scene),this.renderer=new cs(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),pn.destroy(),Ro.destroy(),clearTimeout(Nn),ze.clearCache(),lt.clearCache(),Nn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ye(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ye(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ye(window,"message",this.onWindowMessage,!1),Ye(document,"pointerup",this.removePointer,{passive:!1}),Ye(document,"copy",this.onCopy,{passive:!1}),Ye(document,"keyup",this.onKeyUp,{passive:!0}),Ye(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Ye(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Ye(document,"gesturestart",this.onGestureStart,!1),Ye(document,"gesturechange",this.onGestureChange,!1),Ye(document,"gestureend",this.onGestureEnd,!1),Ye(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ye(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Ye(document,"paste",this.pasteFromClipboard,{passive:!1}),Ye(document,"cut",this.onCut,{passive:!1}),Ye(window,"resize",this.onResize,!1),Ye(window,"unload",this.onUnload,!1),Ye(window,"blur",this.onBlur,!1),Ye(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ye(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Ye(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ye(w1(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&no(this.state)&&this.setState({activeTool:Fe(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&gh(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),no(r)&&!no(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===de.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(yo)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&qn(this.state)&&Ar(s,!1)&&gl(s,this.state,rn(j.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){ys=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await E0(p)}}catch(u){let h=u.message;return u.cause==="FETCH_ERROR"?h=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(h=f("errors.unsupportedFileType")),{errorMessage:h}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),h=await this.insertImageElement(u,p.file);h&&(c||(c=!0,s-=h.height/2),B(h,{y:s},!1),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:ke(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
109
109
 
110
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:As,verticalAlign:ep,locked:!1},l=qe({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=Ir(a.fontFamily),[c,,m]=Op(this.state),d=Math.max(Math.min((m-c)*.5,800),200),p=10,u=i,h=r?[t]:t.split(`
111
- `),b=h.reduce((x,E,w)=>{let y=$n(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=Ft(y,l,s),I=C.width>d,_=I?Hi(y,l,d):y;C=I?Ft(_,l,s):C;let L=n-C.width/2,N=u-C.height/2,P=Gt({...a,x:L,y:N,text:_,originalText:y,lineHeight:s,autoResize:!I,frameId:v?v.id:null});x.push(P),u+=P.height+p}else h[w-1]?.trim()&&(u+=U1(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.setState({selectedElementIds:Me(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&s5===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),s5=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Z(s)?oe(s,{originalText:a,isDeleted:l??s.isDeleted,...Ob(s,ro(s,n),n,a)}):s)])};$v({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=Bt({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:tt(a=>{i(a,!1),kp(t)&&at(t,this.scene.getNonDeletedElementsMap())}),onSubmit:tt(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;ki(()=>{this.setState(m=>({selectedElementIds:Me({...m.selectedElementIds,[c]:!0},m)}))})}s&&tc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),ki(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Eo(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&Z(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=this.getElementsAtPosition(t,r,n?.includeBoundTextElement,n?.includeLockedElements);if(i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return zi({x:t,y:r,element:a,shape:ti(a,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:ie(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n=!1,i=!1){let a=[],l=this.scene.getNonDeletedElementsMap();return(n&&i?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(c=>(i||!c.locked)&&(n||!(Z(c)&&c.containerId)))).filter(c=>this.hitElement(t,r,c)).filter(c=>{let m=Qn(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Mp({x:t,y:r},m,l):!0}).filter(c=>Kn(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return Bf/this.state.zoom.value}hitElement(t,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&Ac([n],this.state)){let l=Pb(n,this.scene.getNonDeletedElementsMap(),he(n)?0:this.getElementHitThreshold());if(Rb(M(t,r),l))return!0}return _1(t,r,Ib(n,this.scene.getNonDeletedElementsMap()))?!0:zi({x:t,y:r,element:n,shape:ti(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ie(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return Lr(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,c,m,d]=Ye(n[l],this.scene.getNonDeletedElementsMap());if(Pe(n[l])&&zi({x:t,y:r,element:n[l],shape:ti(n[l],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){a=n[l];break}else if(s<t&&t<m&&c<r&&r<d){a=n[l];break}}return Lr(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=j.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;zi({x:r,y:n,element:a,shape:ti(a,this.scene.getNonDeletedElementsMap())})?(l=j.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=j.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(ee(a)?l===0||l===a.points.length-1:l>=0)||s?De(this.interactiveCanvas,Se.POINTER):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&De(this.interactiveCanvas,Se.MOVE)):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&De(this.interactiveCanvas,Se.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),j.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else De(this.interactiveCanvas,Se.AUTO)}updateGestureOnPointerDown(t){ke.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ke.pointers.size===2&&(ke.lastCenter=ig(ke.pointers),ke.initialScale=this.state.zoom.value,ke.initialDistance=ag(Array.from(ke.pointers.values())))}initialPointerDownState(t){let r=$e(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ye(n),c=n.findIndex(ee)===0;return{origin:r,withCmdOrCtrl:t[T.CTRL_OR_CMD],originInGrid:en(pt(r.x,r.y,t[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:dg(tf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,uo(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;ef=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=pm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=tt(()=>{Es=null,ef=!1,Eo(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return Es=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=this.getElementHitThreshold(),[i,a,l,s]=ye(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Bi(t)?Qt.ADAPTIVE_RADIUS:Qt.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Ur({event:t,app:this,selectedElements:r})&&(n||!Po.getReferenceSnapPoints())&&Po.setReferenceSnapPoints(_v(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Ur({event:t,app:this,selectedElements:r})&&(n||!Po.getVisibleGaps())&&Po.setVisibleGaps(Av(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return tt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return tt(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return pm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=pt(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(h<0){let x=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());h=x?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=j.moveFixedSegment(this.state.selectedLinearElement,h,p,u,this.scene.getNonDeletedElementsMap());ki(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}})});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=en(I0(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(no(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=pt(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Jr(M(n.x,n.y),M(t.origin.x,t.origin.y))<On)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if(j.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let h=j.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],c);if(!h)return;ki(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=j.handlePointDragging(r,this,n.x,n.y,(h,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(h,b)},p,this.scene);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>ie(x)),h=this.getTopLayerFrameAtSceneCoords(n),b=h&&!u?h:null;if(this.state.frameToHighlight!==b&&ki(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.origin.x,y:n.y-t.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let C=Math.abs(x.x),I=Math.abs(x.y),_=w&&C<I,L=w&&C>I;_&&(x.x=0),L&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&he(C)&&C.crop!==null&&t.hit.element===C){let I=C.crop,_=kr(C)&&this.imageCache.get(C.fileId)?.image;if(_&&!(_ instanceof Promise)){let L=a1(sp(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[N,P,z,V,U,q]=Ye(C,c),H=Gs(se(M(N,P),M(U,q),C.angle)),G=Gs(se(M(z,P),M(U,q),C.angle)),Y=Gs(se(M(N,V),M(U,q),C.angle)),re=mp(dp(G,H)),$=mp(dp(Y,H)),le=sp(cp(L,re),cp(L,$)),be={...I,x:wt(I.x-le[0]*Math.sign(C.scale[0]),0,_.naturalWidth-I.width),y:wt(I.y-le[1]*Math.sign(C.scale[1]),0,_.naturalHeight-I.height)};B(C,{crop:be});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Dv(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||C0(t,p,x,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!ee(p[0]))&&this.setState({suggestedBindings:ec(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),I=t.hit.element,_=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});I&&!_.find(V=>V.id===I.id)&&_.push(I);let{newElements:L,elementsWithClones:N}=ai({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:new Map(_.map(V=>[V.id,V])),overrides:V=>{let U=t.originalElements.get(V.id);return U?{x:U.x,y:U.y}:{}},reverseOrder:!0});L.forEach(V=>{t.originalElements.set(V.id,V)});let P=this.props.onDuplicate?.(N,C),z=Ht(P||N,ne(L));this.scene.replaceAllElements(z),this.maybeCacheVisibleGaps(r,_,!0),this.maybeCacheReferenceSnapPoints(r,_,!0)}return}}if(this.state.selectionElement)t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,h=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===h&&x[1]===b)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];B(p,{points:[...u,M(h,b)],pressures:w},!1),this.setState({newElement:p})}}else if(ce(p)){t.drag.hasOccurred=!0;let u=p.points,h=l-p.x,b=s-p.y;Us(r)&&u.length===2&&({width:h,height:b}=Cp(p.x,p.y,n.x,n.y)),u.length===1?B(p,{points:[...u,M(h,b)]},!1):(u.length===2||u.length>1&&ee(p))&&B(p,{points:[...u.slice(0,-1),M(h,b)]},!1,{isDragging:!0}),this.setState({newElement:p}),Mr(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)j.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&ze(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>ut({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let h=this.state.selectionElement?pb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...h.reduce((E,w)=>(E[w.id]=!0,E),{})};return t.hit.element&&(h.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...ut({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:h.length===1&&ce(h[0])?new j(h[0]):null,showHyperlinkPopup:h.length===1&&(h[0].link||zt(h[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return tt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:m,isCropping:d}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Ni(x.snapLines,[]),originSnapOffset:null})),this.lastPointerMoveCoords=null,Po.setReferenceSnapPoints(null),Po.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let p=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let x=p.get(t.hit.element.id);Zn(x)&&x.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>ee(E)).forEach(E=>{E&&B(E,{},!0)})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(yo);else{let x=j.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);x!==this.state.editingLinearElement&&this.setState({editingLinearElement:x,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=j.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&B(x,{},!0)}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let x=j.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=x,y=this.scene.getElement(x.elementId);Mr(y)&&Qs(y,E,w,p,this.scene),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...x,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let x=$e(r,this.state),E=n.points,w=x.x-n.x,y=x.y-n.y;w===E[0][0]&&y===E[0][1]&&(y+=1e-4,w+=1e-4);let v=n.simulatePressure?[]:[...n.pressures,r.pressure];B(n,{points:[...E,M(w,y)],pressures:v,lastCommittedPoint:M(w,y)}),this.actionManager.executeAction(yo);return}if(he(n)){let x=n;try{this.initializeImageDimensions(x),this.setState({selectedElementIds:Me({[x.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==x.id)),this.actionManager.executeAction(yo)}return}if(ce(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let x=$e(r,this.state);!t.drag.hasOccurred&&n&&!l?(B(n,{points:[...n.points,M(x.x-n.x,x.y-n.y)]}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(jn(this.state)&&Mr(n,!1)&&hl(n,this.state,x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(xo(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:Ge(this.state,{type:"selection"}),selectedElementIds:Me({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new j(n)}))),this.scene.triggerUpdate());return}if(Z(n)){let x=Fi(qe({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<x&&B(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&Jn(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ie(n)){let x=sb(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Wi(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(B(n,ob(n)),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let w=Qn(E,p);w&&E&&(rc(E,w,this.scene.getNonDeletedElementsMap())||(B(E,{groupIds:[]}),nc([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),y=this.scene.getElementsMapIncludingDeleted(),v=C=>{if(C.length>0){for(let I of C){let _=I.groupIds.indexOf(this.state.editingGroupId);B(I,{groupIds:I.groupIds.slice(0,_)},!1)}y.forEach(I=>{I.groupIds.length&&Ue(y,I.groupIds[I.groupIds.length-1]).length<2&&B(I,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let C=w.filter(I=>I.frameId!==E.id&&Lp(I,y,this.state));this.state.editingGroupId&&v(C),y=Wi(y,C,E,this.state)}else if(!E&&this.state.editingGroupId){let C=w.filter(I=>I.frameId&&!Lp(I,y,this.state));v(C)}y=ir(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.shouldCaptureIncrement(),i&&Jn(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let x=ir(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>ie(w));for(let w of E)x=ic(x,Yi(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(x)}let u=t.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&ce(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new j(u)}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let h=this.lastPointerDownEvent,b=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(no(this.state)&&h&&b){if(this.eraserTrail.endPath(),Jr(M(h.clientX,h.clientY),M(b.clientX,b.clientY))===0){let E=$e({clientX:b.clientX,clientY:b.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(y=>this.elementsPendingErasure.add(y.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(u&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[u.id]?dc(this.state,u)?this.setState(x=>{let E={...x.selectedElementIds};for(let w of u.groupIds.flatMap(y=>Ue(this.scene.getNonDeletedElements(),y)))delete E[w.id];return{selectedGroupIds:{...x.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,y)=>({...w,...y}),{})},selectedElementIds:Me(E,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let E={...x.selectedElementIds};delete E[u.id];let w=J(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...ut({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&ce(w[0])?new j(w[0]):x.selectedLinearElement}}):u.frameId&&this.state.selectedElementIds[u.frameId]?this.setState(x=>{let E={...x.selectedElementIds,[u.id]:!0};return delete E[u.frameId],(this.scene.getElement(u.frameId)?.groupIds??[]).flatMap(w=>Ue(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...ut({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:u.link||zt(u)?"info":!1}}):this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[u.id]:!0},x)})):this.setState(x=>({...ut({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:ce(u)&&x.selectedLinearElement?.elementId!==u.id?new j(u):x.selectedLinearElement}))),!(u&&ee(u))&&!t.drag.hasOccurred&&!this.state.isResizing&&(u&&A1({x:t.origin.x,y:t.origin.y,element:u,shape:ti(u,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ie(u)?this.frameNameBoundsCache.get(u):null},p)||!u&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),De(this.interactiveCanvas,Se.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[n.id]:!0},x),showHyperlinkPopup:zt(n)&&!n.link?"editor":x.showHyperlinkPopup})),(s.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state)||!Je(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||c||m||d){let x=this.scene.getSelectedElements(this.state).filter(ce);qn(x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,jn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"?(xo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Ge(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ke.pointers.size<=1&&Oi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(t){this.setState(r=>({selectedElementIds:Me({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ki(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Js(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Of){let{x:d,y:p}=Bt({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=na.find(r=>r.code===this.props.langCode)||dr;await Bc(t),this.setAppState({})}},ML=()=>{(dt()||Fe())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(_r(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};ML();var p5=rf;import{useEffect as AL,useState as _L}from"react";import{jsx as DL}from"react/jsx-runtime";var u5=e=>{let[o,t]=_L(!0);return AL(()=>{let r=async()=>{await Bc(n),t(!1)},n=na.find(i=>i.code===e.langCode)||dr;r()},[e.langCode]),o?DL(um,{theme:e.theme}):e.children};import PL from"clsx";import{jsx as h5}from"react/jsx-runtime";var g5=({children:e})=>{let{FooterCenterTunnel:o}=We(),t=_e();return h5(o.In,{children:h5("div",{className:PL("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},RL=g5;g5.displayName="FooterCenter";import NL from"clsx";import{jsx as BL,jsxs as zL}from"react/jsx-runtime";var f5=({isCollaborating:e,onSelect:o,...t})=>{let r=_e(),n=r.width<830;return zL(vo,{...t,className:NL("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:f("labels.liveCollaboration"),children:[n?ix:f("labels.share"),r.collaborators.size>0&&BL("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},OL=f5;f5.displayName="LiveCollaborationTrigger";import{jsx as Rn,jsxs as x5}from"react/jsx-runtime";var FL=()=>Rn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rn("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"})}),HL=()=>x5("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rn("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)"}),Rn("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)"}),Rn("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)"}),Rn("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)"})]}),b5=({style:e,size:o="small",withText:t})=>x5("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Rn(FL,{}),t&&Rn(HL,{})]});import{Fragment as v5,jsx as bt,jsxs as mf}from"react/jsx-runtime";var pf=({icon:e,shortcut:o,children:t})=>{let r=Ce();return mf(v5,{children:[bt("div",{className:"welcome-screen-menu-item__icon",children:e}),bt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&bt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};pf.displayName="WelcomeScreenMenuItemContent";var ys=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>bt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:bt(pf,{icon:t,shortcut:r,children:o})});ys.displayName="WelcomeScreenMenuItem";var E5=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>bt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noreferrer",children:bt(pf,{icon:t,shortcut:r,children:e})});E5.displayName="WelcomeScreenMenuItemLink";var Bo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=We();return bt(o.In,{children:bt("div",{className:"welcome-screen-center",children:e||mf(v5,{children:[bt(uf,{}),bt(hf,{children:f("welcomeScreen.defaults.center_heading")}),mf(gf,{children:[bt(bf,{}),bt(ff,{})]})]})})})};Bo.displayName="Center";var uf=({children:e})=>bt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||bt(b5,{withText:!0})});uf.displayName="Logo";var hf=({children:e})=>bt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});hf.displayName="Heading";var gf=({children:e})=>bt("div",{className:"welcome-screen-menu",children:e});gf.displayName="Menu";var ff=()=>{let e=gt();return bt(ys,{onSelect:()=>e.executeAction(yi),shortcut:"?",icon:la,children:f("helpDialog.title")})};ff.displayName="MenuItemHelp";var bf=()=>{let e=_e(),o=gt();return e.viewModeEnabled?null:bt(ys,{onSelect:()=>o.executeAction(va),shortcut:st("loadScene"),icon:sa,children:f("buttons.load")})};bf.displayName="MenuItemLoadScene";var y5=({onSelect:e})=>{let{t:o}=mt();return bt(ys,{shortcut:null,onSelect:e,icon:Wc,children:o("labels.liveCollaboration")})};y5.displayName="MenuItemLiveCollaborationTrigger";Bo.Logo=uf;Bo.Heading=hf;Bo.Menu=gf;Bo.MenuItem=ys;Bo.MenuItemLink=E5;Bo.MenuItemHelp=ff;Bo.MenuItemLoadScene=bf;Bo.MenuItemLiveCollaborationTrigger=y5;import{jsx as Xa,jsxs as xf}from"react/jsx-runtime";var Xm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=We();return Xa(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[N0,Xa("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Xm.displayName="MenuHint";var $m=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=We();return Xa(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Xa("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),B0]})})};$m.displayName="ToolbarHint";var jm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=We();return Xa(o.In,{children:xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Xa("div",{children:e||f("welcomeScreen.defaults.helpHint")}),O0]})})};jm.displayName="HelpHint";import{Fragment as w5,jsx as vs,jsxs as GL}from"react/jsx-runtime";var qm=e=>vs(w5,{children:e.children||GL(w5,{children:[vs(Bo,{}),vs(Xm,{}),vs($m,{}),vs(jm,{})]})});qm.displayName="WelcomeScreen";qm.Center=Bo;qm.Hints={MenuHint:Xm,ToolbarHint:$m,HelpHint:jm};var UL=qm;var VL=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},T5=VL;import YL from"lodash.throttle";var WL=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),KL=YL((e,o,t)=>{if(Fe()||dt()||window?.DEBUG_FRACTIONAL_INDICES){let r=_r(e.map(n=>({...n})));Cb(r,{shouldThrow:dt()||Fe(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),ZL=(e,o,t)=>{let r=ne(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=WL(t,s,l);s&&c?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=mc(n);return KL(a,e,o),_r(a),a};import{jsx as C5,jsxs as XL}from"react/jsx-runtime";var I5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=We(),r=Ie();return C5(t.In,{children:XL(Ne.Item,{onSelect:()=>{xe("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??tE,children:[e??f("labels.textToDiagram"),C5(Ne.Item.Badge,{children:"AI"})]})})};I5.displayName="TTDDialogTrigger";import{useLayoutEffect as $L}from"react";var jL=e=>{let o=lt();return $L(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as Ef}from"react/jsx-runtime";T5();var QL=e=>{let{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=dr.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:h,onPaste:b,detectScroll:x=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:y=!1,generateIdForFile:v,onLinkOpen:C,generateLinkForSelection:I,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,children:z,validateEmbeddable:V,renderEmbeddable:U,aiEnabled:q,showDeprecatedFonts:H}=e,G=e.UIOptions?.canvasActions,Y={...e.UIOptions,canvasActions:{...np.canvasActions,...G},tools:{image:e.UIOptions?.tools?.image??!0}};return G?.export&&(Y.canvasActions.export.saveFileToDisk=G.export?.saveFileToDisk??np.canvasActions.export.saveFileToDisk),Y.canvasActions.toggleTheme===null&&typeof p>"u"&&(Y.canvasActions.toggleTheme=!0),JL(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let $=le=>{typeof le.scale=="number"&&le.scale!==1&&le.preventDefault()};return document.addEventListener("touchmove",$,{passive:!1}),()=>{document.removeEventListener("touchmove",$)}},[]),Ef(k0,{store:St,children:Ef(u5,{langCode:l,theme:p,children:Ef(p5,{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:h,UIOptions:Y,onPaste:b,detectScroll:x,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:y,generateIdForFile:v,onLinkOpen:C,generateLinkForSelection:I,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,validateEmbeddable:V,renderEmbeddable:U,aiEnabled:q!==!1,showDeprecatedFonts:H,children:z})})})},e7=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),c=Object.keys(a);return s.length!==c.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&Je(n,l)},t7=qL.memo(QL,e7);t7.displayName="Excalidraw";export{vo as Button,A as CaptureUpdateAction,Qm as DEFAULT_LASER_COLOR,Lm as DefaultSidebar,jL as DiagramToCodePlugin,t7 as Excalidraw,Ot as FONT_FAMILY,RL as Footer,OL as LiveCollaborationTrigger,ue as MIME_TYPES,Nt as MainMenu,Qt as ROUNDNESS,Oo as Sidebar,ps as Stats,de as THEME,Fg as TTDDialog,I5 as TTDDialogTrigger,r1 as UserIdleState,UL as WelcomeScreen,bl as bumpVersion,za as convertToExcalidrawElements,dr as defaultLang,L5 as elementPartiallyOverlapsWithOrContainsBBox,A5 as elementsOverlappingBBox,u2 as exportToBlob,yn as exportToCanvas,bC as exportToClipboard,Aa as exportToSvg,ye as getCommonBounds,kc as getDataURL,_5 as getFreeDrawSvgPath,Gd as getLibraryItemsHash,Ee as getNonDeletedElements,k5 as getSceneVersion,yp as getTextFromElements,Op as getVisibleSceneBounds,Ip as hashElementsVersion,Sp as hashString,M5 as isElementInsideBBox,ni as isElementLink,Jn as isInvisiblySmallElement,ce as isLinearElement,na as languages,Sc as loadFromBlob,Zp as loadLibraryFromBlob,Kp as loadSceneOrLibraryFromBlob,y2 as mergeLibraryItems,B as mutateElement,oe as newElementWith,Go as normalizeLink,Nh as parseLibraryTokensFromUrl,ZL as reconcileElements,ta as restore,D5 as restoreAppState,Wp as restoreElements,Cl as restoreLibraryItems,Bt as sceneCoordsToViewportCoords,wl as serializeAsJSON,Yp as serializeLibraryAsJSON,S5 as setCustomTextMetricsProvider,Ce as useDevice,TC as useHandleLibrary,mt as useI18n,$e as viewportCoordsToSceneCoords,Iy as zoomToFitBounds};
110
+ `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:Ns,verticalAlign:rp,locked:!1},l=qe({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=Sr(a.fontFamily),[c,,m]=Up(this.state),d=Math.max(Math.min((m-c)*.5,800),200),p=10,u=i,h=r?[t]:t.split(`
111
+ `),b=h.reduce((x,E,w)=>{let y=jn(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=Ht(y,l,s),S=C.width>d,_=S?Hi(y,l,d):y;C=S?Ht(_,l,s):C;let L=n-C.width/2,N=u-C.height/2,P=Vt({...a,x:L,y:N,text:_,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else h[w-1]?.trim()&&(u+=j1(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.setState({selectedElementIds:ke(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&x5===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),x5=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Z(s)?te(s,{originalText:a,isDeleted:l??s.isDeleted,...Zb(s,_t(s,n),n,a)}):s)])};nw({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=zt({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:tt(a=>{i(a,!1),Dp(t)&&at(t,this.scene.getNonDeletedElementsMap())}),onSubmit:tt(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;ki(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[c]:!0},m)}))})}s&&ic(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),ki(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Eo(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&Z(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=this.getElementsAtPosition(t,r,n?.includeBoundTextElement,n?.includeLockedElements);if(i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return zi({x:t,y:r,element:a,shape:oi(a,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:ne(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n=!1,i=!1){let a=[],l=this.scene.getNonDeletedElementsMap();return(n&&i?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(c=>(i||!c.locked)&&(n||!(Z(c)&&c.containerId)))).filter(c=>this.hitElement(t,r,c)).filter(c=>{let m=ei(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Pp({x:t,y:r},m,l):!0}).filter(c=>Zn(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return Vf/this.state.zoom.value}hitElement(t,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&Rc([n],this.state)){let l=Yb(n,this.scene.getNonDeletedElementsMap(),he(n)?0:this.getElementHitThreshold());if(Wb(M(t,r),l))return!0}return H1(t,r,Nb(n,this.scene.getNonDeletedElementsMap()))?!0:zi({x:t,y:r,element:n,shape:oi(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ne(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return _r(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,c,m,d]=We(n[l],this.scene.getNonDeletedElementsMap());if(Re(n[l])&&zi({x:t,y:r,element:n[l],shape:oi(n[l],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){a=n[l];break}else if(s<t&&t<m&&c<r&&r<d){a=n[l];break}}return _r(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=j.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;zi({x:r,y:n,element:a,shape:oi(a,this.scene.getNonDeletedElementsMap())})?(l=j.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=j.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(ee(a)?l===0||l===a.points.length-1:l>=0)||s?Me(this.interactiveCanvas,Se.POINTER):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&Me(this.interactiveCanvas,Se.MOVE)):this.hitElement(r,n,a)&&(!ee(a)||!(a.startBinding||a.endBinding))&&Me(this.interactiveCanvas,Se.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),j.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Me(this.interactiveCanvas,Se.AUTO)}updateGestureOnPointerDown(t){Le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Le.pointers.size===2&&(Le.lastCenter=mg(Le.pointers),Le.initialScale=this.state.zoom.value,Le.initialDistance=pg(Array.from(Le.pointers.values())))}initialPointerDownState(t){let r=$e(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ye(n),c=n.findIndex(ee)===0;return{origin:r,withCmdOrCtrl:t[T.CTRL_OR_CMD],originInGrid:rn(ut(r.x,r.y,t[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:fg(sf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,uo(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;lf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=hm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=tt(()=>{Ts=null,lf=!1,Eo(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return Ts=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=this.getElementHitThreshold(),[i,a,l,s]=ye(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Bi(t)?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Vr({event:t,app:this,selectedElements:r})&&(n||!Ro.getReferenceSnapPoints())&&Ro.setReferenceSnapPoints(Hv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Vr({event:t,app:this,selectedElements:r})&&(n||!Ro.getVisibleGaps())&&Ro.setVisibleGaps(Fv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return tt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return tt(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return hm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=ut(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(h<0){let x=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());h=x?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=j.moveFixedSegment(this.state.selectedLinearElement,h,p,u,this.scene.getNonDeletedElementsMap());ki(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}})});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=rn(O0(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(no(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=ut(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&tn(M(n.x,n.y),M(t.origin.x,t.origin.y))<Fn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if(j.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let h=j.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],c);if(!h)return;ki(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=j.handlePointDragging(r,this,n.x,n.y,(h,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(h,b)},p,this.scene);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>ne(x)),h=this.getTopLayerFrameAtSceneCoords(n),b=h&&!u?h:null;if(this.state.frameToHighlight!==b&&ki(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.origin.x,y:n.y-t.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let C=Math.abs(x.x),S=Math.abs(x.y),_=w&&C<S,L=w&&C>S;_&&(x.x=0),L&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&he(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,_=Lr(C)&&this.imageCache.get(C.fileId)?.image;if(_&&!(_ instanceof Promise)){let L=m1(up(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[N,P,F,K,U,q]=We(C,c),H=Ks(ce(M(N,P),M(U,q),C.angle)),G=Ks(ce(M(F,P),M(U,q),C.angle)),V=Ks(ce(M(N,K),M(U,q),C.angle)),ie=fp(gp(G,H)),$=fp(gp(V,H)),se=up(hp(L,ie),hp(L,$)),be={...S,x:wt(S.x-se[0]*Math.sign(C.scale[0]),0,_.naturalWidth-S.width),y:wt(S.y-se[1]*Math.sign(C.scale[1]),0,_.naturalHeight-S.height)};B(C,{crop:be});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Uv(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||N0(t,p,x,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!ee(p[0]))&&this.setState({suggestedBindings:nc(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,_=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!_.find(U=>U.id===S.id)&&_.push(S);let L=new Map(_.map(U=>[U.id,U])),{newElements:N,elementsWithClones:P}=li({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:L,overrides:U=>{let q=t.originalElements.get(U.id);return q?{x:q.x,y:q.y,seed:q.seed}:{}},reverseOrder:!0});N.forEach(U=>{t.originalElements.set(U.id,U)});let F=this.props.onDuplicate?.(P,C),K=Ut(F||P,re(N)).map(U=>L.has(U.id)?te(U,{seed:Mr()}):U);this.scene.replaceAllElements(K),this.maybeCacheVisibleGaps(r,_,!0),this.maybeCacheReferenceSnapPoints(r,_,!0)}return}}if(this.state.selectionElement)t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey?(this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null})):this.maybeDragNewGenericElement(t,r);else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,h=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===h&&x[1]===b)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];B(p,{points:[...u,M(h,b)],pressures:w},!1),this.setState({newElement:p})}}else if(ae(p)){t.drag.hasOccurred=!0;let u=p.points,h=l-p.x,b=s-p.y;Ws(r)&&u.length===2&&({width:h,height:b}=Lp(p.x,p.y,n.x,n.y)),u.length===1?B(p,{points:[...u,M(h,b)]},!1):(u.length===2||u.length>1&&ee(p))&&B(p,{points:[...u.slice(0,-1),M(h,b)]},!1,{isDragging:!0}),this.setState({newElement:p}),Ar(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)j.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&ze(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>lt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let h=this.state.selectionElement?wb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...h.reduce((E,w)=>(E[w.id]=!0,E),{})};return t.hit.element&&(h.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...lt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:h.length===1&&ae(h[0])?new j(h[0]):null,showHyperlinkPopup:h.length===1&&(h[0].link||Ft(h[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return tt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:m,isCropping:d}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Ni(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Ro.setReferenceSnapPoints(null),Ro.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let p=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let x=p.get(t.hit.element.id);Xn(x)&&x.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>ee(E)).forEach(E=>{E&&B(E,{},!0)})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(yo);else{let x=j.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);x!==this.state.editingLinearElement&&this.setState({editingLinearElement:x,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=j.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&B(x,{},!0)}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let x=j.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=x,y=this.scene.getElement(x.elementId);Ar(y)&&rc(y,E,w,p,this.scene),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...x,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let x=$e(r,this.state),E=n.points,w=x.x-n.x,y=x.y-n.y;w===E[0][0]&&y===E[0][1]&&(y+=1e-4,w+=1e-4);let v=n.simulatePressure?[]:[...n.pressures,r.pressure];B(n,{points:[...E,M(w,y)],pressures:v,lastCommittedPoint:M(w,y)}),this.actionManager.executeAction(yo);return}if(he(n)){let x=n;try{this.initializeImageDimensions(x),this.setState({selectedElementIds:ke({[x.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==x.id)),this.actionManager.executeAction(yo)}return}if(ae(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let x=$e(r,this.state);!t.drag.hasOccurred&&n&&!l?(B(n,{points:[...n.points,M(x.x-n.x,x.y-n.y)]}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(qn(this.state)&&Ar(n,!1)&&gl(n,this.state,x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(xo(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:Fe(this.state,{type:"selection"}),selectedElementIds:ke({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new j(n)}))),this.scene.triggerUpdate());return}if(Z(n)){let x=Fi(qe({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<x&&B(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&Qn(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ne(n)){let x=xb(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Wi(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(B(n,pb(n)),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let w=ei(E,p);w&&E&&(lc(E,w,this.scene.getNonDeletedElementsMap())||(B(E,{groupIds:[]}),sc([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),y=this.scene.getElementsMapIncludingDeleted(),v=C=>{if(C.length>0){for(let S of C){let _=S.groupIds.indexOf(this.state.editingGroupId);B(S,{groupIds:S.groupIds.slice(0,_)},!1)}y.forEach(S=>{S.groupIds.length&&Ge(y,S.groupIds[S.groupIds.length-1]).length<2&&B(S,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let C=w.filter(S=>S.frameId!==E.id&&Rp(S,y,this.state));this.state.editingGroupId&&v(C),y=Wi(y,C,E,this.state)}else if(!E&&this.state.editingGroupId){let C=w.filter(S=>S.frameId&&!Rp(S,y,this.state));v(C)}y=ar(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.shouldCaptureIncrement(),i&&Qn(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let x=ar(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>ne(w));for(let w of E)x=cc(x,Yi(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(x)}let u=t.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&ae(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new j(u)}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let h=this.lastPointerDownEvent,b=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(no(this.state)&&h&&b){if(this.eraserTrail.endPath(),tn(M(h.clientX,h.clientY),M(b.clientX,b.clientY))===0){let E=$e({clientX:b.clientX,clientY:b.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(y=>this.elementsPendingErasure.add(y.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(u&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[u.id]?hc(this.state,u)?this.setState(x=>{let E={...x.selectedElementIds};for(let w of u.groupIds.flatMap(y=>Ge(this.scene.getNonDeletedElements(),y)))delete E[w.id];return{selectedGroupIds:{...x.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,y)=>({...w,...y}),{})},selectedElementIds:ke(E,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let E={...x.selectedElementIds};delete E[u.id];let w=J(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&ae(w[0])?new j(w[0]):x.selectedLinearElement}}):u.frameId&&this.state.selectedElementIds[u.frameId]?this.setState(x=>{let E={...x.selectedElementIds,[u.id]:!0};return delete E[u.frameId],(this.scene.getElement(u.frameId)?.groupIds??[]).flatMap(w=>Ge(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:u.link||Ft(u)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[u.id]:!0},x)})):this.setState(x=>({...lt({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:ae(u)&&x.selectedLinearElement?.elementId!==u.id?new j(u):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(u&&ee(u))&&!t.drag.hasOccurred&&!this.state.isResizing&&(u&&F1({x:t.origin.x,y:t.origin.y,element:u,shape:oi(u,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ne(u)?this.frameNameBoundsCache.get(u):null},p)||!u&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Me(this.interactiveCanvas,Se.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[n.id]:!0},x),showHyperlinkPopup:Ft(n)&&!n.link?"editor":x.showHyperlinkPopup})),(s.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state)||!Je(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||c||m||d){let x=this.scene.getSelectedElements(this.state).filter(ae);Jn(x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,qn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(xo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Fe(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Le.pointers.size<=1&&Oi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(t){this.setState(r=>({selectedElementIds:ke({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ki(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=oc(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Gf){let{x:d,y:p}=zt({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=na.find(r=>r.code===this.props.langCode)||mr;await Uc(t),this.setAppState({})}},U8=()=>{(mt()||He())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Pr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};U8();var w5=df;import{useEffect as V8,useState as Y8}from"react";import{jsx as W8}from"react/jsx-runtime";var T5=e=>{let[o,t]=Y8(!0);return V8(()=>{let r=async()=>{await Uc(n),t(!1)},n=na.find(i=>i.code===e.langCode)||mr;r()},[e.langCode]),o?W8(fm,{theme:e.theme}):e.children};import K8 from"clsx";import{jsx as C5}from"react/jsx-runtime";var I5=({children:e})=>{let{FooterCenterTunnel:o}=Ke(),t=De();return C5(o.In,{children:C5("div",{className:K8("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},Z8=I5;I5.displayName="FooterCenter";import X8 from"clsx";import{jsx as j8,jsxs as q8}from"react/jsx-runtime";var S5=({isCollaborating:e,onSelect:o,...t})=>{let r=De(),n=r.width<830;return q8(vo,{...t,className:X8("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:f("labels.liveCollaboration"),children:[n?gx:f("labels.share"),r.collaborators.size>0&&j8("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},$8=S5;S5.displayName="LiveCollaborationTrigger";import{jsx as Bn,jsxs as M5}from"react/jsx-runtime";var J8=()=>Bn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Bn("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"})}),Q8=()=>M5("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Bn("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)"}),Bn("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)"}),Bn("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)"}),Bn("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)"})]}),k5=({style:e,size:o="small",withText:t})=>M5("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Bn(J8,{}),t&&Bn(Q8,{})]});import{Fragment as _5,jsx as bt,jsxs as bf}from"react/jsx-runtime";var xf=({icon:e,shortcut:o,children:t})=>{let r=Ce();return bf(_5,{children:[bt("div",{className:"welcome-screen-menu-item__icon",children:e}),bt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&bt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};xf.displayName="WelcomeScreenMenuItemContent";var Cs=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>bt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:bt(xf,{icon:t,shortcut:r,children:o})});Cs.displayName="WelcomeScreenMenuItem";var L5=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>bt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noreferrer",children:bt(xf,{icon:t,shortcut:r,children:e})});L5.displayName="WelcomeScreenMenuItemLink";var zo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ke();return bt(o.In,{children:bt("div",{className:"welcome-screen-center",children:e||bf(_5,{children:[bt(Ef,{}),bt(yf,{children:f("welcomeScreen.defaults.center_heading")}),bf(vf,{children:[bt(Tf,{}),bt(wf,{})]})]})})})};zo.displayName="Center";var Ef=({children:e})=>bt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||bt(k5,{withText:!0})});Ef.displayName="Logo";var yf=({children:e})=>bt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});yf.displayName="Heading";var vf=({children:e})=>bt("div",{className:"welcome-screen-menu",children:e});vf.displayName="Menu";var wf=()=>{let e=gt();return bt(Cs,{onSelect:()=>e.executeAction(vi),shortcut:"?",icon:la,children:f("helpDialog.title")})};wf.displayName="MenuItemHelp";var Tf=()=>{let e=De(),o=gt();return e.viewModeEnabled?null:bt(Cs,{onSelect:()=>o.executeAction(wa),shortcut:ct("loadScene"),icon:sa,children:f("buttons.load")})};Tf.displayName="MenuItemLoadScene";var A5=({onSelect:e})=>{let{t:o}=pt();return bt(Cs,{shortcut:null,onSelect:e,icon:$c,children:o("labels.liveCollaboration")})};A5.displayName="MenuItemLiveCollaborationTrigger";zo.Logo=Ef;zo.Heading=yf;zo.Menu=vf;zo.MenuItem=Cs;zo.MenuItemLink=L5;zo.MenuItemHelp=wf;zo.MenuItemLoadScene=Tf;zo.MenuItemLiveCollaborationTrigger=A5;import{jsx as $a,jsxs as Cf}from"react/jsx-runtime";var qm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ke();return $a(o.In,{children:Cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[K0,$a("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};qm.displayName="MenuHint";var Jm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ke();return $a(o.In,{children:Cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[$a("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),X0]})})};Jm.displayName="ToolbarHint";var Qm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ke();return $a(o.In,{children:Cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[$a("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Z0]})})};Qm.displayName="HelpHint";import{Fragment as D5,jsx as Is,jsxs as t7}from"react/jsx-runtime";var ep=e=>Is(D5,{children:e.children||t7(D5,{children:[Is(zo,{}),Is(qm,{}),Is(Jm,{}),Is(Qm,{})]})});ep.displayName="WelcomeScreen";ep.Center=zo;ep.Hints={MenuHint:qm,ToolbarHint:Jm,HelpHint:Qm};var e7=ep;var o7=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},P5=o7;import r7 from"lodash.throttle";var n7=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),i7=r7((e,o,t)=>{if(He()||mt()||window?.DEBUG_FRACTIONAL_INDICES){let r=Pr(e.map(n=>({...n})));Rb(r,{shouldThrow:mt()||He(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),a7=(e,o,t)=>{let r=re(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=n7(t,s,l);s&&c?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=gc(n);return i7(a,e,o),Pr(a),a};import{jsx as R5,jsxs as l7}from"react/jsx-runtime";var N5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ke(),r=Ie();return R5(t.In,{children:l7(Pe.Item,{onSelect:()=>{xe("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??mE,children:[e??f("labels.textToDiagram"),R5(Pe.Item.Badge,{children:"AI"})]})})};N5.displayName="TTDDialogTrigger";import{useLayoutEffect as s7}from"react";var c7=e=>{let o=st();return s7(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as If}from"react/jsx-runtime";P5();var p7=e=>{let{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=mr.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:h,onPaste:b,detectScroll:x=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:y=!1,generateIdForFile:v,onLinkOpen:C,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,children:F,validateEmbeddable:K,renderEmbeddable:U,aiEnabled:q,showDeprecatedFonts:H}=e,G=e.UIOptions?.canvasActions,V={...e.UIOptions,canvasActions:{...lp.canvasActions,...G},tools:{image:e.UIOptions?.tools?.image??!0}};return G?.export&&(V.canvasActions.export.saveFileToDisk=G.export?.saveFileToDisk??lp.canvasActions.export.saveFileToDisk),V.canvasActions.toggleTheme===null&&typeof p>"u"&&(V.canvasActions.toggleTheme=!0),m7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let $=se=>{typeof se.scale=="number"&&se.scale!==1&&se.preventDefault()};return document.addEventListener("touchmove",$,{passive:!1}),()=>{document.removeEventListener("touchmove",$)}},[]),If(z0,{store:St,children:If(T5,{langCode:l,theme:p,children:If(w5,{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:h,UIOptions:V,onPaste:b,detectScroll:x,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:y,generateIdForFile:v,onLinkOpen:C,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,validateEmbeddable:K,renderEmbeddable:U,aiEnabled:q!==!1,showDeprecatedFonts:H,children:F})})})},u7=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),c=Object.keys(a);return s.length!==c.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&Je(n,l)},h7=d7.memo(p7,u7);h7.displayName="Excalidraw";export{vo as Button,A as CaptureUpdateAction,op as DEFAULT_LASER_COLOR,Dm as DefaultSidebar,c7 as DiagramToCodePlugin,h7 as Excalidraw,Bt as FONT_FAMILY,Z8 as Footer,$8 as LiveCollaborationTrigger,ue as MIME_TYPES,Ot as MainMenu,eo as ROUNDNESS,Bo as Sidebar,fs as Stats,de as THEME,Wg as TTDDialog,N5 as TTDDialogTrigger,s1 as UserIdleState,e7 as WelcomeScreen,xl as bumpVersion,Fa as convertToExcalidrawElements,mr as defaultLang,F5 as elementPartiallyOverlapsWithOrContainsBBox,H5 as elementsOverlappingBBox,w2 as exportToBlob,Tn as exportToCanvas,kC as exportToClipboard,_a as exportToSvg,ye as getCommonBounds,_c as getDataURL,U5 as getFreeDrawSvgPath,Yd as getLibraryItemsHash,Ee as getNonDeletedElements,B5 as getSceneVersion,Ip as getTextFromElements,Up as getVisibleSceneBounds,Ap as hashElementsVersion,_p as hashString,z5 as isElementInsideBBox,ii as isElementLink,Qn as isInvisiblySmallElement,ae as isLinearElement,na as languages,Ac as loadFromBlob,Jp as loadLibraryFromBlob,qp as loadSceneOrLibraryFromBlob,L2 as mergeLibraryItems,B as mutateElement,te as newElementWith,Vo as normalizeLink,Uh as parseLibraryTokensFromUrl,a7 as reconcileElements,ta as restore,G5 as restoreAppState,jp as restoreElements,Il as restoreLibraryItems,zt as sceneCoordsToViewportCoords,Tl as serializeAsJSON,$p as serializeLibraryAsJSON,O5 as setCustomTextMetricsProvider,Ce as useDevice,PC as useHandleLibrary,pt as useI18n,$e as viewportCoordsToSceneCoords,Ry as zoomToFitBounds};