@excalidraw/excalidraw 0.17.1-d9bbf1e → 0.17.1-e63dd02

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 (416) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  3. package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  4. package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  5. package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  6. package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  7. package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-IT7T3AIK.js} +49 -8
  8. package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
  9. package/dist/browser/dev/excalidraw-assets-dev/{chunk-BLEB3M62.js → chunk-RNHSD5AR.js} +7668 -2142
  10. package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
  11. package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-DNSPZDOZ.js} +66 -32
  12. package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
  13. package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-XV7OZCPP.js} +8 -2
  14. package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js → image-77HZYGLG.js} +2 -2
  15. package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
  16. package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
  17. package/dist/browser/dev/index.css +610 -180
  18. package/dist/browser/dev/index.css.map +3 -3
  19. package/dist/browser/dev/index.js +13306 -8006
  20. package/dist/browser/dev/index.js.map +4 -4
  21. package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  22. package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  23. package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  24. package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  25. package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  26. package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
  27. package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-PDYFZJMS.js} +5 -5
  28. package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
  29. package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
  30. package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
  31. package/dist/browser/prod/index.css +1 -1
  32. package/dist/browser/prod/index.js +70 -51
  33. package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  34. package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  35. package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  36. package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  37. package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  38. package/dist/dev/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
  39. package/dist/dev/index.css +610 -180
  40. package/dist/dev/index.css.map +3 -3
  41. package/dist/dev/index.js +22165 -16833
  42. package/dist/dev/index.js.map +4 -4
  43. package/dist/excalidraw/actions/actionAddToLibrary.d.ts +24 -9
  44. package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
  45. package/dist/excalidraw/actions/actionBoundText.d.ts +20 -10
  46. package/dist/excalidraw/actions/actionBoundText.js +3 -1
  47. package/dist/excalidraw/actions/actionCanvas.d.ts +100 -40
  48. package/dist/excalidraw/actions/actionCanvas.js +1 -1
  49. package/dist/excalidraw/actions/actionClipboard.d.ts +62 -26
  50. package/dist/excalidraw/actions/actionDeleteSelected.d.ts +28 -12
  51. package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
  52. package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
  53. package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
  54. package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
  55. package/dist/excalidraw/actions/actionElementLock.d.ts +17 -7
  56. package/dist/excalidraw/actions/actionExport.d.ts +75 -30
  57. package/dist/excalidraw/actions/actionFinalize.d.ts +17 -7
  58. package/dist/excalidraw/actions/actionFinalize.js +2 -2
  59. package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
  60. package/dist/excalidraw/actions/actionFlip.js +2 -2
  61. package/dist/excalidraw/actions/actionFrame.d.ts +338 -10
  62. package/dist/excalidraw/actions/actionGroup.d.ts +324 -4
  63. package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
  64. package/dist/excalidraw/actions/actionHistory.js +8 -8
  65. package/dist/excalidraw/actions/actionLinearEditor.d.ts +12 -5
  66. package/dist/excalidraw/actions/actionLinearEditor.js +21 -5
  67. package/dist/excalidraw/actions/actionLink.d.ts +8 -3
  68. package/dist/excalidraw/actions/actionMenu.d.ts +24 -9
  69. package/dist/excalidraw/actions/actionNavigate.d.ts +17 -7
  70. package/dist/excalidraw/actions/actionProperties.d.ts +476 -82
  71. package/dist/excalidraw/actions/actionProperties.js +384 -59
  72. package/dist/excalidraw/actions/actionSelectAll.d.ts +9 -4
  73. package/dist/excalidraw/actions/actionStyles.d.ts +12 -4
  74. package/dist/excalidraw/actions/actionStyles.js +3 -2
  75. package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
  76. package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
  77. package/dist/excalidraw/actions/actionToggleGridMode.d.ts +9 -4
  78. package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -3
  79. package/dist/excalidraw/actions/actionToggleStats.d.ts +9 -3
  80. package/dist/excalidraw/actions/actionToggleStats.js +4 -3
  81. package/dist/excalidraw/actions/actionToggleViewMode.d.ts +8 -3
  82. package/dist/excalidraw/actions/actionToggleZenMode.d.ts +8 -3
  83. package/dist/excalidraw/actions/actionZindex.d.ts +8 -4
  84. package/dist/excalidraw/actions/actionZindex.js +4 -0
  85. package/dist/excalidraw/actions/manager.d.ts +3 -3
  86. package/dist/excalidraw/actions/register.d.ts +1 -1
  87. package/dist/excalidraw/actions/shortcuts.d.ts +2 -2
  88. package/dist/excalidraw/actions/types.d.ts +6 -6
  89. package/dist/excalidraw/align.d.ts +1 -1
  90. package/dist/excalidraw/analytics.js +9 -7
  91. package/dist/excalidraw/animated-trail.d.ts +2 -2
  92. package/dist/excalidraw/appState.d.ts +6 -2
  93. package/dist/excalidraw/appState.js +14 -3
  94. package/dist/excalidraw/binaryheap.d.ts +12 -0
  95. package/dist/excalidraw/binaryheap.js +93 -0
  96. package/dist/excalidraw/change.d.ts +6 -5
  97. package/dist/excalidraw/change.js +20 -11
  98. package/dist/excalidraw/charts.d.ts +1 -1
  99. package/dist/excalidraw/charts.js +0 -10
  100. package/dist/excalidraw/clients.d.ts +2 -2
  101. package/dist/excalidraw/clients.js +1 -1
  102. package/dist/excalidraw/clipboard.d.ts +3 -3
  103. package/dist/excalidraw/colors.d.ts +1 -1
  104. package/dist/excalidraw/components/Actions.d.ts +3 -3
  105. package/dist/excalidraw/components/Actions.js +14 -9
  106. package/dist/excalidraw/components/App.d.ts +14 -17
  107. package/dist/excalidraw/components/App.js +356 -217
  108. package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
  109. package/dist/excalidraw/components/ButtonIcon.js +8 -0
  110. package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
  111. package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
  112. package/dist/excalidraw/components/ButtonSeparator.js +7 -0
  113. package/dist/excalidraw/components/CheckboxItem.js +1 -1
  114. package/dist/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -1
  115. package/dist/excalidraw/components/ColorPicker/ColorInput.js +1 -1
  116. package/dist/excalidraw/components/ColorPicker/ColorPicker.d.ts +4 -4
  117. package/dist/excalidraw/components/ColorPicker/ColorPicker.js +48 -80
  118. package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
  119. package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
  120. package/dist/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -1
  121. package/dist/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
  122. package/dist/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -1
  123. package/dist/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  124. package/dist/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
  125. package/dist/excalidraw/components/ColorPicker/colorPickerUtils.js +1 -1
  126. package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  127. package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.js +1 -1
  128. package/dist/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
  129. package/dist/excalidraw/components/CommandPalette/CommandPalette.js +5 -5
  130. package/dist/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -1
  131. package/dist/excalidraw/components/CommandPalette/types.d.ts +3 -3
  132. package/dist/excalidraw/components/ConfirmDialog.d.ts +1 -1
  133. package/dist/excalidraw/components/ContextMenu.d.ts +2 -2
  134. package/dist/excalidraw/components/ContextMenu.js +2 -2
  135. package/dist/excalidraw/components/DarkModeToggle.d.ts +1 -1
  136. package/dist/excalidraw/components/DefaultSidebar.d.ts +2 -2
  137. package/dist/excalidraw/components/Dialog.js +1 -1
  138. package/dist/excalidraw/components/DialogActionButton.d.ts +1 -1
  139. package/dist/excalidraw/components/EyeDropper.d.ts +2 -2
  140. package/dist/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
  141. package/dist/excalidraw/components/FollowMode/FollowMode.js +1 -1
  142. package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
  143. package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
  144. package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
  145. package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
  146. package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
  147. package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
  148. package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
  149. package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
  150. package/dist/excalidraw/components/HelpDialog.js +2 -2
  151. package/dist/excalidraw/components/HintViewer.d.ts +1 -1
  152. package/dist/excalidraw/components/HintViewer.js +6 -3
  153. package/dist/excalidraw/components/IconPicker.js +2 -2
  154. package/dist/excalidraw/components/ImageExportDialog.d.ts +1 -1
  155. package/dist/excalidraw/components/InitializeApp.d.ts +2 -2
  156. package/dist/excalidraw/components/JSONExportDialog.d.ts +3 -3
  157. package/dist/excalidraw/components/LayerUI.d.ts +4 -4
  158. package/dist/excalidraw/components/LayerUI.js +10 -7
  159. package/dist/excalidraw/components/LibraryMenu.d.ts +2 -2
  160. package/dist/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -1
  161. package/dist/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  162. package/dist/excalidraw/components/LibraryMenuHeaderContent.d.ts +2 -2
  163. package/dist/excalidraw/components/LibraryMenuItems.d.ts +1 -1
  164. package/dist/excalidraw/components/LibraryMenuSection.d.ts +5 -4
  165. package/dist/excalidraw/components/LibraryUnit.d.ts +2 -2
  166. package/dist/excalidraw/components/LoadingMessage.d.ts +1 -1
  167. package/dist/excalidraw/components/MagicSettings.js +2 -2
  168. package/dist/excalidraw/components/MobileMenu.d.ts +3 -3
  169. package/dist/excalidraw/components/MobileMenu.js +2 -6
  170. package/dist/excalidraw/components/Modal.d.ts +1 -1
  171. package/dist/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  172. package/dist/excalidraw/components/PasteChartDialog.d.ts +1 -1
  173. package/dist/excalidraw/components/PasteChartDialog.js +1 -1
  174. package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
  175. package/dist/excalidraw/components/PropertiesPopover.js +31 -0
  176. package/dist/excalidraw/components/PublishLibrary.d.ts +1 -1
  177. package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
  178. package/dist/excalidraw/components/QuickSearch.js +8 -0
  179. package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
  180. package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
  181. package/dist/excalidraw/components/ScrollableList.js +8 -0
  182. package/dist/excalidraw/components/Sidebar/Sidebar.js +1 -1
  183. package/dist/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
  184. package/dist/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
  185. package/dist/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
  186. package/dist/excalidraw/components/Sidebar/common.d.ts +1 -1
  187. package/dist/excalidraw/components/Stats/Angle.d.ts +12 -0
  188. package/dist/excalidraw/components/Stats/Angle.js +53 -0
  189. package/dist/excalidraw/components/Stats/Collapsible.d.ts +9 -0
  190. package/dist/excalidraw/components/Stats/Collapsible.js +12 -0
  191. package/dist/excalidraw/components/Stats/Dimension.d.ts +12 -0
  192. package/dist/excalidraw/components/Stats/Dimension.js +68 -0
  193. package/dist/excalidraw/components/Stats/DragInput.d.ts +32 -0
  194. package/dist/excalidraw/components/Stats/DragInput.js +174 -0
  195. package/dist/excalidraw/components/Stats/FontSize.d.ts +12 -0
  196. package/dist/excalidraw/components/Stats/FontSize.js +50 -0
  197. package/dist/excalidraw/components/Stats/MultiAngle.d.ts +12 -0
  198. package/dist/excalidraw/components/Stats/MultiAngle.js +66 -0
  199. package/dist/excalidraw/components/Stats/MultiDimension.d.ts +15 -0
  200. package/dist/excalidraw/components/Stats/MultiDimension.js +199 -0
  201. package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +13 -0
  202. package/dist/excalidraw/components/Stats/MultiFontSize.js +72 -0
  203. package/dist/excalidraw/components/Stats/MultiPosition.d.ts +15 -0
  204. package/dist/excalidraw/components/Stats/MultiPosition.js +101 -0
  205. package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
  206. package/dist/excalidraw/components/Stats/Position.js +40 -0
  207. package/dist/excalidraw/components/Stats/index.d.ts +16 -0
  208. package/dist/excalidraw/components/Stats/index.js +79 -0
  209. package/dist/excalidraw/components/Stats/utils.d.ts +26 -0
  210. package/dist/excalidraw/components/Stats/utils.js +162 -0
  211. package/dist/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -1
  212. package/dist/excalidraw/components/TTDDialog/TTDDialog.js +2 -2
  213. package/dist/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
  214. package/dist/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
  215. package/dist/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
  216. package/dist/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
  217. package/dist/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
  218. package/dist/excalidraw/components/TTDDialog/common.d.ts +5 -5
  219. package/dist/excalidraw/components/TTDDialog/common.js +3 -7
  220. package/dist/excalidraw/components/TextField.d.ts +1 -1
  221. package/dist/excalidraw/components/Toast.d.ts +1 -1
  222. package/dist/excalidraw/components/ToolButton.d.ts +3 -2
  223. package/dist/excalidraw/components/Trans.d.ts +1 -1
  224. package/dist/excalidraw/components/UserList.d.ts +1 -1
  225. package/dist/excalidraw/components/UserList.js +22 -22
  226. package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  227. package/dist/excalidraw/components/canvases/InteractiveCanvas.js +4 -2
  228. package/dist/excalidraw/components/canvases/StaticCanvas.d.ts +2 -2
  229. package/dist/excalidraw/components/canvases/StaticCanvas.js +3 -2
  230. package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
  231. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
  232. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
  233. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
  234. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
  235. package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  236. package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
  237. package/dist/excalidraw/components/footer/Footer.d.ts +2 -2
  238. package/dist/excalidraw/components/hyperlink/Hyperlink.d.ts +2 -2
  239. package/dist/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  240. package/dist/excalidraw/components/icons.d.ts +10 -2
  241. package/dist/excalidraw/components/icons.js +29 -6
  242. package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
  243. package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
  244. package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
  245. package/dist/excalidraw/constants.d.ts +24 -3
  246. package/dist/excalidraw/constants.js +28 -4
  247. package/dist/excalidraw/context/ui-appState.d.ts +1 -1
  248. package/dist/excalidraw/cursor.d.ts +1 -1
  249. package/dist/excalidraw/data/EditorLocalStorage.d.ts +2 -2
  250. package/dist/excalidraw/data/blob.d.ts +5 -5
  251. package/dist/excalidraw/data/filesystem.d.ts +2 -1
  252. package/dist/excalidraw/data/index.d.ts +4 -4
  253. package/dist/excalidraw/data/json.d.ts +3 -3
  254. package/dist/excalidraw/data/library.d.ts +3 -3
  255. package/dist/excalidraw/data/magic.d.ts +3 -3
  256. package/dist/excalidraw/data/reconcile.d.ts +3 -3
  257. package/dist/excalidraw/data/reconcile.js +18 -1
  258. package/dist/excalidraw/data/resave.d.ts +2 -2
  259. package/dist/excalidraw/data/restore.d.ts +3 -3
  260. package/dist/excalidraw/data/restore.js +58 -9
  261. package/dist/excalidraw/data/transform.d.ts +3 -3
  262. package/dist/excalidraw/data/transform.js +8 -5
  263. package/dist/excalidraw/data/types.d.ts +3 -3
  264. package/dist/excalidraw/element/ElementCanvasButtons.d.ts +1 -1
  265. package/dist/excalidraw/element/binding.d.ts +29 -10
  266. package/dist/excalidraw/element/binding.js +303 -71
  267. package/dist/excalidraw/element/bounds.d.ts +3 -3
  268. package/dist/excalidraw/element/collision.d.ts +4 -4
  269. package/dist/excalidraw/element/collision.js +5 -2
  270. package/dist/excalidraw/element/containerCache.d.ts +1 -1
  271. package/dist/excalidraw/element/dragElements.d.ts +6 -6
  272. package/dist/excalidraw/element/dragElements.js +39 -5
  273. package/dist/excalidraw/element/embeddable.d.ts +11 -6
  274. package/dist/excalidraw/element/heading.d.ts +11 -0
  275. package/dist/excalidraw/element/heading.js +81 -0
  276. package/dist/excalidraw/element/image.d.ts +2 -2
  277. package/dist/excalidraw/element/index.d.ts +2 -2
  278. package/dist/excalidraw/element/index.js +1 -1
  279. package/dist/excalidraw/element/linearElementEditor.d.ts +27 -16
  280. package/dist/excalidraw/element/linearElementEditor.js +133 -56
  281. package/dist/excalidraw/element/mutateElement.d.ts +3 -3
  282. package/dist/excalidraw/element/mutateElement.js +5 -3
  283. package/dist/excalidraw/element/newElement.d.ts +12 -10
  284. package/dist/excalidraw/element/newElement.js +31 -16
  285. package/dist/excalidraw/element/resizeElements.d.ts +15 -6
  286. package/dist/excalidraw/element/resizeElements.js +122 -46
  287. package/dist/excalidraw/element/resizeTest.d.ts +4 -4
  288. package/dist/excalidraw/element/resizeTest.js +2 -4
  289. package/dist/excalidraw/element/routing.d.ts +13 -0
  290. package/dist/excalidraw/element/routing.js +641 -0
  291. package/dist/excalidraw/element/showSelectedShapeActions.d.ts +2 -2
  292. package/dist/excalidraw/element/sizeHelpers.d.ts +2 -2
  293. package/dist/excalidraw/element/sortElements.d.ts +1 -1
  294. package/dist/excalidraw/element/textElement.d.ts +6 -28
  295. package/dist/excalidraw/element/textElement.js +64 -112
  296. package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
  297. package/dist/excalidraw/element/textWysiwyg.js +75 -62
  298. package/dist/excalidraw/element/transformHandles.d.ts +3 -3
  299. package/dist/excalidraw/element/transformHandles.js +7 -12
  300. package/dist/excalidraw/element/typeChecks.d.ts +7 -4
  301. package/dist/excalidraw/element/typeChecks.js +17 -0
  302. package/dist/excalidraw/element/types.d.ts +22 -4
  303. package/dist/excalidraw/emitter.d.ts +1 -1
  304. package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
  305. package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
  306. package/dist/excalidraw/fonts/index.d.ts +58 -0
  307. package/dist/excalidraw/fonts/index.js +240 -0
  308. package/dist/excalidraw/fonts/metadata.d.ts +36 -0
  309. package/dist/excalidraw/fonts/metadata.js +91 -0
  310. package/dist/excalidraw/fractionalIndex.d.ts +12 -5
  311. package/dist/excalidraw/fractionalIndex.js +40 -10
  312. package/dist/excalidraw/frame.d.ts +4 -4
  313. package/dist/excalidraw/frame.js +3 -3
  314. package/dist/excalidraw/gatransforms.d.ts +1 -1
  315. package/dist/excalidraw/gesture.d.ts +1 -1
  316. package/dist/excalidraw/groups.d.ts +4 -4
  317. package/dist/excalidraw/history.d.ts +8 -7
  318. package/dist/excalidraw/history.js +8 -8
  319. package/dist/excalidraw/hooks/useEmitter.d.ts +1 -1
  320. package/dist/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  321. package/dist/excalidraw/i18n.d.ts +1 -1
  322. package/dist/excalidraw/index.d.ts +2 -2
  323. package/dist/excalidraw/index.js +3 -3
  324. package/dist/excalidraw/jotai.d.ts +1 -1
  325. package/dist/excalidraw/laser-trails.d.ts +3 -2
  326. package/dist/excalidraw/locales/en.json +42 -7
  327. package/dist/excalidraw/math.d.ts +47 -2
  328. package/dist/excalidraw/math.js +116 -0
  329. package/dist/excalidraw/mermaid.d.ts +2 -0
  330. package/dist/excalidraw/mermaid.js +29 -0
  331. package/dist/excalidraw/points.d.ts +1 -1
  332. package/dist/excalidraw/queue.d.ts +1 -1
  333. package/dist/excalidraw/renderer/helpers.d.ts +2 -2
  334. package/dist/excalidraw/renderer/interactiveScene.d.ts +2 -2
  335. package/dist/excalidraw/renderer/interactiveScene.js +64 -22
  336. package/dist/excalidraw/renderer/renderElement.d.ts +6 -4
  337. package/dist/excalidraw/renderer/renderElement.js +78 -58
  338. package/dist/excalidraw/renderer/renderSnaps.d.ts +1 -1
  339. package/dist/excalidraw/renderer/staticScene.d.ts +1 -1
  340. package/dist/excalidraw/renderer/staticSvgScene.d.ts +4 -4
  341. package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
  342. package/dist/excalidraw/scene/Renderer.d.ts +4 -4
  343. package/dist/excalidraw/scene/Renderer.js +2 -3
  344. package/dist/excalidraw/scene/Scene.d.ts +16 -7
  345. package/dist/excalidraw/scene/Scene.js +26 -11
  346. package/dist/excalidraw/scene/Shape.d.ts +1 -1
  347. package/dist/excalidraw/scene/Shape.js +56 -5
  348. package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
  349. package/dist/excalidraw/scene/comparisons.d.ts +3 -2
  350. package/dist/excalidraw/scene/comparisons.js +1 -1
  351. package/dist/excalidraw/scene/export.d.ts +4 -3
  352. package/dist/excalidraw/scene/export.js +34 -36
  353. package/dist/excalidraw/scene/scroll.d.ts +2 -2
  354. package/dist/excalidraw/scene/scrollbars.d.ts +3 -3
  355. package/dist/excalidraw/scene/selection.d.ts +2 -2
  356. package/dist/excalidraw/scene/types.d.ts +6 -8
  357. package/dist/excalidraw/scene/zoom.d.ts +1 -1
  358. package/dist/excalidraw/shapes.d.ts +8 -0
  359. package/dist/excalidraw/shapes.js +57 -0
  360. package/dist/excalidraw/snapping.d.ts +4 -4
  361. package/dist/excalidraw/snapping.js +2 -1
  362. package/dist/excalidraw/store.d.ts +34 -4
  363. package/dist/excalidraw/store.js +27 -0
  364. package/dist/excalidraw/types.d.ts +32 -21
  365. package/dist/excalidraw/utils.d.ts +15 -5
  366. package/dist/excalidraw/utils.js +22 -0
  367. package/dist/excalidraw/zindex.d.ts +2 -2
  368. package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  369. package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  370. package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  371. package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  372. package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  373. package/dist/prod/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
  374. package/dist/prod/index.css +1 -1
  375. package/dist/prod/index.js +49 -53
  376. package/dist/utils/bbox.d.ts +2 -2
  377. package/dist/utils/collision.d.ts +1 -1
  378. package/dist/utils/export.d.ts +4 -3
  379. package/dist/utils/export.js +2 -1
  380. package/dist/utils/geometry/geometry.d.ts +3 -2
  381. package/dist/utils/geometry/geometry.js +5 -1
  382. package/dist/utils/geometry/shape.d.ts +1 -1
  383. package/dist/utils/index.d.ts +1 -0
  384. package/dist/utils/index.js +1 -0
  385. package/dist/utils/withinBounds.d.ts +1 -1
  386. package/history.ts +13 -6
  387. package/package.json +2 -2
  388. package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
  389. package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
  390. package/dist/browser/dev/excalidraw-assets-dev/chunk-BLEB3M62.js.map +0 -7
  391. package/dist/browser/dev/excalidraw-assets-dev/chunk-XOM7LNOU.js.map +0 -7
  392. package/dist/browser/dev/excalidraw-assets-dev/dist-ITJNUBZF.js.map +0 -7
  393. package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
  394. package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
  395. package/dist/browser/prod/excalidraw-assets/chunk-UWBW5SR2.js +0 -55
  396. package/dist/browser/prod/excalidraw-assets/dist-54276HPL.js +0 -6
  397. package/dist/browser/prod/excalidraw-assets/en-7GPZE2Y2.js +0 -1
  398. package/dist/browser/prod/excalidraw-assets/image-35KQQ5EN.js +0 -1
  399. package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
  400. package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
  401. package/dist/excalidraw/components/Stats.d.ts +0 -11
  402. package/dist/excalidraw/components/Stats.js +0 -13
  403. package/dist/excalidraw/scene/Fonts.d.ts +0 -21
  404. package/dist/excalidraw/scene/Fonts.js +0 -72
  405. package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
  406. package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
  407. /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
  408. /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
  409. /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
  410. /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
  411. /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-XV7OZCPP.js.map} +0 -0
  412. /package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js.map → image-77HZYGLG.js.map} +0 -0
  413. /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
  414. /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
  415. /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
  416. /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
@@ -1,68 +1,64 @@
1
- var VI=Object.defineProperty;var $b=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var j=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ju=(e,t)=>{for(var r in t)VI(e,r,{get:t[r],enumerable:!0})};var T,f=j(()=>{T={PROD:!0}});var eh,qb=j(()=>{eh={}});import t5 from"open-color";var r5,Jb,Yi,Qb,Ka,$a,wo,vo,de,eE,ld,sd,cd,tE,rE,oE,nE,Qt=j(()=>{"use strict";f();r5=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),Jb=5,Yi=5,Qb=4,Ka=4,$a=1,wo=[0,2,4,6,8],vo=(e,t)=>t.map(r=>t5[e][r]),de={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:vo("gray",wo),red:vo("red",wo),pink:vo("pink",wo),grape:vo("grape",wo),violet:vo("violet",wo),blue:vo("blue",wo),cyan:vo("cyan",wo),teal:vo("teal",wo),green:vo("green",wo),yellow:vo("yellow",wo),orange:vo("orange",wo),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},eE=r5(de,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),ld=[de.black,de.red[Ka],de.green[Ka],de.blue[Ka],de.yellow[Ka]],sd=[de.transparent,de.red[$a],de.green[$a],de.blue[$a],de.yellow[$a]],cd=[de.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],tE={transparent:de.transparent,white:de.white,gray:de.gray,black:de.black,bronze:de.bronze,...eE},rE={transparent:de.transparent,white:de.white,gray:de.gray,black:de.black,bronze:de.bronze,...eE},oE=e=>[de.cyan[e],de.blue[e],de.violet[e],de.grape[e],de.pink[e],de.green[e],de.teal[e],de.yellow[e],de.orange[e],de.red[e]],nE=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var ar,dd,iE,bn,o5,x7,md,aE,gs,fs,En,Xa,lE,th,sE,Uo,rh,Le,jn,Ki,bs,yr,pd,mt,ae,je,oh,ud,Lt,Kt,qn,$i,Jn,hd,n5,cE,Es,dE,mE,xn,xs,pE,te,gd,er,ys,uE,hE,gE,fE,Xi,Za,nh,bE,ja,fd,bd,ih,EE,xE,yE,wE,vE,qa,Ja,To,TE,ah,He,Zi,bt,SE,IE,yt,Qn,CE,Ed,AE,at,lh,xd,rt,ws,Nr,yd,wt,Qr,wd,Y=j(()=>{"use strict";f();qb();Qt();ar=/Mac|iPod|iPhone|iPad/.test(navigator.platform),dd=/^Win/.test(navigator.platform),iE=/\b(android)\b/i.test(navigator.userAgent),bn="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,o5=navigator.userAgent.indexOf("Chrome")!==-1,x7=!o5&&navigator.userAgent.indexOf("Safari")!==-1,md=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,aE=()=>navigator.brave?.isBrave?.name==="isBrave",gs=typeof window<"u"&&"ResizeObserver"in window,fs="Excalidraw",En=10,Xa=8,lE=5,th=1,sE=30,Uo=Math.PI/12,rh="red",Le={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},jn={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Ki={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},bs={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},yr={TEST:"test",DEVELOPMENT:"development"},pd={SHAPE_ACTIONS_MENU:"App-menu__left"},mt={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},ae={LIGHT:"light",DARK:"dark"},je={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},oh="Segoe UI Emoji",ud=1,Lt=20,Kt=mt.Virgil,qn="left",$i="top",Jn=2,hd=2*Jn,n5=1e-5,cE=2*hd-n5,Es="#ffffff",dE="#1e1e1e",mE="#a2f1a6",xn=20,xs={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},pE=["text/plain","text/html"],te={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...xs},gd={png:"png",svg:"svg",clipboard:"clipboard"},er={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},ys=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,uE=500,hE=300,gE=500,fE=100,Xi=.1,Za=.1,nh=30,bE=300,ja=eh.themeFilter,fd={addLibrary:"addLibrary"},bd={addLibrary:"addLibrary"},ih={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},EE=730,xE=1e3,yE=500,wE=1229,vE=parseInt(eh.rightSidebarWidth),qa=2,Ja=[1,2,3],To=10,TE=1440,ah=2*1024*1024,He="http://www.w3.org/2000/svg",Zi={excalidraw:2,excalidrawLibrary:2},bt=5,SE=.7,IE=11,yt={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Qn={LEFT:"left",CENTER:"center",RIGHT:"right"},CE=20,Ed=.25,AE=32,at={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},lh={architect:0,artist:1,cartoonist:2},xd={thin:1,bold:2,extraBold:4},rt={strokeColor:de.black,backgroundColor:de.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:lh.artist,opacity:100,locked:!1},ws="library",Nr={name:"default",defaultTab:ws},yd=new Set(["iframe","embeddable","image"]),wt={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},Qr={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},wd="Untitled"});function gt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function VE(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${Td(n[0],i[0]).toFixed(2)},${Td(n[1],i[1]).toFixed(2)} T`;for(let l=2,s=r-1;l<s;l++)o=e[l],n=e[l+1],a+=`${Td(o[0],n[0]).toFixed(2)},${Td(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var ME,ch,ei,DE,dh,_E,eo,Qa,Ye,ji,el,yn,LE,RE,NE,Pt,qe,R,Ke,Ot,vs,p5,u5,h5,Sd,So,Id,mh,ph,lr,Cd,OE,BE,FE,zE,wn,$,HE,Go,Or,UE,Ad,tl,GE,Wo,Ts,PE,Je,ti,Io,WE,Ss,Vo,uh,kd,Td,Md,Br,Is,U=j(()=>{"use strict";f();Qt();Y();ME=null,ch=()=>{if(ME)return ME;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},ei=e=>e.charAt(0).toUpperCase()+e.slice(1),DE=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),dh=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,_E=e=>dh(e)||e instanceof Element&&!!e.closest("label, button"),eo=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Qa=({fontFamily:e})=>{for(let[t,r]of Object.entries(mt))if(r===e)return`${t}, ${oh}`;return oh},Ye=({fontSize:e,fontFamily:t})=>`${e}px ${Qa({fontFamily:t})}`,ji=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},el=(e,t)=>{let r=null,o=null,n=null,i=l=>{r=window.requestAnimationFrame(()=>{r=null,e(...l),o=null,n&&(o=n,n=null,i(o))})},a=(...l)=>{if(T.MODE==="test"){e(...l);return}o=l,r===null?i(o):t?.trailing&&(n=l)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},yn=e=>1-Math.pow(1-e,4),LE=(e,t,r)=>(t-e)*yn(r)+e,RE=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:l})=>{let s=!1,c=0,d;function m(p){if(s)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),h=yn(u/o),E={};if(Object.keys(e).forEach(x=>{let w=x,y=(t[w]-e[w])*h+e[w];E[w]=y}),r(E),u<o){let x=u/o,w={};Object.keys(e).forEach(y=>{let v=y,I=e[v],L=t[v],C;C=n?n(I,L,x,v):LE(I,L,x),C==null&&(C=LE(I,L,x)),w[v]=C}),r(w),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{l?.(),s=!0,window.cancelAnimationFrame(c)}},NE=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},Pt=(e,t)=>Math.abs(e-t),qe=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},R=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),ar?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Ke=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e-o)/r.value-i,s=(t-n)/r.value-a;return{x:l,y:s}},Ot=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let l=(e+i)*r.value+o,s=(t+a)*r.value+n;return{x:l,y:s}},vs=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),p5="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",u5="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",h5=new RegExp(`^[^${p5}]*[${u5}]`),Sd=e=>h5.test(e),So=e=>{let[t,r]=e;return{x:t,y:r}},Id=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},mh=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},ph=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},lr=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===de.transparent},Cd=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},OE=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},BE=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},FE=e=>{e.preventDefault(),e.returnValue=""},zE=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),wn=()=>Or()?1:Date.now(),$=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),HE=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),Go=(e,t)=>e.reduce((r,o)=>(r[t?t(o):String(o)]=o,r),{}),Or=()=>T.MODE==="test",UE=()=>T.MODE==="development",Ad=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),tl=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},GE=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},Wo=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,Ts=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},PE=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,Je=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||PE(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let l=r?.[a],s=l?l(e[a],t[a]):e[a]===t[a]||PE(e[a],t[a]);return!s&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),s})},ti=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},Io=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},WE=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let l=!0;for(let[s,c]of i)if(t.get(s)!==c){l=!1;break}if(l)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},Ss=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Vo=e=>JSON.parse(JSON.stringify(e)),uh=e=>typeof e=="number"&&Number.isFinite(e),kd=(e,t)=>Je(e,t)?e:t;Td=(e,t)=>(e+t)/2;Md=e=>e.replace(/\r?\n|\r/g,`
2
- `),Br=e=>e,Is=async(e,...t)=>new Promise(r=>{r(e(...t))})});var sr,to,It,ro,$t,G,ri,qi,ee,Dt,g5,ne,we,Cs,wr,hh,Ji,Yo,As,tr,Ae,Ko,YE,KE,$E,se=j(()=>{"use strict";f();Y();U();sr=e=>!!e&&e.type==="image"&&!!e.fileId,to=e=>!!e&&e.type==="image",It=e=>!!e&&e.type==="embeddable",ro=e=>!!e&&e.type==="iframe",$t=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),G=e=>e!=null&&e.type==="text",ri=e=>e!=null&&e.type==="frame",qi=e=>e!=null&&e.type==="magicframe",ee=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Dt=e=>e!=null&&g5(e.type),g5=e=>e==="freedraw",ne=e=>e!=null&&Cs(e.type),we=e=>e!=null&&e.type==="arrow",Cs=e=>e==="arrow"||e==="line",wr=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&hh(e.type),hh=e=>e==="arrow",Ji=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),Yo=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||we(e)),As=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return Io(t,null),!1}},tr=e=>Yo(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Ae=e=>e!==null&&"containerId"in e&&e.containerId!==null&&G(e),Ko=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",YE=e=>e==="line"||e==="arrow"||e==="diamond",KE=(e,t)=>!!((e===at.ADAPTIVE_RADIUS||e===at.LEGACY)&&Ko(t.type)||e===at.PROPORTIONAL_RADIUS&&YE(t.type)),$E=e=>YE(e.type)?{type:at.PROPORTIONAL_RADIUS}:Ko(e.type)?{type:at.ADAPTIVE_RADIUS}:null});import{Random as f5}from"roughjs/bin/math";import{nanoid as b5}from"nanoid";var E5,x5,oo,_t,Co=j(()=>{"use strict";f();U();E5=new f5(Date.now()),x5=0,oo=()=>Math.floor(E5.next()*2**31),_t=()=>Or()?`id${x5++}`:b5()});var Ld,$o,Ao,Pd,oi=j(()=>{"use strict";f();Ld=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},$o=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},Ao=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},Pd=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});import{generateNKeysBetween as y5}from"fractional-indexing";var gh,Dd,Bt,cr,w5,v5,ks,ZE,XE,no=j(()=>{"use strict";f();Ue();oi();gh=e=>{for(let[t,r]of e.entries()){let o=e[t-1],n=e[t+1];if(!ks(r,o,n))throw new Pd(`Fractional indices invariant for element has been compromised - ["${o}", "${r}", "${n}"] [predecessor, current, successor]`)}},Dd=e=>e.sort((t,r)=>XE(t)&&XE(r)?t.index<r.index?-1:t.index>r.index?1:t.id<r.id?-1:1:1),Bt=(e,t)=>{try{let r=w5(e,t),o=ZE(e,r);gh(e.map(n=>o.get(n)?.index||n.index));for(let[n,i]of o)F(n,i,!1)}catch{cr(e)}return e},cr=e=>{let t=v5(e),r=ZE(e,t);for(let[o,n]of r)F(o,n,!1);return e},w5=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)&&!ks(e[o]?.index,e[o-1]?.index,e[o+1]?.index)){let n=[o-1,o];for(;++o<e.length&&(t.has(e[o].id)&&!ks(e[o]?.index,e[o-1]?.index,e[o+1]?.index));)n.push(o);n.push(o),r.push(n)}else o++;return r},v5=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},l=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},s=0;for(;s<e.length;){let c=e[s].index;if([r,n]=a(s),[o,i]=l(s),ks(c,r,o))s++;else{let d=[n,s];for(;++s<e.length;){let m=e[s].index,[p,u]=a(s),[h,E]=l(s);if(ks(m,p,h))break;[r,n]=[p,u],[o,i]=[h,E],d.push(s)}d.push(i),t.push(d)}}return t},ks=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,ZE=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=y5(e[n]?.index,e[i]?.index,o.length);for(let l=0;l<o.length;l++){let s=e[o[l]];r.set(s,{index:a[l]})}}return r},XE=e=>!!e.index});var jE,T5,qE,fh,Ct,ni=j(()=>{"use strict";f();be();se();ii();Co();no();U();U();Y();jE=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},T5=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},qE=e=>typeof e=="string",fh=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){qE(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return qE(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Br(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Br(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};versionNonce;getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=T5(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=ue(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getVersionNonce(){return this.versionNonce}getNonDeletedElement(t){let r=this.getElement(t);return r&&Ms(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===yr.TEST)&&gh(r.map(i=>i.index)),this.elements=cr(r),this.elementsMap.clear(),this.elements.forEach(i=>{ee(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=jE(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=jE(this.frames).elements,this.informMutation()}informMutation(){this.versionNonce=oo();for(let t of Array.from(this.callbacks))t()}addCallback(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];Bt(o,$([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];Bt(o,$(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},Ct=fh});var _d,ai,Ls=j(()=>{"use strict";f();_d=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},ai=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),l=i-a,s=l===0?1:t/l,c=1/0,d=r.map(u=>{let h=u[e]*s,E=[...u];return E[e]=h,h<c&&(c=h),E});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((h,E)=>E===e?h+m:h))}});var ye,Ge,JE,vt,Ps,dr,Rd,At,ko,bh,Eh,S5,QE,ex,tx,xh,rx,Ds,_s,Rs,Ft=j(()=>{"use strict";f();Y();lt();Xo();ye=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],Ge=(e,t,r)=>ye(e[0],e[1],t[0],t[1],r),JE=(e,t,r,o,n,i,a,l)=>{let s=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+s),r+=n*c,t+=a*(1-s),r+=a*-c):e.w&&(t+=n*(1-s),r+=n*-c,t+=a*(1+s),r+=a*c),e.n&&e.s?r+=i+l:e.n?(t+=i*c,r+=i*(1-s),t+=l*-c,r+=l*(1+s)):e.s&&(t+=i*-c,r+=i*(1+s),t+=l*c,r+=l*(1-s)),[t,r]},vt=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},Ps=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],dr=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return vt(r[0],r[1],o[0],o[1])<=Xa/t}return!1},Rd=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),At=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],ko=(e,t)=>{if(t.roundness?.type===at.PROPORTIONAL_RADIUS||t.roundness?.type===at.LEGACY)return e*Ed;if(t.roundness?.type===at.ADAPTIVE_RADIUS){let r=t.roundness?.value??AE,o=r/Ed;return e<=o?e*Ed:r}return 0},bh=(e,t)=>{let r=Pe.generateElementShape(e,null);if(!r)return null;let o=li(r[0]),n=[0,0],i=0,a=1/0,l=null;for(;i<o.length;){let{op:s,data:c}=o[i];if(s==="move"&&(n=c),s==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],h=vt(u[0],u[1],t[0],t[1]);h<a&&(a=h,l=[d,m,p,u]),n=u}i++}return l},Eh=(e,t,r,o,n)=>{let i=(s,c)=>Math.pow(1-s,3)*o[c]+3*s*Math.pow(1-s,2)*r[c]+3*Math.pow(s,2)*(1-s)*t[c]+e[c]*Math.pow(s,3),a=i(n,0),l=i(n,1);return[a,l]},S5=(e,t)=>{let r=bh(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=Eh(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&xh(o.at(-1),t)&&o.push([t[0],t[1]]),o},QE=(e,t)=>{let r=[];r[0]=0;let o=S5(e,t),n=0,i=0;for(;n<o.length-1;){let a=vt(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},ex=(e,t)=>QE(e,t).at(-1),tx=(e,t,r)=>{let o=QE(e,t),n=o.length-1,i=o.at(-1),a=r*i,l=0,s=n,c=0;for(;l<s;)c=Math.floor(l+(s-l)/2),o[c]<a?l=c+1:s=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},xh=(e,t)=>e[0]===t[0]&&e[1]===t[1],rx=e=>Math.round(e/Math.PI*1e4)%5e3===0,Ds=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,_s=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},Rs=(e,t,r)=>e>=t&&e<=r});var vn,Ns,Nd,Od,rl,Qi,yh,Os=j(()=>{"use strict";f();se();vn=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",Ns=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",Nd=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",Od=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",rl=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",Qi=e=>e==="arrow",yh=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as I5}from"points-on-curve";function A5(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&rl(e.type)||ne(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var C5,ix,Fr,ox,nx,ax,wh=j(()=>{"use strict";f();be();Ft();Tn();U();Y();se();Os();C5=e=>[8,8+e],ix=e=>[1.5,6+e];Fr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?C5(e.strokeWidth):e.strokeStyle==="dotted"?ix(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:A5(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<lh.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=lr(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return dr(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},ox=(e,t,r)=>$t(e)&&(t||It(e)&&r?.get(e.id)!==!0)&&lr(e.backgroundColor)&&lr(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:ro(e)?{...e,strokeColor:lr(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:lr(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,nx=(e,t,r,o,n,i,a)=>{let l=Th(e,t,r,o);if(l===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[s,c,d]=l;return delete i.strokeLineDash,[n.circle(s,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[s,c,d,m,p,u]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[s,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[s,c,d,m,p,u,h,E]=l;return delete i.strokeLineDash,[n.polygon([[s,c],[d,m],[p,u],[h,E],[s,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[s,c,d,m,p,u]=l;if(e.strokeStyle==="dotted"){let h=ix(e.strokeWidth-1);i.strokeLineDash=[h[0],h[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,s,c,i),n.line(p,u,s,c,i)]}}},ax=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=ko(Math.min(a,l),e);i=t.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Fr(ox(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,Fr(ox(e,r,n),!1));return i}case"diamond":{let i,[a,l,s,c,d,m,p,u]=vh(e);if(e.roundness){let h=ko(Math.abs(a-p),e),E=ko(Math.abs(c-l),e);i=t.path(`M ${a+h} ${l+E} L ${s-h} ${c-E}
3
- C ${s} ${c}, ${s} ${c}, ${s-h} ${c+E}
4
- L ${d+h} ${m-E}
5
- C ${d} ${m}, ${d} ${m}, ${d-h} ${m-E}
6
- L ${p+h} ${u+E}
7
- C ${p} ${u}, ${p} ${u}, ${p+h} ${u-E}
8
- L ${a-h} ${l+E}
9
- C ${a} ${l}, ${a} ${l}, ${a+h} ${l+E}`,Fr(e,!0))}else i=t.polygon([[a,l],[s,c],[d,m],[p,u]],Fr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Fr(e));case"line":case"arrow":{let i,a=Fr(e),l=e.points.length?e.points:[[0,0]];if(e.roundness?i=[t.curve(l,a)]:a.fill?i=[t.polygon(l,a)]:i=[t.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:c="arrow"}=e;if(s!==null){let d=nx(e,i,"start",s,t,a,o);i.push(...d)}if(c!==null){let d=nx(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(lx(e),dr(e.points)){let a=I5(e.points,.75);i=t.curve(a,{...Fr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return Io(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}}});var rr,sx,ea,ol,cx,Sh,si,k5,Ih,Bd,Ch,dx,Ah,mx,ta,px,kh,O_,B_,F_,z_,H_,U_,G_,ra=j(()=>{"use strict";f();rr=(e,t)=>[0,0,0,0,t,e,1,0],sx=(e,t)=>[0,0,0,0,t,e,0,0],ea=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},ol=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],cx=(e,t)=>kh(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Sh=(e,t)=>kh(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],si=(e,t)=>kh(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[k5(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],k5=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],Ih=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],Bd=(e,t)=>[Ch(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],Ch=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],dx=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],Ah=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),mx=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),ta=e=>{let t=Ah(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return si(e,r/t)},px=e=>{let t=mx(e);return t===0||t===1?e:si(e,1/t)},kh=e=>typeof e=="number",O_=ea(1,1),B_=ea(1,2),F_=ea(1,3),z_=ea(1,4),H_=ea(1,5),U_=ea(1,6),G_=ea(1,7)});var Fd,nl,ux,hx,gx,Mh=j(()=>{"use strict";f();ra();Fd=(e,t,r)=>ta([0,r,e,t,0,0,0,0]),nl=(e,t)=>ta(Bd(t,e)),ux=(e,t)=>dx(e,t),hx=(e,t)=>ux(nl(e,t),t),gx=e=>Math.sign(e[1])});var oa,na,bx,Ex,Lh,ci,xx=j(()=>{"use strict";f();ra();Mh();ra();oa=([e,t])=>[0,0,0,0,t,e,1,0],na=e=>[e[5],e[4]],bx=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],Ex=(e,t)=>ta(Ih(e,t)),Lh=(e,t)=>Ah(Bd(e,t)),ci=(e,t)=>Ch(e,t)});var Ph,yx,Dh=j(()=>{"use strict";f();ra();Ph=e=>[0,0,0,0,e[4],e[5],0,0],yx=(e,t)=>px([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var _h,vx,Tx,Sx,Mo,Ix=j(()=>{"use strict";f();ra();Dh();_h=(e,t)=>cx(si(e,Math.sin(t/2)),Math.cos(t/2)),vx=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],Tx=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},Sx=(e,t)=>si(t,e),Mo=(e,t)=>ta(si(si(e,t),ol(e)))});var il,P5,al,Zo,D5,Cx,_5,Et,R5,Rh,N5,Ax,O5,ia,Nh,B5,F5,Oh,kx,Bh,Mx,z5,Lx,Px,zd=j(()=>{"use strict";f();Ft();il=1e-4,P5=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},al=e=>P5(e)?e:[...e,e[0]],Zo=e=>e*180/Math.PI,D5=e=>e/180*Math.PI,Cx=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],_5=e=>e[0]===0&&e[1]===0,Et=(e,t,r)=>{let o=D5(t);return!r||_5(r)?Cx(e,o):Cx(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},R5=e=>[-e[0],-e[1]],Rh=(e,t)=>[e[0]+t[0],e[1]+t[1]],N5=(e,t)=>vt(...e,...t),Ax=(e,t,r)=>{let o=Rh(e,R5(t));return Et(o,-Zo(r))},O5=(e,t)=>{let[r,o]=e,[[n,i],[a,l]]=t,s=r-n,c=o-i,d=a-n,m=l-i,p=s*d+c*m,u=d*d+m*m,h=-1;u!==0&&(h=p/u);let E,x;h<0?(E=n,x=i):h>1?(E=a,x=l):(E=n+h*d,x=i+h*m);let w=r-E,y=o-x;return Math.sqrt(w*w+y*y)},ia=(e,t,r=il)=>{let o=O5(e,t);return o===0?!0:o<r},Nh=(e,t,r=il)=>t.some(o=>ia(e,o,r)),B5=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},F5=(e,t=10)=>{let r=B5(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let l=0;l<t;l++)if(i+=a,i<=1){let s=[r(i,0),r(i,1)];n.push([o,s]),o=s}return n},Oh=(e,t,r=il)=>Nh(e,F5(t),r),kx=(e,t,r=il)=>t.some(o=>Oh(e,o,r)),Bh=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let l=t[i][0],s=t[i][1],c=t[a][0],d=t[a][1];(s>o&&d<=o||s<=o&&d>o)&&r<(c-l)*(o-s)/(d-s)+l&&(n=!n)}return n},Mx=(e,t,r=il)=>{let o=!1,n=al(t);for(let i=0,a=n.length-1;i<a;i++)if(ia(e,[n[i],n[i+1]],r)){o=!0;break}return o},z5=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,l=n,[s,c]=Ax(e,i,r),d=Math.abs(s),m=Math.abs(c),p=.707,u=.707;for(let x=0;x<3;x++){let w=a*p,y=l*u,v=(a*a-l*l)*p**3/a,I=(l*l-a*a)*u**3/l,L=w-v,C=y-I,M=d-v,_=m-I,H=Math.hypot(C,L),k=Math.hypot(_,M);p=Math.min(1,Math.max(0,(M*H/k+v)/a)),u=Math.min(1,Math.max(0,(_*H/k+I)/l));let N=Math.hypot(u,p);p/=N,u/=N}let[h,E]=[a*p*Math.sign(s),l*u*Math.sign(c)];return N5([s,c],[h,E])},Lx=(e,t,r=il)=>z5(e,t)<=r,Px=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,l]=Ax(e,r,o);return a/n*(a/n)+l/i*(l/i)<=1}});var Fs,ll,Hd=j(()=>{"use strict";f();zd();Fs=(e,t,r=0)=>{switch(t.type){case"polygon":return Mx(e,t.data,r);case"ellipse":return Lx(e,t.data,r);case"line":return ia(e,t.data,r);case"polyline":return Nh(e,t.data,r);case"curve":return Oh(e,t.data,r);case"polycurve":return kx(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},ll=(e,t)=>{switch(t.type){case"polygon":return Bh(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return Px(e,t.data);case"polyline":{let r=al(t.data.flat());return Bh(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var fe,S,sl,Ud,cl,aa,ge=j(()=>{"use strict";f();Y();fe={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:ar?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},sl=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,Ud=e=>e.altKey,cl=e=>e.shiftKey,aa=e=>e.shiftKey});var Nx,jo,H5,sa,Dx,U5,Ox,G5,W5,Hs,Vd,Us,la,Bx,Fh,Fx,V5,qo,Y5,zr,K5,$5,X5,_x,dl,zx,Yd,Rx,Kd,zs,Hx,Gs,Z5,j5,q5,J5,Q5,zh,Hh,Uh,eC,tC,rC,oC,Ux,nC,iC,aC,lC,sC,cC,Gx,Gd,Wd,di,mi,io=j(()=>{"use strict";f();ra();xx();Dh();Mh();Ix();lt();Hd();$e();se();Ue();ni();Xt();U();ge();st();Nx=e=>!e[S.CTRL_OR_CMD],jo=e=>e.isBindingEnabled,H5=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},sa=(e,t,r,o)=>{let n=new Set,i=new Set;Dx(e,t,r,"start",n,i,o),Dx(e,r,t,"end",n,i,o);let a=Array.from(i).filter(l=>!n.has(l));H5(Ct.getScene(e),a).forEach(l=>{F(l,{boundElements:l.boundElements?.filter(s=>s.type!=="arrow"||s.id!==e.id)})})},Dx=(e,t,r,o,n,i,a)=>{if(t!=="keep"){if(t===null){let l=V5(e,o);l!=null&&i.add(l);return}Fx(e)?(r==null||(r==="keep"?!Bx(e,t,o):o==="start"||r.id!==t.id))&&(la(e,t,o,a),n.add(t.id)):(la(e,t,o,a),n.add(t.id))}},U5=(e,t,r)=>{let o=r.scene.getNonDeletedElementsMap(),n=zx(e,t,o),i=t==="start"?e.startBinding?.elementId:e.endBinding?.elementId;if(i){let a=o.get(i);if(Hx(a,n,r))return a}return null},Ox=(e,t)=>["start","end"].map(r=>U5(e,r,t)),G5=(e,t,r,o)=>{let i=e.points.length-1,a=r.findIndex(d=>d===0)>-1,l=r.findIndex(d=>d===i)>-1,s=a?t?dl(e,"start",o):null:dl(e,"start",o),c=l?t?dl(e,"end",o):null:dl(e,"end",o);return[s,c]},W5=(e,t,r)=>{let[o,n]=Ox(e,t),i=o&&r?dl(e,"start",t):null,a=n&&r?dl(e,"end",t):null;return[i,a]},Hs=(e,t,r,o)=>{e.forEach(n=>{let[i,a]=o?.length?G5(n,r,o??[],t):W5(n,t,r);sa(n,i,a,t.scene.getNonDeletedElementsMap())})},Vd=(e,t)=>e.length>50?[]:e.filter(ne).flatMap(r=>Ox(r,t)).filter(r=>r!==null).filter(r=>e.filter(o=>o.id===r?.id).length===0),Us=(e,t,r,o)=>{t.startBoundElement!=null&&la(e,t.startBoundElement,"start",o.scene.getNonDeletedElementsMap());let n=qo(r,o);n!=null&&!Bx(e,n,"end")&&la(e,n,"end",o.scene.getNonDeletedElementsMap())},la=(e,t,r,o)=>{F(e,{[r==="start"?"startBinding":"endBinding"]:{elementId:t.id,...Y5(e,t,r,o)}}),$(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Bx=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return Fh(e,o?.elementId,t)},Fh=(e,t,r)=>t===r.id&&Fx(e),Fx=e=>e.points.length<3,V5=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(F(e,{[r]:null}),o.elementId)},qo=(e,t)=>yh(t.scene.getNonDeletedElements(),o=>Ji(o,!1)&&Hx(o,e,t)),Y5=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,l=X.getPointAtIndexGlobalCoordinates(e,i,o),s=X.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:eC(t,s,l,o),gap:Math.max(1,Z5(t,l,o))}},zr=(e,t,r)=>{let{newSize:o,simultaneouslyUpdated:n}=r??{},i=$5(n);Ji(e)&&Gd(t,e,a=>{if(!ne(a)||a.isDeleted||!K5(a,e))return;let l={startBinding:_x(e,a.startBinding,o),endBinding:_x(e,a.endBinding,o)};if(i.has(a.id)){F(a,l);return}Wd(t,a,(c,d)=>{c&&Ji(c)&&(d==="startBinding"||d==="endBinding")&&X5(a,d,l[d],c,t)});let s=me(a,t);s&&!s.isDeleted&&ca(a,t,!1)})},K5=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,$5=e=>new Set((e||[]).map(t=>t.id)),X5=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return;let i=t==="startBinding"?-1:1,a=i===-1?0:e.points.length-1,l=a-i,s=X.getPointAtIndexGlobalCoordinates(e,l,n),c=tC(o,r.focus,s,n),d;if(r.gap===0)d=c;else{let m=rC(o,s,c,r.gap,n);m.length===0?d=c:d=m[0]}X.movePoints(e,[{index:a,point:X.pointFromAbsoluteCoords(e,d,n)}],{[t]:r})},_x=(e,t,r)=>{if(t==null||r==null)return t;let{gap:o,focus:n,elementId:i}=t,{width:a,height:l}=r,{width:s,height:c}=e,d=Math.max(1,Math.min(Gs(e,a,l),o*(a<l?a/s:l/c)));return{elementId:i,gap:d,focus:n}},dl=(e,t,r)=>qo(zx(e,t,r.scene.getNonDeletedElementsMap()),r),zx=(e,t,r)=>{let o=t==="start"?0:-1;return So(X.getPointAtIndexGlobalCoordinates(e,o,r))},Yd=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld";t.forEach(l=>{let{boundElements:s}=l;if(s!=null&&s.length>0&&(s.forEach(c=>{a&&!r.has(c.id)&&n.add(c.id)}),i.add(r.get(l.id))),wr(l)){if(l.startBinding!=null){let{elementId:c}=l.startBinding;a&&!r.has(c)&&i.add(c)}if(l.endBinding!=null){let{elementId:c}=l.endBinding;a&&!r.has(c)&&i.add(c)}(l.startBinding!=null||l.endBinding!=null)&&n.add(r.get(l.id))}}),e.filter(({id:l})=>n.has(l)).forEach(l=>{let{startBinding:s,endBinding:c}=l;F(l,{startBinding:Rx(s,r),endBinding:Rx(c,r)})}),e.filter(({id:l})=>i.has(l)).forEach(l=>{let{boundElements:s}=l;s!=null&&s.length>0&&F(l,{boundElements:s.map(c=>r.has(c.id)?{id:r.get(c.id),type:c.type}:c)})})},Rx=(e,t)=>{if(e==null)return null;let{elementId:r,focus:o,gap:n}=e;return{focus:o,gap:n,elementId:t.get(r)??r}},Kd=(e,t)=>{let r=$(e);for(let o of t)di.unbindAffected(r,o,F),mi.unbindAffected(r,o,F)},zs=(e,t,r=[])=>{if(!e)return null;let o=e.filter(n=>!t.has(n.id));return o.push(...r.map(n=>({id:n.id,type:n.type}))),o},Hx=(e,{x:t,y:r},o)=>{let n=Gs(e,e.width,e.height),i=o.getElementShape(e);return Fs([t,r],i,n)},Gs=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},Z5=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return j5(e,t,r);case"diamond":return q5(e,t,r);case"ellipse":return J5(e,t,r)}},j5=(e,t,r)=>{let[,o,n,i]=zh(e,t,r);return Math.max(ci(o,Fd(0,1,-i)),ci(o,Fd(1,0,-n)))},q5=(e,t,r)=>{let[,o,n,i]=zh(e,t,r),a=Fd(i,n,-i*n);return ci(o,a)},J5=(e,t,r)=>{let[o,n]=Q5(e,t,r);return-gx(n)*ci(o,n)},Q5=(e,t,r)=>{let[,o,n,i]=zh(e,t,r),[a,l]=na(o),s=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(h=>{let E=d*s,x=m*c,w=(d*d-m*m)*s**3/d,y=(m*m-d*d)*c**3/m,v=E-w,I=x-y,L=a-w,C=l-y,M=Math.hypot(I,v),_=Math.hypot(C,L);s=Math.min(1,Math.max(0,(L*M/_+w)/d)),c=Math.min(1,Math.max(0,(C*M/_+y)/m));let H=Math.hypot(c,s);s/=H,c/=H});let p=rr(d*s,m*c),u=hx(o,p);return[o,u]},zh=(e,t,r)=>{let o=oa(t),[n,i,a,l]=re(e,r),s=Uh(n,i,a,l),c=_h(s,e.angle),d=Mo(c,o),m=Sh(d,Ph(s)),p=bx(m),u=sx(e.x,e.y),h=Sh(d,u),E=(a-n)/2,x=(l-i)/2;return[h,p,E,x]},Hh=(e,t)=>{let[r,o,n,i]=re(e,t),a=Uh(r,o,n,i),l=_h(a,e.angle),s=ol(vx(Ph(a)));return Sx(l,s)},Uh=(e,t,r,o)=>rr((e+r)/2,(t+o)/2),eC=(e,t,r,o)=>{let n=Hh(e,o),i=Mo(n,oa(t)),a=Mo(n,oa(r)),l=nl(i,a),s=e.height/e.width,c=e.width/2,d=e.height/2,m=l[2],p=l[3],u=l[1],h=Math.abs(p),E=Math.abs(m),x;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":x=u/(c*(E+s*h));break;case"diamond":x=h<E?u/(E*c):u/(h*d);break;case"ellipse":x=u/(c*Math.sqrt(m**2+s**2*p**2));break}return x||0},tC=(e,t,r,o)=>{if(t===0){let[s,c,d,m]=re(e,o),p=Uh(s,c,d,m);return na(p)}let n=Hh(e,o),i=Mo(n,oa(r)),a=ol(n),l;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":l=cC(e,t,i);break;case"ellipse":l=sC(e,t,i);break}return na(Mo(a,l))},rC=(e,t,r,o=0,n)=>{let i=Hh(e,n),a=Mo(i,oa(t)),l=Mo(i,oa(r)),s=nl(a,l),c=ol(i);return oC(e,s,a,o).map(m=>na(Mo(c,m)))},oC=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=Ux(e);n=a.flatMap((l,s)=>{let c=[l,a[(s+1)%4]];return nC(t,iC(c,o))}).concat(a.flatMap(l=>lC(l,o,t)));break;case"ellipse":n=aC(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,l)=>Lh(a,r)-Lh(l,r));return[i[0],i[i.length-1]]},Ux=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[rr(r,o),rr(r,-o),rr(-r,-o),rr(-r,o)];case"diamond":return[rr(0,o),rr(r,0),rr(0,-o),rr(-r,0)]}},nC=(e,t)=>{let[r,o]=t,n=ci(r,e),i=ci(o,e);return n*i>=0?[]:[Ex(e,nl(r,o))]},iC=(e,t)=>{let[r,o]=e,n=Tx(yx(r,o),t);return[Mo(n,r),Mo(n,o)]},aC=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],l=r[1],s=o*o*i*i+n*n*a*a,c=s-l*l;if(s===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*l,p=-n*n*a*l;return[rr((m+o*n*a*d)/s,(p-o*n*i*d)/s),rr((m-o*n*a*d)/s,(p+o*n*i*d)/s)]},lC=(e,t,r)=>{if(t===0)return ci(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,l]=na(e),s=t,c=o*o+n*n,d=s*s*c-(o*a+n*l+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-l*o*n-o*i,u=l*o*o-a*o*n-n*i;return[rr((p+n*m)/c,(u-o*m)/c),rr((p-n*m)/c,(u+o*m)/c)]},sC=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[l,s]=na(r),c=s===0?1e-4:s,d=l**2*i**2+c**2*n**2,m=(-l*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*l-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return rr(u,(-m*u-1)/p)},cC=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=Ux(e,o),a=0,l=null;return i.forEach(s=>{let c=n*nl(r,s)[1];c>a&&(a=c,l=s)}),l},Gx=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),Gd=(e,t,r)=>{Ji(t)&&(t.boundElements?.slice()??[]).forEach(({id:n})=>{r(e.get(n),"boundElements",n)})},Wd=(e,t,r)=>{if(t.frameId){let o=t.frameId;r(e.get(o),"frameId",o)}if(Ae(t)){let o=t.containerId;r(e.get(o),"containerId",o)}if(we(t)){if(t.startBinding){let o=t.startBinding.elementId;r(e.get(o),"startBinding",o)}if(t.endBinding){let o=t.endBinding.elementId;r(e.get(o),"endBinding",o)}}},di=class{static unbindAffected(t,r,o){r&&Wd(t,r,n=>{!n||n.isDeleted||Gd(t,n,(i,a,l)=>{l===r.id&&o(n,{boundElements:zs(n.boundElements,new Set([l]))})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||Wd(t,r,(n,i)=>{if(!n||n.isDeleted){o(r,{[i]:null});return}i!=="frameId"&&(n.boundElements?.find(a=>a.id===r.id)||(we(r)&&o(n,{boundElements:zs(n.boundElements,new Set,new Array(r))}),G(r)&&(n.boundElements?.find(a=>a.type==="text")?o(r,{[i]:null}):o(n,{boundElements:zs(n.boundElements,new Set,new Array(r))}))))})}},mi=class{static unbindAffected(t,r,o){r&&Gd(t,r,n=>{!n||n.isDeleted||Wd(t,n,(i,a,l)=>{l===r.id&&o(n,{[a]:null})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||Gd(t,r,(n,i,a)=>{if(!n||n.isDeleted){o(r,{boundElements:zs(r.boundElements,new Set([a]))});return}G(n)&&((r.boundElements?.slice()??[]).reverse().find(s=>s.type==="text")?.id===n.id?n.containerId!==r.id&&o(n,{containerId:r.id}):(n.containerId!==null&&o(n,{containerId:null}),o(r,{boundElements:zs(r.boundElements,new Set([n.id]))})))})}}});var Sn,X,dC,Xt=j(()=>{"use strict";f();Ft();be();lt();Ue();io();U();se();ge();st();Y();Xo();Sn={version:null,points:[],zoom:null},X=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,e.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:l}=i,s=e.getElement(l,n);if(!s)return!1;let[c,d,m,p]=re(r.draggingElement,n),h=e.getPointsGlobalCoordinates(s,n).reduce((E,x,w)=>((x[0]>=c&&x[0]<=m&&x[1]>=d&&x[1]<=p||t.shiftKey&&a?.includes(w))&&E.push(w),E),[]);o({editingLinearElement:{...i,selectedPointsIndices:h.length?h:null}})}static handlePointDragging(t,r,o,n,i,a,l){if(!a)return!1;let{selectedPointsIndices:s,elementId:c}=a,d=e.getElement(c,l);if(!d)return!1;let m=d.points[a.pointerDownState.lastClickedPoint];if(s&&m){if(aa(t)&&s.length===1&&d.points.length>1){let u=s[0],h=d.points[u===0?1:u-1],[E,x]=e._getShiftLockedDelta(d,l,h,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:u,point:[E+h[0],x+h[1]],isDragging:u===a.pointerDownState.lastClickedPoint}])}else{let u=e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),h=u[0]-m[0],E=u[1]-m[1];e.movePoints(d,s.map(x=>{let w=x===a.pointerDownState.lastClickedPoint?e.createPointAt(d,l,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[x][0]+h,d.points[x][1]+E];return{index:x,point:w,isDragging:x===a.pointerDownState.lastClickedPoint}}))}if(me(d,l)&&ca(d,l,!1),wr(d,!1)){let u=[];s[0]===0&&u.push(So(e.getPointGlobalCoordinates(d,d.points[0],l)));let E=s[s.length-1];E===d.points.length-1&&u.push(So(e.getPointGlobalCoordinates(d,d.points[E],l))),u.length&&i(d,u)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.scene.getNonDeletedElementsMap(),{elementId:a,selectedPointsIndices:l,isDragging:s,pointerDownState:c}=r,d=e.getElement(a,i);if(!d)return r;let m={};if(s&&l){for(let p of l)if(p===0||p===d.points.length-1){dr(d.points,o.zoom.value)&&e.movePoints(d,[{index:p,point:p===0?d.points[d.points.length-1]:d.points[0]}]);let u=jo(o)?qo(So(e.getPointAtIndexGlobalCoordinates(d,p,i)),n):null;m[p===0?"startBindingElement":"endBindingElement"]=u}}return{...r,...m,selectedPointsIndices:s||t.shiftKey?!s&&t.shiftKey&&c.prevSelectedPointsIndices?.includes(c.lastClickedPoint)?l&&l.filter(p=>p!==c.lastClickedPoint):l:l?.includes(c.lastClickedPoint)?[c.lastClickedPoint]:l,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=me(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(Sn.version===t.version&&Sn.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),Sn.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let l=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(l),i++}Sn.points=a,Sn.version=t.version,Sn.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&vt(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&vt(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=vt(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=ex(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=Ps(r,o);if(t.points.length>2&&t.roundness){let l=bh(t,t.points[n]);if(l){let s=tx(t,t.points[n],.5),[c,d]=Eh(l[0],l[1],l[2],l[3],s);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),l=0;for(;l<a.length;){if(e.arePointsEqual(o,a[l]))return l+1;l++}return-1}static handlePointerDown(t,r,o,n,i,a){let l=a.scene.getNonDeletedElementsMap(),s={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return s;let{elementId:c}=i,d=e.getElement(c,l);if(!d)return s;let m=e.getSegmentMidpointHitCoords(i,n,r,l),p=null;if(m&&(p=e.getSegmentMidPointIndex(i,r,m,l)),t.altKey&&r.editingLinearElement)return i.lastUncommittedPoint==null&&(F(d,{points:[...d.points,e.createPointAt(d,l,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),s.didAddPoint=!0),o.shouldCaptureIncrement(),s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:[d.points.length-1],lastUncommittedPoint:null,endBindingElement:qo(n,a)},s.didAddPoint=!0,s;let u=e.getPointIndexUnderCursor(d,l,r.zoom,n.x,n.y);if(u>=0||m)s.hitElement=d;else{let{startBindingElement:C,endBindingElement:M}=i;jo(r)&&wr(d)&&sa(d,C,M,l)}let[h,E,x,w]=re(d,l),y=(h+x)/2,v=(E+w)/2,I=u>-1&&ye(d.x+d.points[u][0],d.y+d.points[u][1],y,v,d.angle),L=u>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(u)?dC([...i.selectedPointsIndices||[],u]):[u]:null;return s.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:u,origin:{x:n.x,y:n.y},segmentMidpoint:{value:m,index:p,added:!1}},selectedPointsIndices:L,pointerOffset:I?{x:n.x-I[0],y:n.y-I[1]}:{x:0,y:0}},s}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:xh(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:l}=n.editingLinearElement,s=e.getElement(a,i);if(!s)return n.editingLinearElement;let{points:c}=s,d=c[c.length-1];if(!t.altKey)return d===l&&e.deletePoints(s,[c.length-1]),{...n.editingLinearElement,lastUncommittedPoint:null};let m;if(aa(t)&&c.length>=2){let p=c[c.length-2],[u,h]=e._getShiftLockedDelta(s,i,p,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);m=[u+p[0],h+p[1]]}else m=e.createPointAt(s,i,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]?null:n.gridSize);return d===l?e.movePoints(s,[{index:s.points.length-1,point:m}]):e.addPoints(s,n,[{point:m}]),{...n.editingLinearElement,lastUncommittedPoint:s.points[s.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,l]=re(t,o),s=(n+a)/2,c=(i+l)/2,{x:d,y:m}=t;return[d,m]=ye(d+r[0],m+r[1],s,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=re(t,r),l=(o+i)/2,s=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=ye(d+c[0],m+c[1],l,s,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,l,s]=re(t,o),c=(i+l)/2,d=(a+s)/2,m=t.points[n],{x:p,y:u}=t;return m?ye(p+m[0],u+m[1],c,d,t.angle):ye(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){let[n,i,a,l]=re(t,o),s=(n+a)/2,c=(i+l)/2,[d,m]=ye(r[0],r[1],s,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),l=a.length;for(;--l>-1;){let s=a[l];if(vt(n,i,s[0],s[1])*o.value<e.POINT_HANDLE_SIZE+1)return l}return-1}static createPointAt(t,r,o,n,i){let a=At(o,n,i),[l,s,c,d]=re(t,r),m=(l+c)/2,p=(s+d)/2,[u,h]=ye(a[0],a[1],m,p,-t.angle);return[u-t.x,h-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=e.getElement(n,r);if(!i||o===null)return!1;let{points:a}=i,l=[],s=!1,c=-1,d=a.reduce((m,p,u)=>{if(++c,m.push(p),o.includes(u)){let E=a[u+1];E||(s=!0),m.push(E?[(p[0]+E[0])/2,(p[1]+E[1])/2]:[p[0],p[1]]),l.push(c+1),++c}return m},[]);if(F(i,{points:d}),s){let m=i.points[i.points.length-1];e.movePoints(i,[{index:i.points.length-1,point:[m[0]+30,m[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:l}}}}static deletePoints(t,r){let o=0,n=0;if(r.includes(0)){let l=t.points.find((s,c)=>!r.includes(c));l&&(o=l[0],n=l[1])}let a=t.points.reduce((l,s,c)=>(r.includes(c)||l.push(l.length?[s[0]-o,s[1]-n]:[0,0]),l),[]);e._updatePoints(t,a,o,n)}static addPoints(t,r,o){let a=[...t.points,...o.map(l=>l.point)];e._updatePoints(t,a,0,0)}static movePoints(t,r,o){let{points:n}=t,i=0,a=0,l=r.find(({index:c})=>c===0);l&&(i=l.point[0]+n[l.index][0],a=l.point[1]+n[l.index][1]);let s=n.map((c,d)=>{let m=r.find(p=>p.index===d);if(m){if(l)return c;let p=m.point[0]-n[m.index][0],u=m.point[1]-n[m.index][1];return[c[0]+p,c[1]+u]}return i||a?[c[0]-i,c[1]-a]:c});e._updatePoints(t,s,i,a,o)}static shouldAddMidpoint(t,r,o,n){if(!e.getElement(t.elementId,n))return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let l=t.pointerDownState.origin,s=vt(l.x,l.y,r.x,r.y);return!(!o.editingLinearElement&&s<En/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:l}=t.pointerDownState,s={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n?o.gridSize:null),d=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return F(a,{points:d}),s.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:l.index},s.selectedPointsIndices=[l.index],s}static _updatePoints(t,r,o,n,i){let a=Gh(t,r),l=Gh(t,t.points),s=(a[0]+a[2])/2,c=(a[1]+a[3])/2,d=(l[0]+l[2])/2,m=(l[1]+l[3])/2,p=d-s,u=m-c,h=ye(o,n,p,u,t.angle);F(t,{...i,points:r,x:t.x+h[0],y:t.y+h[1]})}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r),[l,s]=At(n[0],n[1],i),{width:c,height:d}=ml(a[0],a[1],l,s);return Ge([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&F(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let l=Math.floor(t.points.length/2),s=e.getPointGlobalCoordinates(t,t.points[l],o);i=s[0]-r.width/2,a=s[1]-r.height/2}else{let l=t.points.length/2-1,s=Sn.points[l];t.points.length===2&&(s=Ps(n[0],n[1])),(!s||Sn.version!==t.version)&&(s=e.getSegmentMidPoint(t,n[l],n[l+1],l+1,o)),i=s[0]-r.width/2,a=s[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,l,s]=o,c=(i+l)/2,d=(a+s)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,h=p+n.height,E=Ge([i,a],[c,d],t.angle),x=Ge([l,a],[c,d],t.angle),w=Ge([m,p],[c,d],-t.angle),y=Ge([u,p],[c,d],-t.angle),v=Ge([m,h],[c,d],-t.angle),I=Ge([u,h],[c,d],-t.angle);return E[0]<x[0]&&E[1]>=x[1]?(i=Math.min(i,v[0]),l=Math.max(l,Math.max(y[0],I[0])),a=Math.min(a,w[1]),s=Math.max(s,I[1])):E[0]>=x[0]&&E[1]>x[1]?(i=Math.min(i,I[0]),l=Math.max(l,Math.max(w[0],y[0])),a=Math.min(a,v[1]),s=Math.max(s,y[1])):E[0]>=x[0]?(i=Math.min(i,y[0]),l=Math.max(l,v[0]),a=Math.min(a,I[1]),s=Math.max(s,w[1])):E[1]<=x[1]&&(i=Math.min(i,Math.min(y[0],w[0])),l=Math.max(l,I[0]),a=Math.min(a,y[1]),s=Math.max(s,v[1])),[i,a,l,s,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,l,s;if(t.points.length<2||!Pe.get(t)){let{minX:p,minY:u,maxX:h,maxY:E}=t.points.reduce((x,[w,y])=>(x.minY=Math.min(x.minY,y),x.minX=Math.min(x.minX,w),x.maxX=Math.max(x.maxX,w),x.maxY=Math.max(x.maxY,y),x),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,l=h+t.x,s=E+t.y}else{let p=Pe.generateElementShape(t,null),u=li(p[0]),[h,E,x,w]=Ws(u);i=h+t.x,a=E+t.y,l=x+t.x,s=w+t.y}let c=(i+l)/2,d=(a+s)/2;if(n=[i,a,l,s,c,d],!o)return n;let m=me(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,l,s],m)),n}},dC=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var da,ma,$d,Wx,Xd=j(()=>{"use strict";f();da={},ma=(e,t)=>{let r=da[e]||(da[e]={height:t});return r.height=t,r},$d=e=>{da[e]&&delete da[e]},Wx=e=>da[e]?.height??null});var pi,Yh,Rt,Zd,ca,pl,Lo,Yx,ui,jd,qd,Wh,Vs,Ys,mC,pC,hi,Kx,$x,Jd,uC,Po,me,pt,Qd,Kh,Xx,Zx,jx,hC,qx,In,vr,pa,Jx,Vh,Vx,Hr,st=j(()=>{"use strict";f();U();Ue();Y();be();se();Xt();Xd();pi=e=>Md(e).replace(/\t/g," "),Yh=e=>pi(e).split(`
10
- `),Rt=(e,t,r,o=!0)=>{let n,i={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?.angle??e.angle};i.text=e.text,t&&(n=vr(t,e),i.text=hi(e.originalText,Ye(e),n));let a=Lo(i.text,Ye(e),e.lineHeight);if(i.width=a.width,i.height=a.height,t){let l=pa(t,e),s=vr(t,e);if(!we(t)&&a.height>l){let p=In(a.height,t.type);F(t,{height:p},o),ma(t.id,p)}if(a.width>s){let p=In(a.width,t.type);F(t,{width:p},o)}let c={...e,...i},{x:d,y:m}=pl(t,c,r);i.x=d,i.y=m}F(e,i,o)},Zd=(e,t,r)=>{let o=$(e);t.forEach(n=>{let i=r.get(n.id),a=Po(n);if(a){let l=r.get(a);if(l){let s=o.get(i);s&&F(s,{boundElements:(n.boundElements||[]).filter(d=>d.id!==l&&d.id!==a).concat({type:"text",id:l})});let c=o.get(l);c&&G(c)&&F(c,{containerId:s?i:null})}}})},ca=(e,t,r,o=!1)=>{if(!Po(e))return;$d(e.id);let i=me(e,t);if(i&&i.text){if(!e)return;let a=i.text,l=i.height,s=i.width,c=vr(e,i),d=pa(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=hi(i.originalText,Ye(i),c));let p=Lo(a,Ye(i),i.lineHeight);l=p.height,s=p.width}if(l>d){m=In(l,e.type);let p=m-e.height,u=!we(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;F(e,{height:m,y:u})}F(i,{text:a,width:s,height:l}),we(e)||F(i,pl(e,i,t))}},pl=(e,t,r)=>{if(we(e))return X.getBoundTextElementPosition(e,t,r);let o=Kh(e),n=pa(e,t),i=vr(e,t),a,l;return t.verticalAlign===yt.TOP?l=o.y:t.verticalAlign===yt.BOTTOM?l=o.y+(n-t.height):l=o.y+(n/2-t.height/2),t.textAlign===Qn.LEFT?a=o.x:t.textAlign===Qn.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:l}},Lo=(e,t,r)=>{e=e.split(`
11
- `).map(a=>a||" ").join(`
12
- `);let o=parseFloat(t),n=mC(e,o,r);return{width:Ys(e,t),height:n}},Yx=e=>{let t=Yh(e.text).length;return e.height/t/e.fontSize},ui=(e,t)=>e*t,jd=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=Vx[e]||Vx[mt.Helvetica],a=t/o,l=r-a*n+a*i;return a*n+l},qd=(e,t)=>ui(e,t)+bt*2,Vs=(e,t)=>{Wh||(Wh=document.createElement("canvas"));let r=Wh.getContext("2d");r.font=t;let o=r.measureText(e).width;return Or()?o*10:o},Ys=(e,t)=>{let r=Yh(e),o=0;return r.forEach(n=>{o=Math.max(o,Vs(n,t))}),o},mC=(e,t,r)=>{let o=Yh(e).length;return ui(t,r)*o},pC=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},hi=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
13
- `),i=Vs(" ",t),a="",l=0,s=d=>{d.trim()&&o.push(d)},c=()=>{a="",l=0};return n.forEach(d=>{if(Ys(d,t)<=r){o.push(d);return}let p=pC(d);c();let u=0;for(;u<p.length;){let h=Vs(p[u],t);if(h===r)s(p[u]),u++;else if(h>r){for(s(a),c();p[u].length>0;){let E=String.fromCodePoint(p[u].codePointAt(0)),x=Kx.calculate(E,t);l+=x,p[u]=p[u].slice(E.length),l>=r?(s(a),a=E,l=x):a+=E}l+i>=r?(s(a),c()):a.endsWith("-")||(a+=" ",l+=i),u++}else for(;l<r&&u<p.length;){let E=p[u];if(l=Vs(a+E,t),l>r){s(a),c();break}u++;let x=!E.endsWith("-");if(a+=E,x&&(a+=" "),l+i>=r){x?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),s(a))}),o.join(`
14
- `)},Kx=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=Vs(o,n);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),$x="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),Jd=(e,t)=>{let r=uC(e);return r===0?Lo($x.split("").join(`
15
- `),e,t).width+bt*2:r+bt*2},uC=e=>{let t=Kx.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},Po=e=>e?.boundElements?.length&&e?.boundElements?.filter(t=>t.type==="text")[0]?.id||null,me=(e,t)=>{if(!e)return null;let r=Po(e);return r&&t.get(r)||null},pt=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Qd=(e,t,r)=>{if(!we(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=X.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),l=X.getPointGlobalCoordinates(e,e.points[a],r);return{x:l[0],y:l[1]}}let n=e.points.length/2-1,i=X.getEditorMidPoints(e,r,t)[n];return i||(i=X.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},Kh=e=>{let t=bt,r=bt;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},Xx=(e,t)=>!t||we(t)?e.angle:t.angle,Zx=(e,t)=>e.some(r=>{if(Ae(r)){let o=pt(r,t);return!we(o)}return!1}),jx=(e,t)=>e.some(r=>{if(Ae(r)){let o=pt(r,t);return!we(o)}return G(r)}),hC=new Set(["rectangle","ellipse","diamond","arrow"]),qx=e=>hC.has(e.type),In=(e,t)=>{e=Math.ceil(e);let r=bt*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},vr=(e,t)=>{let{width:r}=e;if(we(e)){let o=(t?.fontSize??Lt)*IE;return Math.max(SE*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-bt*2:e.type==="diamond"?Math.round(r/2)-bt*2:r-bt*2},pa=(e,t)=>{let{height:r}=e;return we(e)?r-bt*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-bt*2:e.type==="diamond"?Math.round(r/2)-bt*2:r-bt*2},Jx=()=>Ys($x,Ye({fontSize:Lt,fontFamily:Kt}))>0,Vh={[mt.Virgil]:1.25,[mt.Helvetica]:1.15,[mt.Cascadia]:1.2},Vx={[mt.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[mt.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[mt.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[mt.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},Hr=e=>e in Vh?Vh[e]:Vh[Kt]});import Xh from"roughjs/bin/rough";var $h,re,Zh,vh,li,Qx,e0,gC,Ws,jh,fC,bC,EC,Th,xC,yC,Ur,Se,em,ul,Gh,qh,Tr,wC,lt=j(()=>{"use strict";f();Ft();wh();se();Ls();st();Xt();Xo();U();$h=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!Ae(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,l,s,c]=re(t,r);if(Dt(t)){let[d,m,p,u]=jh(t.points.map(([h,E])=>ye(h,E,s-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(ne(t))o=yC(t,s,c,r);else if(t.type==="diamond"){let[d,m]=ye(s,i,s,c,t.angle),[p,u]=ye(s,l,s,c,t.angle),[h,E]=ye(n,c,s,c,t.angle),[x,w]=ye(a,c,s,c,t.angle),y=Math.min(d,p,h,x),v=Math.min(m,u,E,w),I=Math.max(d,p,h,x),L=Math.max(m,u,E,w);o=[y,v,I,L]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(l-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),h=Math.hypot(d*p,m*u),E=Math.hypot(m*p,d*u);o=[s-h,c-E,s+h,c+E]}else{let[d,m]=ye(n,i,s,c,t.angle),[p,u]=ye(n,l,s,c,t.angle),[h,E]=ye(a,l,s,c,t.angle),[x,w]=ye(a,i,s,c,t.angle),y=Math.min(d,p,h,x),v=Math.min(m,u,E,w),I=Math.max(d,p,h,x),L=Math.max(m,u,E,w);o=[y,v,I,L]}return o}},re=(e,t,r=!1)=>{if(Dt(e))return fC(e);if(ne(e))return X.getElementAbsoluteCoords(e,t,r);if(G(e)){let o=t?pt(e,t):null;if(we(o)){let n=X.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},Zh=(e,t)=>{let[r,o,n,i,a,l]=re(e,t),s=[a,l];if(ne(e)||Dt(e)){let w=[],y=0;for(;y<e.points.length-1;)w.push([Ge([e.points[y][0]+e.x,e.points[y][1]+e.y],s,e.angle),Ge([e.points[y+1][0]+e.x,e.points[y+1][1]+e.y],s,e.angle)]),y++;return w}let[c,d,m,p,u,h,E,x]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,l],[n,l]].map(w=>Ge(w,s,e.angle));return e.type==="diamond"?[[u,E],[u,x],[h,E],[h,x]]:e.type==="ellipse"?[[u,E],[u,x],[h,E],[h,x],[u,E],[u,x],[h,E],[h,x]]:[[c,d],[m,p],[c,m],[d,p],[c,x],[m,x],[d,E],[p,E]]},vh=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},li=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},Qx=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},e0=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,l=3*n-6*i+3*a,s=6*i-6*n,c=3*n,d=s*s-4*l*c;if(!(d>=0))return!1;let p=null,u=null,h=1/0,E=1/0;return l===0?h=E=-c/s:(h=(-s+Math.sqrt(d))/(2*l),E=(-s-Math.sqrt(d))/(2*l)),h>=0&&h<=1&&(p=Qx(h,e,t,r,o)),E>=0&&E<=1&&(u=Qx(E,e,t,r,o)),[p,u]},gC=(e,t,r,o)=>{let n=e0(e[0],t[0],r[0],o[0]),i=e0(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),l=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),l=Math.max(l,...d)}let s=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);s=Math.min(s,...d),c=Math.max(c,...d)}return[a,s,l,c]},Ws=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((l,{op:s,data:c})=>{if(s==="move")r=c;else if(s==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,h=t?t(...m):m,E=t?t(...p):p,x=t?t(...r):r;r=p;let[w,y,v,I]=gC(x,u,h,E);l.minX=Math.min(l.minX,w),l.minY=Math.min(l.minY,y),l.maxX=Math.max(l.maxX,v),l.maxY=Math.max(l.maxY,I)}return l},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},jh=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},fC=e=>{let[t,r,o,n]=jh(e.points),i=t+e.x,a=r+e.y,l=o+e.x,s=n+e.y;return[i,a,l,s,(i+l)/2,(a+s)/2]},bC=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},EC=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Th=(e,t,r,o)=>{let n=li(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,l=[a[4],a[5]],s=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(Z,oe)=>Math.pow(1-Z,3)*l[oe]+3*Z*Math.pow(1-Z,2)*s[oe]+3*Math.pow(Z,2)*(1-Z)*c[oe]+m[oe]*Math.pow(Z,3),[u,h]=r==="start"?m:l,[E,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-E,h-x),y=(u-E)/w,v=(h-x)/w,I=bC(o),L=0;{let[Z,oe]=r==="end"?e.points[e.points.length-1]:e.points[0],[Te,V]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];L=Math.hypot(Z-Te,oe-V)}let M=Math.min(I,L*(o==="diamond"||o==="diamond_outline"?.25:.5)),_=u-y*M,H=h-v*M;if(o==="dot"||o==="circle"||o==="circle_outline"){let Z=Math.hypot(H-h,_-u)+e.strokeWidth-2;return[u,h,Z]}let k=EC(o),[N,A]=ye(_,H,u,h,-k*Math.PI/180),[B,q]=ye(_,H,u,h,k*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let Z,oe;if(r==="start"){let[Te,V]=e.points.length>1?e.points[1]:[0,0];[Z,oe]=ye(u+M*2,h,u,h,Math.atan2(V-h,Te-u))}else{let[Te,V]=e.points.length>1?e.points[e.points.length-2]:[0,0];[Z,oe]=ye(u-M*2,h,u,h,Math.atan2(h-V,u-Te))}return[u,h,N,A,Z,oe,B,q]}return[u,h,N,A,B,q]},xC=e=>{let t=Xh.generator(),r=Fr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},yC=(e,t,r,o)=>{let n=me(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,h]=ye(e.x+m,e.y+p,t,r,e.angle),E=[u,h,u,h];if(n){let x=X.getMinMaxXYWithBoundText(e,o,[u,h,u,h],n);E=[x[0],x[1],x[2],x[3]]}return E}let a=Pe.get(e)?.[0]??xC(e),l=li(a),c=Ws(l,(m,p)=>ye(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=X.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},Ur=(e,t)=>$h.getBounds(e,t),Se=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=$(e);return e.forEach(a=>{let[l,s,c,d]=Ur(a,i);t=Math.min(t,l),o=Math.min(o,s),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},em=(e,t)=>{let[r,o,n,i]=Se(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},ul=(e,t,r,o)=>{if(!(ne(e)||Dt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=ai(0,t,ai(1,r,e.points,o),o),i;if(Dt(e))i=jh(n);else{let d=Xh.generator(),m=e.roundness?d.curve(n,Fr(e)):d.linearPath(n,Fr(e)),p=li(m);i=Ws(p)}let[a,l,s,c]=i;return[a+e.x,l+e.y,s+e.x,c+e.y]},Gh=(e,t)=>{let r=Xh.generator(),o=e.roundness==null?r.linearPath(t,Fr(e)):r.curve(t,Fr(e)),n=li(o),[i,a,l,s]=Ws(n);return[i+e.x,a+e.y,l+e.x,s+e.y]},qh=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=$(e);return e.forEach(i=>{let[a,l,s,c]=Ur(i,n),d=vt((a+s)/2,(l+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),Ur(o,n)},Tr=e=>{let[t,r,o,n]=Se(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},wC=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var vC,Zt,TC,t0,tm,r0,Sr,Do,Ir=j(()=>{"use strict";f();Qt();Y();vC=Ja.includes(devicePixelRatio)?devicePixelRatio:1,Zt=()=>({showWelcomeScreen:!1,theme:ae.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:rt.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:rt.fillStyle,currentItemFontFamily:Kt,currentItemFontSize:Lt,currentItemOpacity:rt.opacity,currentItemRoughness:rt.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:rt.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:rt.strokeStyle,currentItemStrokeWidth:rt.strokeWidth,currentItemTextAlign:qn,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:rt.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:vC,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,showStats:!1,startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:de.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),TC=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},showStats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),t0=(e,t)=>{let r={};for(let o of Object.keys(e))if(TC[o]?.[t]){let i=e[o];r[o]=i}return r},tm=e=>t0(e,"export"),r0=e=>t0(e,"server"),Sr=({activeTool:e})=>e.type==="eraser",Do=({activeTool:e})=>e.type==="hand"});var Jh,jt,rm,Qh,Cn,om,o0,ua,tt,n0,i0,a0,l0,ha,s0,c0,mr=j(()=>{"use strict";f();$e();st();ii();Jh=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},jt=function(){let e=null,t=null,r=null,o=(i,a,l,s)=>{if(r!==void 0&&a===t&&i===e&&l.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let h=u.indexOf(l.editingGroupId);h>-1&&(u=u.slice(0,h))}if(u.length>0){let h=u[u.length-1];c[h]=!0}}let d={},m=a.reduce((p,u)=>{let h=u.groupIds.find(E=>c[E]);return h&&(p[u.id]=!0,Array.isArray(d[h])?d[h].push(u.id):d[h]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:Re({...l.selectedElementIds,...m},s)},r},n=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):ue(a,i);return c.length?o(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Re(i.selectedElementIds,l)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),rm=(e,t)=>Qh(e,t)!=null,Qh=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),Cn=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),om=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...Jh(i,r,e)}}}return r.selectedGroupIds},o0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),ua=(e,t)=>e.groupIds.includes(t),tt=(e,t)=>{let r=[];for(let o of e.values())ua(o,t)&&r.push(o);return r},n0=(e,t)=>e.groupIds.find(r=>t[r]),i0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},a0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},l0=(e,t)=>e.filter(r=>!t[r]),ha=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=me(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())},s0=e=>{let t=new Set;for(let[,r]of e)if(!r.isDeleted)for(let o of r.groupIds??[])t.add(o);return t},c0=e=>e.groupIds.length>0});import{sanitizeUrl as SC}from"@braintree/sanitize-url";var nm,pr,im,am,ga=j(()=>{"use strict";f();nm=e=>e.replace(/"/g,"&quot;"),pr=e=>(e=e.trim(),e&&SC(nm(e))),im=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),am=e=>{if(e=pr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var lm,z,Xe=j(()=>{"use strict";f();lm=[],z=e=>(lm=lm.concat(e),e)});import sm from"open-color";var m0,IC,p0,CC,AC,Gr,We,Jo,d0,eg,Wr,hl=j(()=>{"use strict";f();Y();Ir();m0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',IC='<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"/>',p0='<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"/>',CC=`data:${te.svg},${encodeURIComponent(`${m0}${p0}</svg>`)}`,AC=`data:${te.svg},${encodeURIComponent(`${m0}${IC}${p0}</svg>`)}`,Gr=e=>{e&&(e.style.cursor="")},We=(e,t)=>{e&&(e.style.cursor=t)},eg=(e,t)=>{let o=()=>{let n=t===ae.DARK;Jo=document.createElement("canvas"),Jo.theme=t,Jo.height=20,Jo.width=20;let i=Jo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Jo.width/2,Jo.height/2,5,0,2*Math.PI),i.fillStyle=n?sm.black:sm.white,i.fill(),i.strokeStyle=n?sm.white:sm.black,i.stroke(),d0=Jo.toDataURL(te.svg)};(!Jo||Jo.theme!==t)&&o(),We(e,`url(${d0}) ${20/2} ${20/2}, auto`)},Wr=(e,t)=>{if(e)if(t.activeTool.type==="selection")Gr(e);else if(Do(t))e.style.cursor=Le.GRAB;else if(Sr(t))eg(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===ae.LIGHT?CC:AC;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Le.AUTO):e.style.cursor=Le.CROSSHAIR}});var An,Vr,tg,u0,mm,Ks,h0,zt,kC,gl,rg,g0,ao,$s,cm,kn,dm,Xs,pm,Mn=j(()=>{"use strict";f();U();Co();Ue();mr();be();Ft();lt();st();Y();An=(e,{x:t,y:r,strokeColor:o=rt.strokeColor,backgroundColor:n=rt.backgroundColor,fillStyle:i=rt.fillStyle,strokeWidth:a=rt.strokeWidth,strokeStyle:l=rt.strokeStyle,roughness:s=rt.roughness,opacity:c=rt.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:h=null,index:E=null,roundness:x=null,boundElements:w=null,link:y=null,locked:v=rt.locked,...I})=>({id:I.id||_t(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:l,roughness:s,opacity:c,groupIds:u,frameId:h,index:E,roundness:x,seed:I.seed??oo(),version:I.version||1,versionNonce:I.versionNonce??0,isDeleted:!1,boundElements:w,updated:wn(),link:y,locked:v,customData:I.customData}),Vr=e=>An(e.type,e),tg=e=>An("embeddable",e),u0=e=>({...An("iframe",e)}),mm=e=>ie({...An("frame",e),type:"frame",name:e?.name||null},{}),Ks=e=>ie({...An("magicframe",e),type:"magicframe",name:e?.name||null},{}),h0=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),zt=e=>{let t=e.fontFamily||Kt,r=e.fontSize||Lt,o=e.lineHeight||Hr(t),n=pi(e.text),i=Lo(n,Ye({fontFamily:t,fontSize:r}),o),a=e.textAlign||qn,l=e.verticalAlign||$i,s=h0({textAlign:a,verticalAlign:l},i);return ie({...An("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:l,x:e.x-s.x,y:e.y-s.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:n,lineHeight:o},{})},kC=(e,t,r)=>{let{width:o,height:n}=Lo(r,Ye(e),e.lineHeight),{textAlign:i,verticalAlign:a}=e,l,s;if(i==="center"&&a===yt.MIDDLE&&!e.containerId){let c=Lo(e.text,Ye(e),e.lineHeight),d=h0(e,{width:o-c.width,height:n-c.height});l=e.x-d.x,s=e.y-d.y}else{let[c,d,m,p]=re(e,t),[u,h,E,x]=ul(e,o,n,!1),w=(c-u)/2,y=(d-h)/2,v=(m-E)/2,I=(p-x)/2;[l,s]=JE({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,w,y,v,I)}return{width:o,height:n,x:Number.isFinite(l)?l:e.x,y:Number.isFinite(s)?s:e.y}},gl=(e,t,r,o=e.text)=>{if(e.isDeleted)return;t&&(o=hi(o,Ye(e),vr(t,e)));let n=kC(e,r,o);return{text:o,...n}},rg=(e,t,r,{text:o,isDeleted:n,originalText:i})=>ie(e,{originalText:i,isDeleted:n??e.isDeleted,...gl(e,t,r,i)}),g0=e=>({...An(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),ao=e=>({...An(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),$s=e=>({...An("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),cm=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=cm(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=cm(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},kn=e=>cm(e),dm=e=>{if(Or()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return _t()},Xs=(e,t,r,o)=>{let n=kn(r);return n.id=dm(n.id),n.boundElements=null,n.updated=wn(),n.seed=oo(),n.groupIds=i0(n.groupIds,e,i=>(t.has(i)||t.set(i,dm(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},pm=(e,t)=>{let r=[],o=$(e),n=new Map,i=l=>{if(n.has(l))return n.get(l);if(o.has(l)){let s=dm(l);return n.set(l,s),s}return null},a=new Map;for(let l of e){let s=cm(l);if(s.id=i(l.id),t?.randomizeSeed&&(s.seed=oo(),gi(s)),s.groupIds&&(s.groupIds=s.groupIds.map(c=>(a.has(c)||a.set(c,dm(c)),a.get(c)))),"containerId"in s&&s.containerId){let c=i(s.containerId);s.containerId=c}if("boundElements"in s&&s.boundElements&&(s.boundElements=s.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in s&&s.endBinding){let c=i(s.endBinding.elementId);s.endBinding=c?{...s.endBinding,elementId:c}:null}if("startBinding"in s&&s.startBinding){let c=i(s.startBinding.elementId);s.startBinding=c?{...s.startBinding,elementId:c}:null}s.frameId&&(s.frameId=i(s.frameId)),r.push(s)}return r}});var ft,Zs,js,f0=j(()=>{"use strict";f();Y();io();Xt();Ue();st();se();no();mr();Ne();U();ft=class e{constructor(t,r){this.deleted=t;this.inserted=r}static create(t,r,o,n){let i=o&&n!=="inserted"?o(t):t,a=o&&n!=="deleted"?o(r):r;return new e(i,a)}static calculate(t,r,o,n){if(t===r)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",t,r))i[c]=t[c],a[c]=r[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,o)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static mergeObjects(t,r,o){let n={...t};for(let i of Object.keys(o))delete n[i];return{...n,...r}}static mergeArrays(t,r,o,n){return Object.values(e.mergeObjects(Go(t??[],n),Go(r??[],n),Go(o??[],n)))}static diffObjects(t,r,o,n){if(!(!t[o]&&!r[o])&&(typeof t[o]=="object"||typeof r[o]=="object")){let i=t[o]??{},a=r[o]??{},l=e.getLeftDifferences(i,a).reduce((c,d)=>(c[d]=n(i[d]),c),{}),s=e.getRightDifferences(i,a).reduce((c,d)=>(c[d]=n(a[d]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(t,o,l),Reflect.set(r,o,s)):(Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o))}}static diffArrays(t,r,o,n){if(!(!t[o]&&!r[o])&&(Array.isArray(t[o])||Array.isArray(r[o]))){let i=Array.isArray(t[o])?t[o]:[],a=Array.isArray(r[o])?r[o]:[],l=Go(e.getLeftDifferences(Go(i,n),Go(a,n))),s=Go(e.getRightDifferences(Go(i,n),Go(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(m=>l[n?n(m):String(m)]),d=a.filter(m=>s[n?n(m):String(m)]);Reflect.set(t,o,c),Reflect.set(r,o,d)}else Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o)}}static isLeftDifferent(t,r,o=!1){return!!this.distinctKeysIterator("left",t,r,o).next().value}static isRightDifferent(t,r,o=!1){return!!this.distinctKeysIterator("right",t,r,o).next().value}static getLeftDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("left",t,r,o))}static getRightDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("right",t,r,o))}static*distinctKeysIterator(t,r,o,n=!1){if(r===o)return;let i=[];t==="left"?i=Object.keys(r):t==="right"?i=Object.keys(o):t==="full"?i=Array.from(new Set([...Object.keys(r),...Object.keys(o)])):Io(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let a of i){let l=r[a],s=o[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&Je(l,s))continue;yield a}}}},Zs=class e{constructor(t){this.delta=t}static calculate(t,r){let o=ft.calculate(t,r,void 0,e.postProcess);return new e(o)}static empty(){return new e(ft.create({},{}))}inverse(){let t=ft.create(this.delta.inserted,this.delta.deleted);return new e(t)}applyTo(t,r){try{let{selectedElementIds:o={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,d=ft.mergeObjects(t.selectedElementIds,i,o),m=ft.mergeObjects(t.selectedGroupIds,a,n),p=l&&r.has(l)?new X(r.get(l)):null,u=s&&r.has(s)?new X(r.get(s)):null,h={...t,...c,selectedElementIds:d,selectedGroupIds:m,selectedLinearElement:typeof l<"u"?p:t.selectedLinearElement,editingLinearElement:typeof s<"u"?u:t.editingLinearElement},E=this.filterInvisibleChanges(t,h,r);return[h,E]}catch(o){if(console.error("Couldn't apply appstate change",o),T.DEV||T.MODE===yr.TEST)throw o;return[t,!1]}}isEmpty(){return ft.isEmpty(this.delta)}static postProcess(t,r){try{ft.diffObjects(t,r,"selectedElementIds",o=>!0),ft.diffObjects(t,r,"selectedGroupIds",o=>o??!1)}catch(o){if(console.error("Couldn't postprocess appstate change deltas."),T.DEV||T.MODE===yr.TEST)throw o}finally{return[t,r]}}filterInvisibleChanges(t,r,o){let n=qs(t),i=qs(r),a=ft.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=ft.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=ft.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),d=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(d=s0(o));for(let m of c)switch(m){case"selectedElementIds":r[m]=e.filterSelectedElements(r[m],o,s);break;case"selectedGroupIds":r[m]=e.filterSelectedGroups(r[m],d,s);break;case"editingGroupId":let p=r[m];p?d.has(p)?s.value=!0:r[m]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(m),h=r[u];if(!h)s.value=!0;else{let E=o.get(h.elementId);E&&!E.isDeleted?s.value=!0:r[u]=null}break;default:Io(m,`Unknown ObservedElementsAppState's key "${m}"`,!0)}}return s.value}static convertToAppStateKey(t){switch(t){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(t,r,o){let n=Object.keys(t);if(!n.length)return o.value=!0,t;let i={...t};for(let a of n){let l=r.get(a);l&&!l.isDeleted?o.value=!0:delete i[a]}return i}static filterSelectedGroups(t,r,o){if(!Object.keys(t).length)return o.value=!0,t;let i={...t};for(let a of Object.keys(i))r.has(a)?o.value=!0:delete i[a];return i}static stripElementsProps(t){let{editingGroupId:r,selectedGroupIds:o,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,...l}=t;return l}static stripStandaloneProps(t){let{name:r,viewBackgroundColor:o,...n}=t;return n}},js=class e{constructor(t,r,o){this.added=t;this.removed=r;this.updated=o}static create(t,r,o,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,l=new Map,s=new Map,c=[...t,...r,...o];for(let[d,m]of c)this.satisfiesAddition(m)?a.set(d,m):this.satisfiesRemoval(m)?l.set(d,m):s.set(d,m);i=new e(a,l,s)}else i=new e(t,r,o);return(T.DEV||T.MODE===yr.TEST)&&(e.validate(i,"added",this.satisfiesAddition),e.validate(i,"removed",this.satisfiesRemoval),e.validate(i,"updated",this.satisfiesUpdate)),i}static satisfiesAddition=({deleted:t,inserted:r})=>t.isDeleted===!0&&!r.isDeleted;static satisfiesRemoval=({deleted:t,inserted:r})=>!t.isDeleted&&r.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:r})=>!!t.isDeleted==!!r.isDeleted;static validate(t,r,o){for(let[n,i]of t[r].entries())if(!o(i))throw console.error(`Broken invariant for "${r}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(t,r){if(t===r)return e.empty();let o=new Map,n=new Map,i=new Map;for(let a of t.values())if(!r.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},d=ft.create(s,c,e.stripIrrelevantProps);n.set(a.id,d)}for(let a of r.values()){let l=t.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},d=ft.create(s,c,e.stripIrrelevantProps);o.set(a.id,d);continue}if(l.versionNonce!==a.versionNonce){let s=ft.calculate(l,a,e.stripIrrelevantProps,e.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?o.set(a.id,s):n.set(a.id,s);continue}ft.isEmpty(s)||i.set(a.id,s)}}return e.create(o,n,i)}static empty(){return e.create(new Map,new Map,new Map)}inverse(){let t=i=>{let a=new Map;for(let[l,s]of i.entries())a.set(l,ft.create(s.inserted,s.deleted));return a},r=t(this.added),o=t(this.removed),n=t(this.updated);return e.create(o,r,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(t){let r=l=>s=>{let c={};for(let d of Object.keys(s))switch(d){case"boundElements":c[d]=s[d];break;default:c[d]=l[d]}return c},o=l=>{let s=new Map;for(let[c,d]of l.entries()){let m=t.get(c);if(m){let p=ft.create(d.deleted,d.inserted,r(m),"inserted");s.set(c,p)}else s.set(c,d)}return s},n=o(this.added),i=o(this.removed),a=o(this.updated);return e.create(n,i,a,{shouldRedistribute:!0})}applyTo(t,r){let o=Br(new Map(t)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=e.createApplier(o,r,i),l=a(this.added),s=a(this.removed),c=a(this.updated),d=this.resolveConflicts(t,o);n=new Map([...l,...s,...c,...d])}catch(a){if(console.error("Couldn't apply elements change",a),T.DEV||T.MODE===yr.TEST)throw a;return[t,!0]}try{e.redrawTextBoundingBoxes(o,n),e.redrawBoundArrows(o,n),o=e.reorderElements(o,n,i)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),T.DEV||T.MODE===yr.TEST)throw a}finally{return[o,i.containsVisibleDifference]}}static createApplier=(t,r,o)=>{let n=e.createGetter(t,r,o);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let d=e.applyDelta(c,s,o);t.set(d.id,d),a.set(d.id,d)}return a},new Map)};static createGetter=(t,r,o)=>(n,i)=>{let a=t.get(n);return a||(a=r.get(n),a&&(o.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(o.containsVisibleDifference=!0))),a};static applyDelta(t,r,o={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=r.inserted;if(r.deleted.boundElements?.length||r.inserted.boundElements?.length){let a=ft.mergeArrays(t.boundElements,r.inserted.boundElements,r.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(!o.containsVisibleDifference){let{index:a,...l}=i,s=e.checkForVisibleDifference(t,l);o.containsVisibleDifference=s}return o.containsZindexDifference||(o.containsZindexDifference=r.deleted.index!==r.inserted.index),ie(t,i)}static checkForVisibleDifference(t,r){return t.isDeleted&&r.isDeleted!==!1?!1:t.isDeleted&&r.isDeleted===!1||t.isDeleted===!1&&r.isDeleted?!0:ft.isRightDifferent(t,r)}resolveConflicts(t,r){let o=new Map,n=(c,d)=>{let m=r.get(c.id);if(!m)return;let p;t.get(c.id)===m?p=ie(m,d):p=F(m,d),o.set(p.id,p),r.set(p.id,p)};for(let[c]of this.removed)e.unbindAffected(t,r,c,n);for(let[c]of this.added)e.rebindAffected(t,r,c,n);for(let[c]of Array.from(this.updated).filter(([d,m])=>Object.keys({...m.deleted,...m.inserted}).find(p=>Gx.has(p)))){let d=r.get(c);!d||d.isDeleted||e.rebindAffected(t,r,c,n)}let i=new Map(Array.from(t).filter(([c])=>o.has(c))),{added:a,removed:l,updated:s}=e.calculate(i,o);for(let[c,d]of a)this.added.set(c,d);for(let[c,d]of l)this.removed.set(c,d);for(let[c,d]of s)this.updated.set(c,d);return o}static unbindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);di.unbindAffected(r,i(),n),di.unbindAffected(r,a(),n),mi.unbindAffected(r,i(),n),mi.unbindAffected(r,a(),n)}static rebindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);di.unbindAffected(r,i(),n),di.rebindAffected(r,a(),n),mi.unbindAffected(r,i(),(l,s)=>{G(l)&&n(l,s)}),mi.rebindAffected(r,a(),n)}static redrawTextBoundingBoxes(t,r){let o=new Map;for(let n of r.values()){if(Ae(n)){let{containerId:i}=n,a=i?t.get(i):void 0;a&&o.set(a.id,{container:a,boundText:n})}if(tr(n)){let i=Po(n),a=i?t.get(i):void 0;a&&o.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of o.values())n.isDeleted||i.isDeleted||Rt(i,n,t,!1)}static redrawBoundArrows(t,r){for(let o of r.values())!o.isDeleted&&Ji(o)&&zr(o,t)}static reorderElements(t,r,o){if(!o.containsZindexDifference)return t;let n=Array.from(t.values()),i=Dd([...n]);return!o.containsVisibleDifference&&ft.isRightDifferent(n,i,!0)&&(o.containsVisibleDifference=!0),$(Bt(i,r))}static postProcess(t,r){try{ft.diffArrays(t,r,"boundElements",o=>o.id)}catch(o){if(console.error("Couldn't postprocess elements change deltas."),T.DEV||T.MODE===yr.TEST)throw o}finally{return[t,r]}}static stripIrrelevantProps(t){let{id:r,updated:o,version:n,versionNonce:i,seed:a,...l}=t;return l}}});var or,Js=j(()=>{"use strict";f();or=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}}});var b0,qs,MC,D,og,um,hm,Ne=j(()=>{"use strict";f();Ir();f0();Y();Ue();Mn();Js();U();b0="__observedAppState",qs=e=>{let t={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};return Reflect.defineProperty(t,b0,{value:!0,enumerable:!1}),t},MC=e=>!!Reflect.get(e,b0),D={CAPTURE:"capture",UPDATE:"update",NONE:"none"},og=class{constructor(t,r){this.elementsChange=t;this.appStateChange=r}},um=class{onStoreIncrementEmitter=new or;scheduledActions=new Set;_snapshot=hm.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}shouldCaptureIncrement=()=>{this.scheduleAction(D.CAPTURE)};shouldUpdateSnapshot=()=>{this.scheduleAction(D.UPDATE)};scheduleAction=t=>{this.scheduledActions.add(t),this.satisfiesScheduledActionsInvariant()};commit=(t,r)=>{try{this.scheduledActions.has(D.CAPTURE)?this.captureIncrement(t,r):this.scheduledActions.has(D.UPDATE)&&this.updateSnapshot(t,r)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}};captureIncrement=(t,r)=>{let o=this.snapshot,n=this.snapshot.maybeClone(t,r);if(o!==n){let i=n.meta.didElementsChange?js.calculate(o.elements,n.elements):js.empty(),a=n.meta.didAppStateChange?Zs.calculate(o.appState,n.appState):Zs.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new og(i,a)),this.snapshot=n}};updateSnapshot=(t,r)=>{let o=this.snapshot.maybeClone(t,r);this.snapshot!==o&&(this.snapshot=o)};filterUncomittedElements=(t,r)=>{for(let[o,n]of t.entries()){if(!r.get(o))continue;let a=this.snapshot.elements.get(o);a?a.version<n.version&&r.set(o,a):r.delete(o)}return r};clear=()=>{this.snapshot=hm.empty(),this.scheduledActions=new Set};satisfiesScheduledActionsInvariant=()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(t,this.scheduledActions.values()),T.DEV||T.MODE===yr.TEST)throw new Error(t)}}},hm=class e{constructor(t,r,o={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=r;this.meta=o}static empty(){return new e(new Map,qs(Zt()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(t,r){let o=this.maybeCreateElementsSnapshot(t),n=this.maybeCreateAppStateSnapshot(r),i=!1,a=!1;return this.elements!==o&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(o,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(t){if(!t)return this.appState;let r=MC(t)?t:qs(t);return this.detectChangedAppState(r)?r:this.appState}detectChangedAppState(t){return!Je(this.appState,t,{selectedElementIds:Je,selectedGroupIds:Je})}maybeCreateElementsSnapshot(t){return t?this.detectChangedElements(t)?this.createElementsSnapshot(t):this.elements:this.elements}detectChangedElements(t){if(this.elements===t)return!1;if(this.elements.size!==t.size)return!0;let r=Array.from(t.keys());for(let o=r.length-1;o>=0;o--){let n=this.elements.get(r[o]),i=t.get(r[o]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(t){let r=new Map;for(let[o,n]of this.elements.entries())t.get(o)?r.set(o,n):r.set(o,ie(n,{isDeleted:!0}));for(let[o,n]of t.entries()){let i=r.get(o);(!i||i&&i.versionNonce!==n.versionNonce)&&r.set(o,kn(n))}return r}}});var Ln,LC,PC,DC,E0,_C,x0,RC,NC,OC,y0,ng,w0,Qs,Pn,gm,hN,ig,v0,fl,ec=j(()=>{"use strict";f();Xe();Y();U();hl();Mn();st();se();ga();Ne();Ln=new Map,LC=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,PC=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,DC=/^https:\/\/(?:www\.)?figma\.com/,E0=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,_C=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,x0=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,RC=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,NC=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,OC=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,y0=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,ng=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com"]),w0=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com"]),Qs=e=>`<html><body>${e}</body></html>`,Pn=e=>{if(!e)return null;if(Ln.has(e))return Ln.get(e);let t=e,r=w0.has(ig(e,w0)||""),o="generic",n={w:560,h:840},i=e.match(LC);if(i?.[2]){let c=i[3]?`&start=${i[3]}`:"",d=e.includes("shorts");switch(o="video",i[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${i[2]}&enablejsapi=1${c}`;break;default:e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break}return n=d?{w:315,h:560}:{w:560,h:315},Ln.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}}let a=e.match(PC);if(a?.[1]){let c=a?.[1],d=/^\d+$/.test(c)?void 0:new URIError("Invalid embed link format");return o="video",e=`https://player.vimeo.com/video/${c}?api=1`,n={w:560,h:315},Ln.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,error:d,sandbox:{allowSameOrigin:r}}}if(e.match(DC))return o="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,n={w:550,h:550},Ln.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};let s=e.match(NC);if(s)return e=s[1]==="embed"?s[0]:s[0].replace("/v","/embed"),Ln.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};if(x0.test(e)){let c=e.match(x0)[1],d=nm(`https://twitter.com/x/status/${c}`),m={type:"document",srcdoc:p=>Qs(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${p}"><a href="${d}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:r}};return Ln.set(t,m),m}if(E0.test(e)){let[,c,d]=e.match(E0),m=nm(`https://gist.github.com/${c}/${d}`),p={type:"document",srcdoc:()=>Qs(`
1
+ var $A=Object.defineProperty;var Ox=e=>t=>{var r=e[t];if(r)return r();throw new Error("Module not found in bundle: "+t)};var X=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ch=(e,t)=>{for(var r in t)$A(e,r,{get:t[r],enumerable:!0})};var T,f=X(()=>{T={PROD:!0}});var Mh,Hx=X(()=>{Mh={}});import i6 from"open-color";var a6,Ux,Ma,Gx,_s,Rs,Yo,Xo,Ee,Wx,fm,bm,Em,Vx,Yx,Xx,Kx,pr=X(()=>{"use strict";f();a6=(e,t)=>t.reduce((r,o)=>(o in e&&(r[o]=e[o]),r),{}),Ux=5,Ma=5,Gx=4,_s=4,Rs=1,Yo=[0,2,4,6,8],Xo=(e,t)=>t.map(r=>i6[e][r]),Ee={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:Xo("gray",Yo),red:Xo("red",Yo),pink:Xo("pink",Yo),grape:Xo("grape",Yo),violet:Xo("violet",Yo),blue:Xo("blue",Yo),cyan:Xo("cyan",Yo),teal:Xo("teal",Yo),green:Xo("green",Yo),yellow:Xo("yellow",Yo),orange:Xo("orange",Yo),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},Wx=a6(Ee,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),fm=[Ee.black,Ee.red[_s],Ee.green[_s],Ee.blue[_s],Ee.yellow[_s]],bm=[Ee.transparent,Ee.red[Rs],Ee.green[Rs],Ee.blue[Rs],Ee.yellow[Rs]],Em=[Ee.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],Vx={transparent:Ee.transparent,white:Ee.white,gray:Ee.gray,black:Ee.black,bronze:Ee.bronze,...Wx},Yx={transparent:Ee.transparent,white:Ee.white,gray:Ee.gray,black:Ee.black,bronze:Ee.bronze,...Wx},Xx=e=>[Ee.cyan[e],Ee.blue[e],Ee.violet[e],Ee.grape[e],Ee.pink[e],Ee.green[e],Ee.teal[e],Ee.yellow[e],Ee.orange[e],Ee.red[e]],Kx=(e,t,r)=>`#${((1<<24)+(e<<16)+(t<<8)+r).toString(16).slice(1)}`});var Cr,xm,$x,ti,s6,Zx,ym,jx,hc,fc,qx,ri,Ns,Jx,wm,Qx,wn,kh,Be,Ni,ka,bc,Kt,vm,Le,ue,rt,Ph,Tm,ur,gr,vn,Pa,oi,Sm,l6,e0,Ec,t0,r0,ni,xc,o0,se,Im,hr,yc,n0,i0,a0,s0,La,Os,Lh,l0,Fs,Cm,Am,Dh,c0,d0,m0,p0,u0,Bs,zs,Ko,g0,_h,Ke,Da,wt,h0,f0,kt,Oi,b0,Mm,E0,ct,Rh,km,pt,wc,co,Pm,It,To,Lm,Fi,Vr,_t,Y=X(()=>{"use strict";f();Hx();pr();Cr=/Mac|iPod|iPhone|iPad/.test(navigator.platform),xm=/^Win/.test(navigator.platform),$x=/\b(android)\b/i.test(navigator.userAgent),ti="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,s6=navigator.userAgent.indexOf("Chrome")!==-1,Zx=!s6&&navigator.userAgent.indexOf("Safari")!==-1,ym=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,jx=()=>navigator.brave?.isBrave?.name==="isBrave",hc=typeof window<"u"&&"ResizeObserver"in window,fc="Excalidraw",qx=36,ri=10,Ns=8,Jx=5,wm=1,Qx=30,wn=Math.PI/12,kh="red",Be={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},Ni={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},ka={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"},bc={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},Kt={TEST:"test",DEVELOPMENT:"development"},vm={SHAPE_ACTIONS_MENU:"App-menu__left"},Le={Virgil:1,Helvetica:2,Cascadia:3,Excalifont:5,Nunito:6,"Lilita One":7,"Comic Shanns":8,"Liberation Sans":9},ue={LIGHT:"light",DARK:"dark"},rt={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},Ph="Segoe UI Emoji",Tm=1,ur=20,gr=Le.Excalifont,vn="left",Pa="top",oi=2,Sm=2*oi,l6=1e-5,e0=2*Sm-l6,Ec="#ffffff",t0="#1e1e1e",r0="#a2f1a6",ni=20,xc={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},o0=["text/plain","text/html"],se={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...xc},Im={png:"png",svg:"svg",clipboard:"clipboard"},hr={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},yc=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,n0=500,i0=300,a0=500,s0=100,La=.1,Os=.1,Lh=30,l0=300,Fs=Mh.themeFilter,Cm={addLibrary:"addLibrary"},Am={addLibrary:"addLibrary"},Dh={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},c0=730,d0=1e3,m0=500,p0=1229,u0=parseInt(Mh.rightSidebarWidth),Bs=2,zs=[1,2,3],Ko=10,g0=1440,_h=4*1024*1024,Ke="http://www.w3.org/2000/svg",Da={excalidraw:2,excalidrawLibrary:2},wt=5,h0=.7,f0=11,kt={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},Oi={LEFT:"left",CENTER:"center",RIGHT:"right"},b0=20,Mm=.25,E0=32,ct={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Rh={architect:0,artist:1,cartoonist:2},km={thin:1,bold:2,extraBold:4},pt={strokeColor:Ee.black,backgroundColor:Ee.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:Rh.artist,opacity:100,locked:!1},wc="library",co={name:"default",defaultTab:wc},Pm=new Set(["iframe","embeddable","image"]),It={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},To={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},Lm="Untitled",Fi={generalStats:1,elementProperties:2},Vr=1,_t={sharp:"sharp",round:"round",elbow:"elbow"}});function vt(e,t,r,o){return e?(e?.addEventListener?.(t,r,o),()=>{e?.removeEventListener?.(t,r,o)}):()=>{}}function O0(e,t=!0){let r=e.length;if(r<4)return"";let o=e[0],n=e[1],i=e[2],a=`M${o[0].toFixed(2)},${o[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${_m(n[0],i[0]).toFixed(2)},${_m(n[1],i[1]).toFixed(2)} T`;for(let s=2,l=r-1;s<l;s++)o=e[s],n=e[s+1],a+=`${_m(o[0],n[0]).toFixed(2)},${_m(o[1],n[1]).toFixed(2)} `;return t&&(a+="Z"),a}var y0,Oh,Bi,T0,Fh,S0,Tn,Sn,Me,ii,Hs,ai,w0,I0,C0,Ht,nt,O,Qe,$t,vc,f6,b6,E6,Rm,ar,Nm,Bh,zh,Ar,Om,A0,M0,k0,P0,si,Z,L0,In,D0,Yr,_0,Fm,Us,R0,Cn,Tc,v0,it,zi,$o,N0,Sc,Xr,Hh,Bm,_m,zm,Mr,Ic,F0,V=X(()=>{"use strict";f();pr();Y();y0=null,Oh=()=>{if(y0)return y0;let e=new Date,t=e.getFullYear(),r=`${e.getMonth()+1}`.padStart(2,"0"),o=`${e.getDate()}`.padStart(2,"0"),n=`${e.getHours()}`.padStart(2,"0"),i=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${r}-${o}-${n}${i}`},Bi=e=>e.charAt(0).toUpperCase()+e.slice(1),T0=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),Fh=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,S0=e=>Fh(e)||e instanceof Element&&!!e.closest("label, button"),Tn=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Sn=({fontFamily:e})=>{for(let[t,r]of Object.entries(Le))if(r===e)return`${t}, ${Ph}`;return Ph},Me=({fontSize:e,fontFamily:t})=>`${e}px ${Sn({fontFamily:t})}`,ii=(e,t)=>{let r=0,o=null,n=(...i)=>{o=i,clearTimeout(r),r=window.setTimeout(()=>{o=null,e(...i)},t)};return n.flush=()=>{if(clearTimeout(r),o){let i=o;o=null,e(...i)}},n.cancel=()=>{o=null,clearTimeout(r)},n},Hs=(e,t)=>{let r=null,o=null,n=null,i=s=>{r=window.requestAnimationFrame(()=>{r=null,e(...s),o=null,n&&(o=n,n=null,i(o))})},a=(...s)=>{if(T.MODE==="test"){e(...s);return}o=s,r===null?i(o):t?.trailing&&(n=s)};return a.flush=()=>{r!==null&&(cancelAnimationFrame(r),r=null),o&&(e(...n||o),o=n=null)},a.cancel=()=>{o=n=null,r!==null&&(cancelAnimationFrame(r),r=null)},a},ai=e=>1-Math.pow(1-e,4),w0=(e,t,r)=>(t-e)*ai(r)+e,I0=({fromValues:e,toValues:t,onStep:r,duration:o=250,interpolateValue:n,onStart:i,onEnd:a,onCancel:s})=>{let l=!1,c=0,d;function m(p){if(l)return;d===void 0&&(d=p,i?.());let u=Math.min(p-d,o),g=ai(u/o),h={};if(Object.keys(e).forEach(x=>{let v=x,y=(t[v]-e[v])*g+e[v];h[v]=y}),r(h),u<o){let x=u/o,v={};Object.keys(e).forEach(y=>{let w=y,C=e[w],M=t[w],I;I=n?n(C,M,x,w):w0(C,M,x),I==null&&(I=w0(C,M,x)),v[w]=I}),r(v),c=window.requestAnimationFrame(m)}else r(t),a?.()}return c=window.requestAnimationFrame(m),()=>{s?.(),l=!0,window.cancelAnimationFrame(c)}},C0=(e,t)=>{if(!e.length||t<1)return[];let r=0,o=0,n=Array(Math.ceil(e.length/t));for(;r<e.length;)n[o++]=e.slice(r,r+=t);return n},Ht=(e,t)=>Math.abs(e-t),nt=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},O=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),Cr?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),Qe=({clientX:e,clientY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e-o)/r.value-i,l=(t-n)/r.value-a;return{x:s,y:l}},$t=({sceneX:e,sceneY:t},{zoom:r,offsetLeft:o,offsetTop:n,scrollX:i,scrollY:a})=>{let s=(e+i)*r.value+o,l=(t+a)*r.value+n;return{x:s,y:l}},vc=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),f6="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",b6="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",E6=new RegExp(`^[^${f6}]*[${b6}]`),Rm=e=>E6.test(e),ar=e=>{let[t,r]=e;return{x:t,y:r}},Nm=e=>{if(e?.name==="AbortError"){console.warn(e);return}throw e},Bh=(e,t,r=0)=>{r<0&&(r=e.length+r),r=Math.min(e.length,Math.max(r,0));let o=r-1;for(;++o<e.length;)if(t(e[o],o,e))return o;return-1},zh=(e,t,r=e.length-1)=>{r<0&&(r=e.length+r),r=Math.min(e.length-1,Math.max(r,0));let o=r+1;for(;--o>-1;)if(t(e[o],o,e))return o;return-1},Ar=e=>{let t=e.length===5&&e.substr(4,1)==="0",r=e.length===9&&e.substr(7,2)==="00";return t||r||e===Ee.transparent},Om=()=>{let e,t,r=new Promise((o,n)=>{e=o,t=n});return r.resolve=e,r.reject=t,r},A0=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:r}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(r==="auto"||r==="scroll"||r==="overlay"))return t;t=t.parentElement}return document},M0=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},k0=e=>{e.preventDefault(),e.returnValue=""},P0=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),si=()=>Yr()?1:Date.now(),Z=e=>e instanceof Map?e:e.reduce((t,r)=>(t.set(typeof r=="string"?r:r.id,r),t),new Map),L0=e=>e.reduce((t,r,o)=>(t.set(r.id,[r,o]),t),new Map),In=(e,t)=>e.reduce((r,o)=>(r[t?t(o):String(o)]=o,r),{}),D0=e=>e.reduce((t,r,o)=>{let n={...r,prev:null,next:null};if(o!==0){let i=t[o-1];if(n.prev=i,i.next=n,o===e.length-1){let a=t[0];n.next=a,a.prev=n}}return t.push(n),t},[]),Yr=()=>T.MODE==="test",_0=()=>T.MODE==="development",Fm=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Us=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t}:e},R0=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},Cn=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,Tc=e=>{let t=e?.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(r=>r.tabIndex>-1&&!r.disabled):[]},v0=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,it=(e,t,r,o=!1)=>{let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return o&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(r&&Array.isArray(r)){for(let a of r)if(!(e[a]===t[a]||v0(e[a],t[a])))return o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),!1;return!0}return n.every(a=>{let s=r?.[a],l=s?s(e[a],t[a]):e[a]===t[a]||v0(e[a],t[a]);return!l&&o&&console.warn(`%cisShallowEqual: ${a} not equal ->`,"color: #8B4000",e[a],t[a]),l})},zi=(e,t,{checkForDefaultPrevented:r=!0}={})=>function(n){if(e?.(n),!r||!n?.defaultPrevented)return t?.(n)},$o=(e,t,r)=>{if(!t)return e;if(r)return console.error(t),e;throw new Error(t)},N0=e=>{let t,r,o=function(n){let i=Object.entries(n);if(t){let s=!0;for(let[l,c]of i)if(t.get(l)!==c){s=!1;break}if(s)return r}let a=e(n);return t=new Map(i),r=a,a};return o.clear=()=>{t=void 0,r=void 0},o},Sc=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Xr=e=>JSON.parse(JSON.stringify(e)),Hh=e=>typeof e=="number"&&Number.isFinite(e),Bm=(e,t)=>it(e,t)?e:t;_m=(e,t)=>(e+t)/2;zm=e=>e.replace(/\r?\n|\r/g,`
2
+ `),Mr=e=>e,Ic=async(e,...t)=>new Promise(r=>{r(e(...t))}),F0=(...e)=>Math.max(...e.map(t=>t?1:0))>0});var kr,So,Rt,Io,sr,H,B0,_a,Q,Zt,x6,ie,ne,de,Cc,Kr,Uh,An,z0,Mn,Ac,Ct,ze,kn,H0,U0,G0,Gh,me=X(()=>{"use strict";f();Y();V();kr=e=>!!e&&e.type==="image"&&!!e.fileId,So=e=>!!e&&e.type==="image",Rt=e=>!!e&&e.type==="embeddable",Io=e=>!!e&&e.type==="iframe",sr=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),H=e=>e!=null&&e.type==="text",B0=e=>e!=null&&e.type==="frame",_a=e=>e!=null&&e.type==="magicframe",Q=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Zt=e=>e!=null&&x6(e.type),x6=e=>e==="freedraw",ie=e=>e!=null&&Cc(e.type),ne=e=>e!=null&&e.type==="arrow",de=e=>ne(e)&&e.elbowed,Cc=e=>e==="arrow"||e==="line",Kr=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Uh(e.type),Uh=e=>e==="arrow",An=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),z0=e=>e!=null&&(e.type==="rectangle"||e.type==="diamond"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),Mn=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||ne(e)),Ac=e=>{let t=e?.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return $o(t,null),!1}},Ct=e=>Mn(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),ze=e=>e!==null&&"containerId"in e&&e.containerId!==null&&H(e),kn=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",H0=e=>e==="line"||e==="arrow"||e==="diamond",U0=(e,t)=>!!((e===ct.ADAPTIVE_RADIUS||e===ct.LEGACY)&&kn(t.type)||e===ct.PROPORTIONAL_RADIUS&&H0(t.type)),G0=e=>H0(e.type)?{type:ct.PROPORTIONAL_RADIUS}:kn(e.type)?{type:ct.ADAPTIVE_RADIUS}:null,Gh=e=>e.fixedPoint!=null});import{Random as y6}from"roughjs/bin/math";import{nanoid as w6}from"nanoid";var v6,T6,Co,Ut,Zo=X(()=>{"use strict";f();V();v6=new y6(Date.now()),T6=0,Co=()=>Math.floor(v6.next()*2**31),Ut=()=>Yr()?`id${T6++}`:w6()});var Hm,Pn,jo,Um,Hi=X(()=>{"use strict";f();Hm=class extends Error{constructor(t="Couldn't export canvas.",r="CANVAS_ERROR"){super(),this.name=r,this.message=t}},Pn=class extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}},jo=class extends Error{code;constructor(t="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(t),this.name="EncodingError",this.code=r}},Um=class extends Error{code="ELEMENT_HAS_INVALID_INDEX"}});var S6,lr,I6,W0,Gm,V0,$r,qo,Zr=X(()=>{"use strict";f();pr();Y();S6=zs.includes(devicePixelRatio)?devicePixelRatio:1,lr=()=>({showWelcomeScreen:!1,theme:ue.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:pt.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:pt.fillStyle,currentItemFontFamily:gr,currentItemFontSize:ur,currentItemOpacity:pt.opacity,currentItemRoughness:pt.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:pt.strokeColor,currentItemRoundness:"round",currentItemArrowType:_t.round,currentItemStrokeStyle:pt.strokeStyle,currentItemStrokeWidth:pt.strokeWidth,currentItemTextAlign:vn,currentHoveredFontFamily:null,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:pt.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:S6,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,stats:{open:!1,panels:Fi.generalStats|Fi.elementProperties},startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:Ee.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),I6=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemArrowType:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},currentHoveredFontFamily:{browser:!1,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},stats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),W0=(e,t)=>{let r={};for(let o of Object.keys(e))if(I6[o]?.[t]){let i=e[o];r[o]=i}return r},Gm=e=>W0(e,"export"),V0=e=>W0(e,"server"),$r=({activeTool:e})=>e.type==="eraser",qo=({activeTool:e})=>e.type==="hand"});var Wh,cr,Wm,Vh,Jo,Vm,Y0,Ra,ot,X0,K0,$0,Z0,Na,j0,q0,Ln,Gt=X(()=>{"use strict";f();et();He();Ui();Wh=(e,t,r)=>{let o=r.reduce((n,i)=>(i.groupIds.includes(e)&&(n[i.id]=!0),n),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},cr=function(){let e=null,t=null,r=null,o=(i,a,s,l)=>{if(r!==void 0&&a===t&&i===e&&s.editingGroupId===r?.editingGroupId)return r;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let g=u.indexOf(s.editingGroupId);g>-1&&(u=u.slice(0,g))}if(u.length>0){let g=u[u.length-1];c[g]=!0}}let d={},m=a.reduce((p,u)=>{let g=u.groupIds.find(h=>c[h]);return g&&(p[u.id]=!0,Array.isArray(d[g])?d[g].push(u.id):d[g]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,r={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Ge({...s.selectedElementIds,...m},l)},r},n=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):he(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ge(i.selectedElementIds,s)}};return n.clearCache=()=>{t=null,e=null,r=null},n}(),Wm=(e,t)=>Vh(e,t)!=null,Vh=(e,t)=>t.groupIds.filter(r=>r!==e.editingGroupId).find(r=>e.selectedGroupIds[r]),Jo=e=>Object.entries(e.selectedGroupIds).filter(([t,r])=>r).map(([t,r])=>t),Vm=(e,t)=>{let r={...t,selectedGroupIds:{}};for(let o of e){let n=o.groupIds;if(t.editingGroupId){let i=n.indexOf(t.editingGroupId);i>-1&&(n=n.slice(0,i))}if(n.length>0){let i=n[n.length-1];r={...r,...Wh(i,r,e)}}}return r.selectedGroupIds},Y0=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Ra=(e,t)=>e.groupIds.includes(t),ot=(e,t)=>{let r=[];for(let o of e.values())Ra(o,t)&&r.push(o);return r},X0=(e,t)=>e.groupIds.find(r=>t[r]),K0=(e,t,r)=>{let o=[...e],n=t?e.indexOf(t):-1,i=n>-1?n:e.length;for(let a=0;a<i;a++)o[a]=r(o[a]);return o},$0=(e,t,r)=>{let o=[...e],n=r?o.indexOf(r):-1,i=n>-1?n:o.length;return o.splice(i,0,t),o},Z0=(e,t)=>e.filter(r=>!t[r]),Na=(e,t)=>{let r=new Map;return e.forEach(o=>{let n=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],i=r.get(n)||[],a=J(o,t);a&&i.push(a),r.set(n,[...i,o])}),Array.from(r.values())},j0=e=>{let t=new Set;for(let[,r]of e)if(!r.isDeleted)for(let o of r.groupIds??[])t.add(o);return t},q0=e=>{let t=e.flatMap(n=>n.groupIds),r=new Map,o=0;for(let n of t)r.set(n,(r.get(n)??0)+1),r.get(n)>o&&(o=r.get(n));return o===e.length},Ln=e=>e.groupIds.length>0});import{sanitizeUrl as C6}from"@braintree/sanitize-url";var Ym,Pr,Xm,Km,Oa=X(()=>{"use strict";f();Ym=e=>e.replace(/"/g,"&quot;"),Pr=e=>(e=e.trim(),e&&C6(Ym(e))),Xm=e=>!!(e?.includes(location.origin)||e?.startsWith("/")),Km=e=>{if(e=Pr(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e}});var $m,G,$e=X(()=>{"use strict";f();$m=[],G=e=>($m=$m.concat(e),e)});import Zm from"open-color";var Q0,A6,ey,M6,k6,mo,Ze,Dn,J0,Yh,po,Gs=X(()=>{"use strict";f();Y();Zr();Q0='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',A6='<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"/>',ey='<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"/>',M6=`data:${se.svg},${encodeURIComponent(`${Q0}${ey}</svg>`)}`,k6=`data:${se.svg},${encodeURIComponent(`${Q0}${A6}${ey}</svg>`)}`,mo=e=>{e&&(e.style.cursor="")},Ze=(e,t)=>{e&&(e.style.cursor=t)},Yh=(e,t)=>{let o=()=>{let n=t===ue.DARK;Dn=document.createElement("canvas"),Dn.theme=t,Dn.height=20,Dn.width=20;let i=Dn.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Dn.width/2,Dn.height/2,5,0,2*Math.PI),i.fillStyle=n?Zm.black:Zm.white,i.fill(),i.strokeStyle=n?Zm.white:Zm.black,i.stroke(),J0=Dn.toDataURL(se.svg)};(!Dn||Dn.theme!==t)&&o(),Ze(e,`url(${J0}) ${20/2} ${20/2}, auto`)},po=(e,t)=>{if(e)if(t.activeTool.type==="selection")mo(e);else if(qo(t))e.style.cursor=Be.GRAB;else if($r(t))Yh(e,t.theme);else if(t.activeTool.type==="laser"){let r=t.theme===ue.LIGHT?M6:k6;e.style.cursor=`url(${r}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Be.AUTO):e.style.cursor=Be.CROSSHAIR}});import{RoughGenerator as P6}from"roughjs/bin/generator";var _e,Qo=X(()=>{"use strict";f();li();Xh();pr();_e=class e{static rg=new P6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;jm.delete(t);let n=ty(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:Ee.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});import jr from"react";import L6 from"open-color";import D6 from"clsx";import{Fragment as je,jsx as b,jsxs as B}from"react/jsx-runtime";var en,ry,L,j,ve,IF,qm,oy,ny,iy,Fa,Ws,ay,sy,ly,CF,cy,dy,my,py,uy,gy,hy,ci,Jm,fy,by,Kh,$h,Ey,tn,xy,Mc,kc,Pc,Qm,Ba,Vs,yy,Zh,ep,wy,vy,Ty,Lc,Sy,Iy,Ys,AF,Cy,tp,rp,Ay,MF,kF,My,PF,jh,qh,ky,Py,LF,DF,_F,RF,NF,Ly,Dy,Jh,Qh,ef,tf,rf,of,nf,af,_y,Ry,sf,lf,op,OF,FF,Ao,BF,zF,HF,cf,df,Ny,Oy,Fy,By,mf,zy,Hy,UF,Uy,Gy,Wy,Vy,Yy,Xy,Ky,$y,Zy,pf,jy,qy,Jy,Qy,ew,tw,rw,ow,nw,iw,za,aw,Xs,Dc,sw,lw,cw,dw,mw,pw,np,uw,GF,ip,uf,ap,gw,hw,WF,VF,YF,fw,bw,Ew,sp,lp,Ks,cp,$s,XF,_c,xw,Zs,yw,ww,vw,dp,Tw,Sw,Iw,mp,Cw,Aw,Mw,kw,gf,pp,Pw,Lw,Dw,_w,Rw,KF,Nw,Ow,Fw,Bw,zw,Hw,Uw,Gw,ee=X(()=>{"use strict";f();Y();en=e=>"var(--icon-fill-color)",ry=e=>e===ue.LIGHT?L6.white:"#1e1e1e",L=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return b("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:D6({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?b("path",{fill:"currentColor",d:e}):e})},j={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ve={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},IF=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:3,y:8,width:18,height:4,rx:1}),b("line",{x1:12,y1:8,x2:12,y2:21}),b("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),b("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"})]}),j),qm=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),b("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),b("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),j),oy=L(B("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),j),ny=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"1"}),b("circle",{cx:"12",cy:"19",r:"1"}),b("circle",{cx:"12",cy:"5",r:"1"})]}),j),iy=L(B("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),b("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),b("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),j),Fa=L(B("g",{children:[b("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"}),b("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"}),b("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:b("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"})}),b("g",{mask:"url(#UnlockedIcon)",children:b("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"})})]}),ve),Ws=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),b("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"})]}),ve),ay=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),b("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"}),sy=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),b("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"}),ly=L(B(je,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),b("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"}),CF=L(b("g",{fill:"currentColor",children:b("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"}),cy=L(B("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),dy=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),j),my=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),j),py=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"})]}),j),uy=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),j),gy=L(b("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ve),hy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),b("path",{d:"M16 7h4"}),b("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),j),ci=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"m11.25 5.417 3.333 3.333"})]}),ve),Jm=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),b("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),b("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),b("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),b("polyline",{points:"5 20 11 4 13 4 20 20"})]}),j),fy=L(B("g",{strokeWidth:"1.25",children:[b("path",{d:"M12.5 6.667h.01"}),b("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"}),b("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),b("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ve),by=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M18 13.3l-6.3 -6.3"})]}),j),Kh=L(b("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ve),$h=L(b("path",{d:"M5 10h10",strokeWidth:"1.25"}),ve),Ey=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 21l-6 -6"}),b("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"}),b("path",{d:"M3 4v4h4"})]}),j),tn=L(b("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"}),ve),xy=L(B("g",{strokeWidth:"1.25",children:[b("polyline",{points:"12 16 18 10 12 4"}),b("polyline",{points:"8 4 2 10 8 16"})]}),ve),Mc=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),kc=L(b("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"}),ve),Pc=L(b("g",{stroke:"currentColor",strokeLinejoin:"round",children:b("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"})}),{...ve,strokeWidth:1.5}),Qm=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),j),Ba=L(b("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"}),ve),Vs=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),yy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),Zh=L(b("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"}),ve),ep=L(b("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"}),ve),wy=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),vy=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),b("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),j),Ty=L(b("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Lc=L(B("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),ve),Sy=L("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}),Iy=L("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}),Ys=L(b("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"}),ve),AF=L("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}),Cy=L("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"),tp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),b("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"}),b("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"})]}),j),rp=L(B("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 8h.01"}),b("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),b("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),b("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),b("path",{d:"M19 16v6"}),b("path",{d:"M22 19l-3 3l-3 -3"})]}),j),Ay=L("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}),MF=L("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}),kF=L("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}),My=L("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"),PF=L("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"),jh=L(b("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"}),ve),qh=L(b("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"}),ve),ky=L("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}),Py=L(b("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"}),ve),LF=L("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"),DF=L("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}),_F=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 14v-11"}),b("path",{d:"M9 6l3 -3l3 3"})]}),j),RF=L(B(je,{children:[b("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"}),b("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}),NF=L(b("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}),Ly=B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 10l0 10"}),b("path",{d:"M12 10l4 4"}),b("path",{d:"M12 10l-4 4"}),b("path",{d:"M4 4l16 0"})]}),Dy=B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5l0 14"}),b("path",{d:"M16 9l-4 -4"}),b("path",{d:"M8 9l4 -4"})]}),Jh=L(Dy,j),Qh=L(Dy,{...j,style:{transform:"rotate(180deg)"}}),ef=L(Ly,j),tf=L(Ly,{...j,style:{transform:"rotate(180deg)"}}),rf=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),of=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),nf=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),af=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),_y=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),Ry=L(B(je,{children:[B("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),sf=L(B("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),b("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),ve),lf=L(B("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),b("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),ve),op=L(B("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"9",cy:"7",r:"4"}),b("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),b("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),b("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),j),OF=L("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"),FF=L("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"),Ao=L(B(je,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M15 5 5 15M5 5l10 10"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),BF=L("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}),zF=L("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}),HF=L("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}),cf=jr.memo(({theme:e})=>L(B(je,{children:[b("path",{d:"M25 26H111V111H25",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),B("g",{fill:ry(e),stroke:en(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),df=jr.memo(({theme:e})=>L(B(je,{children:[b("path",{d:"M25 26H111V111H25",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:en(e)}),b("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:en(e),strokeWidth:"2"}),B("g",{fill:ry(e),stroke:en(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),b("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Ny=L(b("g",{strokeWidth:1.25,children:b("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"})}),ve),Oy=L(B(je,{children:[b("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"}),b("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:b("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"})}),b("g",{mask:"url(#FillHachureIcon)",children:b("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"})})]}),ve),Fy=L(B(je,{children:[B("g",{clipPath:"url(#a)",children:[b("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"}),b("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:b("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"})}),b("g",{mask:"url(#FillCrossHatchIcon)",children:b("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"})})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),By=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ve,fill:"currentColor"}),mf=L(b(je,{children:b("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ve),zy=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ve),Hy=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ve),UF=jr.memo(({theme:e})=>L(b("path",{d:"M6 10H34",stroke:en(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Uy=L(B("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12h2"}),b("path",{d:"M17 12h2"}),b("path",{d:"M11 12h2"})]}),j),Gy=L(B("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M8 12v.01"}),b("path",{d:"M12 12v.01"}),b("path",{d:"M16 12v.01"}),b("path",{d:"M20 12v.01"})]}),j),Wy=L(b("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"}),ve),Vy=L(b("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"}),ve),Yy=L(b("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"}),ve),Xy=L(B("svg",{strokeWidth:"1.5",children:[b("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"}),b("path",{d:"M13.3333 3.33331V3.34331"}),b("path",{d:"M16.6667 3.33331V3.34331"}),b("path",{d:"M16.6667 6.66669V6.67669"}),b("path",{d:"M16.6667 10V10.01"}),b("path",{d:"M3.33334 13.3333V13.3433"}),b("path",{d:"M16.6667 13.3333V13.3433"}),b("path",{d:"M3.33334 16.6667V16.6767"}),b("path",{d:"M6.66666 16.6667V16.6767"}),b("path",{d:"M10 16.6667V16.6767"}),b("path",{d:"M13.3333 16.6667V16.6767"}),b("path",{d:"M16.6667 16.6667V16.6767"})]}),ve),Ky=L(B("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),b("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),b("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),b("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),b("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),b("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),b("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),b("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),b("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),b("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),b("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),b("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),j),$y=L(b("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),Zy=jr.memo(({flip:e=!1})=>L(B("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[b("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),b("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),pf=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),jy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[b("path",{d:"M26 10L6 10"}),b("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),qy=jr.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:b("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Jy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M32 10L6 10",strokeWidth:2}),b("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Qy=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[b("path",{d:"M6,9.5H27"}),b("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),ew=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),tw=jr.memo(({flip:e=!1})=>L(B("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M6,9.5H20"}),b("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),rw=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),ow=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),nw=L(B(je,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),iw=L(b(je,{children:b("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"})}),ve),za=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),j),aw=L(b(je,{children:B("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 12h10"}),b("path",{d:"M7 5v14"}),b("path",{d:"M17 5v14"}),b("path",{d:"M15 19h4"}),b("path",{d:"M15 5h4"}),b("path",{d:"M5 19h4"}),b("path",{d:"M5 5h4"})]})}),j),Xs=L(b(je,{children:b("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})})}),ve),Dc=L(B(je,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ve),sw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),b("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),j),lw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),b("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),j),cw=L(B("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),j),dw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),b("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),j)),mw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),b("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),j)),pw=jr.memo(({theme:e})=>L(B("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),b("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),b("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),j)),np=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 19h-18l9 -15"}),b("path",{d:"M20.615 15.171h.015"}),b("path",{d:"M19.515 11.771h.015"}),b("path",{d:"M17.715 8.671h.015"}),b("path",{d:"M15.415 5.971h.015"})]}),j),uw=L(b("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}),GF=L(b("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"})),ip=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),b("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),b("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"})]}),j),uf=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),b("path",{d:"M7 11l5 5l5 -5"}),b("path",{d:"M12 4l0 12"})]}),j),ap=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),j),gw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M9.15 14.85l8.85 -10.85"}),b("path",{d:"M6 4l8.85 10.85"})]}),j),hw=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),b("path",{d:"M12 17l0 .01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),j),WF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 4v16l13 -8z"})]}),j),VF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),j),YF=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12l5 5l10 -10"})]}),j),fw=L(B(je,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 9v4"}),b("path",{d:"M12 17h.01"})]}),j),bw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l6 6"}),b("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"})]}),j),Ew=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l-4 7h8z"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("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"})]}),j),sp=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 7l16 0"}),b("path",{d:"M4 17l16 0"}),b("path",{d:"M7 4l0 16"}),b("path",{d:"M17 4l0 16"})]}),j),lp=L(b("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"})),Ks=L(B("g",{strokeWidth:"1.25",children:[b("path",{d:"M4.16602 10H15.8327"}),b("path",{d:"M12.5 13.3333L15.8333 10"}),b("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ve),cp=L(B("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[b("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"}),b("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),$s=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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"})]}),j),XF=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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"})]}),j),_c=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),b("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),b("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"}),b("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),b("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),b("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"})]}),j),xw=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),b("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),b("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),b("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),j),Zs=L(B("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),b("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"})]}),j),yw=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),b("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"}),b("path",{d:"M3 3l18 18"})]}),j),ww=L(B("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),j),vw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),j),dp=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),b("path",{d:"M21 21l-6 -6"})]}),j),Tw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),b("path",{d:"M12 7v5l3 3"}),b("path",{d:"M19 16l-2 3h4l-2 3"})]}),j),Sw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 14 0"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),j),Iw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 3l18 18"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),j),mp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),j),Cw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 20v.01"}),b("path",{d:"M16 20v.01"}),b("path",{d:"M8 20v.01"}),b("path",{d:"M4 20v.01"}),b("path",{d:"M4 16v.01"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M4 8v.01"}),b("path",{d:"M4 4v.01"}),b("path",{d:"M8 4v.01"}),b("path",{d:"M12 4v.01"}),b("path",{d:"M16 4v.01"}),b("path",{d:"M20 4v.01"}),b("path",{d:"M20 8v.01"}),b("path",{d:"M20 12v.01"}),b("path",{d:"M20 16v.01"}),b("path",{d:"M20 20v.01"})]}),j),Aw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 3v18"}),b("path",{d:"M19 21v-18"}),b("path",{d:"M5 7h14"}),b("path",{d:"M5 15h14"}),b("path",{d:"M8 13v4"}),b("path",{d:"M11 13v4"}),b("path",{d:"M16 13v4"}),b("path",{d:"M14 5v4"}),b("path",{d:"M11 5v4"}),b("path",{d:"M8 5v4"}),b("path",{d:"M3 21h18"})]}),j),Mw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 12l18 0"}),b("path",{d:"M7 16l10 0l-10 5l0 -5"}),b("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),j),kw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l0 18"}),b("path",{d:"M16 7l0 10l5 0l-5 -10"}),b("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),j),gf=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),b("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"})]}),j),pp=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),b("path",{d:"M22 22l-3 -3"}),b("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),b("path",{d:"M3 11v-1"}),b("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),b("path",{d:"M10 3h1"}),b("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),j),Pw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("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"}),b("path",{d:"M10 15l2 6l2 -6"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),j),Lw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),b("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),b("path",{d:"M11 21v-6l3 6v-6"})]}),j),Dw=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 8l5 0"}),b("path",{d:"M15 8l4 0"})]}),j),_w=L(B("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),b("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),j),Rw=L(B("g",{stroke:"currentColor",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"})]}),{...j,strokeWidth:1.5}),KF=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M21 12h-13l3 -3"}),b("path",{d:"M11 15l-3 -3"})]}),j),Nw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M10 9l5 3l-5 3z"})]}),j),Ow=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 6h18"}),b("path",{d:"M3 12h18"}),b("path",{d:"M3 18h18"}),b("path",{d:"M6 3v18"}),b("path",{d:"M12 3v18"}),b("path",{d:"M18 3v18"})]}),j),Fw=L(B("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),j),Bw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 18l12 -12"}),b("path",{d:"M18 10v-4h-4"})]}),j),zw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),b("path",{d:"M18 4l3 3l-3 3"})]}),j),Hw=L(B("g",{children:[b("path",{d:"M16,12L20,9L16,6"}),b("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),j),Uw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 9l6 6l6 -6"})]}),j),Gw=L(B("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),j)});var rn,Gi,up,hf=X(()=>{"use strict";f();ee();Y();rn={[Le.Excalifont]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},icon:ci},[Le.Nunito]:{metrics:{unitsPerEm:1e3,ascender:1011,descender:-353,lineHeight:1.35},icon:Xs},[Le["Lilita One"]]:{metrics:{unitsPerEm:1e3,ascender:923,descender:-220,lineHeight:1.15},icon:aw},[Le["Comic Shanns"]]:{metrics:{unitsPerEm:1e3,ascender:750,descender:-250,lineHeight:1.25},icon:Dc},[Le.Virgil]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},icon:ci,deprecated:!0},[Le.Helvetica]:{metrics:{unitsPerEm:2048,ascender:1577,descender:-471,lineHeight:1.15},icon:Xs,deprecated:!0,local:!0},[Le.Cascadia]:{metrics:{unitsPerEm:2048,ascender:1900,descender:-480,lineHeight:1.2},icon:Dc,deprecated:!0},[Le["Liberation Sans"]]:{metrics:{unitsPerEm:2048,ascender:1854,descender:-434,lineHeight:1.15},icon:Xs,serverSide:!0}},Gi={LATIN:"U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD",LATIN_EXT:"U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF",CYRILIC_EXT:"U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F",CYRILIC:"U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116",VIETNAMESE:"U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB"},up="local:"});import{fileOpen as _6,fileSave as R6,supported as Wi}from"browser-fs-access";var Ww,js,qs,di=X(()=>{"use strict";f();Y();Hi();V();Ww=500,js=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(se[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return _6({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=ii(n,Ww),s=()=>{l(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},l=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",s)});let c=window.setInterval(()=>{l()},Ww);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",s),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new Pn))}}})},qs=(e,t)=>R6(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var N6,Vi,gp,ff,Vw,bf,hp,Yw,mi=X(()=>{"use strict";f();di();Zr();Y();we();qr();N6=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},Vi=(e,t,r,o)=>{let n={type:hr.excalidraw,version:Da.excalidraw,source:yc,elements:o==="local"?fp(e):Xw(e),appState:o==="local"?Gm(t):V0(t),files:o==="local"?N6(e,r):void 0};return JSON.stringify(n,null,2)},gp=async(e,t,r,o=t.name||Lm)=>{let n=Vi(e,t,r,"local"),i=new Blob([n],{type:se.excalidraw});return{fileHandle:await qs(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:Js(t.fileHandle)?null:t.fileHandle})}},ff=async(e,t)=>{let r=await js({description:"Excalidraw files"});return Qs(await Rc(r),e,t,r.handle)},Vw=e=>e?.type===hr.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),bf=e=>typeof e=="object"&&e&&e.type===hr.excalidrawLibrary&&(e.version===1||e.version===2),hp=e=>{let t={type:hr.excalidrawLibrary,version:Da.excalidrawLibrary,source:yc,libraryItems:e};return JSON.stringify(t,null,2)},Yw=async e=>{let t=hp(e);await qs(new Blob([t],{type:se.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var pi,Yi,Ha=X(()=>{"use strict";f();pi=e=>{let t=e.map(o=>o[0]),r=e.map(o=>o[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}},Yi=(e,t,r,o)=>{let n=r.map(u=>u[e]),i=Math.max(...n),a=Math.min(...n),s=i-a,l=s===0?1:t/s,c=1/0,d=r.map(u=>{let g=u[e]*l,h=[...u];return h[e]=g,g<c&&(c=g),h});if(!o||d.length===2)return d;let m=a-c;return d.map(u=>u.map((g,h)=>h===e?g+m:g))}});var O6,F6,bp,Ua,B6,z6,H6,U6,Nc,G6,Kw,Zw,Xi,$w,Ga,el=X(()=>{"use strict";f();we();me();Zo();Y();Zr();Wt();De();V();V();He();Oa();ko();Ha();on();O6={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},F6=e=>Object.keys(Le).includes(e)?Le[e]:gr,bp=(e,t)=>t?{...t,focus:t.focus||0,fixedPoint:de(e)?t.fixedPoint??[0,0]:null}:null,Ua=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||Ut(),fillStyle:e.fillStyle||pt.fillStyle,strokeWidth:e.strokeWidth||pt.strokeWidth,strokeStyle:e.strokeStyle??pt.strokeStyle,roughness:e.roughness??pt.roughness,opacity:e.opacity==null?pt.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||pt.strokeColor,backgroundColor:e.backgroundColor||pt.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:kn(e.type)?ct.LEGACY:ct.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??si(),link:e.link?Pr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...Fc(r),...t}},B6=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[d,m]=e.font.split(" ");t=parseFloat(d),r=F6(m)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?jw(e):uo(e.fontFamily));return e=Ua(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||vn,verticalAlign:e.verticalAlign||Pa,containerId:e.containerId??null,originalText:e.originalText||o,autoResize:e.autoResize??!0,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=Ki(e)),e;case"freedraw":return Ua(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return Ua(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":let{startArrowhead:i=null,endArrowhead:a=null}=e,s=e.x,l=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:s,y:l}=K.getNormalizedPoints(e)),Ua(e,{type:e.type==="draw"?"line":e.type,startBinding:bp(e,e.startBinding),endBinding:bp(e,e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:s,y:l,...pi(c)});case"arrow":{let{startArrowhead:d=null,endArrowhead:m="arrow"}=e,p=e.x,u=e.y,g=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(g[0][0]!==0||g[0][1]!==0)&&({points:g,x:p,y:u}=K.getNormalizedPoints(e)),Ua(e,{type:e.type,startBinding:bp(e,e.startBinding),endBinding:bp(e,e.endBinding),lastCommittedPoint:null,startArrowhead:d,endArrowhead:m,points:g,x:p,y:u,elbowed:e.elbowed,...pi(g)})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return Ua(e,{});case"magicframe":case"frame":return Ua(e,{name:e.name??null})}return null},z6=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),H(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},H6=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},U6=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},Nc=(e,t,r)=>{let o=new Set,n=t?Z(t):null,i=fr((e||[]).reduce((s,l)=>{if(l.type!=="selection"&&!Po(l)){let c=B6(l);if(c){let d=n?.get(l.id);d&&d.version>c.version&&(c=Ki(c,d.version)),o.has(c.id)&&(c={...c,id:Ut()}),o.add(c.id),s.push(c)}}return s},[]));if(!r?.repairBindings)return i;let a=Z(i);for(let s of i)s.frameId&&U6(s,a),H(s)&&s.containerId?H6(s,a):s.boundElements&&z6(s,a),r.refreshDimensions&&H(s)&&Object.assign(s,Oc(s,Et(s,a),a)),ie(s)&&(s.startBinding&&(!a.has(s.startBinding.elementId)||!ne(s))&&(s.startBinding=null),s.endBinding&&(!a.has(s.endBinding.elementId)||!ne(s))&&(s.endBinding=null));return i},G6=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},Kw={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??G6("defaultSidebarDockedPreference",e,t)]},Zw=(e,t)=>{e=e||{};let r=lr(),o={};for(let n of Object.keys(Kw))if(n in e){let[i,a]=Kw[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],s=t?t[n]:void 0;o[n]=a!==void 0?a:s!==void 0?s:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...nt(r,o.activeTool.type&&O6[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:co.name}:o.openSidebar}},Xi=(e,t,r,o)=>({elements:Nc(e?.elements,r,o),appState:Zw(e?.appState,t||null),files:e?.files||{}}),$w=e=>{let t=Nc(Ae(e.elements),null);return t.length?{...e,elements:t}:null},Ga=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=$w({status:t,elements:o,id:Ut(),created:Date.now()});n&&r.push(n)}else{let n=o,i=$w({...n,id:n.id||Ut(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var Bc={};Ch(Bc,{decodePngMetadata:()=>V6,decodeSvgMetadata:()=>X6,encodePngMetadata:()=>Ef,encodeSvgMetadata:()=>Y6,getTEXtChunk:()=>Qw});import qw from"png-chunks-extract";import Jw from"png-chunk-text";import W6 from"png-chunks-encode";var Qw,Ef,V6,Y6,X6,tl=X(()=>{"use strict";f();wf();Y();qr();Qw=async e=>{let r=qw(new Uint8Array(await ui(e))).find(o=>o.name==="tEXt");return r?Jw.decode(r.data):null},Ef=async({blob:e,metadata:t})=>{let r=qw(new Uint8Array(await ui(e))),o=Jw.encode(se.excalidraw,JSON.stringify(await xf({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([W6(r)],{type:se.png})},V6=async e=>{let t=await Qw(e);if(t?.keyword===se.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===hr.excalidraw)return t.text;throw new Error("FAILED")}return await yf(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},Y6=async({text:e})=>{let t=await Ep(JSON.stringify(await xf({text:e})),!0),r="";return r+=`<!-- payload-type:${se.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},X6=async({svg:e})=>{if(e.includes(`payload-type:${se.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await e2(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===hr.excalidraw)return i;throw new Error("FAILED")}return await yf(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as K6}from"nanoid";var r2,vf,o2,Js,$i,yp,Qs,Tf,Sf,gi,n2,wp,i2,zc,If,a2,s2,$6,t2,xp,Rc,ui,qr=X(()=>{"use strict";f();Zr();Y();we();Hi();et();V();di();mi();el();r2=async e=>{let t;if(e.type===se.png)try{return await(await Promise.resolve().then(()=>(tl(),Bc))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new jo("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===se.svg)try{return await(await Promise.resolve().then(()=>(tl(),Bc))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new jo("Error: cannot restore image")}return t},vf=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,o2=e=>e==="png"||e==="svg",Js=e=>{let t=vf(e);return t==="png"||t==="svg"},$i=e=>{let{type:t}=e||{};return!!t&&Object.values(xc).includes(t)},yp=async(e,t,r,o)=>{let n=await r2(e),i;try{try{i=JSON.parse(n)}catch(a){throw $i(e)?new jo("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(Vw(i))return{type:se.excalidraw,data:Xi({elements:fp(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...Gm(i.appState||{}),...t?_n(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(bf(i))return{type:se.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof jo?a:new Error("Error: invalid file")}},Qs=async(e,t,r,o)=>{let n=await yp(e,t,r,o);if(n.type!==se.excalidraw)throw new Error("Error: invalid file");return n.data},Tf=(e,t="unpublished")=>{let r=JSON.parse(e);if(!bf(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return Ga(o,t)},Sf=async(e,t="unpublished")=>Tf(await r2(e),t),gi=async e=>new Promise(async(t,r)=>{try{Cn(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new Hm("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),n2=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await ui(e));return P0(new Uint8Array(t))}catch(t){return console.error(t),K6(40)}},wp=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),i2=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let s=0;s<o.length;s++)a[s]=o.charCodeAt(s);return new File([i],t,{type:n})},zc=async(e,t)=>{if(e.type===se.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(s=>(a.out_blob=s,a))}}if(!$i(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},If=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:se.svg}),a2=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&$i(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},s2=async e=>{let t=e.dataTransfer.files.item(0),r=await $6(e);return{file:t?await Rc(t):null,fileHandle:r}},$6=async e=>{if(Wi)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},t2=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=se.png:r.startsWith(o.jpg)?t=se.jpg:r.startsWith(o.gif)&&(t=se.gif),t},xp=(e,t,r)=>new File([e],r||"",{type:t}),Rc=async e=>{if(e.type){if($i(e)){let t=await ui(e),r=t2(t);r&&r!==e.type&&(e=xp(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=xp(await ui(e),se.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=xp(await ui(e),se.excalidraw,e.name);else{let t=await ui(e),r=t2(t);r&&(e=xp(t,r,e.name))}return e},ui=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var l2=X(()=>{"use strict";f();Y();qr()});import{deflate as Z6,inflate as j6}from"pako";var Hc,c2,d2,Ep,e2,xf,yf,wf=X(()=>{"use strict";f();l2();Hc=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),c2=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},d2=e=>new TextDecoder("utf-8").decode(c2(e)),Ep=async(e,t=!1)=>t?window.btoa(e):window.btoa(await Hc(e)),e2=async(e,t=!1)=>t?window.atob(e):d2(window.atob(e)),xf=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await Hc(Z6(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await Hc(e)}},yf=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await d2(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?j6(new Uint8Array(c2(t)),{to:"string"}):t}});var q6,vp,m2=X(()=>{"use strict";f();wf();hf();q6=`https://unpkg.com/${T.VITE_PKG_NAME?`${T.VITE_PKG_NAME}@${T.PKG_VERSION}`:"@excalidraw/excalidraw"}/dist/prod/`,vp=class e{urls;fontFace;constructor(t,r,o){this.urls=e.createUrls(r);let n=this.urls.map(i=>`url(${i}) ${e.getFormat(i)}`).join(", ");this.fontFace=new FontFace(t,n,{display:"swap",style:"normal",weight:"400",...o})}async getContent(){let t=0,r=[];for(;t<this.urls.length;){let o=this.urls[t];if(o.protocol==="data:")return o.toString();try{let n=await fetch(o,{headers:{Accept:"font/woff2"}});if(n.ok){let i=await n.headers.get("Content-Type"),a=await n.arrayBuffer();return`data:${i};base64,${await Ep(await Hc(a),!0)}`}r.push(`"${o.toString()}" returned status "${n.status}"`)}catch(n){r.push(`"${o.toString()}" returned error "${n}"`)}t++}return console.error(`Failed to fetch font "${this.fontFace.family}" from urls "${this.urls.toString()}`,JSON.stringify(r,void 0,2)),this.urls.length?this.urls[this.urls.length-1].toString():""}static createUrls(t){if(t.startsWith(up))return[];if(t.startsWith("http")||t.startsWith("data"))return[new URL(t)];let r=t.replace(/^\/+/,""),o=[];if(typeof window.EXCALIDRAW_ASSET_PATH=="string"){let n=this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);o.push(new URL(r,n))}else Array.isArray(window.EXCALIDRAW_ASSET_PATH)&&window.EXCALIDRAW_ASSET_PATH.forEach(n=>{let i=this.normalizeBaseUrl(n);o.push(new URL(r,i))});return o.push(new URL(r,q6)),o}static getFormat(t){try{let o=new URL(t).pathname.split(".");return o.length===1?"":`format('${o.pop()}')`}catch{return""}}static normalizeBaseUrl(t){let r=t;return/^\.?\//.test(r)&&(r=new URL(r.replace(/^\.?\/+/,""),window?.location?.origin).toString()),r=`${r.replace(/\/+$/,"")}/`,r}}});var u2,p2=X(()=>{u2="./Virgil-Regular-YHAB2VGJ.woff2"});var h2,g2=X(()=>{h2="./Excalifont-Regular-CPKEUDVM.woff2"});var b2,f2=X(()=>{b2="./CascadiaCode-Regular-TMZI7IJ5.woff2"});var x2,E2=X(()=>{x2="./ComicShanns-Regular-6TOETDFT.woff2"});var w2,y2=X(()=>{w2="./LiberationSans-Regular-ZQD73GJM.woff2"});var T2,v2=X(()=>{T2="https://fonts.gstatic.com/s/lilitaone/v15/i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2"});var I2,S2=X(()=>{I2="https://fonts.gstatic.com/s/lilitaone/v15/i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2"});var A2,C2=X(()=>{A2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2"});var k2,M2=X(()=>{k2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2"});var L2,P2=X(()=>{L2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2"});var _2,D2=X(()=>{_2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2"});var N2,R2=X(()=>{N2="https://fonts.gstatic.com/s/nunito/v26/XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2"});function d4(e,t,...r){let o=Le[e];return this.registered.get(o)||this.registered.set(o,{metadata:t,fonts:r.map(({uri:i,descriptors:a})=>new vp(e,i,a))}),this.registered}var Lr,Tp,uo,on=X(()=>{"use strict";f();Qo();we();V();Y();hf();m2();He();p2();g2();f2();E2();y2();v2();S2();C2();M2();P2();D2();R2();Lr=class e{static loadedFontsCache=new Set;static _registered;static _initialized=!1;static get registered(){return e._registered?e._initialized||(e._registered=new Map([...e.init().entries(),...e._registered.entries()])):e._registered=e.init(),e._registered}get registered(){return e.registered}scene;constructor({scene:t}){this.scene=t}onLoaded=t=>{if(t.every(n=>{let i=`${n.family}-${n.style}-${n.weight}-${n.unicodeRange}`;return e.loadedFontsCache.has(i)?!0:(e.loadedFontsCache.add(i),!1)}))return!1;let r=!1,o=this.scene.getNonDeletedElementsMap();for(let n of this.scene.getNonDeletedElements())if(H(n)){r=!0,_e.delete(n);let i=Et(n,o);i&&_e.delete(i)}r&&this.scene.triggerUpdate()};loadSceneFonts=async()=>{let t=this.getSceneFontFamilies(),r=await e.loadFontFaces(t);return this.onLoaded(r),r};getSceneFontFamilies=()=>e.getFontFamilies(this.scene.getNonDeletedElements());static loadFontsForElements=async t=>{let r=e.getFontFamilies(t);return await e.loadFontFaces(r)};static async loadFontFaces(t){for(let{fonts:o,metadata:n}of e.registered.values())if(!n.local)for(let{fontFace:i}of o)window.document.fonts.has(i)||window.document.fonts.add(i);return(await Promise.all(t.map(async o=>{let n=Me({fontFamily:o,fontSize:16});if(!window.document.fonts.check(n))try{return await window.document.fonts.load(n)}catch(i){console.error(`Failed to load font "${n}" from urls "${e.registered.get(o)?.fonts.map(a=>a.urls)}"`,i)}return Promise.resolve()}))).flat().filter(Boolean)}static init(){let t={registered:new Map},r=d4.bind(t);return r("Virgil",rn[Le.Virgil],{uri:u2}),r("Excalifont",rn[Le.Excalifont],{uri:h2}),r("Helvetica",rn[Le.Helvetica],{uri:up}),r("Liberation Sans",rn[Le["Liberation Sans"]],{uri:w2}),r("Cascadia",rn[Le.Cascadia],{uri:b2}),r("Comic Shanns",rn[Le["Comic Shanns"]],{uri:x2}),r("Lilita One",rn[Le["Lilita One"]],{uri:I2,descriptors:{unicodeRange:Gi.LATIN_EXT}},{uri:T2,descriptors:{unicodeRange:Gi.LATIN}}),r("Nunito",rn[Le.Nunito],{uri:_2,descriptors:{unicodeRange:Gi.CYRILIC_EXT,weight:"500"}},{uri:L2,descriptors:{unicodeRange:Gi.CYRILIC,weight:"500"}},{uri:N2,descriptors:{unicodeRange:Gi.VIETNAMESE,weight:"500"}},{uri:k2,descriptors:{unicodeRange:Gi.LATIN_EXT,weight:"500"}},{uri:A2,descriptors:{unicodeRange:Gi.LATIN,weight:"500"}}),e._initialized=!0,t.registered}static getFontFamilies(t){return Array.from(t.reduce((r,o)=>(H(o)&&r.add(o.fontFamily),r),new Set))}};Tp=(e,t,r)=>{let{unitsPerEm:o,ascender:n,descender:i}=Lr.registered.get(e)?.metadata.metrics||rn[Le.Virgil].metrics,a=t/o,s=(r-a*n+a*i)/2;return a*n+s},uo=e=>{let{lineHeight:t}=Lr.registered.get(e)?.metadata.metrics||rn[Le.Excalifont].metrics;return t}});var Rn,go,Cf,O2,Cp,Uc,F2,jt,m4,Oc,B2,nn,Gc,Wc,Sp,an,Ip,Vc,Ap,Nn=X(()=>{"use strict";f();V();Zo();De();Gt();we();mt();dt();He();Y();on();Rn=(e,{x:t,y:r,strokeColor:o=pt.strokeColor,backgroundColor:n=pt.backgroundColor,fillStyle:i=pt.fillStyle,strokeWidth:a=pt.strokeWidth,strokeStyle:s=pt.strokeStyle,roughness:l=pt.roughness,opacity:c=pt.opacity,width:d=0,height:m=0,angle:p=0,groupIds:u=[],frameId:g=null,index:h=null,roundness:x=null,boundElements:v=null,link:y=null,locked:w=pt.locked,...C})=>({id:C.id||Ut(),type:e,x:t,y:r,width:d,height:m,angle:p,strokeColor:o,backgroundColor:n,fillStyle:i,strokeWidth:a,strokeStyle:s,roughness:l,opacity:c,groupIds:u,frameId:g,index:h,roundness:x,seed:C.seed??Co(),version:C.version||1,versionNonce:C.versionNonce??0,isDeleted:!1,boundElements:v,updated:si(),link:y,locked:w,customData:C.customData}),go=e=>Rn(e.type,e),Cf=e=>Rn("embeddable",e),O2=e=>({...Rn("iframe",e)}),Cp=e=>pe({...Rn("frame",e),type:"frame",name:e?.name||null},{}),Uc=e=>pe({...Rn("magicframe",e),type:"magicframe",name:e?.name||null},{}),F2=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),jt=e=>{let t=e.fontFamily||gr,r=e.fontSize||ur,o=e.lineHeight||uo(t),n=Zi(e.text),i=Vt(n,Me({fontFamily:t,fontSize:r}),o),a=e.textAlign||vn,s=e.verticalAlign||Pa,l=F2({textAlign:a,verticalAlign:s},i),c={...Rn("text",e),text:n,fontSize:r,fontFamily:t,textAlign:a,verticalAlign:s,x:e.x-l.x,y:e.y-l.y,width:i.width,height:i.height,containerId:e.containerId||null,originalText:e.originalText??n,autoResize:e.autoResize??!0,lineHeight:o};return pe(c,{})},m4=(e,t,r)=>{let{width:o,height:n}=Vt(r,Me(e),e.lineHeight);e.autoResize||(o=e.width);let{textAlign:i,verticalAlign:a}=e,s,l;if(i==="center"&&a===kt.MIDDLE&&!e.containerId&&e.autoResize){let c=Vt(e.text,Me(e),e.lineHeight),d=F2(e,{width:o-c.width,height:n-c.height});s=e.x-d.x,l=e.y-d.y}else{let[c,d,m,p]=ae(e,t),[u,g,h,x]=hi(e,o,n,!1),v=(c-u)/2,y=(d-g)/2,w=(m-h)/2,C=(p-x)/2;[s,l]=z2({s:!0,e:i==="center"||i==="left",w:i==="center"||i==="right"},e.x,e.y,e.angle,v,y,w,C)}return{width:o,height:n,x:Number.isFinite(s)?s:e.x,y:Number.isFinite(l)?l:e.y}},Oc=(e,t,r,o=e.text)=>{if(e.isDeleted)return;(t||!e.autoResize)&&(o=Lo(o,Me(e),t?br(t,e):e.width));let n=m4(e,r,o);return{text:o,...n}},B2=e=>({...Rn(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),nn=e=>({...Rn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:null,endArrowhead:null}),Gc=e=>({...Rn(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null,elbowed:e.elbowed||!1}),Wc=e=>({...Rn("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Sp=(e,t=0)=>{if(e==null||typeof e!="object")return e;let r=Object.prototype.toString.call(e);if(r==="[object Object]"){let o=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(t===0&&(n==="shape"||n==="canvas"))continue;o[n]=Sp(e[n],t+1)}return o}if(Array.isArray(e)){let o=e.length,n=new Array(o);for(;o--;)n[o]=Sp(e[o],t+1);return n}return T.DEV&&r!=="[object Object]"&&r!=="[object Array]"&&r.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${r}. This value will not be cloned!`),e},an=e=>Sp(e),Ip=e=>{if(Yr()&&e){let t=`${e}_copy`;return window.h?.app?.getSceneElementsIncludingDeleted().find(r=>r.id===t)&&(t+="_copy"),t}return Ut()},Vc=(e,t,r,o)=>{let n=an(r);return n.id=Ip(n.id),n.boundElements=null,n.updated=si(),n.seed=Co(),n.groupIds=K0(n.groupIds,e,i=>(t.has(i)||t.set(i,Ip(i)),t.get(i))),o&&(n=Object.assign(n,o)),n},Ap=(e,t)=>{let r=[],o=Z(e),n=new Map,i=s=>{if(n.has(s))return n.get(s);if(o.has(s)){let l=Ip(s);return n.set(s,l),l}return null},a=new Map;for(let s of e){let l=Sp(s);if(l.id=i(s.id),t?.randomizeSeed&&(l.seed=Co(),Ki(l)),l.groupIds&&(l.groupIds=l.groupIds.map(c=>(a.has(c)||a.set(c,Ip(c)),a.get(c)))),"containerId"in l&&l.containerId){let c=i(l.containerId);l.containerId=c}if("boundElements"in l&&l.boundElements&&(l.boundElements=l.boundElements.reduce((c,d)=>{let m=i(d.id);return m&&c.push({...d,id:m}),c},[])),"endBinding"in l&&l.endBinding){let c=i(l.endBinding.elementId);l.endBinding=c?{...l.endBinding,elementId:c}:null}if("startBinding"in l&&l.startBinding){let c=i(l.startBinding.elementId);l.startBinding=c?{...l.startBinding,elementId:c}:null}l.frameId&&(l.frameId=i(l.frameId)),r.push(l)}return r}});var Er,H2,Wa,rl,U2,Af,ji,p4,Mf,Mp,kf,G2,Pf,W2,Va,V2,Lf,oH,nH,iH,aH,sH,lH,cH,Ya=X(()=>{"use strict";f();Er=(e,t)=>[0,0,0,0,t,e,1,0],H2=(e,t)=>[0,0,0,0,t,e,0,0],Wa=(e=0,t=0)=>{let r=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(r[t]=e),r},rl=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],U2=(e,t)=>Lf(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Af=(e,t)=>Lf(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],ji=(e,t)=>Lf(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[p4(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],p4=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],Mf=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],Mp=(e,t)=>[kf(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],kf=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],G2=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],Pf=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),W2=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),Va=e=>{let t=Pf(e);if(t===0||t===1)return e;let r=e[6]<0?-1:1;return ji(e,r/t)},V2=e=>{let t=W2(e);return t===0||t===1?e:ji(e,1/t)},Lf=e=>typeof e=="number",oH=Wa(1,1),nH=Wa(1,2),iH=Wa(1,3),aH=Wa(1,4),sH=Wa(1,5),lH=Wa(1,6),cH=Wa(1,7)});var kp,ol,Y2,X2,K2,Df=X(()=>{"use strict";f();Ya();kp=(e,t,r)=>Va([0,r,e,t,0,0,0,0]),ol=(e,t)=>Va(Mp(t,e)),Y2=(e,t)=>G2(e,t),X2=(e,t)=>Y2(ol(e,t),t),K2=e=>Math.sign(e[1])});var Xa,Ka,Z2,j2,_f,qi,q2=X(()=>{"use strict";f();Ya();Df();Ya();Xa=([e,t])=>[0,0,0,0,t,e,1,0],Ka=e=>[e[5],e[4]],Z2=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],j2=(e,t)=>Va(Mf(e,t)),_f=(e,t)=>Pf(Mp(e,t)),qi=(e,t)=>kf(e,t)});var Rf,J2,Nf=X(()=>{"use strict";f();Ya();Rf=e=>[0,0,0,0,e[4],e[5],0,0],J2=(e,t)=>V2([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0])});var Of,ev,tv,rv,sn,ov=X(()=>{"use strict";f();Ya();Nf();Of=(e,t)=>U2(ji(e,Math.sin(t/2)),Math.cos(t/2)),ev=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],tv=(e,t)=>{let r=.5*t;return[1,0,0,0,r*e[4],r*e[5],0,0]},rv=(e,t)=>ji(t,e),sn=(e,t)=>Va(ji(ji(e,t),rl(e)))});var nl,Xc,h4,il,ln,f4,nv,b4,At,E4,Ff,x4,iv,av,y4,$a,Bf,w4,v4,zf,sv,Hf,lv,T4,cv,dv,al=X(()=>{"use strict";f();mt();nl=1e-4,Xc=(e,t,r)=>(e[0]-r[0])*(t[1]-r[1])-(e[1]-r[1])*(t[0]-r[0]),h4=e=>{let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},il=e=>h4(e)?e:[...e,e[0]],ln=e=>{let t=e*180/Math.PI;return t<0?360+t:t},f4=e=>e/180*Math.PI,nv=(e,t)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)],b4=e=>e[0]===0&&e[1]===0,At=(e,t,r)=>{let o=f4(t);return!r||b4(r)?nv(e,o):nv(e.map((n,i)=>n-r[i]),o).map((n,i)=>n+r[i])},E4=e=>[-e[0],-e[1]],Ff=(e,t)=>[e[0]+t[0],e[1]+t[1]],x4=(e,t)=>Pt(...e,...t),iv=e=>ln(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0])),av=(e,t,r)=>{let o=Ff(e,E4(t));return At(o,-ln(r))},y4=(e,t)=>{let[r,o]=e,[[n,i],[a,s]]=t,l=r-n,c=o-i,d=a-n,m=s-i,p=l*d+c*m,u=d*d+m*m,g=-1;u!==0&&(g=p/u);let h,x;g<0?(h=n,x=i):g>1?(h=a,x=s):(h=n+g*d,x=i+g*m);let v=r-h,y=o-x;return Math.sqrt(v*v+y*y)},$a=(e,t,r=nl)=>{let o=y4(e,t);return o===0?!0:o<r},Bf=(e,t,r=nl)=>t.some(o=>$a(e,o,r)),w4=e=>{let[t,r,o,n]=e;return(i,a)=>Math.pow(1-i,3)*n[a]+3*i*Math.pow(1-i,2)*o[a]+3*Math.pow(i,2)*(1-i)*r[a]+t[a]*Math.pow(i,3)},v4=(e,t=10)=>{let r=w4(e),o=[r(0,0),r(0,1)],n=[],i=0,a=1/t;for(let s=0;s<t;s++)if(i+=a,i<=1){let l=[r(i,0),r(i,1)];n.push([o,l]),o=l}return n},zf=(e,t,r=nl)=>Bf(e,v4(t),r),sv=(e,t,r=nl)=>t.some(o=>zf(e,o,r)),Hf=(e,t)=>{let r=e[0],o=e[1],n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){let s=t[i][0],l=t[i][1],c=t[a][0],d=t[a][1];(l>o&&d<=o||l<=o&&d>o)&&r<(c-s)*(o-l)/(d-l)+s&&(n=!n)}return n},lv=(e,t,r=nl)=>{let o=!1,n=il(t);for(let i=0,a=n.length-1;i<a;i++)if($a(e,[n[i],n[i+1]],r)){o=!0;break}return o},T4=(e,t)=>{let{angle:r,halfWidth:o,halfHeight:n,center:i}=t,a=o,s=n,[l,c]=av(e,i,r),d=Math.abs(l),m=Math.abs(c),p=.707,u=.707;for(let x=0;x<3;x++){let v=a*p,y=s*u,w=(a*a-s*s)*p**3/a,C=(s*s-a*a)*u**3/s,M=v-w,I=y-C,P=d-w,A=m-C,N=Math.hypot(I,M),k=Math.hypot(A,P);p=Math.min(1,Math.max(0,(P*N/k+w)/a)),u=Math.min(1,Math.max(0,(A*N/k+C)/s));let D=Math.hypot(u,p);p/=D,u/=D}let[g,h]=[a*p*Math.sign(l),s*u*Math.sign(c)];return x4([l,c],[g,h])},cv=(e,t,r=nl)=>T4(e,t)<=r,dv=(e,t)=>{let{center:r,angle:o,halfWidth:n,halfHeight:i}=t,[a,s]=av(e,r,o);return a/n*(a/n)+s/i*(s/i)<=1}});var Kc,sl,Pp=X(()=>{"use strict";f();al();Kc=(e,t,r=0)=>{switch(t.type){case"polygon":return lv(e,t.data,r);case"ellipse":return cv(e,t.data,r);case"line":return $a(e,t.data,r);case"polyline":return Bf(e,t.data,r);case"curve":return zf(e,t.data,r);case"polycurve":return sv(e,t.data,r);default:throw Error(`shape ${t} is not implemented`)}},sl=(e,t)=>{switch(t.type){case"polygon":return Hf(e,t.data);case"line":return!1;case"curve":return!1;case"ellipse":return dv(e,t.data);case"polyline":{let r=il(t.data.flat());return Hf(e,r)}case"polycurve":return!1;default:throw Error(`shape ${t} is not implemented`)}}});var Se,S,ll,Lp,cl,Za,ye=X(()=>{"use strict";f();Y();Se={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},S={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:Cr?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},ll=e=>e===S.ARROW_LEFT||e===S.ARROW_RIGHT||e===S.ARROW_DOWN||e===S.ARROW_UP,Lp=e=>e.altKey,cl=e=>e.shiftKey,Za=e=>e.shiftKey});import{pointsOnBezierCurves as S4}from"points-on-curve";var Dp,mv,pv,uv,gv,I4,hv,fv,_p=X(()=>{"use strict";f();we();al();Dp=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=ln(t),s=n+r/2,l=i+o/2,c=[s,l],d=[];return e.type==="diamond"?d=[At([s,i],a,c),At([n+r,l],a,c),At([s,i+o],a,c),At([n,l],a,c)]:d=[At([n,i],a,c),At([n+r,i],a,c),At([n+r,i+o],a,c),At([n,i+o],a,c)],{type:"polygon",data:d}},mv=(e,t,r=10)=>{let[o,n,i,a,s,l]=ae(e,t,!0);o-=r,i+=r,n-=r,a+=r;let c=ln(e.angle),d=[s,l],m=At([o,n],c,d),p=At([i,n],c,d),u=At([o,a],c,d),g=At([i,a],c,d);return{type:"polygon",data:[m,p,g,u]}},pv=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},uv=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},gv=(e,t=[0,0],r,o)=>{let n=l=>At([l[0]+t[0],l[1]+t[1]],ln(r),o),i=uv(e),a=[],s=[0,0];for(let l of i)if(l.op==="move"&&(s=n(l.data)),l.op==="bcurveTo"){let c=n([l.data[0],l.data[1]]),d=n([l.data[2],l.data[3]]),m=n([l.data[4],l.data[5]]);a.push([s,c,d,m]),s=m}return{type:"polycurve",data:a}},I4=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},hv=(e,t,r=!1)=>{let o=ln(e.angle),n=a=>At(Ff(a,[e.x,e.y]),o,t),i=I4(e.points.map(a=>n(a)));return r?{type:"polygon",data:il(i.flat())}:{type:"polyline",data:i}},fv=(e,t,r=[0,0],o,n)=>{let i=d=>At([d[0]+r[0],d[1]+r[1]],ln(o),n);if(e.roundness===null)return{type:"polygon",data:il(e.points.map(d=>i(d)))};let a=uv(t),s=[],l=!1;for(let d of a)d.op==="move"?(l=!l,l&&s.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?l&&(s.push([d.data[0],d.data[1]]),s.push([d.data[2],d.data[3]]),s.push([d.data[4],d.data[5]])):d.op==="lineTo"&&l&&s.push([d.data[0],d.data[1]]);return{type:"polygon",data:S4(s,10,5).map(d=>i(d))}}});var Rp,ja,$c,bv,Uf,Zc=X(()=>{"use strict";f();mt();dt();_p();Pp();V();me();dl();Rp=e=>{if(e.type==="arrow")return!1;let t=!Ar(e.backgroundColor)||Ct(e)||sr(e)||H(e);return e.type==="line"?t&&Dr(e.points):e.type==="freedraw"?t&&Dr(e.points):t||So(e)},ja=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=Rp(r)?sl([e,t],o)||Kc([e,t],o,n):Kc([e,t],o,n);return!a&&i&&(a=sl([e,t],{type:"polygon",data:Dp(i).data})),a},$c=(e,t,r,o,n=0)=>{let[i,a,s,l]=ho(r,o);return i-=n,a-=n,s+=n,l+=n,Op([i,a],[e,t],[s,l])},bv=(e,t)=>!ja(e)&&!Uf(e.x,e.y,Np(e.element,t))&&$c(e.x,e.y,e.element,t),Uf=(e,t,r)=>!!r&&sl([e,t],r)});var jc,Ev,cn,Np,dl=X(()=>{"use strict";f();_p();ee();we();Zc();Wt();He();ye();Qo();jc=[{icon:cy,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:dy,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:my,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:py,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:uy,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:gy,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:ci,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:Jm,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:fy,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:by,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],Ev=e=>jc.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null,cn=(e,t)=>{switch(e.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return Dp(e);case"arrow":case"line":{let r=_e.get(e)?.[0]??_e.generateElementShape(e,null)[0],[,,,,o,n]=ae(e,t);return Rp(e)?fv(e,r,[e.x,e.y],e.angle,[o,n]):gv(r,[e.x,e.y],e.angle,[o,n])}case"ellipse":return pv(e);case"freedraw":{let[,,,,r,o]=ae(e,t);return hv(e,[r,o],Rp(e))}}},Np=(e,t)=>{let r=J(e,t);return r?e.type==="arrow"?cn({...r,...K.getBoundTextElementPosition(e,r,t)},t):cn(r,t):null}});var Nt,_r,Rr,Nr,Fp,Ji,ml,Gf,Wf=X(()=>{"use strict";f();al();mt();Nt=[1,0],_r=[0,1],Rr=[-1,0],Nr=[0,-1],Fp=(e,t)=>{let r=iv([e,t]);return r>=315||r<45?Nr:r>=45&&r<135?Nt:r>=135&&r<225?_r:Rr},Ji=e=>{let[t,r]=e,o=Math.abs(t),n=Math.abs(r);return t>n?Nt:t<=-n?Rr:r>o?_r:Nr},ml=(e,t)=>e[0]===t[0]&&e[1]===t[1],Gf=(e,t,r)=>{let n=Bp(t);if(e.type==="diamond"){if(r[0]<e.x)return Rr;if(r[1]<e.y)return Nr;if(r[0]>e.x+e.width)return Nt;if(r[1]>e.y+e.height)return _r;let c=ce(dn([e.x+e.width/2,e.y],n,2),n,e.angle),d=ce(dn([e.x+e.width,e.y+e.height/2],n,2),n,e.angle),m=ce(dn([e.x+e.width/2,e.y+e.height],n,2),n,e.angle),p=ce(dn([e.x,e.y+e.height/2],n,2),n,e.angle);return qa(r,c,d,n)?Fp(c,d):qa(r,d,m,n)?Fp(d,m):qa(r,m,p,n)?Fp(m,p):Fp(p,c)}let i=dn([t[0],t[1]],n,2),a=dn([t[2],t[1]],n,2),s=dn([t[0],t[3]],n,2),l=dn([t[2],t[3]],n,2);return qa(r,i,a,n)?Nr:qa(r,a,l,n)?Nt:qa(r,l,s,n)?_r:Rr}});var vv,Fn,at,C4,Qa,xv,A4,Tv,M4,k4,es,Gp,Jc,On,Sv,Xf,Iv,P4,xr,L4,qt,D4,_4,Cv,R4,gl,N4,Av,Mv,O4,Qc,yv,pl,kv,Wp,wv,Vp,qc,Pv,ed,Ja,F4,B4,z4,H4,Kf,$f,Zf,U4,G4,Vf,W4,Lv,V4,Y4,X4,K4,$4,Z4,Dv,zp,Hp,Qi,ea,Up,j4,_v,yr=X(()=>{"use strict";f();Ya();q2();Nf();Df();ov();dt();Pp();et();me();De();Wt();V();ye();He();dl();mt();Wf();vv=e=>!e[S.CTRL_OR_CMD],Fn=e=>e.isBindingEnabled,at=5,C4=(e,t)=>{let r=[];return t.forEach(o=>{let n=e.getNonDeletedElement(o);n!=null&&r.push(n)}),r},Qa=(e,t,r,o,n)=>{let i=new Set,a=new Set;xv(e,t,r,"start",i,a,o,n),xv(e,r,t,"end",i,a,o,n);let s=Array.from(a).filter(l=>!i.has(l));C4(n,s).forEach(l=>{F(l,{boundElements:l.boundElements?.filter(c=>c.type!=="arrow"||c.id!==e.id)})})},xv=(e,t,r,o,n,i,a,s)=>{if(t!=="keep"){if(t===null){let l=P4(e,o);l!=null&&i.add(l);return}Iv(e)?(r==null||(r==="keep"?!Sv(e,t,o):o==="start"||r.id!==t.id))&&(On(e,t,o,a),n.add(t.id)):(On(e,t,o,a),n.add(t.id))}},A4=(e,t,r)=>{let o=kv(e,t,r),n=t==="start"?e.startBinding?.elementId:e.endBinding?.elementId;if(n){let i=r.get(n);if(An(i)&&Pv(i,o,r))return i}return null},Tv=(e,t)=>["start","end"].map(r=>A4(e,r,t)),M4=(e,t,r,o,n)=>{let a=e.points.length-1,s=r.findIndex(m=>m===0)>-1,l=r.findIndex(m=>m===a)>-1,c=s?t?pl(e,"start",o,n):null:pl(e,"start",o,n),d=l?t?pl(e,"end",o,n):null:pl(e,"end",o,n);return[c,d]},k4=(e,t,r,o)=>{let[n,i]=Tv(e,t),a=n&&o?pl(e,"start",t,r):null,s=i&&o?pl(e,"end",t,r):null;return[a,s]},es=(e,t,r,o,n,i)=>{e.forEach(a=>{let[s,l]=i?.length?M4(a,n,i??[],t,r):k4(a,t,r,n);Qa(a,s,l,t,o)})},Gp=(e,t)=>e.length>50?[]:e.filter(ie).flatMap(r=>Tv(r,t)).filter(r=>r!==null).filter(r=>e.filter(o=>o.id===r?.id).length===0),Jc=(e,t,r,o,n)=>{t.startBoundElement!=null&&On(e,t.startBoundElement,"start",o);let i=xr(r,n,o,de(e)&&de(e));i!==null&&(Sv(e,i,"end")||On(e,i,"end",o))},On=(e,t,r,o)=>{if(!ne(e))return;let n={elementId:t.id,...L4(e,t,r,o),...de(e)?Qc(e,t,r,o):{fixedPoint:null}};F(e,{[r==="start"?"startBinding":"endBinding"]:n}),Z(t.boundElements||[]).has(e.id)||F(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Sv=(e,t,r)=>{let o=e[r==="start"?"endBinding":"startBinding"];return Xf(e,o?.elementId,t)},Xf=(e,t,r)=>t===r.id&&Iv(e),Iv=e=>e.points.length<3,P4=(e,t)=>{let r=t==="start"?"startBinding":"endBinding",o=e[r];return o==null?null:(F(e,{[r]:null}),o.elementId)},xr=(e,t,r,o)=>jf(t,i=>An(i,!1)&&Pv(i,e,r,o&&!Q(i))),L4=(e,t,r,o)=>{let n=r==="start"?-1:1,i=n===-1?0:e.points.length-1,a=i-n,s=K.getPointAtIndexGlobalCoordinates(e,i,o),l=K.getPointAtIndexGlobalCoordinates(e,a,o);return{focus:U4(t,l,s,o),gap:Math.max(1,Ja(t,s,o))}},qt=(e,t,r,o)=>{let{oldSize:n,simultaneouslyUpdated:i,changedElements:a}=o??{},s=_4(i);An(e)&&zp(t,e,l=>{if(!ie(l)||l.isDeleted||!D4(l,e))return;let c={startBinding:yv(e,l.startBinding,n),endBinding:yv(e,l.endBinding,n)};if(s.has(l.id)){F(l,c);return}let d=Hp(t,l,(p,u)=>{if(p&&An(p)&&(u==="startBinding"||u==="endBinding")&&e.id===l[u]?.elementId){let g=O4(l,u,c[u],p,t);if(g)return{index:u==="startBinding"?0:l.points.length-1,point:g}}return null}).filter(p=>p!==null);K.movePoints(l,d,r,{...e.id===l.startBinding?.elementId?{startBinding:c.startBinding}:{},...e.id===l.endBinding?.elementId?{endBinding:c.endBinding}:{}},{changedElements:a});let m=J(l,t);m&&!m.isDeleted&&mn(l,t,!1)})},D4=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,_4=e=>new Set((e||[]).map(t=>t.id)),Cv=(e,t,r,o,n,i)=>{let a=Ji(fi(t,e));return!r||!o?a:R4(i,r,n)?Gf(r,o,e):Ji(fi(e,Yp(r)))},R4=(e,t,r)=>{let o=Ja(t,e,r),n=ed(t,t.width,t.height);return o>n?null:o},gl=(e,t,r,o)=>{let n=r&&bi(r);if(r&&n){let i=[...Vf(r,[e[0],e[1]-2*r.height],[e[0],e[1]+2*r.height],at,o),...Vf(r,[e[0]-2*r.width,e[1]],[e[0]+2*r.width,e[1]],at,o)].map(d=>Ja(r,d,o)>Math.min(r.width,r.height)/2?[-1*d[0],-1*d[1]]:d),a=Gf(r,n,e),s=ml(a,Rr)||ml(a,Nt),l=Ja(r,e,o),c=s?l<r.width*-.1:l<r.height*-.1;return i.sort((d,m)=>ul(d,e)-ul(m,e)),c?N4(t,r,n):i.filter(d=>s?Math.abs(e[1]-d[1])<.1:Math.abs(e[0]-d[0])<.1)[0]??e}return e},N4=(e,t,r)=>{let o=Bp(r),n=Ji(fi(e,o));switch(!0){case ml(n,Nr):return ce([(r[0]+r[2])/2+.1,r[1]],o,t.angle);case ml(n,Nt):return ce([r[2],(r[1]+r[3])/2+.1],o,t.angle);case ml(n,_r):return ce([(r[0]+r[2])/2-.1,r[3]],o,t.angle);default:return ce([r[0],(r[1]+r[3])/2-.1],o,t.angle)}},Av=(e,t)=>{let r=Yp(e),o=ce(t,r,-e.angle);return o[0]<e.x&&o[1]<e.y?o[1]-e.y>-at?ce([e.x-at,e.y],r,e.angle):ce([e.x,e.y-at],r,e.angle):o[0]<e.x&&o[1]>e.y+e.height?o[0]-e.x>-at?ce([e.x,e.y+e.height+at],r,e.angle):ce([e.x-at,e.y+e.height],r,e.angle):o[0]>e.x+e.width&&o[1]>e.y+e.height?o[0]-e.x<e.width+at?ce([e.x+e.width,e.y+e.height+at],r,e.angle):ce([e.x+e.width+at,e.y+e.height],r,e.angle):o[0]>e.x+e.width&&o[1]<e.y?o[0]-e.x<e.width+at?ce([e.x+e.width,e.y-at],r,e.angle):ce([e.x+e.width+at,e.y],r,e.angle):t},Mv=(e,t,r=.05)=>{let{x:o,y:n,width:i,height:a,angle:s}=e,l=[o+i/2-.1,n+a/2-.1],c=ce(t,l,-s),d=Yf(r*a,5,80),m=Yf(r*i,5,80);return c[0]<=o+i/2&&c[1]>l[1]-d&&c[1]<l[1]+d?ce([o-at,l[1]],l,s):c[1]<=n+a/2&&c[0]>l[0]-m&&c[0]<l[0]+m?ce([l[0],n-at],l,s):c[0]>=o+i/2&&c[1]>l[1]-d&&c[1]<l[1]+d?ce([o+i+at,l[1]],l,s):c[1]>=n+a/2&&c[0]>l[0]-m&&c[0]<l[0]+m?ce([l[0],n+a+at],l,s):t},O4=(e,t,r,o,n)=>{if(r==null||r.elementId!==o.id&&e.points.length>2)return null;let i=t==="startBinding"?-1:1,a=i===-1?0:e.points.length-1;if(de(e)){let m=r.fixedPoint??Qc(e,o,t==="startBinding"?"start":"end",n).fixedPoint,p=[o.x+o.width/2,o.y+o.height/2],u=[o.x+m[0]*o.width,o.y+m[1]*o.height],g=ce(u,p,o.angle);return K.pointFromAbsoluteCoords(e,g,n)}let s=a-i,l=K.getPointAtIndexGlobalCoordinates(e,s,n),c=G4(o,r.focus,l,n),d;if(r.gap===0)d=c;else{let m=Vf(o,l,c,r.gap,n);m.length===0?d=c:d=m[0]}return K.pointFromAbsoluteCoords(e,d,n)},Qc=(e,t,r,o)=>{let n=[t.x,t.y,t.x+t.width,t.y+t.height],i=r==="start"?0:e.points.length-1,a=K.getPointAtIndexGlobalCoordinates(e,i,o),s=K.getPointAtIndexGlobalCoordinates(e,i,o),l=gl(a,s,t,o),c=[n[0]+(n[2]-n[0])/2,n[1]+(n[3]-n[1])/2],d=ce(l,c,-t.angle);return{fixedPoint:[(d[0]-t.x)/t.width,(d[1]-t.y)/t.height]}},yv=(e,t,r)=>{if(t==null||r==null)return t;let{width:o,height:n}=r,{width:i,height:a}=e,s=Math.max(1,Math.min(ed(e,o,n),t.gap*(o<n?o/i:n/a)));return{...t,gap:s}},pl=(e,t,r,o)=>xr(kv(e,t,r),o,r),kv=(e,t,r)=>{let o=t==="start"?0:-1;return ar(K.getPointAtIndexGlobalCoordinates(e,o,r))},Wp=(e,t,r,o)=>{let n=new Set,i=new Set,a=o==="duplicatesServeAsOld",s=new Map([...r].map(([l,c])=>[c,l]));t.forEach(l=>{let{boundElements:c}=l;if(c!=null&&c.length>0&&(c.forEach(d=>{a&&!r.has(d.id)&&n.add(d.id)}),i.add(r.get(l.id))),Kr(l)){if(l.startBinding!=null){let{elementId:d}=l.startBinding;a&&!r.has(d)&&i.add(d)}if(l.endBinding!=null){let{elementId:d}=l.endBinding;a&&!r.has(d)&&i.add(d)}(l.startBinding!=null||l.endBinding!=null)&&n.add(r.get(l.id))}}),e.filter(({id:l})=>n.has(l)).forEach(l=>{let{startBinding:c,endBinding:d}=l;F(l,{startBinding:wv(c,r),endBinding:wv(d,r)})}),e.filter(({id:l})=>i.has(l)).forEach(l=>{let c=s.get(l.id),{boundElements:d}=e.find(({id:m})=>m===c);d!=null&&d.length>0&&F(l,{boundElements:d.map(m=>r.has(m.id)?{id:r.get(m.id),type:m.type}:m)})})},wv=(e,t)=>e==null?null:{...e,elementId:t.get(e.elementId)??e.elementId},Vp=(e,t)=>{let r=Z(e);for(let o of t)Qi.unbindAffected(r,o,F),ea.unbindAffected(r,o,F)},qc=(e,t,r=[])=>{if(!e)return null;let o=e.filter(n=>!t.has(n.id));return o.push(...r.map(n=>({id:n.id,type:n.type}))),o},Pv=(e,{x:t,y:r},o,n)=>{let i=ed(e,e.width,e.height),a=cn(e,o);return Kc([t,r],a,i)||n===!0&&ta([t,r],bi(e))},ed=(e,t,r)=>{let n=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,r);return Math.max(16,Math.min(.25*n,32))},Ja=(e,t,r)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return F4(e,t,r);case"diamond":return B4(e,t,r);case"ellipse":return z4(e,t,r)}},F4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r);return Math.max(qi(o,kp(0,1,-i)),qi(o,kp(1,0,-n)))},B4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r),a=kp(i,n,-i*n);return qi(o,a)},z4=(e,t,r)=>{let[o,n]=H4(e,t,r);return-K2(n)*qi(o,n)},H4=(e,t,r)=>{let[,o,n,i]=Kf(e,t,r),[a,s]=Ka(o),l=.707,c=.707,d=n,m=i;[0,1,2,3].forEach(g=>{let h=d*l,x=m*c,v=(d*d-m*m)*l**3/d,y=(m*m-d*d)*c**3/m,w=h-v,C=x-y,M=a-v,I=s-y,P=Math.hypot(C,w),A=Math.hypot(I,M);l=Math.min(1,Math.max(0,(M*P/A+v)/d)),c=Math.min(1,Math.max(0,(I*P/A+y)/m));let N=Math.hypot(c,l);l/=N,c/=N});let p=Er(d*l,m*c),u=X2(o,p);return[o,u]},Kf=(e,t,r)=>{let o=Xa(t),[n,i,a,s]=ae(e,r),l=Zf(n,i,a,s),c=Of(l,e.angle),d=sn(c,o),m=Af(d,Rf(l)),p=Z2(m),u=H2(e.x,e.y),g=Af(d,u),h=(a-n)/2,x=(s-i)/2;return[g,p,h,x]},$f=(e,t)=>{let[r,o,n,i]=ae(e,t),a=Zf(r,o,n,i),s=Of(a,e.angle),l=rl(ev(Rf(a)));return rv(s,l)},Zf=(e,t,r,o)=>Er((e+r)/2,(t+o)/2),U4=(e,t,r,o)=>{let n=$f(e,o),i=sn(n,Xa(t)),a=sn(n,Xa(r)),s=ol(i,a),l=e.height/e.width,c=e.width/2,d=e.height/2,m=s[2],p=s[3],u=s[1],g=Math.abs(p),h=Math.abs(m),x;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":x=u/(c*(h+l*g));break;case"diamond":x=g<h?u/(h*c):u/(g*d);break;case"ellipse":x=u/(c*Math.sqrt(m**2+l**2*p**2));break}return x||0},G4=(e,t,r,o)=>{if(t===0){let[l,c,d,m]=ae(e,o),p=Zf(l,c,d,m);return Ka(p)}let n=$f(e,o),i=sn(n,Xa(r)),a=rl(n),s;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":s=Z4(e,t,i);break;case"ellipse":s=$4(e,t,i);break}return Ka(sn(a,s))},Vf=(e,t,r,o=0,n)=>{let i=$f(e,n),a=sn(i,Xa(t)),s=sn(i,Xa(r)),l=ol(a,s),c=rl(i);return W4(e,l,a,o).map(m=>Ka(sn(c,m)))},W4=(e,t,r,o=0)=>{let n;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":let a=Lv(e);n=a.flatMap((s,l)=>{let c=[s,a[(l+1)%4]];return V4(t,Y4(c,o))}).concat(a.flatMap(s=>K4(s,o,t)));break;case"ellipse":n=X4(e,o,t);break}if(n.length<2)return[];let i=n.sort((a,s)=>_f(a,r)-_f(s,r));return[i[0],i[i.length-1]]},Lv=(e,t=1)=>{let r=t*e.width/2,o=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[Er(r,o),Er(r,-o),Er(-r,-o),Er(-r,o)];case"diamond":return[Er(0,o),Er(r,0),Er(0,-o),Er(-r,0)]}},V4=(e,t)=>{let[r,o]=t,n=qi(r,e),i=qi(o,e);return n*i>=0?[]:[j2(e,ol(r,o))]},Y4=(e,t)=>{let[r,o]=e,n=tv(J2(r,o),t);return[sn(n,r),sn(n,o)]},X4=(e,t,r)=>{let o=e.width/2+t,n=e.height/2+t,i=r[2],a=r[3],s=r[1],l=o*o*i*i+n*n*a*a,c=l-s*s;if(l===0||c<=0)return[];let d=Math.sqrt(c),m=-o*o*i*s,p=-n*n*a*s;return[Er((m+o*n*a*d)/l,(p-o*n*i*d)/l),Er((m-o*n*a*d)/l,(p+o*n*i*d)/l)]},K4=(e,t,r)=>{if(t===0)return qi(r,e)===0?[e]:[];let o=r[2],n=r[3],i=r[1],[a,s]=Ka(e),l=t,c=o*o+n*n,d=l*l*c-(o*a+n*s+i)**2;if(c===0||d<=0)return[];let m=Math.sqrt(d),p=a*n*n-s*o*n-o*i,u=s*o*o-a*o*n-n*i;return[Er((p+n*m)/c,(u-o*m)/c),Er((p-n*m)/c,(u+o*m)/c)]},$4=(e,t,r)=>{let o=Math.abs(t),n=e.width*o/2,i=e.height*o/2,a=Math.sign(t),[s,l]=Ka(r),c=l===0?1e-4:l,d=s**2*i**2+c**2*n**2,m=(-s*i**2+a*c*Math.sqrt(Math.max(0,d-n**2*i**2)))/d,p=(-m*s-1)/c;p===0&&(p=(Object.is(p,-0)?-1:1)*.01);let u=-(n**2*m)/(p**2*i**2+m**2*n**2);return Er(u,(-m*u-1)/p)},Z4=(e,t,r)=>{let o=Math.abs(t),n=Math.sign(t),i=Lv(e,o),a=0,s=null;return i.forEach(l=>{let c=n*ol(r,l)[1];c>a&&(a=c,s=l)}),s},Dv=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),zp=(e,t,r)=>{An(t)&&(t.boundElements?.slice()??[]).forEach(({id:n})=>{r(e.get(n),"boundElements",n)})},Hp=(e,t,r)=>{let o=[];if(t.frameId){let n=t.frameId;o.push(r(e.get(n),"frameId",n))}if(ze(t)){let n=t.containerId;o.push(r(e.get(n),"containerId",n))}if(ne(t)){if(t.startBinding){let n=t.startBinding.elementId;o.push(r(e.get(n),"startBinding",n))}if(t.endBinding){let n=t.endBinding.elementId;o.push(r(e.get(n),"endBinding",n))}}return o},Qi=class{static unbindAffected(t,r,o){r&&Hp(t,r,n=>{!n||n.isDeleted||zp(t,n,(i,a,s)=>{s===r.id&&o(n,{boundElements:qc(n.boundElements,new Set([s]))})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||Hp(t,r,(n,i)=>{if(!n||n.isDeleted){o(r,{[i]:null});return}i!=="frameId"&&(n.boundElements?.find(a=>a.id===r.id)||(ne(r)&&o(n,{boundElements:qc(n.boundElements,new Set,new Array(r))}),H(r)&&(n.boundElements?.find(a=>a.type==="text")?o(r,{[i]:null}):o(n,{boundElements:qc(n.boundElements,new Set,new Array(r))}))))})}},ea=class{static unbindAffected(t,r,o){r&&zp(t,r,n=>{!n||n.isDeleted||Hp(t,n,(i,a,s)=>{s===r.id&&o(n,{[a]:null})})})}static rebindAffected=(t,r,o)=>{!r||r.isDeleted||zp(t,r,(n,i,a)=>{if(!n||n.isDeleted){o(r,{boundElements:qc(r.boundElements,new Set([a]))});return}H(n)&&((r.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===n.id?n.containerId!==r.id&&o(n,{containerId:r.id}):(n.containerId!==null&&o(n,{containerId:null}),o(r,{boundElements:qc(r.boundElements,new Set([n.id]))})))})}},Up=(e,t)=>{let[r,o]=e;return ce([t.x+t.width*r,t.y+t.height*o],Yp(t),t.angle)},j4=(e,t)=>{let r=e.startBinding&&t.get(e.startBinding.elementId),o=e.endBinding&&t.get(e.endBinding.elementId),n=r&&e.startBinding?Up(e.startBinding.fixedPoint,r):[e.x+e.points[0][0],e.y+e.points[0][1]],i=o&&e.endBinding?Up(e.endBinding.fixedPoint,o):[e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]];return[n,i]},_v=(e,t)=>{let[r,o]=j4(e,t);return[K.pointFromAbsoluteCoords(e,r,t),K.pointFromAbsoluteCoords(e,o,t)]}});var Tt,td,rd,Rv=X(()=>{"use strict";f();Y();yr();Wt();De();He();me();ko();Gt();Re();V();Tt=class e{constructor(t,r){this.deleted=t;this.inserted=r}static create(t,r,o,n){let i=o&&n!=="inserted"?o(t):t,a=o&&n!=="deleted"?o(r):r;return new e(i,a)}static calculate(t,r,o,n){if(t===r)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",t,r))i[c]=t[c],a[c]=r[c];let[s,l]=n?n(i,a):[i,a];return e.create(s,l,o)}static empty(){return new e({},{})}static isEmpty(t){return!Object.keys(t.deleted).length&&!Object.keys(t.inserted).length}static mergeObjects(t,r,o){let n={...t};for(let i of Object.keys(o))delete n[i];return{...n,...r}}static mergeArrays(t,r,o,n){return Object.values(e.mergeObjects(In(t??[],n),In(r??[],n),In(o??[],n)))}static diffObjects(t,r,o,n){if(!(!t[o]&&!r[o])&&(typeof t[o]=="object"||typeof r[o]=="object")){let i=t[o]??{},a=r[o]??{},s=e.getLeftDifferences(i,a).reduce((c,d)=>(c[d]=n(i[d]),c),{}),l=e.getRightDifferences(i,a).reduce((c,d)=>(c[d]=n(a[d]),c),{});Object.keys(s).length||Object.keys(l).length?(Reflect.set(t,o,s),Reflect.set(r,o,l)):(Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o))}}static diffArrays(t,r,o,n){if(!(!t[o]&&!r[o])&&(Array.isArray(t[o])||Array.isArray(r[o]))){let i=Array.isArray(t[o])?t[o]:[],a=Array.isArray(r[o])?r[o]:[],s=In(e.getLeftDifferences(In(i,n),In(a,n))),l=In(e.getRightDifferences(In(i,n),In(a,n)));if(Object.keys(s).length||Object.keys(l).length){let c=i.filter(m=>s[n?n(m):String(m)]),d=a.filter(m=>l[n?n(m):String(m)]);Reflect.set(t,o,c),Reflect.set(r,o,d)}else Reflect.deleteProperty(t,o),Reflect.deleteProperty(r,o)}}static isLeftDifferent(t,r,o=!1){return!!this.distinctKeysIterator("left",t,r,o).next().value}static isRightDifferent(t,r,o=!1){return!!this.distinctKeysIterator("right",t,r,o).next().value}static getLeftDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("left",t,r,o))}static getRightDifferences(t,r,o=!1){return Array.from(this.distinctKeysIterator("right",t,r,o))}static*distinctKeysIterator(t,r,o,n=!1){if(r===o)return;let i=[];t==="left"?i=Object.keys(r):t==="right"?i=Object.keys(o):t==="full"?i=Array.from(new Set([...Object.keys(r),...Object.keys(o)])):$o(t,`Unknown distinctKeysIterator's join param "${t}"`,!0);for(let a of i){let s=r[a],l=o[a];if(s!==l){if(!n&&typeof s=="object"&&typeof l=="object"&&s!==null&&l!==null&&it(s,l))continue;yield a}}}},td=class e{constructor(t){this.delta=t}static calculate(t,r){let o=Tt.calculate(t,r,void 0,e.postProcess);return new e(o)}static empty(){return new e(Tt.create({},{}))}inverse(){let t=Tt.create(this.delta.inserted,this.delta.deleted);return new e(t)}applyTo(t,r){try{let{selectedElementIds:o={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:s,editingLinearElementId:l,...c}=this.delta.inserted,d=Tt.mergeObjects(t.selectedElementIds,i,o),m=Tt.mergeObjects(t.selectedGroupIds,a,n),p=s&&r.has(s)?new K(r.get(s)):null,u=l&&r.has(l)?new K(r.get(l)):null,g={...t,...c,selectedElementIds:d,selectedGroupIds:m,selectedLinearElement:typeof s<"u"?p:t.selectedLinearElement,editingLinearElement:typeof l<"u"?u:t.editingLinearElement},h=this.filterInvisibleChanges(t,g,r);return[g,h]}catch(o){if(console.error("Couldn't apply appstate change",o),T.DEV||T.MODE===Kt.TEST)throw o;return[t,!1]}}isEmpty(){return Tt.isEmpty(this.delta)}static postProcess(t,r){try{Tt.diffObjects(t,r,"selectedElementIds",o=>!0),Tt.diffObjects(t,r,"selectedGroupIds",o=>o??!1)}catch(o){if(console.error("Couldn't postprocess appstate change deltas."),T.DEV||T.MODE===Kt.TEST)throw o}finally{return[t,r]}}filterInvisibleChanges(t,r,o){let n=od(t),i=od(r),a=Tt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),s=Tt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!s)return!1;let l={value:a};if(s){let c=Tt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),d=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(d=j0(o));for(let m of c)switch(m){case"selectedElementIds":r[m]=e.filterSelectedElements(r[m],o,l);break;case"selectedGroupIds":r[m]=e.filterSelectedGroups(r[m],d,l);break;case"editingGroupId":let p=r[m];p?d.has(p)?l.value=!0:r[m]=null:l.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(m),g=r[u];if(!g)l.value=!0;else{let h=o.get(g.elementId);h&&!h.isDeleted?l.value=!0:r[u]=null}break;default:$o(m,`Unknown ObservedElementsAppState's key "${m}"`,!0)}}return l.value}static convertToAppStateKey(t){switch(t){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(t,r,o){let n=Object.keys(t);if(!n.length)return o.value=!0,t;let i={...t};for(let a of n){let s=r.get(a);s&&!s.isDeleted?o.value=!0:delete i[a]}return i}static filterSelectedGroups(t,r,o){if(!Object.keys(t).length)return o.value=!0,t;let i={...t};for(let a of Object.keys(i))r.has(a)?o.value=!0:delete i[a];return i}static stripElementsProps(t){let{editingGroupId:r,selectedGroupIds:o,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,...s}=t;return s}static stripStandaloneProps(t){let{name:r,viewBackgroundColor:o,...n}=t;return n}},rd=class e{constructor(t,r,o){this.added=t;this.removed=r;this.updated=o}static create(t,r,o,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,s=new Map,l=new Map,c=[...t,...r,...o];for(let[d,m]of c)this.satisfiesAddition(m)?a.set(d,m):this.satisfiesRemoval(m)?s.set(d,m):l.set(d,m);i=new e(a,s,l)}else i=new e(t,r,o);return(T.DEV||T.MODE===Kt.TEST)&&(e.validate(i,"added",this.satisfiesAddition),e.validate(i,"removed",this.satisfiesRemoval),e.validate(i,"updated",this.satisfiesUpdate)),i}static satisfiesAddition=({deleted:t,inserted:r})=>t.isDeleted===!0&&!r.isDeleted;static satisfiesRemoval=({deleted:t,inserted:r})=>!t.isDeleted&&r.isDeleted===!0;static satisfiesUpdate=({deleted:t,inserted:r})=>!!t.isDeleted==!!r.isDeleted;static validate(t,r,o){for(let[n,i]of t[r].entries())if(!o(i))throw console.error(`Broken invariant for "${r}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(t,r){if(t===r)return e.empty();let o=new Map,n=new Map,i=new Map;for(let a of t.values())if(!r.get(a.id)){let l={...a,isDeleted:!1},c={isDeleted:!0},d=Tt.create(l,c,e.stripIrrelevantProps);n.set(a.id,d)}for(let a of r.values()){let s=t.get(a.id);if(!s){let l={isDeleted:!0},c={...a,isDeleted:!1},d=Tt.create(l,c,e.stripIrrelevantProps);o.set(a.id,d);continue}if(s.versionNonce!==a.versionNonce){let l=Tt.calculate(s,a,e.stripIrrelevantProps,e.postProcess);if(typeof s.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&s.isDeleted!==a.isDeleted){s.isDeleted&&!a.isDeleted?o.set(a.id,l):n.set(a.id,l);continue}Tt.isEmpty(l)||i.set(a.id,l)}}return e.create(o,n,i)}static empty(){return e.create(new Map,new Map,new Map)}inverse(){let t=i=>{let a=new Map;for(let[s,l]of i.entries())a.set(s,Tt.create(l.inserted,l.deleted));return a},r=t(this.added),o=t(this.removed),n=t(this.updated);return e.create(o,r,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(t){let r=s=>l=>{let c={};for(let d of Object.keys(l))switch(d){case"boundElements":c[d]=l[d];break;default:c[d]=s[d]}return c},o=s=>{let l=new Map;for(let[c,d]of s.entries()){let m=t.get(c);if(m){let p=Tt.create(d.deleted,d.inserted,r(m),"inserted");l.set(c,p)}else l.set(c,d)}return l},n=o(this.added),i=o(this.removed),a=o(this.updated);return e.create(n,i,a,{shouldRedistribute:!0})}applyTo(t,r,o){let n=Mr(new Map(t)),i,a={containsVisibleDifference:!1,containsZindexDifference:!1};try{let s=e.createApplier(n,r,a),l=s(this.added),c=s(this.removed),d=s(this.updated),m=this.resolveConflicts(t,n);i=new Map([...l,...c,...d,...m])}catch(s){if(console.error("Couldn't apply elements change",s),T.DEV||T.MODE===Kt.TEST)throw s;return[t,!0]}try{e.redrawTextBoundingBoxes(n,i),e.redrawBoundArrows(n,i,o),n=e.reorderElements(n,i,a)}catch(s){if(console.error("Couldn't mutate elements after applying elements change",s),T.DEV||T.MODE===Kt.TEST)throw s}finally{return[n,a.containsVisibleDifference]}}static createApplier=(t,r,o)=>{let n=e.createGetter(t,r,o);return i=>Array.from(i.entries()).reduce((a,[s,l])=>{let c=n(s,l.inserted);if(c){let d=e.applyDelta(c,l,o);t.set(d.id,d),a.set(d.id,d)}return a},new Map)};static createGetter=(t,r,o)=>(n,i)=>{let a=t.get(n);return a||(a=r.get(n),a&&(o.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(o.containsVisibleDifference=!0))),a};static applyDelta(t,r,o={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=r.inserted;if(r.deleted.boundElements?.length||r.inserted.boundElements?.length){let a=Tt.mergeArrays(t.boundElements,r.inserted.boundElements,r.deleted.boundElements,s=>s.id);Object.assign(i,{boundElements:a})}if(!o.containsVisibleDifference){let{index:a,...s}=i,l=e.checkForVisibleDifference(t,s);o.containsVisibleDifference=l}return o.containsZindexDifference||(o.containsZindexDifference=r.deleted.index!==r.inserted.index),pe(t,i)}static checkForVisibleDifference(t,r){return t.isDeleted&&r.isDeleted!==!1?!1:t.isDeleted&&r.isDeleted===!1||t.isDeleted===!1&&r.isDeleted?!0:Tt.isRightDifferent(t,r)}resolveConflicts(t,r){let o=new Map,n=(c,d)=>{let m=r.get(c.id);if(!m)return;let p;t.get(c.id)===m?p=pe(m,d):p=F(m,d),o.set(p.id,p),r.set(p.id,p)};for(let[c]of this.removed)e.unbindAffected(t,r,c,n);for(let[c]of this.added)e.rebindAffected(t,r,c,n);for(let[c]of Array.from(this.updated).filter(([d,m])=>Object.keys({...m.deleted,...m.inserted}).find(p=>Dv.has(p)))){let d=r.get(c);!d||d.isDeleted||e.rebindAffected(t,r,c,n)}let i=new Map(Array.from(t).filter(([c])=>o.has(c))),{added:a,removed:s,updated:l}=e.calculate(i,o);for(let[c,d]of a)this.added.set(c,d);for(let[c,d]of s)this.removed.set(c,d);for(let[c,d]of l)this.updated.set(c,d);return o}static unbindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Qi.unbindAffected(r,i(),n),Qi.unbindAffected(r,a(),n),ea.unbindAffected(r,i(),n),ea.unbindAffected(r,a(),n)}static rebindAffected(t,r,o,n){let i=()=>t.get(o),a=()=>r.get(o);Qi.unbindAffected(r,i(),n),Qi.rebindAffected(r,a(),n),ea.unbindAffected(r,i(),(s,l)=>{H(s)&&n(s,l)}),ea.rebindAffected(r,a(),n)}static redrawTextBoundingBoxes(t,r){let o=new Map;for(let n of r.values()){if(ze(n)){let{containerId:i}=n,a=i?t.get(i):void 0;a&&o.set(a.id,{container:a,boundText:n})}if(Ct(n)){let i=pn(n),a=i?t.get(i):void 0;a&&o.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of o.values())n.isDeleted||i.isDeleted||ft(i,n,t,!1)}static redrawBoundArrows(t,r,o){for(let n of r.values())!n.isDeleted&&An(n)&&qt(n,t,o,{changedElements:r})}static reorderElements(t,r,o){if(!o.containsZindexDifference)return t;let n=Array.from(t.values()),i=Xp([...n]),a=Tt.getRightDifferences(n,i,!0).reduce((s,l)=>{let c=n[Number(l)];return c&&r.has(c.id)&&s.set(c.id,c),s},new Map);return!o.containsVisibleDifference&&a.size&&(o.containsVisibleDifference=!0),Z(Jt(i,a))}static postProcess(t,r){try{Tt.diffArrays(t,r,"boundElements",o=>o.id)}catch(o){if(console.error("Couldn't postprocess elements change deltas."),T.DEV||T.MODE===Kt.TEST)throw o}finally{return[t,r]}}static stripIrrelevantProps(t){let{id:r,updated:o,version:n,versionNonce:i,seed:a,...s}=t;return s}}});var wr,nd=X(()=>{"use strict";f();wr=class{subscribers=[];on(...t){let r=t.flat().filter(o=>typeof o=="function");return this.subscribers.push(...r),()=>this.off(r)}once(...t){let r=t.flat().filter(n=>typeof n=="function");r.push(()=>o());let o=this.on(...r);return o}off(...t){let r=t.flat();this.subscribers=this.subscribers.filter(o=>!r.includes(o))}trigger(...t){for(let r of this.subscribers)r(...t);return this}clear(){this.subscribers=[]}}});var Nv,od,q4,_,qf,Kp,$p,Re=X(()=>{"use strict";f();Zr();Rv();Y();De();Nn();nd();V();Nv="__observedAppState",od=e=>{let t={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};return Reflect.defineProperty(t,Nv,{value:!0,enumerable:!1}),t},q4=e=>!!Reflect.get(e,Nv),_={CAPTURE:"capture",UPDATE:"update",NONE:"none"},qf=class{constructor(t,r){this.elementsChange=t;this.appStateChange=r}},Kp=class{onStoreIncrementEmitter=new wr;scheduledActions=new Set;_snapshot=$p.empty();get snapshot(){return this._snapshot}set snapshot(t){this._snapshot=t}shouldCaptureIncrement=()=>{this.scheduleAction(_.CAPTURE)};shouldUpdateSnapshot=()=>{this.scheduleAction(_.UPDATE)};scheduleAction=t=>{this.scheduledActions.add(t),this.satisfiesScheduledActionsInvariant()};commit=(t,r)=>{try{this.scheduledActions.has(_.CAPTURE)?this.captureIncrement(t,r):this.scheduledActions.has(_.UPDATE)&&this.updateSnapshot(t,r)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}};captureIncrement=(t,r)=>{let o=this.snapshot,n=this.snapshot.maybeClone(t,r);if(o!==n){let i=n.meta.didElementsChange?rd.calculate(o.elements,n.elements):rd.empty(),a=n.meta.didAppStateChange?td.calculate(o.appState,n.appState):td.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new qf(i,a)),this.snapshot=n}};updateSnapshot=(t,r)=>{let o=this.snapshot.maybeClone(t,r);this.snapshot!==o&&(this.snapshot=o)};filterUncomittedElements=(t,r)=>{for(let[o,n]of t.entries()){if(!r.get(o))continue;let a=this.snapshot.elements.get(o);a?a.version<n.version&&r.set(o,a):r.delete(o)}return r};clear=()=>{this.snapshot=$p.empty(),this.scheduledActions=new Set};satisfiesScheduledActionsInvariant=()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let t=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(t,this.scheduledActions.values()),T.DEV||T.MODE===Kt.TEST)throw new Error(t)}}},$p=class e{constructor(t,r,o={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=t;this.appState=r;this.meta=o}static empty(){return new e(new Map,od(lr()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(t,r){let o=this.maybeCreateElementsSnapshot(t),n=this.maybeCreateAppStateSnapshot(r),i=!1,a=!1;return this.elements!==o&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(o,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(t){if(!t)return this.appState;let r=q4(t)?t:od(t);return this.detectChangedAppState(r)?r:this.appState}detectChangedAppState(t){return!it(this.appState,t,{selectedElementIds:it,selectedGroupIds:it})}maybeCreateElementsSnapshot(t){return t?this.detectChangedElements(t)?this.createElementsSnapshot(t):this.elements:this.elements}detectChangedElements(t){if(this.elements===t)return!1;if(this.elements.size!==t.size)return!0;let r=Array.from(t.keys());for(let o=r.length-1;o>=0;o--){let n=this.elements.get(r[o]),i=t.get(r[o]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(t){let r=new Map;for(let[o,n]of this.elements.entries())t.get(o)?r.set(o,n):r.set(o,pe(n,{isDeleted:!0}));for(let[o,n]of t.entries()){let i=r.get(o);(!i||i&&i.versionNonce!==n.versionNonce)&&r.set(o,an(n))}return r}}});var Ei,J4,Q4,eM,Ov,tM,Fv,rM,oM,nM,Bv,Jf,zv,id,xi,Zp,KU,Qf,Hv,hl,ad=X(()=>{"use strict";f();$e();Y();V();Gs();Nn();He();me();Oa();Re();Ei=new Map,J4=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,Q4=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}\.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,eM=/^https:\/\/(?:www\.)?figma\.com/,Ov=/^https:\/\/gist\.github\.com\/([\w_-]+)\/([\w_-]+)/,tM=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist\.github\.com\/.*?)\.js["']/i,Fv=/(?:https?:\/\/)?(?:(?:w){3}\.)?(?:twitter|x)\.com\/[^/]+\/status\/(\d+)/,rM=/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:twitter|x)\.com\/[^"']*)/i,oM=/^https:\/\/(?:www\.)?val\.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,nM=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,Bv=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,Jf=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com"]),zv=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com"]),id=e=>`<html><body>${e}</body></html>`,xi=e=>{if(!e)return null;if(Ei.has(e))return Ei.get(e);let t=e,r=zv.has(Qf(e,zv)||""),o="generic",n={w:560,h:840},i=e.match(J4);if(i?.[2]){let c=i[3]?`&start=${i[3]}`:"",d=e.includes("shorts");switch(o="video",i[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${i[2]}&enablejsapi=1${c}`;break;default:e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${c}`;break}return n=d?{w:315,h:560}:{w:560,h:315},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}}let a=e.match(Q4);if(a?.[1]){let c=a?.[1],d=/^\d+$/.test(c)?void 0:new URIError("Invalid embed link format");return o="video",e=`https://player.vimeo.com/video/${c}?api=1`,n={w:560,h:315},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,error:d,sandbox:{allowSameOrigin:r}}}if(e.match(eM))return o="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,n={w:550,h:550},Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};let l=e.match(oM);if(l)return e=l[1]==="embed"?l[0]:l[0].replace("/v","/embed"),Ei.set(t,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}};if(Fv.test(e)){let c=e.match(Fv)[1],d=Ym(`https://twitter.com/x/status/${c}`),m={type:"document",srcdoc:p=>id(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${p}"><a href="${d}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480},sandbox:{allowSameOrigin:r}};return Ei.set(t,m),m}if(Ov.test(e)){let[,c,d]=e.match(Ov),m=Ym(`https://gist.github.com/${c}/${d}`),p={type:"document",srcdoc:()=>id(`
16
3
  <script src="${m}.js"><\/script>
17
4
  <style type="text/css">
18
5
  * { margin: 0px; }
19
6
  table, .gist { height: 100%; }
20
7
  .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
21
8
  </style>
22
- `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:r}};return Ln.set(e,p),p}return Ln.set(e,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}},gm=e=>{let t;ro(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let r=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=mt.Helvetica,n=Ye({fontSize:r,fontFamily:o});return zt({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:r,text:hi(t,n,e.width-20),textAlign:"center",verticalAlign:yt.MIDDLE,angle:e.angle??0})},hN=z({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,r,o)=>{let n=qe(t,{type:"embeddable"});return Wr(o.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:qe(t,{type:"embeddable"})},storeAction:D.NONE}}}),ig=(e,t)=>{try{let{hostname:r}=new URL(e),o=r.replace(/^www\./,"");if(t instanceof Set){if(ng.has(o))return o;let i=o.replace(/^([^.]+)/,"*");return ng.has(i)?i:null}let n=t.replace(/^www\./,"");if(o===n)return n}catch{}return null},v0=e=>{let t=e.match(RC);if(t&&t.length===2)return t[1];let r=e.match(_C);if(r&&r.length===2)return r[1];if(y0.test(e))return`https://giphy.com/embed/${y0.exec(e)[1]}`;let o=e.match(OC);return o&&o.length===2?o[1]:e},fl=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let r=t(e);if(typeof r=="boolean")return r}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let r of t)if(r instanceof RegExp){if(e.match(r))return!0}else if(ig(e,r))return!0;return!1}}return!!ig(e,ng)}});var tc,rc,fm,T0,S0=j(()=>{"use strict";f();Y();ga();be();ec();Xt();st();se();nr();Ft();Xo();U();Tn();tc=(e,t,r)=>{if(typeof r>"u")return e.draw(t);let o={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:r}};return e.draw(o)},rc=(e,t,r,o,n)=>{if(!o.enabled||!o.clip)return null;let i=Ht(e,n);if(i){let a=t.ownerDocument.createElementNS(He,"g");return a.setAttributeNS(He,"clip-path",`url(#${i.id})`),r.forEach(l=>a.appendChild(l)),a}return null},fm=(e,t,r,o,n,i,a,l)=>{let s={x:i,y:a},[c,d,m,p]=re(e,t),u=(m-c)/2-(e.x-c),h=(p-d)/2-(e.y-d);if(G(e)){let v=pt(e,t);if(we(v)){let[I,L,C,M]=re(v,t),_=X.getBoundTextElementPosition(v,e,t);u=(C-I)/2-(_.x-I),h=(M-L)/2-(_.y-L),i=i+_.x-e.x,a=a+_.y-e.y}}let E=180*e.angle/Math.PI,x=o;if(e.link){let v=o.ownerDocument.createElementNS(He,"a");v.setAttribute("href",pr(e.link)),x.appendChild(v),x=v}let w=(v,I)=>{Or()&&v.setAttribute("data-id",I.id),x.appendChild(v)},y=(Ht(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let v=Pe.generateElementShape(e,null),I=tc(r,v,qa);y!==1&&(I.setAttribute("stroke-opacity",`${y}`),I.setAttribute("fill-opacity",`${y}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`);let L=rc(e,x,[I],l.frameRendering,t);w(L||I,e);break}case"iframe":case"embeddable":{let v=Pe.generateElementShape(e,l),I=tc(r,v,qa),L=e.opacity/100;L!==1&&(I.setAttribute("stroke-opacity",`${L}`),I.setAttribute("fill-opacity",`${L}`)),I.setAttribute("stroke-linecap","round"),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`),w(I,e);let C=gm(e);fm(C,t,r,x,n,C.x+s.x-e.x,C.y+s.y-e.y,l);let M=tc(r,v,qa);for(M.setAttribute("stroke-linecap","round"),M.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`);M.firstChild;)M.removeChild(M.firstChild);let _=ko(Math.min(e.width,e.height),e),H=Pn(am(e.link||""));if(l.renderEmbeddables===!1||H?.type==="document"){let k=o.ownerDocument.createElementNS(He,"a");k.setAttribute("href",pr(e.link||"")),k.setAttribute("target","_blank"),k.setAttribute("rel","noopener noreferrer"),k.style.borderRadius=`${_}px`,M.appendChild(k)}else{let k=o.ownerDocument.createElementNS(He,"foreignObject");k.style.width=`${e.width}px`,k.style.height=`${e.height}px`,k.style.border="none";let N=k.ownerDocument.createElementNS(He,"div");N.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),N.style.width="100%",N.style.height="100%";let A=N.ownerDocument.createElement("iframe");A.src=H?.link??"",A.style.width="100%",A.style.height="100%",A.style.border="none",A.style.borderRadius=`${_}px`,A.style.top="0",A.style.left="0",A.allowFullscreen=!0,N.appendChild(A),k.appendChild(N),M.appendChild(k)}w(M,e);break}case"line":case"arrow":{let v=me(e,t),I=o.ownerDocument.createElementNS(He,"mask");if(v){I.setAttribute("id",`mask-${e.id}`);let _=o.ownerDocument.createElementNS(He,"rect");i=i||0,a=a||0,_.setAttribute("x","0"),_.setAttribute("y","0"),_.setAttribute("fill","#fff"),_.setAttribute("width",`${e.width+100+i}`),_.setAttribute("height",`${e.height+100+a}`),I.appendChild(_);let H=o.ownerDocument.createElementNS(He,"rect"),k=X.getBoundTextElementPosition(e,v,t),N=i+k.x-e.x,A=a+k.y-e.y;H.setAttribute("x",N.toString()),H.setAttribute("y",A.toString()),H.setAttribute("fill","#000"),H.setAttribute("width",`${v.width}`),H.setAttribute("height",`${v.height}`),H.setAttribute("opacity","1"),I.appendChild(H)}let L=o.ownerDocument.createElementNS(He,"g");v&&L.setAttribute("mask",`url(#mask-${e.id})`),L.setAttribute("stroke-linecap","round"),Pe.generateElementShape(e,l).forEach(_=>{let H=tc(r,_,qa);y!==1&&(H.setAttribute("stroke-opacity",`${y}`),H.setAttribute("fill-opacity",`${y}`)),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`),e.type==="line"&&dr(e.points)&&e.backgroundColor!=="transparent"&&H.setAttribute("fill-rule","evenodd"),L.appendChild(H)});let M=rc(e,x,[L,I],l.frameRendering,t);M?(w(M,e),x.appendChild(M)):(w(L,e),x.append(I));break}case"freedraw":{let v=Pe.generateElementShape(e,l),I=v?tc(r,v,qa):o.ownerDocument.createElementNS(He,"g");y!==1&&(I.setAttribute("stroke-opacity",`${y}`),I.setAttribute("fill-opacity",`${y}`)),I.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`),I.setAttribute("stroke","none");let L=o.ownerDocument.createElementNS(He,"path");L.setAttribute("fill",e.strokeColor),L.setAttribute("d",bm(e)),I.appendChild(L);let C=rc(e,x,[I],l.frameRendering,t);w(C||I,e);break}case"image":{let v=Math.round(e.width),I=Math.round(e.height),L=sr(e)&&n[e.fileId];if(L){let C=`image-${L.id}`,M=o.querySelector(`#${C}`);if(!M){M=o.ownerDocument.createElementNS(He,"symbol"),M.id=C;let N=o.ownerDocument.createElementNS(He,"image");N.setAttribute("width","100%"),N.setAttribute("height","100%"),N.setAttribute("href",L.dataURL),M.appendChild(N),x.prepend(M)}let _=o.ownerDocument.createElementNS(He,"use");if(_.setAttribute("href",`#${C}`),l.exportWithDarkMode&&L.mimeType!==te.svg&&_.setAttribute("filter",ag),_.setAttribute("width",`${v}`),_.setAttribute("height",`${I}`),_.setAttribute("opacity",`${y}`),e.scale[0]!==1||e.scale[1]!==1){let N=e.scale[0]!==1?-v:0,A=e.scale[1]!==1?-I:0;_.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${N} ${A})`)}let H=o.ownerDocument.createElementNS(He,"g");if(H.appendChild(_),H.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`),e.roundness){let N=o.ownerDocument.createElementNS(He,"clipPath");N.id=`image-clipPath-${e.id}`;let A=o.ownerDocument.createElementNS(He,"rect"),B=ko(Math.min(e.width,e.height),e);A.setAttribute("width",`${e.width}`),A.setAttribute("height",`${e.height}`),A.setAttribute("rx",`${B}`),A.setAttribute("ry",`${B}`),N.appendChild(A),w(N,e),H.setAttributeNS(He,"clip-path",`url(#${N.id})`)}let k=rc(e,x,[H],l.frameRendering,t);w(k||H,e)}break}case"frame":case"magicframe":{if(l.frameRendering.enabled&&l.frameRendering.outline){let v=document.createElementNS(He,"rect");v.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`),v.setAttribute("width",`${e.width}px`),v.setAttribute("height",`${e.height}px`),v.setAttribute("rx",je.radius.toString()),v.setAttribute("ry",je.radius.toString()),v.setAttribute("fill","none"),v.setAttribute("stroke",je.strokeColor),v.setAttribute("stroke-width",je.strokeWidth.toString()),w(v,e)}break}default:if(G(e)){let v=o.ownerDocument.createElementNS(He,"g");y!==1&&(v.setAttribute("stroke-opacity",`${y}`),v.setAttribute("fill-opacity",`${y}`)),v.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${E} ${u} ${h})`);let I=e.text.replace(/\r\n?/g,`
9
+ `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:r}};return Ei.set(e,p),p}return Ei.set(e,{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}),{link:e,intrinsicSize:n,type:o,sandbox:{allowSameOrigin:r}}},Zp=e=>{let t;Io(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let r=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),o=Le.Helvetica,n=Me({fontSize:r,fontFamily:o});return jt({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:o,fontSize:r,text:Lo(t,n,e.width-20),textAlign:"center",verticalAlign:kt.MIDDLE,angle:e.angle??0})},KU=G({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,r,o)=>{let n=nt(t,{type:"embeddable"});return po(o.canvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:nt(t,{type:"embeddable"})},storeAction:_.NONE}}}),Qf=(e,t)=>{try{let{hostname:r}=new URL(e),o=r.replace(/^www\./,"");if(t instanceof Set){if(Jf.has(o))return o;let i=o.replace(/^([^.]+)/,"*");return Jf.has(i)?i:null}let n=t.replace(/^www\./,"");if(o===n)return n}catch{}return null},Hv=e=>{let t=e.match(rM);if(t&&t.length===2)return t[1];let r=e.match(tM);if(r&&r.length===2)return r[1];if(Bv.test(e))return`https://giphy.com/embed/${Bv.exec(e)[1]}`;let o=e.match(nM);return o&&o.length===2?o[1]:e},hl=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let r=t(e);if(typeof r=="boolean")return r}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let r of t)if(r instanceof RegExp){if(e.match(r))return!0}else if(Qf(e,r))return!0;return!1}}return!!Qf(e,Jf)}});var sd,ld,jp,Uv,Gv=X(()=>{"use strict";f();Y();Oa();we();ad();Wt();He();me();vr();mt();Qo();V();li();on();sd=(e,t,r)=>{if(typeof r>"u")return e.draw(t);let o={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:r}};return e.draw(o)},ld=(e,t,r,o,n)=>{if(!o.enabled||!o.clip)return null;let i=Qt(e,n);if(i){let a=t.ownerDocument.createElementNS(Ke,"g");return a.setAttributeNS(Ke,"clip-path",`url(#${i.id})`),r.forEach(s=>a.appendChild(s)),a}return null},jp=(e,t,r,o,n,i,a,s)=>{let l={x:i,y:a},[c,d,m,p]=ae(e,t),u=(m-c)/2-(e.x-c),g=(p-d)/2-(e.y-d);if(H(e)){let w=Et(e,t);if(ne(w)){let[C,M,I,P]=ae(w,t),A=K.getBoundTextElementPosition(w,e,t);u=(I-C)/2-(A.x-C),g=(P-M)/2-(A.y-M),i=i+A.x-e.x,a=a+A.y-e.y}}let h=180*e.angle/Math.PI,x=o;if(e.link){let w=o.ownerDocument.createElementNS(Ke,"a");w.setAttribute("href",Pr(e.link)),x.appendChild(w),x=w}let v=(w,C)=>{Yr()&&w.setAttribute("data-id",C.id),x.appendChild(w)},y=(Qt(e,t)?.opacity??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{let w=_e.generateElementShape(e,null),C=sd(r,w,Bs);y!==1&&(C.setAttribute("stroke-opacity",`${y}`),C.setAttribute("fill-opacity",`${y}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);let M=ld(e,x,[C],s.frameRendering,t);v(M||C,e);break}case"iframe":case"embeddable":{let w=_e.generateElementShape(e,s),C=sd(r,w,Bs),M=e.opacity/100;M!==1&&(C.setAttribute("stroke-opacity",`${M}`),C.setAttribute("fill-opacity",`${M}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),v(C,e);let I=Zp(e);jp(I,t,r,x,n,I.x+l.x-e.x,I.y+l.y-e.y,s);let P=sd(r,w,Bs);for(P.setAttribute("stroke-linecap","round"),P.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);P.firstChild;)P.removeChild(P.firstChild);let A=fo(Math.min(e.width,e.height),e),N=xi(Km(e.link||""));if(s.renderEmbeddables===!1||N?.type==="document"){let k=o.ownerDocument.createElementNS(Ke,"a");k.setAttribute("href",Pr(e.link||"")),k.setAttribute("target","_blank"),k.setAttribute("rel","noopener noreferrer"),k.style.borderRadius=`${A}px`,P.appendChild(k)}else{let k=o.ownerDocument.createElementNS(Ke,"foreignObject");k.style.width=`${e.width}px`,k.style.height=`${e.height}px`,k.style.border="none";let D=k.ownerDocument.createElementNS(Ke,"div");D.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),D.style.width="100%",D.style.height="100%";let z=D.ownerDocument.createElement("iframe");z.src=N?.link??"",z.style.width="100%",z.style.height="100%",z.style.border="none",z.style.borderRadius=`${A}px`,z.style.top="0",z.style.left="0",z.allowFullscreen=!0,D.appendChild(z),k.appendChild(D),P.appendChild(k)}v(P,e);break}case"line":case"arrow":{let w=J(e,t),C=o.ownerDocument.createElementNS(Ke,"mask");if(w){C.setAttribute("id",`mask-${e.id}`);let A=o.ownerDocument.createElementNS(Ke,"rect");i=i||0,a=a||0,A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("fill","#fff"),A.setAttribute("width",`${e.width+100+i}`),A.setAttribute("height",`${e.height+100+a}`),C.appendChild(A);let N=o.ownerDocument.createElementNS(Ke,"rect"),k=K.getBoundTextElementPosition(e,w,t),D=i+k.x-e.x,z=a+k.y-e.y;N.setAttribute("x",D.toString()),N.setAttribute("y",z.toString()),N.setAttribute("fill","#000"),N.setAttribute("width",`${w.width}`),N.setAttribute("height",`${w.height}`),N.setAttribute("opacity","1"),C.appendChild(N)}let M=o.ownerDocument.createElementNS(Ke,"g");w&&M.setAttribute("mask",`url(#mask-${e.id})`),M.setAttribute("stroke-linecap","round"),_e.generateElementShape(e,s).forEach(A=>{let N=sd(r,A,Bs);y!==1&&(N.setAttribute("stroke-opacity",`${y}`),N.setAttribute("fill-opacity",`${y}`)),N.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),e.type==="line"&&Dr(e.points)&&e.backgroundColor!=="transparent"&&N.setAttribute("fill-rule","evenodd"),M.appendChild(N)});let P=ld(e,x,[M,C],s.frameRendering,t);P?(v(P,e),x.appendChild(P)):(v(M,e),x.append(C));break}case"freedraw":{let w=_e.generateElementShape(e,s),C=w?sd(r,w,Bs):o.ownerDocument.createElementNS(Ke,"g");y!==1&&(C.setAttribute("stroke-opacity",`${y}`),C.setAttribute("fill-opacity",`${y}`)),C.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),C.setAttribute("stroke","none");let M=o.ownerDocument.createElementNS(Ke,"path");M.setAttribute("fill",e.strokeColor),M.setAttribute("d",qp(e)),C.appendChild(M);let I=ld(e,x,[C],s.frameRendering,t);v(I||C,e);break}case"image":{let w=Math.round(e.width),C=Math.round(e.height),M=kr(e)&&n[e.fileId];if(M){let I=`image-${M.id}`,P=o.querySelector(`#${I}`);if(!P){P=o.ownerDocument.createElementNS(Ke,"symbol"),P.id=I;let D=o.ownerDocument.createElementNS(Ke,"image");D.setAttribute("width","100%"),D.setAttribute("height","100%"),D.setAttribute("href",M.dataURL),P.appendChild(D),x.prepend(P)}let A=o.ownerDocument.createElementNS(Ke,"use");if(A.setAttribute("href",`#${I}`),s.exportWithDarkMode&&M.mimeType!==se.svg&&A.setAttribute("filter",eb),A.setAttribute("width",`${w}`),A.setAttribute("height",`${C}`),A.setAttribute("opacity",`${y}`),e.scale[0]!==1||e.scale[1]!==1){let D=e.scale[0]!==1?-w:0,z=e.scale[1]!==1?-C:0;A.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${D} ${z})`)}let N=o.ownerDocument.createElementNS(Ke,"g");if(N.appendChild(A),N.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),e.roundness){let D=o.ownerDocument.createElementNS(Ke,"clipPath");D.id=`image-clipPath-${e.id}`;let z=o.ownerDocument.createElementNS(Ke,"rect"),R=fo(Math.min(e.width,e.height),e);z.setAttribute("width",`${e.width}`),z.setAttribute("height",`${e.height}`),z.setAttribute("rx",`${R}`),z.setAttribute("ry",`${R}`),D.appendChild(z),v(D,e),N.setAttributeNS(Ke,"clip-path",`url(#${D.id})`)}let k=ld(e,x,[N],s.frameRendering,t);v(k||N,e)}break}case"frame":case"magicframe":{if(s.frameRendering.enabled&&s.frameRendering.outline){let w=document.createElementNS(Ke,"rect");w.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`),w.setAttribute("width",`${e.width}px`),w.setAttribute("height",`${e.height}px`),w.setAttribute("rx",rt.radius.toString()),w.setAttribute("ry",rt.radius.toString()),w.setAttribute("fill","none"),w.setAttribute("stroke",rt.strokeColor),w.setAttribute("stroke-width",rt.strokeWidth.toString()),v(w,e)}break}default:if(H(e)){let w=o.ownerDocument.createElementNS(Ke,"g");y!==1&&(w.setAttribute("stroke-opacity",`${y}`),w.setAttribute("fill-opacity",`${y}`)),w.setAttribute("transform",`translate(${i||0} ${a||0}) rotate(${h} ${u} ${g})`);let C=e.text.replace(/\r\n?/g,`
23
10
  `).split(`
24
- `),L=ui(e.fontSize,e.lineHeight),C=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,M=jd(e.fontFamily,e.fontSize,L),_=Sd(e.text)?"rtl":"ltr",H=e.textAlign==="center"?"middle":e.textAlign==="right"||_==="rtl"?"end":"start";for(let N=0;N<I.length;N++){let A=o.ownerDocument.createElementNS(He,"text");A.textContent=I[N],A.setAttribute("x",`${C}`),A.setAttribute("y",`${N*L+M}`),A.setAttribute("font-family",Qa(e)),A.setAttribute("font-size",`${e.fontSize}px`),A.setAttribute("fill",e.strokeColor),A.setAttribute("text-anchor",H),A.setAttribute("style","white-space: pre;"),A.setAttribute("direction",_),A.setAttribute("dominant-baseline","alphabetic"),v.appendChild(A)}let k=rc(e,x,[v],l.frameRendering,t);w(k||v,e)}else throw new Error(`Unimplemented type ${e.type}`)}},T0=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!$t(a)).forEach(a=>{if(!a.isDeleted){if(G(a)&&a.containerId&&t.has(a.containerId))return;try{fm(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i);let l=me(a,t);l&&fm(l,t,r,o,n,l.x+i.offsetX,l.y+i.offsetY,i)}catch(l){console.error(l)}}}),e.filter(a=>$t(a)).forEach(a=>{if(!a.isDeleted)try{fm(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(l){console.error(l)}}))}});import{fileOpen as BC,fileSave as FC,supported as fi}from"browser-fs-access";var I0,bl,El,Dn=j(()=>{"use strict";f();Y();oi();U();I0=500,bl=e=>{let t=e.extensions?.reduce((o,n)=>(o.push(te[n]),o),[]),r=e.extensions?.reduce((o,n)=>n==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${n}`),[]);return BC({description:e.description,extensions:r,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,n,i)=>{let a=ji(n,I0),l=()=>{s(),document.addEventListener("keyup",a),document.addEventListener("pointerup",a),a()},s=()=>{if(i.files?.length){let d=e.multiple?[...i.files]:i.files[0];o(d)}};requestAnimationFrame(()=>{window.addEventListener("focus",l)});let c=window.setInterval(()=>{s()},I0);return d=>{clearInterval(c),a.cancel(),window.removeEventListener("focus",l),document.removeEventListener("keyup",a),document.removeEventListener("pointerup",a),d&&(console.warn("Opening the file was canceled (legacy-fs)."),d(new $o))}}})},El=(e,t)=>FC(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle)});var zC,HC,C0,xl,UC,GC,WC,VC,oc,YC,A0,M0,bi,k0,fa,yl=j(()=>{"use strict";f();be();se();Co();Y();Ir();Xt();Ue();U();U();st();ga();no();zC={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},HC=e=>Object.keys(mt).includes(e)?mt[e]:Kt,C0=e=>e?{...e,focus:e.focus||0}:null,xl=(e,t)=>{let r={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||_t(),fillStyle:e.fillStyle||rt.fillStyle,strokeWidth:e.strokeWidth||rt.strokeWidth,strokeStyle:e.strokeStyle??rt.strokeStyle,roughness:e.roughness??rt.roughness,opacity:e.opacity==null?rt.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||rt.strokeColor,backgroundColor:e.backgroundColor||rt.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:Ko(e.type)?at.LEGACY:at.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(o=>({type:"arrow",id:o})):e.boundElements??[],updated:e.updated??wn(),link:e.link?pr(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(r.customData="customData"in t?t.customData:e.customData),{...r,...nc(r),...t}},UC=e=>{switch(e.type){case"text":let t=e.fontSize,r=e.fontFamily;if("font"in e){let[i,a]=e.font.split(" ");t=parseFloat(i),r=HC(a)}let o=typeof e.text=="string"&&e.text||"",n=e.lineHeight||(e.height?Yx(e):Hr(e.fontFamily));return e=xl(e,{fontSize:t,fontFamily:r,text:o,textAlign:e.textAlign||qn,verticalAlign:e.verticalAlign||$i,containerId:e.containerId??null,originalText:e.originalText||o,lineHeight:n}),!o&&!e.isDeleted&&(e={...e,originalText:o,isDeleted:!0},e=gi(e)),e;case"freedraw":return xl(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return xl(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{let{startArrowhead:i=null,endArrowhead:a=e.type==="arrow"?"arrow":null}=e,l=e.x,s=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:l,y:s}=X.getNormalizedPoints(e)),xl(e,{type:e.type==="draw"?"line":e.type,startBinding:C0(e.startBinding),endBinding:C0(e.endBinding),lastCommittedPoint:null,startArrowhead:i,endArrowhead:a,points:c,x:l,y:s})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return xl(e,{});case"magicframe":case"frame":return xl(e,{name:e.name??null})}return null},GC=(e,t)=>{if(e.boundElements){let r=e.boundElements.slice(),o=new Set;e.boundElements=r.reduce((n,i)=>{let a=t.get(i.id);if(a&&!o.has(i.id)){if(o.add(i.id),a.isDeleted)return n;n.push(i),G(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},WC=(e,t)=>{let r=e.containerId?t.get(e.containerId):null;if(!r){e.containerId=null;return}if(!e.isDeleted&&r.boundElements&&!r.boundElements.find(o=>o.id===e.id)){let o=(r.boundElements||(r.boundElements=[])).slice();o.push({type:"text",id:e.id}),r.boundElements=o}},VC=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},oc=(e,t,r)=>{let o=new Set,n=t?$(t):null,i=cr((e||[]).reduce((l,s)=>{if(s.type!=="selection"&&!lo(s)){let c=UC(s);if(c){let d=n?.get(s.id);d&&d.version>c.version&&(c=gi(c,d.version)),o.has(c.id)&&(c={...c,id:_t()}),o.add(c.id),l.push(c)}}return l},[]));if(!r?.repairBindings)return i;let a=$(i);for(let l of i)l.frameId&&VC(l,a),G(l)&&l.containerId?WC(l,a):l.boundElements&&GC(l,a),r.refreshDimensions&&G(l)&&Object.assign(l,gl(l,pt(l,a),a));return i},YC=(e,t,r)=>{let o=t[e];return o!==void 0?o:r[e]},A0={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??YC("defaultSidebarDockedPreference",e,t)]},M0=(e,t)=>{e=e||{};let r=Zt(),o={};for(let n of Object.keys(A0))if(n in e){let[i,a]=A0[n](e,r);o[i]=a}for(let[n,i]of Object.entries(r)){let a=e[n],l=t?t[n]:void 0;o[n]=a!==void 0?a:l!==void 0?l:i}return{...o,cursorButton:t?.cursorButton||"up",penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...qe(r,o.activeTool.type&&zC[o.activeTool.type]?o.activeTool:{type:"selection"}),lastActiveTool:null,locked:o.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:e.zoom?.value?e.zoom:r.zoom,openSidebar:typeof e.openSidebar=="string"?{name:Nr.name}:o.openSidebar}},bi=(e,t,r,o)=>({elements:oc(e?.elements,r,o),appState:M0(e?.appState,t||null),files:e?.files||{}}),k0=e=>{let t=oc(xe(e.elements),null);return t.length?{...e,elements:t}:null},fa=(e=[],t)=>{let r=[];for(let o of e)if(Array.isArray(o)){let n=k0({status:t,elements:o,id:_t(),created:Date.now()});n&&r.push(n)}else{let n=o,i=k0({...n,id:n.id||_t(),status:n.status||t,created:n.created||Date.now()});i&&r.push(i)}return r}});var L0=j(()=>{"use strict";f();Y();Cr()});import{deflate as KC,inflate as $C}from"pako";var lg,P0,D0,_0,R0,sg,cg,N0=j(()=>{"use strict";f();L0();lg=e=>new Promise((t,r)=>{let o=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),n=new FileReader;n.onload=i=>{if(!i.target||typeof i.target.result!="string")return r(new Error("couldn't convert to byte string"));t(i.target.result)},n.readAsBinaryString(o)}),P0=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0,n=e.length;o<n;o++)r[o]=e.charCodeAt(o);return t},D0=e=>new TextDecoder("utf-8").decode(P0(e)),_0=async(e,t=!1)=>t?window.btoa(e):window.btoa(await lg(e)),R0=async(e,t=!1)=>t?window.atob(e):D0(window.atob(e)),sg=async({text:e,compress:t})=>{let r;if(t!==!1)try{r=await lg(KC(e))}catch(o){console.error("encode: cannot deflate",o)}return{version:"1",encoding:"bstring",compressed:!!r,encoded:r||await lg(e)}},cg=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await D0(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?$C(new Uint8Array(P0(t)),{to:"string"}):t}});var ic={};Ju(ic,{decodePngMetadata:()=>ZC,decodeSvgMetadata:()=>qC,encodePngMetadata:()=>dg,encodeSvgMetadata:()=>jC,getTEXtChunk:()=>F0});import O0 from"png-chunks-extract";import B0 from"png-chunk-text";import XC from"png-chunks-encode";var F0,dg,ZC,jC,qC,wl=j(()=>{"use strict";f();N0();Y();Cr();F0=async e=>{let r=O0(new Uint8Array(await _n(e))).find(o=>o.name==="tEXt");return r?B0.decode(r.data):null},dg=async({blob:e,metadata:t})=>{let r=O0(new Uint8Array(await _n(e))),o=B0.encode(te.excalidraw,JSON.stringify(await sg({text:t,compress:!0})));return r.splice(-1,0,o),new Blob([XC(r)],{type:te.png})},ZC=async e=>{let t=await F0(e);if(t?.keyword===te.excalidraw)try{let r=JSON.parse(t.text);if(!("encoded"in r)){if("type"in r&&r.type===er.excalidraw)return t.text;throw new Error("FAILED")}return await cg(r)}catch(r){throw console.error(r),new Error("FAILED")}throw new Error("INVALID")},jC=async({text:e})=>{let t=await _0(JSON.stringify(await sg({text:e})),!0),r="";return r+=`<!-- payload-type:${te.excalidraw} -->`,r+="<!-- payload-version:2 -->",r+="<!-- payload-start -->",r+=t,r+="<!-- payload-end -->",r},qC=async({svg:e})=>{if(e.includes(`payload-type:${te.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||"1")!=="1";try{let i=await R0(t[1],n),a=JSON.parse(i);if(!("encoded"in a)){if("type"in a&&a.type===er.excalidraw)return i;throw new Error("FAILED")}return await cg(a)}catch(i){throw console.error(i),new Error("FAILED")}}throw new Error("INVALID")}});import{nanoid as JC}from"nanoid";var H0,mg,U0,vl,Ei,xm,Tl,pg,ug,Rn,G0,ym,W0,ac,hg,V0,Y0,QC,z0,Em,lc,_n,Cr=j(()=>{"use strict";f();Ir();Y();be();oi();$e();U();Dn();Nn();yl();H0=async e=>{let t;if(e.type===te.png)try{return await(await Promise.resolve().then(()=>(wl(),ic))).decodePngMetadata(e)}catch(r){throw r.message==="INVALID"?new Ao("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Ao("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(r=>{let o=new FileReader;o.readAsText(e,"utf8"),o.onloadend=()=>{o.readyState===FileReader.DONE&&r(o.result)}}),e.type===te.svg)try{return await(await Promise.resolve().then(()=>(wl(),ic))).decodeSvgMetadata({svg:t})}catch(r){throw r.message==="INVALID"?new Ao("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new Ao("Error: cannot restore image")}return t},mg=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,U0=e=>e==="png"||e==="svg",vl=e=>{let t=mg(e);return t==="png"||t==="svg"},Ei=e=>{let{type:t}=e||{};return!!t&&Object.values(xs).includes(t)},xm=async(e,t,r,o)=>{let n=await H0(e),i;try{try{i=JSON.parse(n)}catch(a){throw Ei(e)?new Ao("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):a}if(K0(i))return{type:te.excalidraw,data:bi({elements:wm(i.elements||[]),appState:{theme:t?.theme,fileHandle:o||e.handle||null,...tm(i.appState||{}),...t?Qo(i.elements||[],t):{}},files:i.files},t,r,{repairBindings:!0,refreshDimensions:!1})};if(gg(i))return{type:te.excalidrawlib,data:i};throw new Error("Error: invalid file")}catch(a){throw a instanceof Ao?a:new Error("Error: invalid file")}},Tl=async(e,t,r,o)=>{let n=await xm(e,t,r,o);if(n.type!==te.excalidraw)throw new Error("Error: invalid file");return n.data},pg=(e,t="unpublished")=>{let r=JSON.parse(e);if(!gg(r))throw new Error("Invalid library");let o=r.libraryItems||r.library;return fa(o,t)},ug=async(e,t="unpublished")=>pg(await H0(e),t),Rn=async e=>new Promise(async(t,r)=>{try{Wo(e)&&(e=await e),e.toBlob(o=>{if(!o)return r(new Ld("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(o)})}catch(o){r(o)}}),G0=async e=>{try{let t=await window.crypto.subtle.digest("SHA-1",await _n(e));return zE(new Uint8Array(t))}catch(t){return console.error(t),JC(40)}},ym=async e=>new Promise((t,r)=>{let o=new FileReader;o.onload=()=>{let n=o.result;t(n)},o.onerror=n=>r(n),o.readAsDataURL(e)}),W0=(e,t="")=>{let r=e.indexOf(","),o=atob(e.slice(r+1)),n=e.slice(0,r).split(":")[1].split(";")[0],i=new ArrayBuffer(o.length),a=new Uint8Array(i);for(let l=0;l<o.length;l++)a[l]=o.charCodeAt(l);return new File([i],t,{type:n})},ac=async(e,t)=>{if(e.type===te.svg)return e;let[r,o]=await Promise.all([import("pica").then(i=>i.default),import("image-blob-reduce").then(i=>i.default)]),n=o({pica:r({features:["js","wasm"]})});if(t.outputType){let{outputType:i}=t;n._create_blob=function(a){return this.pica.toBlob(a.out_canvas,i,.8).then(l=>(a.out_blob=l,a))}}if(!Ei(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await n.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},hg=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:te.svg}),V0=async(e,t="")=>{let r;try{r=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!r.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});let o=await r.blob();if(o.type&&Ei(o)){let n=t||o.name||"";return new File([o],n,{type:o.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},Y0=async e=>{let t=e.dataTransfer.files.item(0),r=await QC(e);return{file:t?await lc(t):null,fileHandle:r}},QC=async e=>{if(fi)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},z0=e=>{let t=null,r=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,o={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return r===o.png?t=te.png:r.startsWith(o.jpg)?t=te.jpg:r.startsWith(o.gif)&&(t=te.gif),t},Em=(e,t,r)=>new File([e],r||"",{type:t}),lc=async e=>{if(e.type){if(Ei(e)){let t=await _n(e),r=z0(t);r&&r!==e.type&&(e=Em(t,r,e.name))}}else if(e?.name?.endsWith(".excalidrawlib"))e=Em(await _n(e),te.excalidrawlib,e.name);else if(e?.name?.endsWith(".excalidraw"))e=Em(await _n(e),te.excalidraw,e.name);else{let t=await _n(e),r=z0(t);r&&(e=Em(t,r,e.name))}return e},_n=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,r)=>{let o=new FileReader;o.onload=n=>{if(!n.target?.result)return r(new Error("Couldn't convert blob to ArrayBuffer"));t(n.target.result)},o.readAsArrayBuffer(e)})});var e6,xi,vm,fg,K0,gg,Tm,$0,Nn=j(()=>{"use strict";f();Dn();Ir();Y();be();Cr();e6=(e,t)=>{let r={};for(let o of e)!o.isDeleted&&"fileId"in o&&o.fileId&&t[o.fileId]&&(r[o.fileId]=t[o.fileId]);return r},xi=(e,t,r,o)=>{let n={type:er.excalidraw,version:Zi.excalidraw,source:ys,elements:o==="local"?wm(e):X0(e),appState:o==="local"?tm(t):r0(t),files:o==="local"?e6(e,r):void 0};return JSON.stringify(n,null,2)},vm=async(e,t,r,o=t.name||wd)=>{let n=xi(e,t,r,"local"),i=new Blob([n],{type:te.excalidraw});return{fileHandle:await El(i,{name:o,extension:"excalidraw",description:"Excalidraw file",fileHandle:vl(t.fileHandle)?null:t.fileHandle})}},fg=async(e,t)=>{let r=await bl({description:"Excalidraw files"});return Tl(await lc(r),e,t,r.handle)},K0=e=>e?.type===er.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),gg=e=>typeof e=="object"&&e&&e.type===er.excalidrawLibrary&&(e.version===1||e.version===2),Tm=e=>{let t={type:er.excalidrawLibrary,version:Zi.excalidrawLibrary,source:ys,libraryItems:e};return JSON.stringify(t,null,2)},$0=async e=>{let t=Tm(e);await El(new Blob([t],{type:te.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})}});var bg,Sm,Im,t6,Z0,Eg=j(()=>{"use strict";f();Y();se();bg=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),Sm=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let l=t[a];return l&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(l.mimeType===te.binary)throw new Error("Only images can be added to ImageCache");let s=bg(l.dataURL),c={image:s,mimeType:l.mimeType};r.set(a,c);let d=await s;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},Im=e=>e.filter(t=>sr(t)),t6=e=>e?.nodeName.toLowerCase()==="svg",Z0=async e=>{let t=new DOMParser().parseFromString(e,te.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!t6(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",He),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let l=n.match(/\d+ +\d+ +(\d+) +(\d+)/);l&&([,i,a]=l)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});import{pointsOnBezierCurves as r6}from"points-on-curve";var Cm,j0,q0,J0,Q0,o6,ey,ty,xg=j(()=>{"use strict";f();be();zd();Cm=e=>{let{angle:t,width:r,height:o,x:n,y:i}=e,a=Zo(t),l=n+r/2,s=i+o/2,c=[l,s],d=[];return e.type==="diamond"?d=[Et([l,i],a,c),Et([n+r,s],a,c),Et([l,i+o],a,c),Et([n,s],a,c)]:d=[Et([n,i],a,c),Et([n+r,i],a,c),Et([n+r,i+o],a,c),Et([n,i+o],a,c)],{type:"polygon",data:d}},j0=(e,t,r=10)=>{let[o,n,i,a,l,s]=re(e,t,!0);o-=r,i+=r,n-=r,a+=r;let c=Zo(e.angle),d=[l,s],m=Et([o,n],c,d),p=Et([i,n],c,d),u=Et([o,a],c,d),h=Et([i,a],c,d);return{type:"polygon",data:[m,p,h,u]}},q0=e=>{let{width:t,height:r,angle:o,x:n,y:i}=e;return{type:"ellipse",data:{center:[n+t/2,i+r/2],angle:o,halfWidth:t/2,halfHeight:r/2}}},J0=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},Q0=(e,t=[0,0],r,o)=>{let n=s=>Et([s[0]+t[0],s[1]+t[1]],Zo(r),o),i=J0(e),a=[],l=[0,0];for(let s of i)if(s.op==="move"&&(l=n(s.data)),s.op==="bcurveTo"){let c=n([s.data[0],s.data[1]]),d=n([s.data[2],s.data[3]]),m=n([s.data[4],s.data[5]]);a.push([l,c,d,m]),l=m}return{type:"polycurve",data:a}},o6=e=>{let t=e[0],r=[];for(let o=1;o<e.length;o++){let n=e[o];r.push([t,n]),t=n}return r},ey=(e,t,r=!1)=>{let o=Zo(e.angle),n=a=>Et(Rh(a,[e.x,e.y]),o,t),i=o6(e.points.map(a=>n(a)));return r?{type:"polygon",data:al(i.flat())}:{type:"polyline",data:i}},ty=(e,t,r=[0,0],o,n)=>{let i=d=>Et([d[0]+r[0],d[1]+r[1]],Zo(o),n);if(e.roundness===null)return{type:"polygon",data:al(e.points.map(d=>i(d)))};let a=J0(t),l=[],s=!1;for(let d of a)d.op==="move"?(s=!s,s&&l.push([d.data[0],d.data[1]])):d.op==="bcurveTo"?s&&(l.push([d.data[0],d.data[1]]),l.push([d.data[2],d.data[3]]),l.push([d.data[4],d.data[5]])):d.op==="lineTo"&&s&&l.push([d.data[0],d.data[1]]);return{type:"polygon",data:r6(l,10,5).map(d=>i(d))}}});var Am,ba,sc,ry,oy,km=j(()=>{"use strict";f();Ft();lt();xg();Hd();U();se();Am=e=>{if(e.type==="arrow")return!1;let t=!lr(e.backgroundColor)||tr(e)||$t(e)||G(e);return e.type==="line"?t&&dr(e.points):e.type==="freedraw"?t&&dr(e.points):t||to(e)},ba=({x:e,y:t,element:r,shape:o,threshold:n=10,frameNameBound:i=null})=>{let a=Am(r)?ll([e,t],o)||Fs([e,t],o,n):Fs([e,t],o,n);return!a&&i&&(a=ll([e,t],{type:"polygon",data:Cm(i).data})),a},sc=(e,t,r,o,n=0)=>{let[i,a,l,s]=Ur(r,o);return i-=n,a-=n,l+=n,s+=n,Rd([i,a],[e,t],[l,s])},ry=(e,t)=>!ba(e)&&sc(e.x,e.y,e.element,t),oy=(e,t,r)=>r&&ll([e,t],r)});var yg,cc,wg,Mm,Lm=j(()=>{"use strict";f();Y();lt();km();Ft();Tn();yg=document.createElement("img");yg.src=`data:${te.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;cc=([e,t,r,o],n,i)=>{let a=ny,l=a/i.zoom.value,s=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,h=r+u-p,E=t-u-c+p,[x,w]=ye(h+l/2,E+s/2,d,m,n);return[x-l/2,w-s/2,l,s]},wg=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,l,s,c]=re(e,t),[d,m,p,u]=cc([a,l,s,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},Mm=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&sc(o,n,e,t)?!0:wg(e,t,r,[o,n])});var dc,Pm,Dm,vg=j(()=>{"use strict";f();Y();dc=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},Pm=(e,t)=>[e.width/t,e.height/t],Dm=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let l=e.getContext("2d");return l.setTransform(1,0,0,1,0,0),l.scale(t,t),i&&n===ae.DARK&&(l.filter=ja),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&l.clearRect(0,0,r,o),l.save(),l.fillStyle=a,l.fillRect(0,0,r,o),l.restore()):l.clearRect(0,0,r,o),l}});var n6,iy,On,ay,ly,Tg,Rm,Nm=j(()=>{"use strict";f();Y();be();nr();se();Tn();ec();Lm();vg();U();st();n6=(e,t,r,o,n,i,a)=>{let s;(x=>(x.Bold="#cccccc",x.Regular="#e5e5e5"))(s||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let h=c;h<c+i+t*2;h+=t){let E=Math.round(h-r)%(5*t)===0;e.beginPath(),e.setLineDash(E?[]:u),e.strokeStyle=E?"#cccccc":"#e5e5e5",e.moveTo(h,d-t),e.lineTo(h,d+a+t*2),e.stroke()}for(let h=d;h<d+a+t*2;h+=t){let E=Math.round(h-o)%(5*t)===0;e.beginPath(),e.setLineDash(E?[]:u),e.strokeStyle=E?"#cccccc":"#e5e5e5",e.moveTo(c-t,h),e.lineTo(c+i+t*2,h),e.stroke()}e.restore()},iy=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,je.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},ay=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,l]=re(e,o),[s,c,d,m]=cc([n,i,a,l],e.angle,r),p=s+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!On||On.zoom!==r.zoom.value){On=document.createElement("canvas"),On.zoom=r.zoom.value,On.width=d*window.devicePixelRatio*r.zoom.value,On.height=m*window.devicePixelRatio*r.zoom.value;let h=On.getContext("2d");h.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),h.fillStyle="#fff",h.fillRect(0,0,d,m),h.drawImage(yg,0,0,d,m),h.restore(),t.drawImage(On,s-p,c-u,d,m)}else t.drawImage(On,s-p,c-u,d,m);t.restore()}},ly=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:l})=>{if(e===null)return;let{renderGrid:s=!0,isExporting:c}=l,[d,m]=Pm(e,i),p=Dm({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),s&&a.gridSize&&n6(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(h=>{h.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[h.id]&&(en(h,a.frameToHighlight,r)||h.groupIds.find(E=>u.has(E)))&&h.groupIds.forEach(E=>u.add(E))}),n.filter(h=>!$t(h)).forEach(h=>{try{let E=h.frameId||a.frameToHighlight?.id;if(G(h)&&h.containerId&&r.has(h.containerId))return;if(p.save(),E&&a.frameRendering.enabled&&a.frameRendering.clip){let w=_m(h,r,a);w&&Ea(h,r,a)&&iy(w,p,l,a),Sl(h,r,o,t,p,l,a)}else Sl(h,r,o,t,p,l,a);let x=me(h,r);x&&Sl(x,r,o,t,p,l,a),p.restore(),c||ay(h,p,a,r)}catch(E){console.error(E)}}),n.filter(h=>$t(h)).forEach(h=>{try{let E=()=>{if(Sl(h,r,o,t,p,l,a),$t(h)&&(c||It(h)&&l.embedsValidationStatus.get(h.id)!==!0)&&h.width&&h.height){let w=gm(h);Sl(w,r,o,t,p,l,a)}c||ay(h,p,a,r)};if((h.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let w=_m(h,r,a);w&&Ea(h,r,a)&&iy(w,p,l,a),E(),p.restore()}else E()}catch(E){console.error(E)}})},Tg=el(e=>{ly(e)},{trailing:!0}),Rm=(e,t)=>{if(t){Tg(e);return}ly(e)}});import sy from"roughjs/bin/rough";var i6,a6,l6,cy,dy,Om,Il,Sg,my,mc=j(()=>{"use strict";f();lt();S0();U();Y();Ir();Nn();Eg();nr();be();Ue();se();no();Nm();i6="<!-- svg-source:excalidraw -->",a6=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Ye({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let l=`${n.slice(0,a)}...`;if(o.measureText(l).width<=t){n=l;break}}return ie(e,{text:n,width:t})},l6=(e,t)=>{let r=[],o=0,n=0;for(let i of e){if(ee(i)){ri(i)?o++:n++;let a=zt({x:i.x,y:i.y-je.nameOffsetY,fontFamily:mt.Assistant,fontSize:je.nameFontSize,lineHeight:je.nameLineHeight,strokeColor:t.exportWithDarkMode?je.nameColorDarkTheme:je.nameColorLightTheme,text:Bm(i,ri(i)?o:n)});a.y-=a.height,a=a6(a,i.width),r.push(a)}r.push(i)}return r},cy=(e,t)=>(t=t||Zt().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),dy=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=Cl(e,t):r.enabled&&r.name?n=l6(e,{exportWithDarkMode:o}):n=e,n},Om=async(e,t,r,{exportBackground:o,exportPadding:n=To,viewBackgroundColor:i,exportingFrame:a},l=(s,c)=>{let d=document.createElement("canvas");return d.width=s*t.exportScale,d.height=c*t.exportScale,{canvas:d,scale:t.exportScale}})=>{let s=cy(a??null,t.frameRendering??null),c=dy({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:s});a&&(n=0);let[d,m,p,u]=Sg(a?[a]:Ig(c),n),{canvas:h,scale:E=1}=l(p,u),x=Zt(),{imageCache:w}=await Sm({imageCache:new Map,fileIds:Im(c).map(y=>y.fileId),files:r});return Rm({canvas:h,rc:sy.canvas(h),elementsMap:Br($(c)),allElementsMap:Br($(cr(e))),visibleElements:c,scale:E,appState:{...t,frameRendering:s,viewBackgroundColor:o?i:null,scrollX:-d+n,scrollY:-m+n,zoom:x.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?ae.DARK:ae.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:w,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},Il=async(e,t,r,o)=>{let n=cy(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=To,exportWithDarkMode:a=!1,viewBackgroundColor:l,exportScale:s=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=dy({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(wl(),ic))).encodeSvgMetadata({text:xi(e,t,r||{},"local")})}catch(k){console.error(k)}let[u,h,E,x]=Sg(d?[d]:Ig(m),i),w=document.createElementNS(He,"svg");w.setAttribute("version","1.1"),w.setAttribute("xmlns",He),w.setAttribute("viewBox",`0 0 ${E} ${x}`),w.setAttribute("width",`${E*s}`),w.setAttribute("height",`${x*s}`),a&&w.setAttribute("filter",ja);let y="https://excalidraw.com/";T.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(y=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${T.VITE_PKG_NAME}@${T.PKG_VERSION}`,y?.startsWith("/")&&(y=y.replace("/",`${window.location.origin}/`)),y=`${y}/dist/excalidraw-assets/`);let v=-u+i,I=-h+i,L=pc(e),C="",M=$(e);for(let k of L){let[N,A,B,q]=re(k,M),Z=(B-N)/2-(k.x-N),oe=(q-A)/2-(k.y-A);C+=`<clipPath id=${k.id}>
25
- <rect transform="translate(${k.x+v} ${k.y+I}) rotate(${k.angle} ${Z} ${oe})"
26
- width="${k.width}"
27
- height="${k.height}"
11
+ `),M=ra(e.fontSize,e.lineHeight),I=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,P=Tp(e.fontFamily,e.fontSize,M),A=Rm(e.text)?"rtl":"ltr",N=e.textAlign==="center"?"middle":e.textAlign==="right"||A==="rtl"?"end":"start";for(let D=0;D<C.length;D++){let z=o.ownerDocument.createElementNS(Ke,"text");z.textContent=C[D],z.setAttribute("x",`${I}`),z.setAttribute("y",`${D*M+P}`),z.setAttribute("font-family",Sn(e)),z.setAttribute("font-size",`${e.fontSize}px`),z.setAttribute("fill",e.strokeColor),z.setAttribute("text-anchor",N),z.setAttribute("style","white-space: pre;"),z.setAttribute("direction",A),z.setAttribute("dominant-baseline","alphabetic"),w.appendChild(z)}let k=ld(e,x,[w],s.frameRendering,t);v(k||w,e)}else throw new Error(`Unimplemented type ${e.type}`)}},Uv=(e,t,r,o,n,i)=>{o&&(e.filter(a=>!sr(a)).forEach(a=>{if(!a.isDeleted){if(H(a)&&a.containerId&&t.has(a.containerId))return;try{jp(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i);let s=J(a,t);s&&jp(s,t,r,o,n,s.x+i.offsetX,s.y+i.offsetY,i)}catch(s){console.error(s)}}}),e.filter(a=>sr(a)).forEach(a=>{if(!a.isDeleted)try{jp(a,t,r,o,n,a.x+i.offsetX,a.y+i.offsetY,i)}catch(s){console.error(s)}}))}});var tb,Jp,Qp,iM,Wv,rb=X(()=>{"use strict";f();Y();me();tb=e=>new Promise((t,r)=>{let o=new Image;o.onload=()=>{t(o)},o.onerror=n=>{r(n)},o.src=e}),Jp=async({fileIds:e,files:t,imageCache:r})=>{let o=new Map,n=new Map;return await Promise.all(e.reduce((i,a)=>{let s=t[a];return s&&!o.has(a)?(o.set(a,!0),i.concat((async()=>{try{if(s.mimeType===se.binary)throw new Error("Only images can be added to ImageCache");let l=tb(s.dataURL),c={image:l,mimeType:s.mimeType};r.set(a,c);let d=await l;r.set(a,{...c,image:d})}catch{n.set(a,!0)}})())):i},[])),{imageCache:r,updatedFiles:o,erroredFiles:n}},Qp=e=>e.filter(t=>kr(t)),iM=e=>e?.nodeName.toLowerCase()==="svg",Wv=async e=>{let t=new DOMParser().parseFromString(e,se.svg),r=t.querySelector("svg");if(t.querySelector("parsererror")||!iM(r))throw new Error("Invalid SVG");if(r.hasAttribute("xmlns")||r.setAttribute("xmlns",Ke),!r.hasAttribute("width")||!r.hasAttribute("height")){let n=r.getAttribute("viewBox"),i=r.getAttribute("width")||"50",a=r.getAttribute("height")||"50";if(n){let s=n.match(/\d+ +\d+ +(\d+) +(\d+)/);s&&([,i,a]=s)}r.setAttribute("width",i),r.setAttribute("height",a)}return r.outerHTML}});var ob,cd,nb,eu,tu=X(()=>{"use strict";f();Y();dt();Zc();mt();li();ob=document.createElement("img");ob.src=`data:${se.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;cd=([e,t,r,o],n,i)=>{let a=Vv,s=a/i.zoom.value,l=a/i.zoom.value,c=a/i.zoom.value,d=(e+r)/2,m=(t+o)/2,p=(a-8)/(2*i.zoom.value),u=4/i.zoom.value,g=r+u-p,h=t-u-c+p,[x,v]=xe(g+s/2,h+l/2,d,m,n);return[x-s/2,v-l/2,s,l]},nb=(e,t,r,[o,n])=>{let i=4/r.zoom.value,[a,s,l,c]=ae(e,t),[d,m,p,u]=cd([a,s,l,c],e.angle,r);return o>d-i&&o<d+i+p&&n>m-i&&n<m+u+i},eu=(e,t,r,[o,n],i)=>!e.link||r.selectedElementIds[e.id]?!1:!i&&r.viewModeEnabled&&$c(o,n,e,t)?!0:nb(e,t,r,[o,n])});var dd,ru,ou,ib=X(()=>{"use strict";f();Y();dd=(e,t,r,o,n=!0)=>{e.beginPath(),e.arc(t,r,o,0,Math.PI*2),e.fill(),n&&e.stroke()},ru=(e,t)=>[e.width/t,e.height/t],ou=({canvas:e,scale:t,normalizedWidth:r,normalizedHeight:o,theme:n,isExporting:i,viewBackgroundColor:a})=>{let s=e.getContext("2d");return s.setTransform(1,0,0,1,0,0),s.scale(t,t),i&&n===ue.DARK&&(s.filter=Fs),typeof a=="string"?((a==="transparent"||a.length===5||a.length===9||/(hsla|rgba)\(/.test(a))&&s.clearRect(0,0,r,o),s.save(),s.fillStyle=a,s.fillRect(0,0,r,o),s.restore()):s.clearRect(0,0,r,o),s}});var aM,Yv,yi,Xv,Kv,ab,iu,au=X(()=>{"use strict";f();Y();we();vr();me();li();ad();tu();ib();V();He();aM=(e,t,r,o,n,i,a)=>{let l;(x=>(x.Bold="#cccccc",x.Regular="#e5e5e5"))(l||={});let c=-Math.round(n.value/t)*t+r%t,d=-Math.round(n.value/t)*t+o%t,m=Math.min(1/n.value,1),p=1/n.value,u=[m*3,p+(m+p)];e.save(),e.lineWidth=m;for(let g=c;g<c+i+t*2;g+=t){let h=Math.round(g-r)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:u),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(g,d-t),e.lineTo(g,d+a+t*2),e.stroke()}for(let g=d;g<d+a+t*2;g+=t){let h=Math.round(g-o)%(5*t)===0;e.beginPath(),e.setLineDash(h?[]:u),e.strokeStyle=h?"#cccccc":"#e5e5e5",e.moveTo(c-t,g),e.lineTo(c+i+t*2,g),e.stroke()}e.restore()},Yv=(e,t,r,o)=>{t.translate(e.x+o.scrollX,e.y+o.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,rt.radius/o.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+o.scrollX),-(e.y+o.scrollY))},Xv=(e,t,r,o)=>{if(e.link&&!r.selectedElementIds[e.id]){let[n,i,a,s]=ae(e,o),[l,c,d,m]=cd([n,i,a,s],e.angle,r),p=l+d/2,u=c+m/2;if(t.save(),t.translate(r.scrollX+p,r.scrollY+u),t.rotate(e.angle),!yi||yi.zoom!==r.zoom.value){yi=document.createElement("canvas"),yi.zoom=r.zoom.value,yi.width=d*window.devicePixelRatio*r.zoom.value,yi.height=m*window.devicePixelRatio*r.zoom.value;let g=yi.getContext("2d");g.scale(window.devicePixelRatio*r.zoom.value,window.devicePixelRatio*r.zoom.value),g.fillStyle="#fff",g.fillRect(0,0,d,m),g.drawImage(ob,0,0,d,m),g.restore(),t.drawImage(yi,l-p,c-u,d,m)}else t.drawImage(yi,l-p,c-u,d,m);t.restore()}},Kv=({canvas:e,rc:t,elementsMap:r,allElementsMap:o,visibleElements:n,scale:i,appState:a,renderConfig:s})=>{if(e===null)return;let{renderGrid:l=!0,isExporting:c}=s,[d,m]=ru(e,i),p=ou({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m,theme:a.theme,isExporting:c,viewBackgroundColor:a.viewBackgroundColor});p.scale(a.zoom.value,a.zoom.value),l&&a.gridSize&&aM(p,a.gridSize,a.scrollX,a.scrollY,a.zoom,d/a.zoom.value,m/a.zoom.value);let u=new Set;n.forEach(g=>{g.groupIds.length>0&&a.frameToHighlight&&a.selectedElementIds[g.id]&&(Bn(g,a.frameToHighlight,r)||g.groupIds.find(h=>u.has(h)))&&g.groupIds.forEach(h=>u.add(h))}),n.filter(g=>!sr(g)).forEach(g=>{try{let h=g.frameId||a.frameToHighlight?.id;if(H(g)&&g.containerId&&r.has(g.containerId))return;if(p.save(),h&&a.frameRendering.enabled&&a.frameRendering.clip){let v=nu(g,r,a);v&&ts(g,r,a)&&Yv(v,p,s,a),fl(g,r,o,t,p,s,a)}else fl(g,r,o,t,p,s,a);let x=J(g,r);x&&fl(x,r,o,t,p,s,a),p.restore(),c||Xv(g,p,a,r)}catch(h){console.error(h)}}),n.filter(g=>sr(g)).forEach(g=>{try{let h=()=>{if(fl(g,r,o,t,p,s,a),sr(g)&&(c||Rt(g)&&s.embedsValidationStatus.get(g.id)!==!0)&&g.width&&g.height){let v=Zp(g);fl(v,r,o,t,p,s,a)}c||Xv(g,p,a,r)};if((g.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){p.save();let v=nu(g,r,a);v&&ts(g,r,a)&&Yv(v,p,s,a),h(),p.restore()}else h()}catch(h){console.error(h)}})},ab=Hs(e=>{Kv(e)},{trailing:!0}),iu=(e,t)=>{if(t){ab(e);return}Kv(e)}});import $v from"roughjs/bin/rough";var sM,lM,cM,Zv,jv,su,bl,sb,qv,md=X(()=>{"use strict";f();dt();Gv();V();Y();Zr();mi();rb();vr();we();De();me();ko();au();on();sM="<!-- svg-source:excalidraw -->",lM=(e,t)=>{if(e.width<=t)return e;let o=document.createElement("canvas").getContext("2d");o.font=Me({fontFamily:e.fontFamily,fontSize:e.fontSize});let n=e.text;if(o.measureText(n).width>t)for(let a=n.length;a>0;a--){let s=`${n.slice(0,a)}...`;if(o.measureText(s).width<=t){n=s;break}}return pe(e,{text:n,width:t})},cM=(e,t)=>{let r=[];for(let o of e){if(Q(o)){let n=jt({x:o.x,y:o.y-rt.nameOffsetY,fontFamily:Le.Helvetica,fontSize:rt.nameFontSize,lineHeight:rt.nameLineHeight,strokeColor:t.exportWithDarkMode?rt.nameColorDarkTheme:rt.nameColorLightTheme,text:lu(o)});n.y-=n.height,n=lM(n,o.width),r.push(n)}r.push(o)}return r},Zv=(e,t)=>(t=t||lr().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),jv=({elements:e,exportingFrame:t,frameRendering:r,exportWithDarkMode:o})=>{let n;return t?n=El(e,t):r.enabled&&r.name?n=cM(e,{exportWithDarkMode:o}):n=e,n},su=async(e,t,r,{exportBackground:o,exportPadding:n=Ko,viewBackgroundColor:i,exportingFrame:a},s=(c,d)=>{let m=document.createElement("canvas");return m.width=c*t.exportScale,m.height=d*t.exportScale,{canvas:m,scale:t.exportScale}},l=async()=>{await Lr.loadFontsForElements(e)})=>{await l();let c=Zv(a??null,t.frameRendering??null),d=jv({elements:e,exportingFrame:a,exportWithDarkMode:t.exportWithDarkMode,frameRendering:c});a&&(n=0);let[m,p,u,g]=sb(a?[a]:lb(d),n),{canvas:h,scale:x=1}=s(u,g),v=lr(),{imageCache:y}=await Jp({imageCache:new Map,fileIds:Qp(d).map(w=>w.fileId),files:r});return iu({canvas:h,rc:$v.canvas(h),elementsMap:Mr(Z(d)),allElementsMap:Mr(Z(fr(e))),visibleElements:d,scale:x,appState:{...t,frameRendering:c,viewBackgroundColor:o?i:null,scrollX:-m+n,scrollY:-p+n,zoom:v.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?ue.DARK:ue.LIGHT},renderConfig:{canvasBackgroundColor:i,imageCache:y,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),h},bl=async(e,t,r,o)=>{let n=Zv(o?.exportingFrame??null,t.frameRendering??null),{exportPadding:i=Ko,exportWithDarkMode:a=!1,viewBackgroundColor:s,exportScale:l=1,exportEmbedScene:c}=t,{exportingFrame:d=null}=o||{},m=jv({elements:e,exportingFrame:d,exportWithDarkMode:a,frameRendering:n});d&&(i=0);let p="";if(c)try{p=await(await Promise.resolve().then(()=>(tl(),Bc))).encodeSvgMetadata({text:Vi(e,t,r||{},"local")})}catch(D){console.error(D)}let[u,g,h,x]=sb(d?[d]:lb(m),i),v=document.createElementNS(Ke,"svg");v.setAttribute("version","1.1"),v.setAttribute("xmlns",Ke),v.setAttribute("viewBox",`0 0 ${h} ${x}`),v.setAttribute("width",`${h*l}`),v.setAttribute("height",`${x*l}`),a&&v.setAttribute("filter",Fs);let y=-u+i,w=-g+i,C=pd(e),M="",I=Z(e);for(let D of C){let[z,R,W,q]=ae(D,I),re=(W-z)/2-(D.x-z),ge=(q-R)/2-(D.y-R);M+=`<clipPath id=${D.id}>
12
+ <rect transform="translate(${D.x+y} ${D.y+w}) rotate(${D.angle} ${re} ${ge})"
13
+ width="${D.width}"
14
+ height="${D.height}"
28
15
  >
29
16
  </rect>
30
- </clipPath>`}if(w.innerHTML=`
31
- ${i6}
17
+ </clipPath>`}let P=e.reduce((D,z)=>(H(z)&&D.add(z.fontFamily),D),new Set),A=o?.skipInliningFonts?[]:await Promise.all(Array.from(P).map(async D=>{let{fonts:z,metadata:R}=Lr.registered.get(D)??{};if(!Array.isArray(z)){console.error(`Couldn't find registered fonts for font-family "${D}"`,Lr.registered);return}if(!R?.local)return Promise.all(z.map(async W=>`@font-face {
18
+ font-family: ${W.fontFace.family};
19
+ src: url(${await W.getContent()});
20
+ }`))}));if(v.innerHTML=`
21
+ ${sM}
32
22
  ${p}
33
23
  <defs>
34
24
  <style class="style-fonts">
35
- @font-face {
36
- font-family: "Virgil";
37
- src: url("${y}Virgil.woff2");
38
- }
39
- @font-face {
40
- font-family: "Cascadia";
41
- src: url("${y}Cascadia.woff2");
42
- }
43
- @font-face {
44
- font-family: "Assistant";
45
- src: url("${y}Assistant-Regular.woff2");
46
- }
25
+ ${A.flat().filter(Boolean).join(`
26
+ `)}
47
27
  </style>
48
- ${C}
28
+ ${M}
49
29
  </defs>
50
- `,t.exportBackground&&l){let k=w.ownerDocument.createElementNS(He,"rect");k.setAttribute("x","0"),k.setAttribute("y","0"),k.setAttribute("width",`${E}`),k.setAttribute("height",`${x}`),k.setAttribute("fill",l),w.appendChild(k)}let _=sy.svg(w),H=o?.renderEmbeddables??!1;return T0(m,Br($(m)),_,w,r||{},{offsetX:v,offsetY:I,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:H,frameRendering:n,canvasBackgroundColor:l,embedsValidationStatus:H?new Map(m.filter(k=>ee(k)).map(k=>[k.id,!0])):new Map}),w},Sg=(e,t)=>{let[r,o,n,i]=Se(e),a=Pt(r,n)+t*2,l=Pt(o,i)+t*2;return[r,o,a,l]},my=(e,t,r)=>{let[,,o,n]=Sg(e,t).map(i=>Math.trunc(i*r));return[o,n]}});var Ro,Qe,yi,uy,xa,Al,uc,Cg,py,s6,hy,Fm,so,gy,c6,d6,m6,fy,p6,u6,by,Ag=j(()=>{"use strict";f();Qt();Y();be();Co();Ro=32,Qe=12,yi=256,uy=50,xa="NOT_SPREADSHEET",Al="VALID_SPREADSHEET",uc=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},Cg=(e,t)=>e.slice(1).every(r=>uc(r[t])!==null),py=e=>{let t=e[0].length;if(t>2)return{type:xa,reason:"More than 2 columns"};if(t===1){if(!Cg(e,0))return{type:xa,reason:"Value is not numeric"};let s=uc(e[0][0])===null,c=(s?e.slice(1):e).map(d=>uc(d[0]));return c.length<2?{type:xa,reason:"Less than two rows"}:{type:Al,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let r=Cg(e,0),o=Cg(e,1);if(!r&&!o)return{type:xa,reason:"Value is not numeric"};let[n,i]=o?[0,1]:[1,0],a=uc(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:xa,reason:"Less than 2 rows"}:{type:Al,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>uc(s[i]))}}},s6=e=>{let t=[];for(let r=0;r<e[0].length;r++){let o=[];for(let n=0;n<e.length;n++)o.push(e[n][r]);t.push(o)}return t},hy=e=>{let t=e.trim().split(`
30
+ `,t.exportBackground&&s){let D=v.ownerDocument.createElementNS(Ke,"rect");D.setAttribute("x","0"),D.setAttribute("y","0"),D.setAttribute("width",`${h}`),D.setAttribute("height",`${x}`),D.setAttribute("fill",s),v.appendChild(D)}let N=$v.svg(v),k=o?.renderEmbeddables??!1;return Uv(m,Mr(Z(m)),N,v,r||{},{offsetX:y,offsetY:w,isExporting:!0,exportWithDarkMode:a,renderEmbeddables:k,frameRendering:n,canvasBackgroundColor:s,embedsValidationStatus:k?new Map(m.filter(D=>Q(D)).map(D=>[D.id,!0])):new Map}),v},sb=(e,t)=>{let[r,o,n,i]=Te(e),a=Ht(r,n)+t*2,s=Ht(o,i)+t*2;return[r,o,a,s]},qv=(e,t,r)=>{let[,,o,n]=sb(e,t).map(i=>Math.trunc(i*r));return[o,n]}});var un,st,oa,Qv,rs,xl,ud,cb,Jv,dM,eT,cu,Do,tT,mM,pM,uM,rT,gM,hM,oT,db=X(()=>{"use strict";f();pr();Y();we();Zo();un=32,st=12,oa=256,Qv=50,rs="NOT_SPREADSHEET",xl="VALID_SPREADSHEET",ud=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},cb=(e,t)=>e.slice(1).every(r=>ud(r[t])!==null),Jv=e=>{let t=e[0].length;if(t>2)return{type:rs,reason:"More than 2 columns"};if(t===1){if(!cb(e,0))return{type:rs,reason:"Value is not numeric"};let l=ud(e[0][0])===null,c=(l?e.slice(1):e).map(d=>ud(d[0]));return c.length<2?{type:rs,reason:"Less than two rows"}:{type:xl,spreadsheet:{title:l?e[0][0]:null,labels:null,values:c}}}let r=cb(e,0),o=cb(e,1);if(!r&&!o)return{type:rs,reason:"Value is not numeric"};let[n,i]=o?[0,1]:[1,0],a=ud(e[0][i])===null,s=a?e.slice(1):e;return s.length<2?{type:rs,reason:"Less than 2 rows"}:{type:xl,spreadsheet:{title:a?e[0][i]:null,labels:s.map(l=>l[n]),values:s.map(l=>ud(l[i]))}}},dM=e=>{let t=[];for(let r=0;r<e[0].length;r++){let o=[];for(let n=0;n<e.length;n++)o.push(e[n][r]);t.push(o)}return t},eT=e=>{let t=e.trim().split(`
51
31
  `).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
52
- `).map(i=>i.trim().split(","))),t.length===0)return{type:xa,reason:"No values"};let r=t[0].length;if(!t.every(i=>i.length===r))return{type:xa,reason:"All rows don't have same number of columns"};let n=py(t);if(n.type!==Al){let i=py(s6(t));if(i.type===Al)return i}return n},Fm=oE(Qb),so={fillStyle:"hachure",fontFamily:Kt,fontSize:Lt,opacity:100,roughness:1,strokeColor:de.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:yt.MIDDLE,locked:!1},gy=e=>{let t=(Ro+Qe)*e.values.length+Qe,r=yi+Qe*2;return{chartWidth:t,chartHeight:r}},c6=(e,t,r,o,n)=>e.labels?.map((i,a)=>zt({groupIds:[o],backgroundColor:n,...so,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(Ro+Qe)+Qe*2,y:r+Qe/2,width:Ro,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],d6=(e,t,r,o,n)=>{let i=zt({groupIds:[o],backgroundColor:n,...so,x:t-Qe,y:r-Qe,text:"0",textAlign:"right"}),a=zt({groupIds:[o],backgroundColor:n,...so,x:t-Qe,y:r-yi-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},m6=(e,t,r,o,n)=>{let{chartWidth:i,chartHeight:a}=gy(e),l=ao({backgroundColor:n,groupIds:[o],...so,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,width:i,points:[[0,0],[i,0]]}),s=ao({backgroundColor:n,groupIds:[o],...so,type:"line",x:t,y:r,startArrowhead:null,endArrowhead:null,height:a,points:[[0,0],[0,-a]]}),c=ao({backgroundColor:n,groupIds:[o],...so,type:"line",x:t,y:r-yi-Qe,startArrowhead:null,endArrowhead:null,strokeStyle:"dotted",width:i,opacity:uy,points:[[0,0],[i,0]]});return[l,s,c]},fy=(e,t,r,o,n,i)=>{let{chartWidth:a,chartHeight:l}=gy(e),s=e.title?zt({backgroundColor:n,groupIds:[o],...so,text:e.title,x:t+a/2,y:r-yi-Qe*2-Lt,roundness:null,textAlign:"center"}):null,c=i?Vr({backgroundColor:n,groupIds:[o],...so,type:"rectangle",x:t,y:r-l,width:a,height:l,strokeColor:de.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...c6(e,t,r,o,n),...d6(e,t,r,o,n),...m6(e,t,r,o,n)]},p6=(e,t,r)=>{let o=Math.max(...e.values),n=_t(),i=Fm[Math.floor(Math.random()*Fm.length)];return[...e.values.map((l,s)=>{let c=l/o*yi;return Vr({backgroundColor:i,groupIds:[n],...so,type:"rectangle",x:t+s*(Ro+Qe)+Qe,y:r-c-Qe,width:Ro,height:c})}),...fy(e,t,r,n,i,T.DEV)]},u6=(e,t,r)=>{let o=Math.max(...e.values),n=_t(),i=Fm[Math.floor(Math.random()*Fm.length)],a=0,l=[];for(let E of e.values){let x=a*(Ro+Qe),w=-(E/o)*yi;l.push([x,w]),a++}let s=Math.max(...l.map(E=>E[0])),c=Math.max(...l.map(E=>E[1])),d=Math.min(...l.map(E=>E[0])),m=Math.min(...l.map(E=>E[1])),p=ao({backgroundColor:i,groupIds:[n],...so,type:"line",x:t+Qe+Ro/2,y:r-Qe,startArrowhead:null,endArrowhead:null,height:c-m,width:s-d,strokeWidth:2,points:l}),u=e.values.map((E,x)=>{let w=x*(Ro+Qe)+Qe/2,y=-(E/o)*yi+Qe/2;return Vr({backgroundColor:i,groupIds:[n],...so,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+w+Ro/2,y:r+y-Qe*2,width:Qe,height:Qe})}),h=e.values.map((E,x)=>{let w=x*(Ro+Qe)+Qe/2,y=E/o*yi+Qe/2+Qe;return ao({backgroundColor:i,groupIds:[n],...so,type:"line",x:t+w+Ro/2+Qe/2,y:r-y,startArrowhead:null,endArrowhead:null,height:y,strokeStyle:"dotted",opacity:uy,points:[[0,0],[0,y]]})});return[...fy(e,t,r,n,i,T.DEV),p,...h,...u]},by=(e,t,r,o)=>e==="line"?u6(t,r,o):p6(t,r,o)});function xy(e){let t=[];for(let r of e.childNodes)if(r.nodeType===3){let o=r.textContent?.trim();o&&t.push({type:"text",value:o})}else if(r instanceof HTMLImageElement){let o=r.getAttribute("src");o&&o.startsWith("http")&&t.push({type:"imageUrl",value:o})}else t=t.concat(xy(r));return t}var tF,zm,kl,h6,Ey,g6,Hm,f6,b6,yy,E6,Um,Gm,Bn,x6,wi=j(()=>{"use strict";f();Ag();Y();se();Mn();Ue();nr();U();tF="clipboard"in navigator&&"readText"in navigator.clipboard,zm="clipboard"in navigator&&"writeText"in navigator.clipboard,kl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,h6=e=>!!([er.excalidraw,er.excalidrawClipboard,er.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Ey=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[o,n]of Object.entries(e))try{if(r.clipboardData?.setData(o,n),r.clipboardData?.getData(o)!==n)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let o=-1;for(let n of t){o++;try{if(r.clipboardData?.items.add(n),r.clipboardData?.files[o]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return r},g6=({elements:e,files:t})=>{let r=$(e),o=new Set(e.filter(l=>ee(l))),n=!1,i=e.reduce((l,s)=>(sr(s)&&(n=!0,t&&t[s.fileId]&&(l[s.fileId]=t[s.fileId])),l),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:er.excalidrawClipboard,elements:e.map(l=>{if(Ht(l,r)&&!o.has(Ht(l,r))){let s=kn(l);return F(s,{frameId:null}),s}return l}),files:t?i:void 0};return JSON.stringify(a)},Hm=async(e,t,r)=>{await Bn(g6({elements:e,files:t}),r)},f6=e=>{let t=hy(e);return t.type===Al?{spreadsheet:t.spreadsheet}:null};b6=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let r=new DOMParser().parseFromString(t,"text/html"),o=xy(r.body);if(o.length)return{type:"mixedContent",value:o}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},yy=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else throw r}let t;try{t=await navigator.clipboard?.read()}catch(r){if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}for(let r of t)for(let o of r.types)if(Ss(pE,o))try{e[o]=await(await r.getType(o)).text()}catch(n){console.warn(`Cannot retrieve ${o} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},E6=async(e,t=!1)=>{try{let r=!t&&e&&b6(e);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||r.value.map(n=>n.value).join(`
53
- `).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},Um=async(e,t=!1)=>{let r=await E6(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&f6(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===er.excalidrawClipboardWithAPI;if(h6(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},Gm=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[te.png]:e})])}catch(t){if(Wo(e))await navigator.clipboard.write([new window.ClipboardItem({[te.png]:await e})]);else throw t}},Bn=async(e,t)=>{if(zm)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!x6(e))throw new Error("Error copying to clipboard.")},x6=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var vi,Wm,Ml,y6,ya=j(()=>{"use strict";f();mc();Ir();yl();Y();wl();Nn();wi();vi=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=bi({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=s;return Om(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let E=Math.max(m,p),x=o<E?o/E:t?.exportScale??1;return u.width=m*x,u.height=p*x,{canvas:u,scale:x}}let h=n?.(m,p)||{width:m,height:p};return u.width=h.width,u.height=h.height,{canvas:u,scale:h.scale??1}})},Wm=async e=>{let{mimeType:t=te.png,quality:r}=e;t===te.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${te.png}" mimeType`),t==="image/jpg"&&(t=te.jpg),t===te.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${te.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await vi(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===te.png&&e.appState?.exportEmbedScene&&(a=await dg({blob:a,metadata:xi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},Ml=async({elements:e,appState:t=Zt(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i})=>{let{elements:a,appState:l}=bi({elements:e,appState:t},null,null),s={...l,exportPadding:o};return Il(a,s,r,{exportingFrame:i,renderEmbeddables:n})},y6=async e=>{if(e.type==="svg"){let t=await Ml(e);await Bn(t.outerHTML)}else if(e.type==="png")await Gm(Wm(e));else if(e.type==="json")await Hm(e.elements,e.files);else throw new Error("Invalid export type")}});var w6,v6,wy,vy,kg,Ty,Mg,Lg=j(()=>{"use strict";f();se();Ft();lt();U();w6=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],v6=e=>ne(e)||Dt(e)?e.points:w6(e),wy=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},vy=e=>{let t=v6(e),{cx:r,cy:o}=wy(t),n=[r,o],i=t.map(d=>Ge([d[0],d[1]],n,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=wy(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},kg=(e,t,r=!1)=>{let o=vy(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},Ty=(e,t)=>{let r=vy(e);return(Rs(r[0],t[0],t[2])||Rs(t[0],r[0],r[2]))&&(Rs(r[1],t[1],t[3])||Rs(t[1],r[1],r[3]))},Mg=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{As(t)&&(t=Ur(t,$(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?Ty(a,n):r==="inside"?kg(a,n):kg(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);G(a)&&a.containerId&&i.add(a.containerId),we(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function Sy(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function Ay(e,t){return e[0]*t[1]-t[0]*e[1]}function T6(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function Vm(e,t){return[e[0]-t[0],e[1]-t[1]]}function Iy(e,t){let r=Vm(e[1],e[0]),o=Vm(t,e[0]),n=Ay(r,o);return Math.abs(n)<S6}function Pg(e,t){let r=Vm(e[1],e[0]),o=Vm(t,e[0]);return Ay(r,o)<0}function Cy(e,t){return Iy(e,t[0])||Iy(e,t[1])||(Pg(e,t[0])?!Pg(e,t[1]):Pg(e,t[1]))}function ky(e,t){return T6(Sy(e),Sy(t))&&Cy(e,t)&&Cy(t,e)}var S6,My=j(()=>{"use strict";f();S6=1e-6});var Ly=j(()=>{"use strict";f();ya();Lg();My()});function Py(e,t,r){let o=Zh(t,r),n=Zh(e,r);return o.some(a=>n.some(l=>ky(a,l)))}var Ym,Dy,_y,Ry,en,Dg,Ny,Yr,pc,Ig,Ll,Oy,Ht,By,hc,Pl,_g,Km,tn,$m,_m,Ea,Bm,Cl,nr=j(()=>{"use strict";f();be();Ft();st();U();Ue();$e();mr();lt();Ly();se();Ym=(e,t,r)=>{let o=$(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let l=o.get(i);l&&F(l,{frameId:a??n.frameId},!1)}}};Dy=(e,t,r)=>$m(Dl(e,t,r,!1)).filter(o=>!ee(o)&&!o.frameId||o.frameId===t.id),_y=(e,t,r,o)=>Dl(e,t,o).some(n=>n.id===r.id),Ry=(e,t,r)=>{let[o,n,i,a]=re(t,r),[l,s,c,d]=Se(e);return o<=l&&n<=s&&i>=c&&a>=d},en=(e,t,r)=>Ry([e],t,r)||Py(e,t,r)||_y([t],e,t,r),Dg=(e,t,r)=>{let[o,n,i,a]=re(t,r);return Rd([o,n],[e.x,e.y],[i,a])},Ny=e=>{let t=new Map;for(let r of e){let o=ee(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,Yr(e,o))}return t},Yr=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},pc=e=>e.filter(t=>ee(t)),Ig=e=>{let t=$(pc(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},Ll=(e,t,r,o)=>{let n=Yr(e,t.id),i=new Set(n),a=new Set([...Dy(e,t,o),...n.filter(p=>_y(e,p,t,o))]),l=n.filter(p=>!a.has(p)),s=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of l)if(!Py(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)s.add(u);for(let p of l)if(p.groupIds.length>0){let u=!0;for(let h of p.groupIds)s.has(h)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=om(d,r);for(let[p,u]of Object.entries(m))if(u){let h=tt(e,p);if(Ry(h,t,o))for(let E of h)i.add(E)}return[...i].filter(p=>!(G(p)&&p.containerId))},Oy=(e,t,r)=>$m(e,Dy(e,t,r)),Ht=(e,t)=>e.frameId&&t.get(e.frameId)||null,By=(e,t)=>{let r=new Set,o=$(e);e=$m(e);for(let a of e)ee(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(ee(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let l=a.groupIds.at(-1);if(!n.has(l)){n.add(l);let s=tt(e,l);if(s.some(c=>en(c,t,o)))for(let c of s)i.push(c)}}else en(a,t,o)&&i.push(a);return i},hc=(e,t,r)=>{let o=$(e),n=new Map;for(let s of e.values())s.frameId===r.id&&n.set(s.id,!0);let i=new Set(t.map(s=>s.id)),a=[],l=new Set;for(let s of t)ee(s)&&s.id!==r.id&&l.add(s.id);for(let s of $m(e,t)){if(ee(s)||s.frameId&&l.has(s.frameId))continue;n.has(s.id)||a.push(s);let c=me(s,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let s of a)F(s,{frameId:r.id},!1);return e},Pl=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=me(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)F(n,{frameId:null},!1)},_g=(e,t)=>{let r=Yr(e,t.id);return Pl(r,$(e)),e},Km=(e,t,r,o)=>hc(_g(e,r),t,r).slice(),tn=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let l of o)l.groupIds.length===0?n.add(l):l.groupIds.flatMap(s=>tt(e,s)).forEach(s=>n.add(s));let i=new Set,a=$(e);return n.forEach(l=>{l.frameId&&!ee(l)&&!Ea(l,a,t)&&i.add(l)}),i.size>0&&Pl(i,a),e},$m=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let l=a.groupIds[a.groupIds.length-1];l&&r.add(l)}let n=new Set;for(let a of r)tt(e,a).some(l=>ee(l))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},_m=(e,t,r)=>{let o=G(e)&&pt(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Ht(o,t)},Ea=(e,t,r)=>{let o=_m(e,t,r),n=G(e)&&pt(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return en(n,o,t);let i=new Set(n.groupIds.flatMap(a=>tt(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(ue(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(s=>{i.delete(s)})}for(let a of i)if(ee(a))return!1;for(let a of i)if(en(a,o,t))return!0}return!1},Bm=(e,t)=>e.name===null?ri(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,Cl=(e,t)=>Mg({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import Uy from"roughjs/bin/rough";import{getStroke as I6}from"perfect-freehand";function lx(e){let t=bm(e),r=new Path2D(t);return $y.set(e,r),r}function L6(e){return $y.get(e)}function bm(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return D6(I6(t,r))}function Hy(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function D6(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,Hy(o,i[0]),"L",i[0],"Z"):r.push(o,Hy(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(P6,"$1")}var ag,C6,Gy,Wy,jm,Rg,A6,k6,ny,Vy,Yy,M6,Xm,Zm,Fy,zy,Ky,Sl,$y,P6,Tn=j(()=>{"use strict";f();se();lt();U();Ft();Ir();Y();st();Xt();nr();Xo();ag="invert(100%) hue-rotate(180deg) saturate(1.25)",C6=Zt(),Gy=(e,t)=>sr(e)&&!t.imageCache.has(e.fileId),Wy=(e,t,r)=>r.theme===ae.DARK&&sr(e)&&!Gy(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==te.svg,jm=e=>e.type==="freedraw"?e.strokeWidth*12:20,Rg=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=CE/100),o},A6=(e,t,r)=>{let i=jm(e),[a,l,s,c]=re(e,t),d=ne(e)||Dt(e)?Pt(a,s):e.width,m=ne(e)||Dt(e)?Pt(l,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,h=r.value;return(p*h>32767||u*h>32767)&&(h=Math.min(32767/p,32767/u)),p*u*h*h>16777216&&(h=Math.sqrt(16777216/(p*u))),p=Math.floor(p*h),u=Math.floor(u*h),{width:p,height:u,scale:h}},k6=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),l=jm(e),{width:s,height:c,scale:d}=A6(e,t,r);i.width=s,i.height=c;let m=0,p=0;if(ne(e)||Dt(e)){let[h,E]=re(e,t);m=e.x>h?Pt(e.x,h)*window.devicePixelRatio*d:0,p=e.y>E?Pt(e.y,E)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(l*d,l*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=Uy.canvas(i);return Wy(e,o,n)&&(a.filter=ag),Xm(e,u,a,o,n),a.restore(),{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:me(e,t)?.version||null,containingFrameOpacity:Ht(e,t)?.opacity||100}},ny=14,Vy=document.createElement("img");Vy.src=`data:${te.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;Yy=document.createElement("img");Yy.src=`data:${te.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;M6=(e,t,r)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let o=Math.min(e.width,e.height),n=Math.min(o,Math.min(o*.4,100));t.drawImage(e.status==="error"?Yy:Vy,e.width/2-n/2,e.height/2-n/2,n,n)},Xm=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(Pe.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",Pe.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=L6(e),a=Pe.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=sr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,ko(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):M6(e,r,n.zoom.value);break}default:if(G(e)){let i=Sd(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Ye(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let l=e.text.replace(/\r\n?/g,`
32
+ `).map(i=>i.trim().split(","))),t.length===0)return{type:rs,reason:"No values"};let r=t[0].length;if(!t.every(i=>i.length===r))return{type:rs,reason:"All rows don't have same number of columns"};let n=Jv(t);if(n.type!==xl){let i=Jv(dM(t));if(i.type===xl)return i}return n},cu=Xx(Gx),Do={fillStyle:"hachure",fontFamily:gr,fontSize:ur,opacity:100,roughness:1,strokeColor:Ee.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:kt.MIDDLE,locked:!1},tT=e=>{let t=(un+st)*e.values.length+st,r=oa+st*2;return{chartWidth:t,chartHeight:r}},mM=(e,t,r,o,n)=>e.labels?.map((i,a)=>jt({groupIds:[o],backgroundColor:n,...Do,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(un+st)+st*2,y:r+st/2,width:un,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],pM=(e,t,r,o,n)=>{let i=jt({groupIds:[o],backgroundColor:n,...Do,x:t-st,y:r-st,text:"0",textAlign:"right"}),a=jt({groupIds:[o],backgroundColor:n,...Do,x:t-st,y:r-oa-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},uM=(e,t,r,o,n)=>{let{chartWidth:i,chartHeight:a}=tT(e),s=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r,width:i,points:[[0,0],[i,0]]}),l=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r,height:a,points:[[0,0],[0,-a]]}),c=nn({backgroundColor:n,groupIds:[o],...Do,type:"line",x:t,y:r-oa-st,strokeStyle:"dotted",width:i,opacity:Qv,points:[[0,0],[i,0]]});return[s,l,c]},rT=(e,t,r,o,n,i)=>{let{chartWidth:a,chartHeight:s}=tT(e),l=e.title?jt({backgroundColor:n,groupIds:[o],...Do,text:e.title,x:t+a/2,y:r-oa-st*2-ur,roundness:null,textAlign:"center"}):null,c=i?go({backgroundColor:n,groupIds:[o],...Do,type:"rectangle",x:t,y:r-s,width:a,height:s,strokeColor:Ee.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...l?[l]:[],...mM(e,t,r,o,n),...pM(e,t,r,o,n),...uM(e,t,r,o,n)]},gM=(e,t,r)=>{let o=Math.max(...e.values),n=Ut(),i=cu[Math.floor(Math.random()*cu.length)];return[...e.values.map((s,l)=>{let c=s/o*oa;return go({backgroundColor:i,groupIds:[n],...Do,type:"rectangle",x:t+l*(un+st)+st,y:r-c-st,width:un,height:c})}),...rT(e,t,r,n,i,T.DEV)]},hM=(e,t,r)=>{let o=Math.max(...e.values),n=Ut(),i=cu[Math.floor(Math.random()*cu.length)],a=0,s=[];for(let h of e.values){let x=a*(un+st),v=-(h/o)*oa;s.push([x,v]),a++}let l=Math.max(...s.map(h=>h[0])),c=Math.max(...s.map(h=>h[1])),d=Math.min(...s.map(h=>h[0])),m=Math.min(...s.map(h=>h[1])),p=nn({backgroundColor:i,groupIds:[n],...Do,type:"line",x:t+st+un/2,y:r-st,height:c-m,width:l-d,strokeWidth:2,points:s}),u=e.values.map((h,x)=>{let v=x*(un+st)+st/2,y=-(h/o)*oa+st/2;return go({backgroundColor:i,groupIds:[n],...Do,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+v+un/2,y:r+y-st*2,width:st,height:st})}),g=e.values.map((h,x)=>{let v=x*(un+st)+st/2,y=h/o*oa+st/2+st;return nn({backgroundColor:i,groupIds:[n],...Do,type:"line",x:t+v+un/2+st/2,y:r-y,height:y,strokeStyle:"dotted",opacity:Qv,points:[[0,0],[0,y]]})});return[...rT(e,t,r,n,i,T.DEV),p,...g,...u]},oT=(e,t,r,o)=>e==="line"?hM(t,r,o):gM(t,r,o)});function iT(e){let t=[];for(let r of e.childNodes)if(r.nodeType===3){let o=r.textContent?.trim();o&&t.push({type:"text",value:o})}else if(r instanceof HTMLImageElement){let o=r.getAttribute("src");o&&o.startsWith("http")&&t.push({type:"imageUrl",value:o})}else t=t.concat(iT(r));return t}var uW,du,yl,fM,nT,bM,mu,EM,xM,aT,yM,pu,uu,wi,wM,na=X(()=>{"use strict";f();db();Y();me();Nn();De();vr();V();uW="clipboard"in navigator&&"readText"in navigator.clipboard,du="clipboard"in navigator&&"writeText"in navigator.clipboard,yl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,fM=e=>!!([hr.excalidraw,hr.excalidrawClipboard,hr.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),nT=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[o,n]of Object.entries(e))try{if(r.clipboardData?.setData(o,n),r.clipboardData?.getData(o)!==n)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}if(t){let o=-1;for(let n of t){o++;try{if(r.clipboardData?.items.add(n),r.clipboardData?.files[o]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return r},bM=({elements:e,files:t})=>{let r=Z(e),o=new Set(e.filter(s=>Q(s))),n=!1,i=e.reduce((s,l)=>(kr(l)&&(n=!0,t&&t[l.fileId]&&(s[l.fileId]=t[l.fileId])),s),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:hr.excalidrawClipboard,elements:e.map(s=>{if(Qt(s,r)&&!o.has(Qt(s,r))){let l=an(s);return F(l,{frameId:null}),l}return s}),files:t?i:void 0};return JSON.stringify(a)},mu=async(e,t,r)=>{await wi(bM({elements:e,files:t}),r)},EM=e=>{let t=eT(e);return t.type===xl?{spreadsheet:t.spreadsheet}:null};xM=e=>{let t=e.clipboardData?.getData("text/html");if(!t)return null;try{let r=new DOMParser().parseFromString(t,"text/html"),o=iT(r.body);if(o.length)return{type:"mixedContent",value:o}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},aT=async()=>{let e={};try{if(navigator.clipboard?.readText)return{"text/plain":await navigator.clipboard?.readText()}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else throw r}let t;try{t=await navigator.clipboard?.read()}catch(r){if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}for(let r of t)for(let o of r.types)if(Sc(o0,o))try{e[o]=await(await r.getType(o)).text()}catch(n){console.warn(`Cannot retrieve ${o} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},yM=async(e,t=!1)=>{try{let r=!t&&e&&xM(e);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData("text/plain")||r.value.map(n=>n.value).join(`
33
+ `).trim()}:r:{type:"text",value:(e.clipboardData?.getData("text/plain")||"").trim()}}catch{return{type:"text",value:""}}},pu=async(e,t=!1)=>{let r=await yM(e,t);if(r.type==="mixedContent")return{mixedContent:r.value};try{let o=!t&&EM(r.value);if(o)return o}catch(o){console.error(o)}try{let o=JSON.parse(r.value),n=o.type===hr.excalidrawClipboardWithAPI;if(fM(o))return{elements:o.elements,files:o.files,text:t?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:r.value}},uu=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[se.png]:e})])}catch(t){if(Cn(e))await navigator.clipboard.write([new window.ClipboardItem({[se.png]:await e})]);else throw t}},wi=async(e,t)=>{if(du)try{await navigator.clipboard.writeText(e||"");return}catch(r){console.error(r)}try{if(t){if(t.clipboardData?.setData("text/plain",e||""),t.clipboardData?.getData("text/plain")!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}if(!wM(e))throw new Error("Error copying to clipboard.")},wM=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[t?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${o}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),r.setSelectionRange(0,r.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return r.remove(),n}});var ia,gu,wl,vM,os=X(()=>{"use strict";f();md();Zr();el();Y();tl();mi();na();ia=({elements:e,appState:t,files:r,maxWidthOrHeight:o,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:s,appState:l}=Xi({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:d}=l;return su(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},r||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let h=Math.max(m,p),x=o<h?o/h:t?.exportScale??1;return u.width=m*x,u.height=p*x,{canvas:u,scale:x}}let g=n?.(m,p)||{width:m,height:p};return u.width=g.width,u.height=g.height,{canvas:u,scale:g.scale??1}})},gu=async e=>{let{mimeType:t=se.png,quality:r}=e;t===se.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${se.png}" mimeType`),t==="image/jpg"&&(t=se.jpg),t===se.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${se.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await ia(e);return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((n,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&t===se.png&&e.appState?.exportEmbedScene&&(a=await Ef({blob:a,metadata:Vi(e.elements,e.appState,e.files||{},"local")})),n(a)},t,r)})},wl=async({elements:e,appState:t=lr(),files:r={},exportPadding:o,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a})=>{let{elements:s,appState:l}=Xi({elements:e,appState:t},null,null),c={...l,exportPadding:o};return bl(s,c,r,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a})},vM=async e=>{if(e.type==="svg"){let t=await wl(e);await wi(t.outerHTML)}else if(e.type==="png")await uu(gu(e));else if(e.type==="json")await mu(e.elements,e.files);else throw new Error("Invalid export type")}});var TM,SM,sT,lT,mb,cT,pb,ub=X(()=>{"use strict";f();me();mt();dt();V();TM=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],SM=e=>ie(e)||Zt(e)?e.points:TM(e),sT=e=>{let t=e.reduce((r,[o,n])=>(r.minY=Math.min(r.minY,n),r.minX=Math.min(r.minX,o),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,n),r),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},lT=e=>{let t=SM(e),{cx:r,cy:o}=sT(t),n=[r,o],i=t.map(d=>ce([d[0],d[1]],n,e.angle)),{minX:a,minY:s,maxX:l,maxY:c}=sT(i);return[a+e.x,s+e.y,l+e.x,c+e.y]},mb=(e,t,r=!1)=>{let o=lT(e),n=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return r?n?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:n},cT=(e,t)=>{let r=lT(e);return(gd(r[0],t[0],t[2])||gd(t[0],r[0],r[2]))&&(gd(r[1],t[1],t[3])||gd(t[1],r[1],r[3]))},pb=({elements:e,bounds:t,type:r,errorMargin:o=0})=>{Ac(t)&&(t=ho(t,Z(e)));let n=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],i=new Set;for(let a of e){if(i.has(a.id))continue;if(r==="overlap"?cT(a,n):r==="inside"?mb(a,n):mb(a,n,!0)){if(i.add(a.id),a.boundElements)for(let l of a.boundElements)i.add(l.id);H(a)&&a.containerId&&i.add(a.containerId),ne(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))}});function dT(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function uT(e,t){return e[0]*t[1]-t[0]*e[1]}function IM(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function hu(e,t){return[e[0]-t[0],e[1]-t[1]]}function mT(e,t){let r=hu(e[1],e[0]),o=hu(t,e[0]),n=uT(r,o);return Math.abs(n)<CM}function gb(e,t){let r=hu(e[1],e[0]),o=hu(t,e[0]);return uT(r,o)<0}function pT(e,t){return mT(e,t[0])||mT(e,t[1])||(gb(e,t[0])?!gb(e,t[1]):gb(e,t[1]))}function gT(e,t){return IM(dT(e),dT(t))&&pT(e,t)&&pT(t,e)}var CM,hT=X(()=>{"use strict";f();CM=1e-6});var fT=X(()=>{"use strict";f();os();ub();hT();dt()});function bT(e,t,r){let o=hb(t,r),n=hb(e,r);return o.some(a=>n.some(s=>gT(a,s)))}var fu,ET,xT,yT,Bn,fb,wT,bo,pd,lb,vl,vT,Qt,TT,hd,Tl,bb,bu,zn,Eu,nu,ts,lu,El,vr=X(()=>{"use strict";f();we();mt();He();V();De();et();Gt();dt();fT();me();fu=(e,t,r)=>{let o=Z(e);for(let n of t)if(n.frameId){let i=r.get(n.id),a=r.get(n.frameId);if(i){let s=o.get(i);s&&F(s,{frameId:a??n.frameId},!1)}}};ET=(e,t,r)=>Eu(Sl(e,t,r,!1)).filter(o=>!Q(o)&&!o.frameId||o.frameId===t.id),xT=(e,t,r,o)=>Sl(e,t,o).some(n=>n.id===r.id),yT=(e,t,r)=>{let[o,n,i,a]=ae(t,r),[s,l,c,d]=Te(e);return o<=s&&n<=l&&i>=c&&a>=d},Bn=(e,t,r)=>yT([e],t,r)||bT(e,t,r)||xT([t],e,t,r),fb=(e,t,r)=>{let[o,n,i,a]=ae(t,r);return Op([o,n],[e.x,e.y],[i,a])},wT=e=>{let t=new Map;for(let r of e){let o=Q(r)?r.id:r.frameId;o&&!t.has(o)&&t.set(o,bo(e,o))}return t},bo=(e,t)=>{let r=[];for(let o of e.values())o.frameId===t&&r.push(o);return r},pd=e=>e.filter(t=>Q(t)),lb=e=>{let t=Z(pd(e));return e.filter(r=>t.has(r.id)||!r.frameId||!t.has(r.frameId))},vl=(e,t,r,o)=>{let n=bo(e,t.id),i=new Set(n),a=new Set([...ET(e,t,o),...n.filter(p=>xT(e,p,t,o))]),s=n.filter(p=>!a.has(p)),l=new Set(Array.from(a).flatMap(p=>p.groupIds));for(let p of s)if(!bT(p,t,o))p.groupIds.length===0&&i.delete(p);else if(p.groupIds.length>0)for(let u of p.groupIds)l.add(u);for(let p of s)if(p.groupIds.length>0){let u=!0;for(let g of p.groupIds)l.has(g)&&(u=!1);u&&i.delete(p)}let c=Array.from(a).filter(p=>p.groupIds.length===0);for(let p of c)i.add(p);let d=Array.from(a).filter(p=>p.groupIds.length>0),m=Vm(d,r);for(let[p,u]of Object.entries(m))if(u){let g=ot(e,p);if(yT(g,t,o))for(let h of g)i.add(h)}return[...i].filter(p=>!(H(p)&&p.containerId))},vT=(e,t,r)=>Eu(e,ET(e,t,r)),Qt=(e,t)=>e.frameId&&t.get(e.frameId)||null,TT=(e,t)=>{let r=new Set,o=Z(e);e=Eu(e);for(let a of e)Q(a)&&a.id!==t.id&&r.add(a.id);let n=new Set,i=[];for(let a of e)if(!(Q(a)||a.frameId&&r.has(a.frameId)))if(a.groupIds.length){let s=a.groupIds.at(-1);if(!n.has(s)){n.add(s);let l=ot(e,s);if(l.some(c=>Bn(c,t,o)))for(let c of l)i.push(c)}}else Bn(a,t,o)&&i.push(a);return i},hd=(e,t,r)=>{let o=Z(e),n=new Map;for(let l of e.values())l.frameId===r.id&&n.set(l.id,!0);let i=new Set(t.map(l=>l.id)),a=[],s=new Set;for(let l of t)Q(l)&&l.id!==r.id&&s.add(l.id);for(let l of Eu(e,t)){if(Q(l)||l.frameId&&s.has(l.frameId))continue;n.has(l.id)||a.push(l);let c=J(l,o);c&&!i.has(c.id)&&!n.has(c.id)&&a.push(c)}for(let l of a)F(l,{frameId:r.id},!1);return e},Tl=(e,t)=>{let r=new Map,o=new Map;for(let n of e)if(n.frameId){r.set(n.id,n);let i=o.get(n.frameId)||[];i.push(n);let a=J(n,t);a&&(r.set(a.id,a),i.push(a)),o.set(n.frameId,i)}for(let[,n]of r)F(n,{frameId:null},!1)},bb=(e,t)=>{let r=bo(e,t.id);return Tl(r,Z(e)),e},bu=(e,t,r,o)=>hd(bb(e,r),t,r).slice(),zn=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),n=new Set(o);if(t.editingGroupId)for(let s of o)s.groupIds.length===0?n.add(s):s.groupIds.flatMap(l=>ot(e,l)).forEach(l=>n.add(l));let i=new Set,a=Z(e);return n.forEach(s=>{s.frameId&&!Q(s)&&!ts(s,a,t)&&i.add(s)}),i.size>0&&Tl(i,a),e},Eu=(e,t)=>{let r=new Set,o=t||e;for(let a of o.values()){let s=a.groupIds[a.groupIds.length-1];s&&r.add(s)}let n=new Set;for(let a of r)ot(e,a).some(s=>Q(s))&&n.add(a);let i=[];for(let a of o.values())n.has(a.groupIds[a.groupIds.length-1])||i.push(a);return i},nu=(e,t,r)=>{let o=H(e)&&Et(e,t)||e;return r.selectedElementIds[o.id]&&r.selectedElementsAreBeingDragged?r.frameToHighlight:Qt(o,t)},ts=(e,t,r)=>{let o=nu(e,t,r),n=H(e)&&Et(e,t)||e;if(o){if(!r.selectedElementIds[e.id]||!r.selectedElementsAreBeingDragged)return!0;if(n.groupIds.length===0)return Bn(n,o,t);let i=new Set(n.groupIds.flatMap(a=>ot(t,a)));if(r.editingGroupId&&r.selectedElementsAreBeingDragged){let a=new Set(he(t,r));if(r.frameToHighlight!==null)return!0;a.forEach(l=>{i.delete(l)})}for(let a of i)if(Q(a))return!1;for(let a of i)if(Bn(a,o,t))return!0}return!1},lu=e=>e.name===null?B0(e)?"Frame":"AI Frame":e.name,El=(e,t)=>pb({elements:e,bounds:t,type:"overlap"}).filter(r=>!r.frameId||r.frameId===t.id)});import AT from"roughjs/bin/rough";import{getStroke as AM}from"perfect-freehand";function RT(e){let t=qp(e),r=new Path2D(t);return _T.set(e,r),r}function DM(e){return _T.get(e)}function qp(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,n],i)=>[o,n,e.pressures[i]]):[[0,0,.5]],r={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return RM(AM(t,r))}function CT(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function RM(e){if(!e.length)return"";let t=e.length-1;return e.reduce((r,o,n,i)=>(n===t?r.push(o,CT(o,i[0]),"L",i[0],"Z"):r.push(o,CT(o,i[n+1])),r),["M",e[0],"Q"]).join(" ").replace(_M,"$1")}var eb,MM,MT,kT,yu,Eb,kM,PM,Vv,PT,LT,LM,xu,jm,ST,IT,DT,fl,_T,_M,li=X(()=>{"use strict";f();me();dt();V();mt();Zr();Y();He();Wt();vr();Qo();on();eb="invert(100%) hue-rotate(180deg) saturate(1.25)",MM=lr(),MT=(e,t)=>kr(e)&&!t.imageCache.has(e.fileId),kT=(e,t,r)=>r.theme===ue.DARK&&kr(e)&&!MT(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==se.svg,yu=e=>{switch(e.type){case"freedraw":return e.strokeWidth*12;case"text":return e.fontSize/2;default:return 20}},Eb=(e,t,r)=>{let o=(t?.opacity??100)*e.opacity/1e4;return(r.has(e.id)||t&&r.has(t.id))&&(o*=b0/100),o},kM=(e,t,r)=>{let i=yu(e),[a,s,l,c]=ae(e,t),d=ie(e)||Zt(e)?Ht(a,l):e.width,m=ie(e)||Zt(e)?Ht(s,c):e.height,p=d*window.devicePixelRatio+i*2,u=m*window.devicePixelRatio+i*2,g=r.value;return(p*g>32767||u*g>32767)&&(g=Math.min(32767/p,32767/u)),p*u*g*g>16777216&&(g=Math.sqrt(16777216/(p*u))),p=Math.floor(p*g),u=Math.floor(u*g),{width:p,height:u,scale:g}},PM=(e,t,r,o,n)=>{let i=document.createElement("canvas"),a=i.getContext("2d"),s=yu(e),{width:l,height:c,scale:d}=kM(e,t,r);i.width=l,i.height=c;let m=-100,p=0;if(ie(e)||Zt(e)){let[v,y]=ae(e,t);m=e.x>v?Ht(e.x,v)*window.devicePixelRatio*d:0,p=e.y>y?Ht(e.y,y)*window.devicePixelRatio*d:0,a.translate(m,p)}a.save(),a.translate(s*d,s*d),a.scale(window.devicePixelRatio*d,window.devicePixelRatio*d);let u=AT.canvas(i);kT(e,o,n)&&(a.filter=eb),xu(e,u,a,o,n),a.restore();let g=J(e,t),h=document.createElement("canvas"),x=h.getContext("2d");if(ne(e)&&g){let[v,y,w,C]=ae(e,t),M=Math.max(Ht(v,w),Ht(y,C));h.width=M*window.devicePixelRatio*d+s*d*10,h.height=M*window.devicePixelRatio*d+s*d*10,x.translate(h.width/2,h.height/2),x.rotate(e.angle),x.drawImage(i,-i.width/2,-i.height/2,i.width,i.height);let[,,,,I,P]=ae(g,t);x.rotate(-e.angle);let A=(h.width-i.width)/2,N=(h.height-i.height)/2,k=h.width/2-(I-v)*window.devicePixelRatio*d-A-s*d,D=h.height/2-(P-y)*window.devicePixelRatio*d-N-s*d;x.translate(-k,-D),x.clearRect(-(g.width/2+wt)*window.devicePixelRatio*d,-(g.height/2+wt)*window.devicePixelRatio*d,(g.width+wt*2)*window.devicePixelRatio*d,(g.height+wt*2)*window.devicePixelRatio*d)}return{element:e,canvas:i,theme:n.theme,scale:d,zoomValue:r.value,canvasOffsetX:m,canvasOffsetY:p,boundTextElementVersion:J(e,t)?.version||null,containingFrameOpacity:Qt(e,t)?.opacity||100,boundTextCanvas:h,angle:e.angle}},Vv=14,PT=document.createElement("img");PT.src=`data:${se.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;LT=document.createElement("img");LT.src=`data:${se.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;LM=(e,t)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let r=Math.min(e.width,e.height),o=Math.min(r,Math.min(r*.4,100));t.drawImage(e.status==="error"?LT:PT,e.width/2-o/2,e.height/2-o/2,o,o)},xu=(e,t,r,o,n)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{r.lineJoin="round",r.lineCap="round",t.draw(_e.get(e));break}case"arrow":case"line":{r.lineJoin="round",r.lineCap="round",_e.get(e).forEach(i=>{t.draw(i)});break}case"freedraw":{r.save(),r.fillStyle=e.strokeColor;let i=DM(e),a=_e.get(e);a&&t.draw(a),r.fillStyle=e.strokeColor,r.fill(i),r.restore();break}case"image":{let i=kr(e)?o.imageCache.get(e.fileId)?.image:void 0;i!=null&&!(i instanceof Promise)?(e.roundness&&r.roundRect&&(r.beginPath(),r.roundRect(0,0,e.width,e.height,fo(Math.min(e.width,e.height),e)),r.clip()),r.drawImage(i,0,0,e.width,e.height)):LM(e,r);break}default:if(H(e)){let i=Rm(e.text),a=i&&!r.canvas.isConnected;a&&document.body.appendChild(r.canvas),r.canvas.setAttribute("dir",i?"rtl":"ltr"),r.save(),r.font=Me(e),r.fillStyle=e.strokeColor,r.textAlign=e.textAlign;let s=e.text.replace(/\r\n?/g,`
54
34
  `).split(`
55
- `),s=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=ui(e.fontSize,e.lineHeight),d=jd(e.fontFamily,e.fontSize,c);for(let m=0;m<l.length;m++)r.fillText(l[m],s,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},Zm=new WeakMap,Fy=(e,t,r,o)=>{let n=r?o.zoom:C6.zoom,i=Zm.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,l=me(e,t)?.version||null,s=Ht(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==l||i.containingFrameOpacity!==s){let c=k6(e,t,n,r,o);return Zm.set(e,c),c}return i},zy=(e,t,r,o,n)=>{let i=e.element,a=jm(i),l=e.scale,[s,c,d,m]=re(i,n);Dt(i)&&(s=Math.floor(s),d=Math.ceil(d),c=Math.floor(c),m=Math.ceil(m));let p=((s+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let h=me(i,n);if(we(i)&&h){let E=document.createElement("canvas"),x=E.getContext("2d"),w=Math.max(Pt(s,d),Pt(c,m));E.width=w*window.devicePixelRatio*l+a*e.scale*10,E.height=w*window.devicePixelRatio*l+a*e.scale*10;let y=(E.width-e.canvas.width)/2,v=(E.height-e.canvas.height)/2;x.translate(E.width/2,E.height/2),x.rotate(i.angle),x.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);let[,,,,I,L]=re(h,n);x.rotate(-i.angle);let C=E.width/2-(I-s)*window.devicePixelRatio*l-y-a*l,M=E.height/2-(L-c)*window.devicePixelRatio*l-v-a*l;x.translate(-C,-M),x.clearRect(-(h.width/2+bt)*window.devicePixelRatio*l,-(h.height/2+bt)*window.devicePixelRatio*l,(h.width+bt*2)*window.devicePixelRatio*l,(h.height+bt*2)*window.devicePixelRatio*l),t.translate(p,u),t.drawImage(E,-(d-s)/2*window.devicePixelRatio-y/l-a,-(m-c)/2*window.devicePixelRatio-v/l-a,E.width/l,E.height/l)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!Gy(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(s+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&tr(i)){let E=me(i,n),x=Kh(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((x.x+o.scrollX)*window.devicePixelRatio,(x.y+o.scrollY)*window.devicePixelRatio,vr(i,E)*window.devicePixelRatio,pa(i,E)*window.devicePixelRatio)}t.restore()},Ky=(e,t,r)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let o=.5/r.zoom.value;t.fillRect(o,o,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=" rgb(105, 101, 219)",t.strokeRect(o,o,e.width,e.height),t.restore()},Sl=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=Rg(e,Ht(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=je.strokeWidth/a.zoom.value,n.strokeStyle=je.strokeColor,qi(e)&&(n.strokeStyle=a.theme===ae.LIGHT?"#7affd7":"#1d8264"),je.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,je.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(Pe.generateElementShape(e,null),i.isExporting){let[l,s,c,d]=re(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-h),Xm(e,o,n,i,a),n.restore()}else{let l=Fy(e,t,i,a);zy(l,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(Pe.generateElementShape(e,i),i.isExporting){let[l,s,c,d]=re(e,t),m=(l+c)/2+a.scrollX,p=(s+d)/2+a.scrollY,u=(c-l)/2-(e.x-l),h=(d-s)/2-(e.y-s);if(G(e)){let x=pt(e,t);if(we(x)){let w=X.getBoundTextElementPosition(x,e,t);u=(c-l)/2-(w.x-l),h=(d-s)/2-(w.y-s)}}n.save(),n.translate(m,p),Wy(e,i,a)&&(n.filter="none");let E=me(e,t);if(we(e)&&E){let x=document.createElement("canvas"),w=x.getContext("2d"),y=Math.max(Pt(l,c),Pt(s,d)),v=jm(e);x.width=y*a.exportScale+v*10*a.exportScale,x.height=y*a.exportScale+v*10*a.exportScale,w.translate(x.width/2,x.height/2),w.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-l),h=e.height/2-(e.y-s),w.rotate(e.angle);let I=Uy.canvas(x);w.translate(-u,-h),Xm(e,I,w,i,a),w.translate(u,h),w.rotate(-e.angle);let[,,,,L,C]=re(E,t),M=(l+c)/2-L,_=(s+d)/2-C;w.translate(-M,-_),w.clearRect(-E.width/2,-E.height/2,E.width,E.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(x,-x.width/2,-x.height/2,x.width,x.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-h),Xm(e,o,n,i,a);n.restore()}else{let l=Fy(e,t,i,a),s=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||rx(e.angle))&&(n.imageSmoothingEnabled=!1),zy(l,n,i,a,r),n.imageSmoothingEnabled=s}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},$y=new WeakMap([]);P6=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});import{RoughGenerator as _6}from"roughjs/bin/generator";var Pe,Xo=j(()=>{"use strict";f();Tn();wh();Qt();Pe=class e{static rg=new _6;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,r)=>e.cache.set(t,r);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,r)=>{let o=r?.isExporting?void 0:e.get(t);if(o!==void 0)return o;Zm.delete(t);let n=ax(t,e.rg,r||{isExporting:!1,canvasBackgroundColor:de.white,embedsValidationStatus:null});return e.cache.set(t,n),n}}});var F,ie,gi,Ue=j(()=>{"use strict";f();ni();Ls();Co();U();Xo();F=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={..._d(n),...t});for(let a in t){let l=t[a];if(typeof l<"u"){if(e[a]===l&&(typeof l!="object"||l===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let s=e[a],c=l;if(s[0]===c[0]&&s[1]===c[1])continue}else if(a==="points"){let s=e[a],c=l;if(s.length===c.length){let d=!1,m=s.length;for(;--m;){let p=s[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=l,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&Pe.delete(e),e.version++,e.versionNonce=oo(),e.updated=wn(),r&&Ct.getScene(e)?.informMutation()),e},ie=(e,t)=>{let r=!1;for(let o in t){let n=t[o];if(typeof n<"u"){if(e[o]===n&&(typeof n!="object"||n===null))continue;r=!0}}return r?{...e,...t,updated:wn(),version:e.version+1,versionNonce:oo()}:e},gi=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=oo(),e.updated=wn(),e)});var lo,wa,qm,ml,nc,va=j(()=>{"use strict";f();Ue();se();Y();lt();U();lo=e=>ne(e)||Dt(e)?e.points.length<2:e.width===0&&e.height===0,wa=(e,t,r,o,n)=>{let[i,a,l,s]=Ur(e,n),c=Ke({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=Ke({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=l&&c.y<=s&&d.x>=i&&d.y>=a},qm=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/Uo)*Uo;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},ml=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/Uo)*Uo;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let l=Math.tan(a),s=-1,c=t-l*e,d=-1/l,m=-1,p=o-d*r,u=(s*p-m*c)/(l*m-d*s),h=(c*d-p*l)/(l*m-d*s);n=u-e,i=h-t}return{width:n,height:i}},nc=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var Xy,R6,jy,N6,Zy,Ng,Fn,Jm,Ta,_l,gc,Qm,fc=j(()=>{"use strict";f();lt();Ft();be();se();Y();Xy={mouse:8,pen:16,touch:28},R6=16,jy={e:!0,s:!0,n:!0,w:!0},N6={e:!0,s:!0,n:!0,w:!0},Zy={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Ng={e:!0,s:!0,n:!0,w:!0},Fn=(e,t,r,o,n,i,a)=>{let[l,s]=ye(e+r/2,t+o/2,n,i,a);return[l-r/2,s-o/2,r,o]},Jm=e=>!(e.viewport.isMobile||e.isTouchScreen&&(iE||md)),Ta=e=>Jm(e)?jy:{},_l=([e,t,r,o,n,i],a,l,s,c={},d=4)=>{let m=Xy[s],p=m/l.value,u=m/l.value,h=m/l.value,E=m/l.value,x=r-e,w=o-t,y=d/l.value,v=(m-Jn*2)/(2*l.value),I={nw:c.nw?void 0:Fn(e-y-h+v,t-y-E+v,p,u,n,i,a),ne:c.ne?void 0:Fn(r+y-v,t-y-E+v,p,u,n,i,a),sw:c.sw?void 0:Fn(e-y-h+v,o+y-v,p,u,n,i,a),se:c.se?void 0:Fn(r+y-v,o+y-v,p,u,n,i,a),rotation:c.rotation?void 0:Fn(e+x/2-p/2,t-y-E+v-R6/l.value,p,u,n,i,a)},L=5*Xy.mouse/l.value;return Math.abs(x)>L&&(c.n||(I.n=Fn(e+x/2-p/2,t-y-E+v,p,u,n,i,a)),c.s||(I.s=Fn(e+x/2-p/2,o+y-v,p,u,n,i,a))),Math.abs(w)>L&&(c.w||(I.w=Fn(e-y-h+v,t+w/2-u/2,p,u,n,i,a)),c.e||(I.e=Fn(r+y-v,t+w/2-u/2,p,u,n,i,a))),I},gc=(e,t,r,o="mouse",n=jy)=>{if(e.locked)return{};if(e.type==="freedraw"||ne(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=Ng:a[0]>0&&a[1]<0?n=Zy:a[0]>0&&a[1]>0?n=Ng:a[0]<0&&a[1]>0?n=Zy:a[0]<0&&a[1]<0&&(n=Ng)}}else G(e)?n=N6:ee(e)&&(n={...n,rotation:!0});let i=ne(e)?Jn+8:Jn;return _l(re(e,r,!0),e.angle,t,o,n,i)},Qm=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return ne(r)?r.points.length>2:!0}});var Bg,qy,ep,tp,Og,O6,rp,Jy,Qy=j(()=>{"use strict";f();fc();lt();Y();zd();se();Bg=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],qy=(e,t,r,o,n,i,a,l)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:s,...c}=gc(e,i,t,a,Ta(l));if(s&&Bg(s,o,n))return"rotation";let d=Object.keys(c).filter(m=>{let p=c[m];return p?Bg(p,o,n):!1});if(d.length>0)return d[0];if(Jm(l)){let[m,p,u,h,E,x]=re(e,t);if(e.type!=="text"&&!(ne(e)&&e.points.length<=2)){let w=hd/i.value,y=Jy([m-w,p-w],[u+w,h+w],[E,x],Zo(e.angle));for(let[v,I]of Object.entries(y))if(ia([o,n],I,w))return v}}return!1},ep=(e,t,r,o,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let d=qy(c,a,t,r,o,n,i,l);return d?{element:c,transformHandleType:d}:null},null),tp=([e,t,r,o],n,i,a,l,s)=>{let c=_l([e,t,r,o,(e+r)/2,(t+o)/2],0,a,l,Ta(s)),d=Object.keys(c).find(m=>{let p=c[m];return p&&Bg(p,n,i)});if(d)return d;if(Jm(s)){let m=(e+r)/2,p=(t+o)/2,u=hd/a.value,h=Jy([e-u,t-u],[r+u,o+u],[m,p],Zo(0));for(let[E,x]of Object.entries(h))if(ia([n,i],x,u))return E}return!1},Og=["ns","nesw","ew","nwse"],O6=(e,t)=>{let r=Og.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=Og[(r+o)%Og.length]}return e},rp=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=O6(n,t.angle)),n?`${n}-resize`:""},Jy=([e,t],[r,o],n,i)=>{let a=Et([e,t],i,n),l=Et([r,t],i,n),s=Et([e,o],i,n),c=Et([r,o],i,n);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}}});var op,Fg,B6,F6,zg,z6,H6,Hg,U6,Ug,Gg,Wg=j(()=>{"use strict";f();Y();Ls();Ft();lt();se();Ue();U();io();ni();st();Xt();mr();op=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,Fg=(e,t,r,o,n,i,a,l,s,c,d)=>{if(r.length===1){let[m]=r;return t==="rotation"?(B6(m,o,l,s,n),zr(m,o)):G(m)&&(t==="nw"||t==="ne"||t==="sw"||t==="se")?(z6(m,o,t,i,l,s),zr(m,o)):t&&H6(e,a,m,o,t,i,l,s),!0}else if(r.length>1){if(t==="rotation")return U6(e,r,o,l,s,n,c,d),!0;if(t)return Hg(e,r,o,t,i,a,l,s),!0}return!1},B6=(e,t,r,o,n)=>{let[i,a,l,s]=re(e,t),c=(i+l)/2,d=(a+s)/2,m;ee(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=Uo/2,m-=m%Uo),m=op(m));let p=Po(e);if(F(e,{angle:m}),p){let u=Ct.getScene(e)?.getElement(p);u&&!we(e)&&F(u,{angle:m})}},F6=(e,t,r,o)=>ne(e)||Dt(e)?{points:ai(0,t,ai(1,r,e.points,o),o)}:{},zg=(e,t,r)=>{let o=e.width;if(Ae(e)){let a=pt(e,t);a&&(o=vr(a,e))}let i=e.fontSize*(r/o);return i<ud?null:{size:i}},z6=(e,t,r,o,n,i)=>{let[a,l,s,c,d,m]=re(e,t),[p,u]=ye(n,i,d,m,-e.angle),h=0,E=0;r.includes("e")&&(h=(p-a)/(s-a)),r.includes("w")&&(h=(s-p)/(s-a)),r.includes("n")&&(E=(c-u)/(c-l)),r.includes("s")&&(E=(u-l)/(c-l));let x=Math.max(h,E);if(x>0){let w=e.width*x,y=e.height*x,v=zg(e,t,w);if(v===null)return;let I=[a,l],L=[s,c],C=[d,m],M=[a,l];if(["n","w","nw"].includes(r)&&(M=[L[0]-Math.abs(w),L[1]-Math.abs(y)]),r==="ne"){let q=[I[0],L[1]];M=[q[0],q[1]-Math.abs(y)]}if(r==="sw"){let q=[L[0],I[1]];M=[q[0]-Math.abs(w),q[1]]}["s","n"].includes(r)&&(M[0]=C[0]-w/2),["e","w"].includes(r)&&(M[1]=C[1]-y/2),o&&(M[0]=C[0]-Math.abs(w)/2,M[1]=C[1]-Math.abs(y)/2);let _=e.angle,H=Ge(M,[d,m],_),k=[M[0]+Math.abs(w)/2,M[1]+Math.abs(y)/2],N=Ge(k,[d,m],_);M=Ge(H,N,-_);let[A,B]=M;F(e,{fontSize:v.size,width:w,height:y,x:A,y:B})}},H6=(e,t,r,o,n,i,a,l)=>{let s=e.get(r.id),[c,d,m,p]=ul(s,s.width,s.height,!0),u=[c,d],h=[m,p],E=Ps(u,h),x=Ge([a,l],E,-s.angle),[w,y,v,I]=ul(r,r.width,r.height,!0),L=v-w,C=I-y,M=h[0]-u[0],_=h[1]-u[1],H=M/L,k=_/C,N={},A=me(r,o);n.includes("e")&&(H=(x[0]-u[0])/L),n.includes("s")&&(k=(x[1]-u[1])/C),n.includes("w")&&(H=(h[0]-x[0])/L),n.includes("n")&&(k=(h[1]-x[1])/C);let B=s.width,q=s.height,Z=r.width*H,oe=r.height*k;if(i&&(Z=2*Z-B,oe=2*oe-q),t){let xr=Math.abs(Z)/B,Wa=Math.abs(oe)/q;if(n.length===1&&(oe*=xr,Z*=Wa),n.length===2){let Vi=Math.max(xr,Wa);Z=B*Vi*Math.sign(Z),oe=q*Vi*Math.sign(oe)}}if(A){let xr=e.get(A.id);if(xr&&(N={fontSize:xr.fontSize}),t){let Wa={...r,width:Z,height:oe},Vi=zg(A,o,vr(Wa,A));if(Vi===null)return;N={fontSize:Vi.size}}else{let Wa=Jd(Ye(A),A.lineHeight),Vi=qd(A.fontSize,A.lineHeight);Z=Math.max(Z,Wa),oe=Math.max(oe,Vi)}}let[Te,V,W,he]=ul(s,Z,oe,!0),Ie=W-Te,it=he-V,ke=[...u];if(["n","w","nw"].includes(n)&&(ke=[h[0]-Math.abs(Ie),h[1]-Math.abs(it)]),n==="ne"){let xr=[u[0],h[1]];ke=[xr[0],xr[1]-Math.abs(it)]}if(n==="sw"){let xr=[h[0],u[1]];ke=[xr[0]-Math.abs(Ie),xr[1]]}t&&(["s","n"].includes(n)&&(ke[0]=E[0]-Ie/2),["e","w"].includes(n)&&(ke[1]=E[1]-it/2));let Jr=Z<0,$n=oe<0;Jr&&(n.includes("e")&&(ke[0]-=Math.abs(Ie)),n.includes("w")&&(ke[0]+=Math.abs(Ie))),$n&&(n.includes("s")&&(ke[1]-=Math.abs(it)),n.includes("n")&&(ke[1]+=Math.abs(it))),i&&(ke[0]=E[0]-Math.abs(Ie)/2,ke[1]=E[1]-Math.abs(it)/2);let zo=s.angle,gn=Ge(ke,E,zo),Xn=[ke[0]+Math.abs(Ie)/2,ke[1]+Math.abs(it)/2],Ga=Ge(Xn,E,zo);ke=Ge(gn,Ga,-zo);let yo=[...ke],Rr=s.x-Te,Er=s.y-V;yo[0]+=Rr,yo[1]+=Er;let Wi=yo[0],WI=yo[1],Yb,Kb;(ne(r)||Dt(r))&&(Yb=ai(1,oe,s.points,!0),Kb=ai(0,Z,Yb,!0));let Zn={width:Math.abs(Z),height:Math.abs(oe),x:Wi,y:WI,points:Kb};if("scale"in r&&"scale"in s&&F(r,{scale:[(Math.sign(W-s.x)||s.scale[0])*s.scale[0],(Math.sign(he-s.y)||s.scale[1])*s.scale[1]]}),we(r)&&A&&t){let xr=Zn.width/r.width*A.fontSize;if(xr<ud)return;N.fontSize=xr}Zn.width!==0&&Zn.height!==0&&Number.isFinite(Zn.x)&&Number.isFinite(Zn.y)&&(F(r,Zn),zr(r,o,{newSize:{width:Zn.width,height:Zn.height}}),A&&N!=null&&F(A,{fontSize:N.fontSize}),ca(r,o,n,t))},Hg=(e,t,r,o,n,i,a,l)=>{let s=t.reduce((V,W)=>{let he=e.get(W.id);return he&&V.push({orig:he,latest:W}),V},[]),c=s.reduce((V,{orig:W})=>{if(!ne(W))return V;let he=Po(W);if(!he)return V;let Ie=e.get(he)??null;if(!Ae(Ie))return V;let it=X.getBoundTextElementPosition(W,Ie,r);return[...V,{...Ie,...it}]},[]),{minX:d,minY:m,maxX:p,maxY:u,midX:h,midY:E}=Tr(s.map(({orig:V})=>V).concat(c)),x=p-d,w=u-m,y=o,v={ne:[d,u],se:[d,m],sw:[p,m],nw:[p,u],e:[d,m+w/2],w:[p,m+w/2],n:[d+x/2,u],s:[d+x/2,m]},[I,L]=n?[h,E]:v[y],C=n?2:1,M=Math.max(Math.abs(a-I)/x||0,Math.abs(l-L)/w||0)*C;if(M===0)return;let _=y.includes("e")||y.includes("w")?Math.abs(a-I)/x*C:1,H=y.includes("n")||y.includes("s")?Math.abs(l-L)/w*C:1,k=i||s.some(V=>V.latest.angle!==0||G(V.latest)||c0(V.latest));k&&(_=M,H=M);let N={ne:[a<I,l>L],se:[a<I,l<L],sw:[a>I,l<L],nw:[a>I,l>L],e:[a<I,!1],w:[a>I,!1],n:[!1,l>L],s:[!1,l<L]},[A,B]=N[y].map(V=>V?-1:1),q=A<0,Z=B<0,oe=[];for(let{orig:V,latest:W}of s){if(G(V)&&Ae(V))continue;let he=V.width*_,Ie=V.height*H,it=op(V.angle*A*B),ke=ne(V)||Dt(V),Jr=V.x-I,$n=V.y-L,zo=q&&!ke?he:0,gn=Z&&!ke?Ie:0,Xn=I+A*(Jr*_+zo),Ga=L+B*($n*H+gn),yo=F6(V,he*A,Ie*B,!1),Rr={x:Xn,y:Ga,width:he,height:Ie,angle:it,...yo};if(to(V)&&(Rr.scale=[V.scale[0]*A,V.scale[1]*B]),G(V)){let Wi=zg(V,r,he);if(!Wi)return;Rr.fontSize=Wi.size}let Er=e.get(Po(V)??"");if(Er)if(k){let Wi=Er.fontSize*M;if(Wi<ud)return;Rr.boundTextFontSize=Wi}else Rr.boundTextFontSize=Er.fontSize;oe.push({element:W,update:Rr})}let Te=oe.map(({element:V})=>V);for(let{element:V,update:{boundTextFontSize:W,...he}}of oe){let{width:Ie,height:it,angle:ke}=he;F(V,he,!1),zr(V,r,{simultaneouslyUpdated:Te,newSize:{width:Ie,height:it}});let Jr=me(V,r);Jr&&W&&(F(Jr,{fontSize:W,angle:ne(V)?void 0:ke},!1),ca(V,r,o,!0))}Ct.getScene(oe[0].element)?.informMutation()},U6=(e,t,r,o,n,i,a,l)=>{let s=5*Math.PI/2+Math.atan2(n-l,o-a);i&&(s+=Uo/2,s-=s%Uo),t.filter(c=>!ee(c)).forEach(c=>{let[d,m,p,u]=re(c,r),h=(d+p)/2,E=(m+u)/2,x=e.get(c.id)?.angle??c.angle,[w,y]=ye(h,E,a,l,s+x-c.angle);F(c,{x:c.x+(w-h),y:c.y+(y-E),angle:op(s+x)},!1),zr(c,r,{simultaneouslyUpdated:t});let v=me(c,r);v&&!we(c)&&F(v,{x:v.x+(w-h),y:v.y+(y-E),angle:op(s+x)},!1)}),Ct.getScene(t[0])?.informMutation()},Ug=(e,t,r,o,n)=>{let[i,a,l,s]=t.length===1?re(t[0],r):Se(t),c=(i+l)/2,d=(a+s)/2,m=t.length===1?t[0].angle:0;switch([o,n]=ye(o,n,c,d,-m),e){case"n":return ye(o-(i+l)/2,n-a,0,0,m);case"s":return ye(o-(i+l)/2,n-s,0,0,m);case"w":return ye(o-i,n-(a+s)/2,0,0,m);case"e":return ye(o-l,n-(a+s)/2,0,0,m);case"nw":return ye(o-i,n-a,0,0,m);case"ne":return ye(o-l,n-a,0,0,m);case"sw":return ye(o-i,n-s,0,0,m);case"se":return ye(o-l,n-s,0,0,m);default:return[0,0]}},Gg=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var Vg,G6,ew,Yg,np,tw=j(()=>{"use strict";f();io();lt();Ue();va();st();Ft();se();Vg=(e,t,r,o,n,i,a)=>{let l=new Set(t),s=t.filter(m=>ee(m)).map(m=>m.id);if(s.length>0)for(let m of n.getNonDeletedElements())m.frameId!==null&&s.includes(m.frameId)&&l.add(m);let c=Se(Array.from(l).map(m=>e.originalElements.get(m.id)??m)),d=G6(c,r,i,a);l.forEach(m=>{if(ew(e,m,d),!we(m)){let p=me(m,n.getNonDeletedElementsMap());p&&ew(e,p,d)}zr(m,n.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})})},G6=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,l=i+t.y+r.y;if(r.x===0||r.y===0){let[s,c]=At(n+t.x,i+t.y,o);r.x===0&&(a=s),r.y===0&&(l=c)}return{x:a-n,y:l-i}},ew=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;F(t,{x:n,y:i})},Yg=(e,t,r)=>{let[o,n]=Se(e);return[t-o,r-n]},np=(e,t,r,o,n,i,a,l,s,c,d,m=null)=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:l}=qm(t,l,n<r?-a:a):{width:a,height:l}=qm(t,a,i<o?-l:l),l<0&&(l=-l)));let p=n<r?r-a:r,u=i<o?o-l:o;c&&(a+=a,l+=l,p=r-a/2,u=o-l/2),a!==0&&l!==0&&F(e,{x:p+(m?.x??0),y:u+(m?.y??0),width:a,height:l})}});var Sa,rw=j(()=>{"use strict";f();$e();Sa=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||ue(t,e).length))});var W6,Kg,$g,ow,xe,Ms,nw,X0,wm,be=j(()=>{"use strict";f();va();se();Mn();lt();fc();Qy();Wg();tw();se();st();va();rw();W6=e=>e.reduce((t,r)=>t+r.version,0),Kg=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},$g=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},ow=e=>e.filter(t=>!t.isDeleted&&!lo(t)),xe=e=>e.filter(t=>!t.isDeleted),Ms=e=>!e.isDeleted,nw=e=>xe(e).map(t=>Cs(t.type)?{...t,lastCommittedPoint:null}:t),X0=e=>nw(e),wm=e=>nw(e)});var Ia,Dl,Xg,Ve,Zg,ue,Ca,Re,ii=j(()=>{"use strict";f();be();se();nr();U();va();Ia=e=>{let t=new Set;return e.forEach(r=>{ee(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},Dl=(e,t,r,o=!0)=>{let[n,i,a,l]=re(t,r),s=e.filter(c=>{let[d,m,p,u]=Ur(c,r),h=Ht(c,r);if(h){let[E,x,w,y]=Ur(h,r);d=Math.max(E,d),m=Math.max(x,m),p=Math.min(w,p),u=Math.min(y,u)}return c.locked===!1&&c.type!=="selection"&&!Ae(c)&&n<=d&&i<=m&&a>=p&&l>=u});return s=o?Ia(s):s,s=s.filter(c=>{let d=Ht(c,r);return d?en(c,d,r):!0}),s},Xg=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=wa(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},Ve=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),Zg=(e,t,r)=>{let o=Array.from(new Set(ue(e,t).map(n=>r(n))));return o.length===1?o[0]:null},ue=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&Ae(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{ee(i)&&Yr(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},Ca=(e,t)=>t.editingElement?[t.editingElement]:ue(e,t,{includeBoundTextElement:!0}),Re=(e,t)=>Je(t.selectedElementIds,e)?t.selectedElementIds:e});var V6,jg,Qo,qg=j(()=>{"use strict";f();be();U();V6=(e,t)=>{let[r,o,n,i]=t,{x:a,y:l}=Ot({sceneX:r,sceneY:o},e),{x:s,y:c}=Ot({sceneX:n,sceneY:i},e);return s-a>e.width||c-l>e.height},jg=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),Qo=(e,t)=>{if(e=ow(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=Se(e);V6(t,[r,o,n,i])&&([r,o,n,i]=qh(e,Ke({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,l=(o+i)/2;return jg({scenePoint:{x:a,y:l},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var rn,zn,ip=j(()=>{"use strict";f();Y();rn=e=>Math.max(Za,Math.min(e,30)),zn=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,l=o.scrollX+(n-n/a),s=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:l+c,scrollY:s+d,zoom:{value:r}}}});var $e=j(()=>{"use strict";f();ii();qg();Os();ip()});f();import OD,{useEffect as BD}from"react";f();import{useEffect as c5,useState as d5}from"react";f();f();import Zb from"./en-XW4JO6VX.json";import XI from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as KI,useAtom as KD}from"jotai";import{useLayoutEffect as XD}from"react";var ze=Symbol(),Jt=KI();import{atom as ZI,useAtomValue as jI}from"jotai";var $I=$b({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-XW4JO6VX.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var qI=85,Ho={code:"en",label:"English"},Ya=[Ho,...[{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=>XI[e.code]>=qI).sort((e,t)=>e.label>t.label?1:-1)],id="__test__";T.DEV&&Ya.unshift({code:id,label:"test language"},{code:`${id}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Va=Ho,nd={},ad=async e=>{if(Va=e,document.documentElement.dir=Va.rtl?"rtl":"ltr",document.documentElement.lang=Va.code,e.code.startsWith(id))nd={};else try{nd=await $I(`./locales/${Va.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),nd=Zb}Jt.set(jb,e.code)},fn=()=>Va,Xb=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},b=(e,t,r)=>{if(Va.code.startsWith(id))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=Xb(nd,o)||Xb(Zb,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},jb=ZI(Ho.code),St=()=>{let e=jI(jb,ze);return{t:b,langCode:e}};import{useState as i5,useEffect as a5}from"react";f();import JI from"react";import{jsx as Qu}from"react/jsx-runtime";var QI=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(JI.useRef(Date.now()).current%1600);return Qu("div",{className:"Spinner",children:Qu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:Qu("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Yt=QI;Y();import l5 from"clsx";import{jsx as sh,jsxs as s5}from"react/jsx-runtime";var vd=({delay:e,theme:t})=>{let[r,o]=i5(!!e);return a5(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:s5("div",{className:l5("LoadingMessage",{"LoadingMessage--dark":t===ae.DARK}),children:[sh("div",{children:sh(Yt,{})}),sh("div",{className:"LoadingMessage-text",children:b("labels.loadingScene")})]})};import{jsx as m5}from"react/jsx-runtime";var kE=e=>{let[t,r]=d5(!0);return c5(()=>{let o=async()=>{await ad(n),r(!1)},n=Ya.find(i=>i.code===e.langCode)||Ho;o()},[e.langCode]),t?m5(vd,{theme:e.theme}):e.children};f();import hn,{useContext as Ui}from"react";import{flushSync as Sb}from"react-dom";import bD from"roughjs/bin/rough";import SI from"clsx";import{nanoid as ED}from"nanoid";f();f();$e();ge();f();import Jg,{useEffect as Y6,useRef as iw,useState as K6}from"react";import aw from"clsx";oi();U();import{jsx as bc,jsxs as Ec}from"react/jsx-runtime";var ce=Jg.forwardRef((e,t)=>{let{id:r}=Ut(),o=Jg.useRef(null);Jg.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=K6(!1),l=iw(!0),s=async d=>{let m="onClick"in e&&e.onClick?.(d);if(Wo(m))try{a(!0),await m}catch(p){if(p instanceof $o)console.warn(p);else throw p}finally{l.current&&a(!1)}};Y6(()=>(l.current=!0,()=>{l.current=!1}),[]);let c=iw(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return Ec("button",{className:aw("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:s,ref:o,disabled:i||e.isLoading||!!e.disabled,children:[(e.icon||e.label)&&Ec("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!e.disabled,children:[e.icon||e.label,e.keyBindingLabel&&bc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&bc(Yt,{})]}),e.showAriaLabel&&Ec("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&bc(Yt,{})]}),e.children]})}return Ec("label",{className:aw("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[bc("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),Ec("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&bc("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});ce.defaultProps={visible:!0,className:"",size:"medium"};ce.displayName="ToolButton";Xe();be();Ue();mr();Xt();io();se();U();f();Y();import Ar from"react";import $6 from"open-color";import X6 from"clsx";import{Fragment as De,jsx as g,jsxs as O}from"react/jsx-runtime";var No=e=>"var(--icon-fill-color)",lw=e=>e===ae.LIGHT?$6.white:"#1e1e1e",P=(e,t=512)=>{let{width:r=512,height:o=r,mirror:n,style:i,...a}=typeof t=="number"?{width:t}:t;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${r} ${o}`,className:X6({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},Q={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pU=P(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"})]}),Q),ap=P(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"})]}),Q),sw=P(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"})]}),Q),cw=P(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"})]}),Q),dw=P(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"})]}),Q),Aa=P(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"})})]}),pe),Rl=P(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"})]}),pe),mw=P(O(De,{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"}),pw=P(O(De,{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"}),uw=P(O(De,{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"}),uU=P(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"}),hw=P(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}),gw=P(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"})]}),Q),fw=P(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"})]}),Q),bw=P(O("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),Q),Ew=P(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"})]}),Q),xw=P(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),pe),yw=P(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"})]}),Q),Nl=P(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"})]}),pe),ww=P(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"})]}),Q),vw=P(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"})]}),pe),Tw=P(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"})]}),Q),Qg=P(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),pe),ef=P(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),pe),Sw=P(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"})]}),Q),Oo=P(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"}),pe),Iw=P(O("g",{strokeWidth:"1.25",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),pe),xc=P(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"})]}),pe),yc=P(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"}),pe),wc=P(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"})}),{...pe,strokeWidth:1.5}),lp=P(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"})]}),Q),ka=P(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"}),pe),Ol=P(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"})]}),Q),Cw=P(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"})]}),Q),tf=P(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"}),pe),sp=P(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"}),pe),Aw=P(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"})]}),pe),kw=P(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"})]}),Q),Mw=P(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),vc=P(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"})]}),pe),Lw=P("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}),Pw=P("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}),Bl=P(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"}),pe),hU=P("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}),Dw=P("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"),cp=P(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"})]}),Q),dp=P(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"})]}),Q),_w=P("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}),gU=P("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}),fU=P("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}),Rw=P("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"),bU=P("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"),rf=P(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"}),pe),of=P(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"}),pe),Nw=P("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}),Ow=P(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"}),pe),EU=P("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"),xU=P("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}),yU=P(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"})]}),Q),wU=P(O(De,{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}),vU=P(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}),nf=P(O(De,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.622-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.767-.622-1.39-1.39-1.39Z",fill:"currentColor"}),g("path",{d:"M12.5 12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),af=P(O(De,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.944 12.5H12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388",fill:"currentColor"}),g("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.621-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.768-.622-1.39-1.39-1.39Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),lf=P(O(De,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M8.775 6.458h2.45a2.316 2.316 0 0 1 2.317 2.316v2.452a2.316 2.316 0 0 1-2.316 2.316H8.774a2.316 2.316 0 0 1-2.317-2.316V8.774a2.316 2.316 0 0 1 2.317-2.316Z",fill:"currentColor"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316ZM12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),sf=P(O(De,{children:[O("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"SendToBackIcon",fill:"#fff",children:g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z"})}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z",fill:"currentColor"}),g("path",{d:"M9.167 5.833h1.25v-1.25h-1.25v1.25Zm5 5h1.25v-1.25h-1.25v1.25Zm-3.334 3.334h-1.25v1.25h1.25v-1.25Zm-5-5h-1.25v1.25h1.25v-1.25Zm2.084-3.334v2.06h2.5v-2.06h-2.5Zm0 2.06a4.191 4.191 0 0 0 4.19 4.19v-2.5a1.691 1.691 0 0 1-1.69-1.69h-2.5Zm4.19 4.19h2.06v-2.5h-2.06v2.5Zm.81-1.25v.393h2.5v-.393h-2.5Zm0 .393c0 .933-.758 1.69-1.691 1.69v2.5a4.191 4.191 0 0 0 4.19-4.19h-2.5Zm-1.691 1.69h-.393v2.5h.393v-2.5Zm.857 1.25v-2.058h-2.5v2.059h2.5Zm0-2.058a4.191 4.191 0 0 0-4.19-4.191v2.5c.933 0 1.69.757 1.69 1.69h2.5Zm-4.19-4.191h-2.06v2.5h2.06v-2.5Zm-.81 1.25v-.393h-2.5v.393h2.5Zm0-.393c0-.934.758-1.69 1.692-1.69v-2.5a4.191 4.191 0 0 0-4.192 4.19h2.5Zm1.692-1.69h.392v-2.5h-.392v2.5Z",fill:"currentColor",mask:"url(#SendToBackIcon)"}),g("path",{d:"M12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z",stroke:"currentColor",strokeWidth:"1.25"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),cf=P(O(De,{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"})})})]}),pe),df=P(O(De,{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"})})})]}),pe),mf=P(O(De,{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"})})})]}),pe),pf=P(O(De,{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"})})})]}),pe),Bw=P(O(De,{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"})})})]}),pe),Fw=P(O(De,{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"})})})]}),pe),uf=P(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"})]}),pe),hf=P(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"})]}),pe),mp=P(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"})]}),Q),TU=P("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"),SU=P("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"),co=P(O(De,{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"})})})]}),pe),IU=P("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}),CU=P("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}),AU=P("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}),gf=Ar.memo(({theme:e})=>P(O(De,{children:[g("path",{d:"M25 26H111V111H25",fill:No(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:No(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:No(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:No(e),strokeWidth:"2"}),O("g",{fill:lw(e),stroke:No(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})),ff=Ar.memo(({theme:e})=>P(O(De,{children:[g("path",{d:"M25 26H111V111H25",fill:No(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:No(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:No(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:No(e),strokeWidth:"2"}),O("g",{fill:lw(e),stroke:No(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})),zw=P(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"})}),pe),Hw=P(O(De,{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"})})]}),pe),Uw=P(O(De,{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"})})})]}),pe),Gw=P(O(De,{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"})})})]}),{...pe,fill:"currentColor"}),bf=P(g(De,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),pe),Ww=P(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),pe),Vw=P(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),pe),kU=Ar.memo(({theme:e})=>P(g("path",{d:"M6 10H34",stroke:No(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Yw=P(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"})]}),Q),Kw=P(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"})]}),Q),$w=P(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"}),pe),Xw=P(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"}),pe),Zw=P(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"}),pe),jw=P(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"})]}),pe),qw=P(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"})]}),Q),Jw=P(g("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),Qw=Ar.memo(({flip:e=!1})=>P(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})),Ef=Ar.memo(({flip:e=!1})=>P(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})),e2=Ar.memo(({flip:e=!1})=>P(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})),t2=Ar.memo(({flip:e=!1})=>P(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})),r2=Ar.memo(({flip:e=!1})=>P(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})),o2=Ar.memo(({flip:e=!1})=>P(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})),n2=Ar.memo(({flip:e=!1})=>P(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})),i2=Ar.memo(({flip:e=!1})=>P(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})),a2=P(O(De,{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"})})})]}),pe),l2=P(O(De,{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"})})})]}),pe),s2=P(O(De,{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"})})})]}),pe),c2=P(g(De,{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"})}),pe),xf=P(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"})]}),Q),d2=P(g(De,{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"})})}),pe),m2=P(O(De,{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"})})})]}),pe),p2=P(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"})]}),Q),u2=P(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"})]}),Q),h2=P(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"})]}),Q),g2=Ar.memo(({theme:e})=>P(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"})]}),Q)),f2=Ar.memo(({theme:e})=>P(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"})]}),Q)),b2=Ar.memo(({theme:e})=>P(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"})]}),Q)),E2=P(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}),MU=P(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"})),pp=P(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"})]}),Q),yf=P(O(De,{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"})]}),Q),up=P(O(De,{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"})]}),Q),x2=P(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"})]}),Q),y2=P(O(De,{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"})]}),Q),LU=P(O(De,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),Q),PU=P(O(De,{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"})]}),Q),DU=P(O(De,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),Q),w2=P(O(De,{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"})]}),Q),v2=P(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"})]}),Q),T2=P(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"})]}),Q),hp=P(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"})]}),Q),gp=P(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"})),Fl=P(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"})]}),pe),fp=P(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),zl=P(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"})]}),Q),_U=P(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"})]}),Q),Tc=P(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"})]}),Q),S2=P(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"})]}),Q),Hl=P(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"})]}),Q),I2=P(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"})]}),Q),C2=P(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"})]}),Q),A2=P(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"})]}),Q),bp=P(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"})]}),Q),k2=P(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"})]}),Q),M2=P(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"})]}),Q),L2=P(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"})]}),Q),Ep=P(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"})]}),Q),P2=P(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"})]}),Q),D2=P(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"})]}),Q),_2=P(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"})]}),Q),R2=P(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"})]}),Q),wf=P(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"})]}),Q),xp=P(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"})]}),Q),N2=P(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"})]}),Q),O2=P(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"})]}),Q),B2=P(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"})]}),Q),F2=P(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"})]}),Q),z2=P(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"})]}),{...Q,strokeWidth:1.5}),RU=P(O("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M10 12l4 4"}),g("path",{d:"M10 12l4 -4"}),g("path",{d:"M4 4l0 16"})]}),Q),H2=P(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"})]}),Q),U2=P(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"})]}),Q);Ne();import{jsx as j6}from"react/jsx-runtime";var Z6=(e,t)=>{let r=new Set(ue(e.filter(o=>ee(o)),t).map(o=>o.id));return{elements:e.map(o=>t.selectedElementIds[o.id]?ie(o,{isDeleted:!0}):o.frameId&&r.has(o.frameId)?ie(o,{isDeleted:!0}):Ae(o)&&t.selectedElementIds[o.containerId]?ie(o,{isDeleted:!0}):o),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},G2=(e,t)=>{if(e.editingGroupId){let r=tt(xe(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},Sc=z({name:"deleteSelectedElements",label:"labels.delete",icon:Oo,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=X.getElement(a,d);if(!m||l==null)return!1;if(m.points.length<2){let u=e.map(E=>E.id===m.id?ie(E,{isDeleted:!0}):E),h=G2(t,u);return{elements:u,appState:{...h,editingLinearElement:null},storeAction:D.CAPTURE}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(m.points.length-1)?null:c};return X.deletePoints(m,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},storeAction:D.CAPTURE}}let{elements:n,appState:i}=Z6(e,t);return Kd(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=G2(i,n),{elements:n,appState:{...i,activeTool:qe(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},storeAction:Ve(xe(e),t)?D.CAPTURE:D.NONE}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>j6(ce,{type:"button",icon:Oo,title:b("labels.delete"),"aria-label":b("labels.delete"),onClick:()=>r(null),visible:Ve(xe(e),t)})});f();f();se();no();mr();$e();ni();U();var vf=(e,t)=>e.frameId===t||e.id===t,V2=(e,t,r)=>{let o=[],n=[],i=null,a=-1,l=$(r||ue(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},q6=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},W2=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=Ct.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=Ct.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},J6=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{vf(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},Q6=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=o==="left"?ph(t,m=>a(m),Math.max(0,r-1)):mh(t,m=>a(m),r+1),s=t[l];if(!s)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===s?.groupIds.join(""))return W2(s,t,o)??l;if(!s?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(s.frameId||ee(s))){let m=J6(t,s.frameId||s.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!s.groupIds.length)return W2(s,t,o)??l;let c=e.editingGroupId?s.groupIds[s.groupIds.indexOf(e.editingGroupId)-1]:s.groupIds[s.groupIds.length-1],d=tt(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):l},Y2=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),K2=(e,t,r)=>{let o=V2(e,t),n=Y2(e,o),i=q6(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(l=>ee(e[l])).map(l=>e[l].id));return i.forEach((l,s)=>{let c=l[0],d=l[l.length-1],m=r==="left"?c:d,p=l.some(y=>{let v=e[y];return v.frameId&&a.has(v.frameId)})?null:e[m]?.frameId,u=Q6(t,e,m,r,p);if(u===-1||m===u)return;let h=r==="left"?e.slice(0,u):e.slice(0,c),E=e.slice(c,d+1),x=r==="left"?e.slice(u,c):e.slice(d+1,u+1),w=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...h,...E,...x,...w]:[...h,...x,...E,...w]}),Bt(e,n),e},$2=(e,t,r,o,n)=>{let i=V2(e,t,n),a=Y2(e,i),l=[],s,c;if(r==="left"){if(o)s=mh(e,h=>vf(h,o));else if(t.editingGroupId){let h=tt(e,t.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(o)c=ph(e,h=>vf(h,o));else if(t.editingGroupId){let h=tt(e,t.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 d=Array.from(a.values()),m=e.slice(0,s),p=e.slice(c+1),u=r==="left"?[...m,...d,...l,...p]:[...m,...l,...d,...p];return Bt(u,a),u};function X2(e,t,r,o){let n=$(ue(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&ee(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ee(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,d]of s)l=o(e,t,r,c,d);return o(l,t,r,null,i.regularElements)}var Z2=(e,t)=>K2(e,t,"left"),j2=(e,t)=>K2(e,t,"right"),q2=(e,t)=>X2(e,t,"left",$2),J2=(e,t)=>X2(e,t,"right",$2);ge();U();Xe();Y();Ne();import{jsx as yp}from"react/jsx-runtime";var Tf=z({name:"sendBackward",label:"labels.sendBackward",icon:af,trackEvent:{category:"element"},perform:(e,t)=>({elements:Z2(e,t),appState:t,storeAction:D.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===fe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>yp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:af})}),Sf=z({name:"bringForward",label:"labels.bringForward",icon:nf,trackEvent:{category:"element"},perform:(e,t)=>({elements:j2(e,t),appState:t,storeAction:D.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===fe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>yp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:nf})}),If=z({name:"sendToBack",label:"labels.sendToBack",icon:sf,trackEvent:{category:"element"},perform:(e,t)=>({elements:q2(e,t),appState:t,storeAction:D.CAPTURE}),keyTest:e=>ar?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===fe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>yp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendToBack")} \u2014 ${ar?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:sf})}),Cf=z({name:"bringToFront",label:"labels.bringToFront",icon:lf,trackEvent:{category:"element"},perform:(e,t)=>({elements:J2(e,t),appState:t,storeAction:D.CAPTURE}),keyTest:e=>ar?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===fe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>yp("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${b("labels.bringToFront")} \u2014 ${ar?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:lf})});f();ge();Xe();mr();be();se();Xt();ii();Ne();var Af=z({name:"selectAll",label:"labels.selectAll",icon:P2,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=Ia(e.filter(i=>!i.isDeleted&&!(G(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...jt({editingGroupId:null,selectedElementIds:n},xe(e),t,o),selectedLinearElement:Object.keys(n).length===1&&ne(e[0])?new X(e[0]):null},storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ge();Xe();be();$e();U();Xt();mr();io();Y();st();se();f();U();var e4=e=>{let t=e.slice(),r=new Set,o=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,...o(s)]:l},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===l);return d&&n.set(c.id,!0),d});for(let c of o(s))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},t4=e=>{let t=HE(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let l=t.get(a.id);l&&a.type==="text"&&(o.add(l[0]),r[l[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},Q2=e=>t4(e4(e));nr();ii();no();Ne();import{jsx as o4}from"react/jsx-runtime";var kf=z({name:"duplicateSelection",label:"labels.duplicateSelection",icon:xc,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getNonDeletedElementsMap();if(t.editingLinearElement){let i=X.duplicateSelectedPoints(t,n);return i?{elements:e,appState:i.appState,storeAction:D.CAPTURE}:!1}return{...r4(e,t),storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>o4(ce,{type:"button",icon:xc,title:`${b("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":b("labels.duplicateSelection"),onClick:()=>r(null),visible:Ve(xe(e),t)})}),r4=(e,t)=>{let r=Q2(e),o=new Map,n=[],i=[],a=new Map,l=new Map,s=y=>{let v=Xs(t.editingGroupId,o,y,{x:y.x+xn/2,y:y.y+xn/2});return l.set(v.id,v),a.set(y.id,v.id),i.push(y),n.push(v),v},c=$(ue(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=y=>{for(let v of y)d.set(v.id,!0);return y},p=[],u=-1;for(;++u<r.length;){let y=r[u];if(d.get(y.id))continue;let v=me(y,$(e)),I=ee(y);if(c.get(y.id)){if(y.groupIds.length||v||I){let L=Qh(t,y);if(L){let C=tt(r,L).flatMap(M=>ee(M)?[...Yr(e,M.id),M]:[M]);p.push(...m([...C,...C.map(M=>s(M))]));continue}if(v){p.push(...m([y,v,s(y),s(v)]));continue}if(I){let C=Yr(r,y.id);p.push(...m([...C,y,...C.map(M=>s(M)),s(y)]));continue}}(!y.frameId||!c.has(y.frameId))&&p.push(...m([y,s(y)]))}else p.push(...m([y]))}let h=[],E=new Map;for(u=p.length;--u>=0;){let y=p[u];E.get(y.id)||(E.set(y.id,!0),h.push(y))}let x=Bt(h.reverse(),$(n));Zd(p,i,a),Yd(p,i,a),Ym(x,i,a);let w=Ia(n);return{elements:x,appState:{...t,...jt({editingGroupId:t.editingGroupId,selectedElementIds:w.reduce((y,v)=>(Ae(v)||(y[v.id]=!0),y),{})},xe(x),t,null)}}};f();Qt();f();var n4=["ai","command_palette"],Ee=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.PROD||!n4.includes(e))return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import ev from"clsx";import{jsx as Mf,jsxs as i4}from"react/jsx-runtime";var on=e=>Mf("div",{className:"buttonList buttonListIcon",children:e.options.map(t=>e.type==="button"?Mf("button",{onClick:r=>e.onClick(t.value,r),className:ev({active:t.active??e.value===t.value}),"data-testid":t.testId,title:t.text,children:t.icon},t.text):i4("label",{className:ev({active:e.value===t.value}),title:t.text,children:[Mf("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();U();f();Qt();import a4 from"clsx";import{jsx as Lf}from"react/jsx-runtime";var tv=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=ld),t==="elementBackground"&&(n=sd),t==="canvasBackground"&&(n=cd),o&&(n=o),n?Lf("div",{className:"color-picker__top-picks",children:n.map(i=>Lf("button",{className:a4("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Lf("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import dv,{useEffect as mv,useState as k4}from"react";f();import d4 from"clsx";import{useAtom as m4}from"jotai";import{useEffect as p4,useRef as u4}from"react";f();Qt();import{atom as l4}from"jotai";var Ti=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},Ic=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Pf=({color:e,palette:t})=>!Object.values(t).flat().includes(e),ov=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[o[t]];return Pf({color:l,palette:r})}),i=new Map;return n.forEach(a=>{let l=a[o[t]];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,Jb)},mo=l4(null),rv=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",nv=(e,t)=>{if(t){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 rv(l,s,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return rv(r,o,n)};f();import{jsxs as c4}from"react/jsx-runtime";var s4=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>c4("div",{className:"color-picker__button__hotkey-label",style:{color:nv(e,r)},children:[o&&"\u21E7",t]}),Ul=s4;import{jsx as Cc,jsxs as iv}from"react/jsx-runtime";var av=({hex:e,onChange:t,palette:r})=>{let o=Ti({color:e||"transparent",palette:r}),[n,i]=m4(mo),a=u4(null);if(p4(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:l,shade:s}=o,c=r[l];if(Array.isArray(c))return Cc("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>iv("button",{ref:m===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:d4("color-picker__button color-picker__button--large",{active:m===s}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[Cc("div",{className:"color-picker__button-outline"}),Cc(Ul,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return iv("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Cc("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Cc("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:b("colorPicker.noShades")})]})};f();import h4 from"clsx";import{useAtom as g4}from"jotai";import{useEffect as f4,useRef as b4}from"react";import{jsx as Df,jsxs as x4}from"react/jsx-runtime";var E4=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=Ti({color:t||"transparent",palette:e}),[a,l]=g4(mo),s=b4(null);return f4(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Df("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=Ic[m],h=b(`colors.${c.replace(/\d+/,"")}`,null,"");return x4("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:h4("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(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:[Df("div",{className:"color-picker__button-outline"}),Df(Ul,{color:p,keyLabel:u})]},c)})})},lv=E4;import{useAtom as M4}from"jotai";f();import y4 from"clsx";import{useAtom as w4}from"jotai";import{useEffect as v4,useRef as T4}from"react";import{jsx as _f,jsxs as S4}from"react/jsx-runtime";var sv=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=w4(mo),a=T4(null);return v4(()=>{a.current&&a.current.focus()},[t,n]),_f("div",{className:"color-picker-content--default",children:e.map((l,s)=>S4("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:y4("color-picker__button color-picker__button--large",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{r(l),i("custom")},title:l,"aria-label":o,style:{"--swatch-color":l},children:[_f("div",{className:"color-picker__button-outline"}),_f(Ul,{color:l,keyLabel:s+1,isCustomColor:!0})]},s))})};f();ge();Qt();var Rf=(e,t,r)=>{let o=Math.ceil(r/Yi);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+Yi;return n>=r?t%Yi:n}case"ArrowUp":{let n=t-Yi,i=n<0?Yi*o+n:n;return i>=r?void 0:i}}},I4=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return r(o[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(Ic.includes(e.key)){let l=Ic.indexOf(e.key),s=Object.keys(o)[l],c=o[s],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},cv=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=Ti({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((y,[v,I])=>(I&&y.push(v),y),[]),h=u.indexOf(t),E=e.shiftKey?-1:1,x=h+E>u.length-1?0:h+E<0?u.length-1:h+E,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(r).find(([v,I])=>Array.isArray(I)?I.includes(o):I===o?v:null)||n(de.black)),e.preventDefault(),e.stopPropagation(),!0}if(I4({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=Rf(e.key,p,Yi);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),h=u.indexOf(p),E=Rf(e.key,h,u.length);if(E!==void 0){let x=u[E],w=r[x];return n(Array.isArray(w)?w[s]:w),!0}}if(t==="custom"){let p=i.indexOf(o),u=Rf(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};f();import{jsx as A4}from"react/jsx-runtime";var C4=({children:e})=>A4("div",{className:"color-picker__heading",children:e}),Gl=C4;Qt();ge();Y();import{jsx as Ma,jsxs as wp}from"react/jsx-runtime";var pv=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[d]=dv.useState(()=>o==="canvasBackground"?[]:ov(n,o,i)),[m,p]=M4(mo),u=Ti({color:e,palette:i});mv(()=>{if(!m){let w=Pf({color:e,palette:i}),y=w&&!d.includes(e);p(y?"hex":w?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[h,E]=k4(u?.shade??(o==="elementBackground"?$a:Ka));mv(()=>{u?.shade!=null&&E(u.shade);let w=y=>{y.key===S.ALT&&s(!1)};return document.addEventListener("keyup",w,{capture:!0}),()=>{document.removeEventListener("keyup",w,{capture:!0})}},[u,s]);let x=dv.useRef(null);return Ma("div",{role:"dialog","aria-modal":"true","aria-label":b("labels.colorPicker"),children:wp("div",{ref:x,onKeyDown:w=>{cv({event:w,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:s,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content",tabIndex:-1,children:[!!d.length&&wp("div",{children:[Ma(Gl,{children:b("colorPicker.mostUsedCustomColors")}),Ma(sv,{colors:d,color:e,label:b("colorPicker.mostUsedCustomColors"),onChange:t})]}),wp("div",{children:[Ma(Gl,{children:b("colorPicker.colors")}),Ma(lv,{color:e,label:r,palette:i,onChange:t,activeShade:h})]}),wp("div",{children:[Ma(Gl,{children:b("colorPicker.shades")}),Ma(av,{hex:e,onChange:t,palette:i})]}),l]})})};import*as nn from"@radix-ui/react-popover";import{useAtom as wv}from"jotai";Qt();import G4 from"clsx";f();import{useCallback as F4,useEffect as Of,useRef as fv,useState as z4}from"react";import{useAtom as bv}from"jotai";ge();f();Qt();Y();import{atom as _4}from"jotai";import{useEffect as R4,useRef as N4}from"react";import{createPortal as O4}from"react-dom";f();import uv from"react";var Nf=uv.createContext(null),_e=()=>uv.useContext(Nf);f();import{useState as L4,useLayoutEffect as hv}from"react";Y();var vp=e=>{let[t,r]=L4(null),o=Me(),{theme:n}=_e(),{container:i}=Ut();return hv(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===ae.DARK))},[t,n,o.editor.isMobile,e?.className]),hv(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),r(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};f();Y();import{useEffect as P4}from"react";function Wl(e,t,r){P4(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ge();$e();f();import{useRef as D4}from"react";var Vl=e=>{let t=D4(e);return Object.assign(t.current,e),t.current};import{jsx as B4}from"react/jsx-runtime";var Si=_4(null),gv=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=vp({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=_e(),a=Ii(),l=kr(),s=ue(a,i),c=Vl({app:l,onCancel:e,onChange:t,onSelect:r,selectedElements:s}),{container:d}=Ut();R4(()=>{let p=m.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),E=({clientX:C,clientY:M})=>{let _=h.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return nE(_[0],_[1],_[2])},x=({clientX:C,clientY:M,altKey:_})=>{p.style.top=`${M+20}px`,p.style.left=`${C+20}px`;let H=E({clientX:C,clientY:M});u&&c.onChange(o,H,c.selectedElements,{altKey:_}),p.style.background=H},w=()=>{c.onCancel()},y=(C,M)=>{c.onSelect(C,M)},v=C=>{u=!0,C.stopImmediatePropagation()},I=C=>{u=!1,d?.focus(),C.stopImmediatePropagation(),C.preventDefault(),y(E(C),C)},L=C=>{C.key===S.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",L),n.addEventListener("pointerdown",v),n.addEventListener("pointerup",I),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",w),()=>{u=!1,n.removeEventListener("keydown",L),n.removeEventListener("pointerdown",v),n.removeEventListener("pointerup",I),window.removeEventListener("pointermove",x),window.removeEventListener("blur",w)}},[c,l.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=N4(null);return Wl(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?O4(B4("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import H4 from"clsx";U();import{Fragment as U4,jsx as Tp,jsxs as Ev}from"react/jsx-runtime";var xv=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=Me(),[i,a]=z4(e),[l,s]=bv(mo);Of(()=>{a(e)},[e]);let c=F4(h=>{let E=h.toLowerCase(),x=yv(E);x&&t(x),a(E)},[t]),d=fv(null),m=fv(null);Of(()=>{d.current&&d.current.focus()},[l]);let[p,u]=bv(Si,ze);return Of(()=>()=>{u(null)},[u]),Ev("div",{className:"color-picker__input-label",children:[Tp("div",{className:"color-picker__input-hash",children:"#"}),Tp("input",{ref:l==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==S.TAB&&(h.key===S.ESCAPE&&m.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&Ev(U4,{children:[Tp("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Tp("div",{ref:m,className:H4("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:E=>t(E),colorPickerType:o}),title:`${b("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${R("Alt")} `,children:v2})]})]})};import{useRef as W4}from"react";import{jsx as po,jsxs as Sp}from"react/jsx-runtime";var vv=e=>{let t=new Option().style;return t.color=e,!!t.color},yv=e=>lr(e)?e:vv(`#${e}`)?`#${e}`:vv(e)?e:null,V4=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=de,updateData:a})=>{let[,l]=wv(mo),[s,c]=wv(Si,ze),{container:d}=Ut(),m=Me(),p=Sp("div",{children:[po(Gl,{children:b("colorPicker.hexCode")}),po(xv,{color:t,label:o,onChange:E=>{r(E)},colorPickerType:e})]}),u=W4(null),h=()=>{u.current?.querySelector(".color-picker-content")?.focus()};return po(nn.Portal,{container:d,children:Sp(nn.Content,{ref:u,className:"focus-visible-none","data-prevent-outside-click":!0,onFocusOutside:E=>{h(),E.preventDefault()},onPointerDownOutside:E=>{s&&E.preventDefault()},onCloseAutoFocus:E=>{E.stopPropagation(),E.preventDefault(),d&&!_E(document.activeElement)&&d.focus(),a({openPopup:null}),l(null)},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-layerUI)",backgroundColor:"var(--popup-bg-color)",maxWidth:"208px",maxHeight:window.innerHeight,padding:"12px",borderRadius:"8px",boxSizing:"border-box",overflowY:"auto",boxShadow:"0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)"},children:[i?po(pv,{palette:i,color:t,onChange:E=>{r(E)},onEyeDropperToggle:E=>{c(x=>E?(x=x||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},x.keepOpenOnAlt=!0,x):E===!1||x?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:E=>{s?c(null):eo(E.target)?h():a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:p}):p,po(nn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})},Y4=({label:e,color:t,type:r})=>po(nn.Trigger,{type:"button",className:G4("color-picker__button active-color",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?b("labels.showStroke"):b("labels.showBackground"),children:po("div",{className:"color-picker__button-outline"})}),Ac=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=de,topPicks:a,updateData:l,appState:s})=>po("div",{children:Sp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[po(tv,{activeColor:t,onChange:r,type:e,topPicks:a}),po("div",{style:{width:1,height:"100%",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),Sp(nn.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[po(Y4,{color:t,label:o,type:e}),s.openPopup===e&&po(V4,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:l})]})]})});f();import La from"react";f();import{useLayoutEffect as K4,useRef as Tv,useEffect as Sv}from"react";U();ge();import{unstable_batchedUpdates as $4}from"react-dom";import{jsx as X4}from"react/jsx-runtime";var Ip=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=Tv(null);Sv(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let h=Ts(m),{activeElement:E}=document,x=h.findIndex(w=>w===E);E===m?(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 m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=Tv(null);return K4(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=l?(m.style.width=`${l}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>l?m.style.left=`${l-p-10}px`:m.style.left=`${t}px`,u>=s?(m.style.height=`${s-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>s?m.style.top=`${s-u}px`:m.style.top=`${r}px`}},[r,t,n,l,s,i,a]),Sv(()=>{if(o){let m=p=>{c.current?.contains(p.target)||$4(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),X4("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ge();import Z4 from"clsx";import{Fragment as q4,jsx as Ci,jsxs as Bf}from"react/jsx-runtime";function j4({options:e,value:t,label:r,onChange:o,onClose:n}){let i=La.useRef(),a=La.useRef(),l=La.useRef(null);return La.useEffect(()=>{a.current?a.current.focus():l.current&&l.current.focus()},[]),Ci("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);l.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(sl(c.key)){let{activeElement:m}=document,p=fn().rtl,u=Array.prototype.indexOf.call(l.current.children,m);if(u!==-1){let h=e.length,E=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{E=(u+1)%h;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{E=(h+u-1)%h;break}}l.current.children[E].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:Ci("div",{className:"picker-content",ref:l,children:e.map((c,d)=>Bf("button",{className:Z4("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&Ci("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function Ff({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=La.useState(!1),l=La.useRef(null),s=fn().rtl;return Bf("div",{children:[Ci("button",{name:n,className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:l,children:r.find(c=>c.value===e)?.icon}),Ci(La.Suspense,{fallback:"",children:i?Bf(q4,{children:[Ci(Ip,{onCloseRequest:c=>c.target!==l.current&&a(!1),...s?{right:5.5}:{left:-5.5},children:Ci(j4,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),l.current?.focus()}})}),Ci("div",{className:"picker-triangle"})]}):null})]})}Y();be();Ue();st();se();ge();Co();$e();Os();U();Xe();Ne();import{Fragment as Av,jsx as Ce,jsxs as Kr}from"react/jsx-runtime";var Cv=.1,$r=(e,t,r,o=!1)=>{let n=$(ue(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},Mr=function(e,t,r,o,n){let i=t.editingElement,a=xe(e),l=null;return i&&(l=r(i)),l||(Ve(a,t)?l=Zg(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},J4=(e,t)=>Ae(t)?t:F(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),zf=(e,t,r,o,n)=>{let i=new Set;return{elements:$r(e,t,a=>{if(G(a)){let l=o(a);i.add(l);let s=ie(a,{fontSize:l});return Rt(s,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),s=J4(a,s),s}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},storeAction:D.CAPTURE}},Q4=z({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:$r(e,t,o=>Ns(o.type)?ie(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},storeAction:r.currentItemStrokeColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>Kr(Av,{children:[Ce("h3",{"aria-hidden":"true",children:b("labels.stroke")}),Ce(Ac,{topPicks:ld,palette:tE,type:"elementStroke",label:b("labels.stroke"),color:Mr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),eA=z({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:$r(e,t,o=>ie(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},storeAction:r.currentItemBackgroundColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>Kr(Av,{children:[Ce("h3",{"aria-hidden":"true",children:b("labels.background")}),Ce(Ac,{topPicks:sd,palette:rE,type:"elementBackground",label:b("labels.background"),color:Mr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),tA=z({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(Ee("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:$r(e,t,n=>ie(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=ue(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return Kr("fieldset",{children:[Ce("legend",{children:b("labels.fill")}),Ce(on,{type:"button",options:[{value:"hachure",text:`${n?b("labels.zigzag"):b("labels.hachure")} (${R("Alt-Click")})`,icon:n?zw:Hw,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:b("labels.crossHatch"),icon:Uw,testId:"fill-cross-hatch"},{value:"solid",text:b("labels.solid"),icon:Gw,testId:"fill-solid"}],value:Mr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&o.every(s=>s.fillStyle==="hachure")?"zigzag":i;r(l)}})]})}}),rA=z({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>ie(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>Kr("fieldset",{children:[Ce("legend",{children:b("labels.strokeWidth")}),Ce(on,{group:"stroke-width",options:[{value:xd.thin,text:b("labels.thin"),icon:bf,testId:"strokeWidth-thin"},{value:xd.bold,text:b("labels.bold"),icon:Ww,testId:"strokeWidth-bold"},{value:xd.extraBold,text:b("labels.extraBold"),icon:Vw,testId:"strokeWidth-extraBold"}],value:Mr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),oA=z({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>ie(o,{seed:oo(),roughness:r})),appState:{...t,currentItemRoughness:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>Kr("fieldset",{children:[Ce("legend",{children:b("labels.sloppiness")}),Ce(on,{group:"sloppiness",options:[{value:0,text:b("labels.architect"),icon:$w},{value:1,text:b("labels.artist"),icon:Xw},{value:2,text:b("labels.cartoonist"),icon:Zw}],value:Mr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),PK=z({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>ie(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>Kr("fieldset",{children:[Ce("legend",{children:b("labels.strokeStyle")}),Ce(on,{group:"strokeStyle",options:[{value:"solid",text:b("labels.strokeStyle_solid"),icon:bf},{value:"dashed",text:b("labels.strokeStyle_dashed"),icon:Yw},{value:"dotted",text:b("labels.strokeStyle_dotted"),icon:Kw}],value:Mr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),nA=z({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>ie(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>Kr("label",{className:"control-label",children:[b("labels.opacity"),Ce("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:Mr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),iA=z({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>zf(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Kr("fieldset",{children:[Ce("legend",{children:b("labels.fontSize")}),Ce(on,{group:"font-size",options:[{value:16,text:b("labels.small"),icon:a2,testId:"fontSize-small"},{value:20,text:b("labels.medium"),icon:l2,testId:"fontSize-medium"},{value:28,text:b("labels.large"),icon:s2,testId:"fontSize-large"},{value:36,text:b("labels.veryLarge"),icon:c2,testId:"fontSize-veryLarge"}],value:Mr(e,t,n=>{if(G(n))return n.fontSize;let i=me(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>G(n)||me(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||Lt),onChange:n=>r(n)})]})}),Hf=z({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:xf,trackEvent:!1,perform:(e,t,r,o)=>zf(e,t,o,n=>Math.round(1/(1+Cv)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),Uf=z({name:"increaseFontSize",label:"labels.increaseFontSize",icon:xf,trackEvent:!1,perform:(e,t,r,o)=>zf(e,t,o,n=>Math.round(n.fontSize*(1+Cv))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),aA=z({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>({elements:$r(e,t,n=>{if(G(n)){let i=ie(n,{fontFamily:r,lineHeight:Hr(r)});return Rt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemFontFamily:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=[{value:mt.Virgil,text:b("labels.handDrawn"),icon:Nl,testId:"font-family-virgil"},{value:mt.Helvetica,text:b("labels.normal"),icon:d2,testId:"font-family-normal"},{value:mt.Cascadia,text:b("labels.code"),icon:m2,testId:"font-family-code"}];return Kr("fieldset",{children:[Ce("legend",{children:b("labels.fontFamily")}),Ce(on,{group:"font-family",options:n,value:Mr(e,t,i=>{if(G(i))return i.fontFamily;let a=me(i,o.scene.getNonDeletedElementsMap());return a?a.fontFamily:null},i=>G(i)||me(i,o.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontFamily||Kt),onChange:i=>r(i)})]})}}),lA=z({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:$r(e,t,n=>{if(G(n)){let i=ie(n,{textAlign:r});return Rt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return Kr("fieldset",{children:[Ce("legend",{children:b("labels.textAlign")}),Ce(on,{group:"text-align",options:[{value:"left",text:b("labels.left"),icon:p2,testId:"align-left"},{value:"center",text:b("labels.center"),icon:u2,testId:"align-horizontal-center"},{value:"right",text:b("labels.right"),icon:h2,testId:"align-right"}],value:Mr(e,t,i=>{if(G(i))return i.textAlign;let a=me(i,n);return a?a.textAlign:null},i=>G(i)||me(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),sA=z({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:$r(e,t,n=>{if(G(n)){let i=ie(n,{verticalAlign:r});return Rt(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Ce("fieldset",{children:Ce(on,{group:"text-align",options:[{value:yt.TOP,text:b("labels.alignTop"),icon:Ce(g2,{theme:t.theme}),testId:"align-top"},{value:yt.MIDDLE,text:b("labels.centerVertically"),icon:Ce(b2,{theme:t.theme}),testId:"align-middle"},{value:yt.BOTTOM,text:b("labels.alignBottom"),icon:Ce(f2,{theme:t.theme}),testId:"align-bottom"}],value:Mr(e,t,n=>{if(G(n)&&n.containerId)return n.verticalAlign;let i=me(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>G(n)||me(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:yt.MIDDLE),onChange:n=>r(n)})})}),DK=z({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>ie(o,{roundness:r==="round"?{type:Ko(o.type)?at.ADAPTIVE_RADIUS:at.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=Ca(xe(e),t).some(i=>i.roundness?.type===at.LEGACY);return Kr("fieldset",{children:[Ce("legend",{children:b("labels.edges")}),Ce(on,{group:"edges",options:[{value:"sharp",text:b("labels.sharp"),icon:jw},{value:"round",text:b("labels.round"),icon:qw}],value:Mr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),Iv=e=>[{value:null,text:b("labels.arrowhead_none"),keyBinding:"q",icon:Jw},{value:"arrow",text:b("labels.arrowhead_arrow"),keyBinding:"w",icon:Ce(Qw,{flip:e})},{value:"bar",text:b("labels.arrowhead_bar"),keyBinding:"e",icon:Ce(t2,{flip:e})},{value:"dot",text:b("labels.arrowhead_circle"),keyBinding:null,icon:Ce(Ef,{flip:e}),showInPicker:!1},{value:"circle",text:b("labels.arrowhead_circle"),keyBinding:"r",icon:Ce(Ef,{flip:e}),showInPicker:!1},{value:"circle_outline",text:b("labels.arrowhead_circle_outline"),keyBinding:null,icon:Ce(e2,{flip:e}),showInPicker:!1},{value:"triangle",text:b("labels.arrowhead_triangle"),icon:Ce(r2,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:b("labels.arrowhead_triangle_outline"),icon:Ce(o2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:b("labels.arrowhead_diamond"),icon:Ce(n2,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:b("labels.arrowhead_diamond_outline"),icon:Ce(i2,{flip:e}),keyBinding:null,showInPicker:!1}],_K=z({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:$r(e,t,o=>{if(ne(o)){let{position:n,type:i}=r;if(n==="start")return ie(o,{startArrowhead:i});if(n==="end")return ie(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=fn().rtl;return Kr("fieldset",{children:[Ce("legend",{children:b("labels.arrowheads")}),Kr("div",{className:"iconSelectList buttonList",children:[Ce(Ff,{label:"arrowhead_start",options:Iv(!o),value:Mr(e,t,n=>ne(n)&&Qi(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),Ce(Ff,{label:"arrowhead_end",group:"arrowheads",options:Iv(!!o),value:Mr(e,t,n=>ne(n)&&Qi(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}});f();Y();be();ge();$e();qg();ip();U();Xe();f();import{useEffect as cA}from"react";import{jsx as mA}from"react/jsx-runtime";var Yl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},Gf=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-o.width/2;l<0?l=a:l+o.width>=n&&(l=n-o.width-a);let s;r==="bottom"?(s=t.top+t.height+a,s+o.height>=i&&(s=t.top-o.height-a)):(s=t.top-o.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},dA=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();Gf(t,n)},Xr=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(cA(()=>()=>Yl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:mA("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>dA(i.currentTarget,Yl(),t,r),onPointerLeave:()=>Yl().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));Ue();Ir();Qt();hl();Ne();import{jsx as kp,jsxs as fA}from"react/jsx-runtime";var pA=z({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},storeAction:r.viewBackgroundColor?D.CAPTURE:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>kp(Ac,{palette:null,topPicks:cd,label:b("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),Hn=z({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:Oo,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>ie(n,{isDeleted:!0})),appState:{...Zt(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,showStats:t.showStats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},storeAction:D.CAPTURE})}),Cp=z({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Qg,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...zn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:rn(t.zoom.value+Xi)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>kp(ce,{type:"button",className:"zoom-in-button zoom-button",icon:Qg,title:`${b("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":b("buttons.zoomIn"),disabled:t.zoom.value>=nh,onClick:()=>{e(null)}}),keyTest:e=>(e.code===fe.EQUAL||e.code===fe.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),Ap=z({name:"zoomOut",label:"buttons.zoomOut",icon:ef,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...zn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:rn(t.zoom.value-Xi)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>kp(ce,{type:"button",className:"zoom-out-button zoom-button",icon:ef,title:`${b("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":b("buttons.zoomOut"),disabled:t.zoom.value<=Za,onClick:()=>{e(null)}}),keyTest:e=>(e.code===fe.MINUS||e.code===fe.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),uA=z({name:"resetZoom",label:"buttons.resetZoom",icon:Sw,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...zn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:rn(1)},t),userToFollow:null},storeAction:D.NONE}),PanelComponent:({updateData:e,appState:t})=>kp(Xr,{label:b("buttons.resetZoom"),style:{height:"100%"},children:fA(ce,{type:"button",className:"reset-zoom-button zoom-button",title:b("buttons.resetZoom"),"aria-label":b("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===fe.ZERO||e.code===fe.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),hA=(e,t)=>{let[r,o,n,i]=e,a=n-r,l=t.width/a,s=i-o,c=t.height/s,d=Math.min(l,c),m=Math.floor(d/Xi)*Xi;return Math.min(Math.max(m,Za),1)},kv=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,l]=e,s=(n+a)/2,c=(i+l)/2,d,m,p;if(r){let u=a-n,h=l-i;d=Math.min(t.width/u,t.height/h)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,Za),nh);let E=t.width;if(t.openSidebar){let w=document.querySelector(".sidebar")?.offsetWidth??0;E=document.documentElement.getAttribute("dir")==="rtl"?t.width+w:t.width-w}m=E/2*(1/d)-s,p=t.height/2*(1/d)-c}else{d=hA(e,{width:t.width,height:t.height});let u=jg({scenePoint:{x:s,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},storeAction:D.NONE}},kc=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=Se(xe(e));return kv({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},c$=z({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:xp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return kc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===fe.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),d$=z({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:xp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return kc({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===fe.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),gA=z({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:xp,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>kc({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===fe.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),Pa=z({name:"toggleTheme",label:(e,t)=>t.theme===ae.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ae.LIGHT?yc:wc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===ae.LIGHT?ae.DARK:ae.LIGHT)},storeAction:D.NONE}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===fe.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),m$=z({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return Sr(t)?r=qe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=qe(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},storeAction:D.CAPTURE}},keyTest:e=>e.key===S.E}),Mv=z({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:pp,viewMode:!1,perform:(e,t,r,o)=>{let n;return Do(t)?n=qe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=qe(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),We(o.interactiveCanvas,Le.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},storeAction:D.CAPTURE}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ge();be();U();Xe();Ue();Ft();Xt();io();se();hl();Ne();import{jsx as bA}from"react/jsx-runtime";var uo=z({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,l=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:h}=t.editingLinearElement,E=X.getElement(p,l);if(E)return wr(E)&&sa(E,u,h,l),{elements:E.points.length<2||lo(E)?e.filter(x=>x.id!==E.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null,selectedLinearElement:null},storeAction:D.CAPTURE}}let s=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&F(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:h}=d;(!h||u[u.length-1]!==h)&&F(d,{points:d.points.slice(0,-1)})}lo(d)&&(s=s.filter(u=>u.id!==d.id));let p=dr(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,h=u[0];F(d,{points:u.map((E,x)=>x===u.length-1?[h[0],h[1]]:E)})}if(wr(d)&&!p&&d.points.length>1){let[u,h]=X.getPointAtIndexGlobalCoordinates(d,-1,$(e));Us(d,t,{x:u,y:h},o)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&Gr(n);let m;return t.activeTool.type==="eraser"?m=qe(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=qe(t,{type:"selection"}),{elements:s,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&ne(d)?new X(d):t.selectedLinearElement,pendingImageElementId:null},storeAction:D.CAPTURE}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>bA(ce,{type:"button",icon:Rw,title:b("buttons.done"),"aria-label":b("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();f();U();import{useState as EA}from"react";ge();import{jsx as Lv,jsxs as xA}from"react/jsx-runtime";var Pv=e=>{let{id:t}=Ut(),[r,o]=EA(e.value),n=a=>{e.ignoreFocus||BE(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return xA("div",{className:"ProjectName",children:[Lv("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Lv("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();Y();import{jsx as Mc}from"react/jsx-runtime";var _v=e=>{let t=e.title||(e.value===ae.DARK?b("buttons.lightMode"):b("buttons.darkMode"));return Mc(ce,{type:"icon",icon:e.value===ae.LIGHT?Dv.MOON:Dv.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===ae.DARK?ae.LIGHT:ae.DARK),"data-testid":"toggle-dark-mode"})},Dv={SUN:Mc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Mc("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:Mc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Mc("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"})})};f();wi();Y();be();se();$e();mc();U();Cr();Dn();Nn();nr();Cr();Nn();var Da=(e,{selectedElementIds:t},r)=>{e=xe(e);let o=r&&Ve(e,{selectedElementIds:t}),n=null,i=o?ue(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&ee(i[0])?(n=i[0],i=Cl(e,n)):i.length>1&&(i=ue(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Vo(i)}},_a=async(e,t,r,o,{exportBackground:n,exportPadding:i=To,viewBackgroundColor:a,name:l=r.name||wd,fileHandle:s=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(b("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Il(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return El(m.then(p=>new Blob([p.outerHTML],{type:te.svg})),{description:"Export to SVG",name:l,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:s});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await Bn(p)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return}}let d=Om(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Rn(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(wl(),ic)).then(({encodePngMetadata:u})=>u({blob:p,metadata:xi(t,r,o,"local")})))),El(m,{description:"Export to PNG",name:l,extension:"png",fileHandle:s})}else if(e==="clipboard")try{let m=Rn(d);await Gm(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):bn&&m.name==="TypeError"?new Error(`${b("alerts.couldNotCopyToClipboard")}
35
+ `),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,c=ra(e.fontSize,e.lineHeight),d=Tp(e.fontFamily,e.fontSize,c);for(let m=0;m<s.length;m++)r.fillText(s[m],l,m*c+d);r.restore(),a&&r.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},jm=new WeakMap,ST=(e,t,r,o)=>{let n=r?o.zoom:MM.zoom,i=jm.get(e),a=i&&i.zoomValue!==n.value&&!o?.shouldCacheIgnoreZoom,s=J(e,t),l=s?.version||null,c=Qt(e,t)?.opacity||100;if(!i||a||i.theme!==o.theme||i.boundTextElementVersion!==l||i.containingFrameOpacity!==c||ne(e)&&s&&e.angle!==i.angle){let d=PM(e,t,n,r,o);return jm.set(e,d),d}return i},IT=(e,t,r,o,n)=>{let i=e.element,a=yu(i),s=e.scale,[l,c,d,m]=ae(i,n),p=((l+d)/2+o.scrollX)*window.devicePixelRatio,u=((c+m)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let g=J(i,n);if(ne(i)&&g){let h=(e.boundTextCanvas.width-e.canvas.width)/2,x=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(p,u),t.drawImage(e.boundTextCanvas,-(d-l)/2*window.devicePixelRatio-h/s-a,-(m-c)/2*window.devicePixelRatio-x/s-a,e.boundTextCanvas.width/s,e.boundTextCanvas.height/s)}else if(t.translate(p,u),t.rotate(i.angle),"scale"in e.element&&!MT(i,r)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-u),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-a*e.scale/e.scale,(c+o.scrollY)*window.devicePixelRatio-a*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),T.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&Ct(i)){let h=J(i,n),x=xb(i);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((x.x+o.scrollX)*window.devicePixelRatio,(x.y+o.scrollY)*window.devicePixelRatio,br(i,h)*window.devicePixelRatio,ns(i,h)*window.devicePixelRatio)}t.restore()},DT=(e,t,r,o)=>{t.save(),t.translate(e.x+r.scrollX,e.y+r.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let n=.5/r.zoom.value;t.fillRect(n,n,e.width,e.height),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(n,n,e.width,e.height),t.restore()},fl=(e,t,r,o,n,i,a)=>{switch(n.globalAlpha=Eb(e,Qt(e,t),i.elementsPendingErasure),e.type){case"magicframe":case"frame":{a.frameRendering.enabled&&a.frameRendering.outline&&(n.save(),n.translate(e.x+a.scrollX,e.y+a.scrollY),n.fillStyle="rgba(0, 0, 200, 0.04)",n.lineWidth=rt.strokeWidth/a.zoom.value,n.strokeStyle=rt.strokeColor,_a(e)&&(n.strokeStyle=a.theme===ue.LIGHT?"#7affd7":"#1d8264"),rt.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,e.width,e.height,rt.radius/a.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,e.width,e.height),n.restore());break}case"freedraw":{if(_e.generateElementShape(e,null),i.isExporting){let[s,l,c,d]=ae(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),g=(d-l)/2-(e.y-l);n.save(),n.translate(m,p),n.rotate(e.angle),n.translate(-u,-g),xu(e,o,n,i,a),n.restore()}else{let s=ST(e,r,i,a);IT(s,n,i,a,r)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(_e.generateElementShape(e,i),i.isExporting){let[s,l,c,d]=ae(e,t),m=(s+c)/2+a.scrollX,p=(l+d)/2+a.scrollY,u=(c-s)/2-(e.x-s),g=(d-l)/2-(e.y-l);if(H(e)){let x=Et(e,t);if(ne(x)){let v=K.getBoundTextElementPosition(x,e,t);u=(c-s)/2-(v.x-s),g=(d-l)/2-(v.y-l)}}n.save(),n.translate(m,p),kT(e,i,a)&&(n.filter="none");let h=J(e,t);if(ne(e)&&h){let x=document.createElement("canvas"),v=x.getContext("2d"),y=Math.max(Ht(s,c),Ht(l,d)),w=yu(e);x.width=y*a.exportScale+w*10*a.exportScale,x.height=y*a.exportScale+w*10*a.exportScale,v.translate(x.width/2,x.height/2),v.scale(a.exportScale,a.exportScale),u=e.width/2-(e.x-s),g=e.height/2-(e.y-l),v.rotate(e.angle);let C=AT.canvas(x);v.translate(-u,-g),xu(e,C,v,i,a),v.translate(u,g),v.rotate(-e.angle);let[,,,,M,I]=ae(h,t),P=(s+c)/2-M,A=(l+d)/2-I;v.translate(-P,-A),v.clearRect(-h.width/2,-h.height/2,h.width,h.height),n.scale(1/a.exportScale,1/a.exportScale),n.drawImage(x,-x.width/2,-x.height/2,x.width,x.height)}else n.rotate(e.angle),e.type==="image"&&n.scale(e.scale[0],e.scale[1]),n.translate(-u,-g),xu(e,o,n,i,a);n.restore()}else{let s=ST(e,r,i,a),l=n.imageSmoothingEnabled;!a?.shouldCacheIgnoreZoom&&(!e.angle||NT(e.angle))&&(n.imageSmoothingEnabled=!1),IT(s,n,i,a,r),n.imageSmoothingEnabled=l}break}default:throw new Error(`Unimplemented type ${e.type}`)}n.globalAlpha=1},_T=new WeakMap([]);_M=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g});var vi,fd,wu,vu,Il,yb,is,jf,bd=X(()=>{"use strict";f();me();vi=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",fd=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",wu=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",vu=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Il=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",yb=e=>e==="arrow",is=e=>e==="arrow",jf=(e,t)=>{let r=null;for(let o=e.length-1;o>=0;--o){let n=e[o];if(!n.isDeleted&&t(n)){r=n;break}}return r}});import{simplify as NM}from"points-on-curve";function FM(e){let t=e.roughness,r=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&r>=50||o>=15&&e.roundness&&Il(e.type)||ie(e)&&r>=50?t:Math.min(t/(r<10?3:2),2.5)}var OM,BT,Jr,OT,FT,ty,BM,Xh=X(()=>{"use strict";f();we();mt();li();V();Y();me();bd();OM=e=>[8,8+e],BT=e=>[1.5,6+e];Jr=(e,t=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?OM(e.strokeWidth):e.strokeStyle==="dotted"?BT(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:FM(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<Rh.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return r.fillStyle=e.fillStyle,r.fill=Ar(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(r.curveFitting=1),r;case"line":case"freedraw":return Dr(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),r;case"arrow":return r;default:throw new Error(`Unimplemented type ${e.type}`)}},OT=(e,t,r)=>sr(e)&&(t||Rt(e)&&r?.get(e.id)!==!0)&&Ar(e.backgroundColor)&&Ar(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Io(e)?{...e,strokeColor:Ar(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Ar(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,FT=(e,t,r,o,n,i,a)=>{let s=vb(e,t,r,o);if(s===null)return[];switch(o){case"dot":case"circle":case"circle_outline":{let[l,c,d]=s;return delete i.strokeLineDash,[n.circle(l,c,d,{...i,fill:o==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[l,c,d,m,p,u]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[l,c]],{...i,fill:o==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[l,c,d,m,p,u,g,h]=s;return delete i.strokeLineDash,[n.polygon([[l,c],[d,m],[p,u],[g,h],[l,c]],{...i,fill:o==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"bar":case"arrow":default:{let[l,c,d,m,p,u]=s;if(e.strokeStyle==="dotted"){let g=BT(e.strokeWidth-1);i.strokeLineDash=[g[0],g[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,m,l,c,i),n.line(p,u,l,c,i)]}}},ty=(e,t,{isExporting:r,canvasBackgroundColor:o,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,s=e.height,l=fo(Math.min(a,s),e);i=t.path(`M ${l} 0 L ${a-l} 0 Q ${a} 0, ${a} ${l} L ${a} ${s-l} Q ${a} ${s}, ${a-l} ${s} L ${l} ${s} Q 0 ${s}, 0 ${s-l} L 0 ${l} Q 0 0, ${l} 0`,Jr(OT(e,r,n),!0))}else i=t.rectangle(0,0,e.width,e.height,Jr(OT(e,r,n),!1));return i}case"diamond":{let i,[a,s,l,c,d,m,p,u]=wb(e);if(e.roundness){let g=fo(Math.abs(a-p),e),h=fo(Math.abs(c-s),e);i=t.path(`M ${a+g} ${s+h} L ${l-g} ${c-h}
36
+ C ${l} ${c}, ${l} ${c}, ${l-g} ${c+h}
37
+ L ${d+g} ${m-h}
38
+ C ${d} ${m}, ${d} ${m}, ${d-g} ${m-h}
39
+ L ${p+g} ${u+h}
40
+ C ${p} ${u}, ${p} ${u}, ${p+g} ${u-h}
41
+ L ${a-g} ${s+h}
42
+ C ${a} ${s}, ${a} ${s}, ${a+g} ${s+h}`,Jr(e,!0))}else i=t.polygon([[a,s],[l,c],[d,m],[p,u]],Jr(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,Jr(e));case"line":case"arrow":{let i,a=Jr(e),s=e.points.length?e.points:[[0,0]];if(de(e)?i=[t.path(BM(s,16),Jr(e,!0))]:e.roundness?i=[t.curve(s,a)]:a.fill?i=[t.polygon(s,a)]:i=[t.linearPath(s,a)],e.type==="arrow"){let{startArrowhead:l=null,endArrowhead:c="arrow"}=e;if(l!==null){let d=FT(e,i,"start",l,t,a,o);i.push(...d)}if(c!==null){let d=FT(e,i,"end",c,t,a,o);i.push(...d)}}return i}case"freedraw":{let i;if(RT(e),Dr(e.points)){let a=NM(e.points,.75);i=t.curve(a,{...Jr(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return $o(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},BM=(e,t)=>{let r=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],s=Math.min(t,Math.sqrt(ul(e[n],a))/2,Math.sqrt(ul(e[n],i))/2);i[0]<e[n][0]&&i[1]===e[n][1]?r.push([e[n][0]-s,e[n][1]]):i[0]===e[n][0]&&i[1]<e[n][1]?r.push([e[n][0],e[n][1]-s]):i[0]>e[n][0]&&i[1]===e[n][1]?r.push([e[n][0]+s,e[n][1]]):r.push([e[n][0],e[n][1]+s]),r.push(e[n]),a[0]<e[n][0]&&a[1]===e[n][1]?r.push([e[n][0]-s,e[n][1]]):a[0]===e[n][0]&&a[1]<e[n][1]?r.push([e[n][0],e[n][1]-s]):a[0]>e[n][0]&&a[1]===e[n][1]?r.push([e[n][0]+s,e[n][1]]):r.push([e[n][0],e[n][1]+s])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<r.length;n+=3)o.push(`L ${r[n][0]} ${r[n][1]}`),o.push(`Q ${r[n+1][0]} ${r[n+1][1]}, ${r[n+2][0]} ${r[n+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")}});import Sb from"roughjs/bin/rough";var Tb,ae,hb,wb,aa,zT,HT,zM,Ed,Ib,HM,UM,GM,vb,WM,VM,ho,Te,Tu,hi,Cb,Ab,Qr,Mb,dt=X(()=>{"use strict";f();mt();Xh();me();Ha();He();Wt();Qo();V();Tb=class e{static boundsCache=new WeakMap;static getBounds(t,r){let o=e.boundsCache.get(t);if(o?.version&&o.version===t.version&&!ze(t))return o.bounds;let n=e.calculateBounds(t,r);return e.boundsCache.set(t,{version:t.version,bounds:n}),n}static calculateBounds(t,r){let o,[n,i,a,s,l,c]=ae(t,r);if(Zt(t)){let[d,m,p,u]=Ib(t.points.map(([g,h])=>xe(g,h,l-t.x,c-t.y,t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(ie(t))o=VM(t,l,c,r);else if(t.type==="diamond"){let[d,m]=xe(l,i,l,c,t.angle),[p,u]=xe(l,s,l,c,t.angle),[g,h]=xe(n,c,l,c,t.angle),[x,v]=xe(a,c,l,c,t.angle),y=Math.min(d,p,g,x),w=Math.min(m,u,h,v),C=Math.max(d,p,g,x),M=Math.max(m,u,h,v);o=[y,w,C,M]}else if(t.type==="ellipse"){let d=(a-n)/2,m=(s-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),g=Math.hypot(d*p,m*u),h=Math.hypot(m*p,d*u);o=[l-g,c-h,l+g,c+h]}else{let[d,m]=xe(n,i,l,c,t.angle),[p,u]=xe(n,s,l,c,t.angle),[g,h]=xe(a,s,l,c,t.angle),[x,v]=xe(a,i,l,c,t.angle),y=Math.min(d,p,g,x),w=Math.min(m,u,h,v),C=Math.max(d,p,g,x),M=Math.max(m,u,h,v);o=[y,w,C,M]}return o}},ae=(e,t,r=!1)=>{if(Zt(e))return HM(e);if(ie(e))return K.getElementAbsoluteCoords(e,t,r);if(H(e)){let o=t?Et(e,t):null;if(ne(o)){let n=K.getBoundTextElementPosition(o,e,t);return[n.x,n.y,n.x+e.width,n.y+e.height,n.x+e.width/2,n.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},hb=(e,t)=>{let[r,o,n,i,a,s]=ae(e,t),l=[a,s];if(ie(e)||Zt(e)){let v=[],y=0;for(;y<e.points.length-1;)v.push([ce([e.points[y][0]+e.x,e.points[y][1]+e.y],l,e.angle),ce([e.points[y+1][0]+e.x,e.points[y+1][1]+e.y],l,e.angle)]),y++;return v}let[c,d,m,p,u,g,h,x]=[[r,o],[n,o],[r,i],[n,i],[a,o],[a,i],[r,s],[n,s]].map(v=>ce(v,l,e.angle));return e.type==="diamond"?[[u,h],[u,x],[g,h],[g,x]]:e.type==="ellipse"?[[u,h],[u,x],[g,h],[g,x],[u,h],[u,x],[g,h],[g,x]]:[[c,d],[m,p],[c,m],[d,p],[c,x],[m,x],[d,h],[p,h]]},wb=e=>{let t=Math.floor(e.width/2)+1,r=0,o=e.width,n=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,r,o,n,i,a,0,n]},aa=e=>{for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},zT=(e,t,r,o,n)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*r+3*i*Math.pow(e,2)*o+Math.pow(e,3)*n},HT=(e,t,r,o)=>{let n=t-e,i=r-t,a=o-r,s=3*n-6*i+3*a,l=6*i-6*n,c=3*n,d=l*l-4*s*c;if(!(d>=0))return!1;let p=null,u=null,g=1/0,h=1/0;return s===0?g=h=-c/l:(g=(-l+Math.sqrt(d))/(2*s),h=(-l-Math.sqrt(d))/(2*s)),g>=0&&g<=1&&(p=zT(g,e,t,r,o)),h>=0&&h<=1&&(u=zT(h,e,t,r,o)),[p,u]},zM=(e,t,r,o)=>{let n=HT(e[0],t[0],r[0],o[0]),i=HT(e[1],t[1],r[1],o[1]),a=Math.min(e[0],o[0]),s=Math.max(e[0],o[0]);if(n){let d=n.filter(m=>m!==null);a=Math.min(a,...d),s=Math.max(s,...d)}let l=Math.min(e[1],o[1]),c=Math.max(e[1],o[1]);if(i){let d=i.filter(m=>m!==null);l=Math.min(l,...d),c=Math.max(c,...d)}return[a,l,s,c]},Ed=(e,t)=>{let r=[0,0],{minX:o,minY:n,maxX:i,maxY:a}=e.reduce((s,{op:l,data:c})=>{if(l==="move")r=c;else if(l==="bcurveTo"){let d=[c[0],c[1]],m=[c[2],c[3]],p=[c[4],c[5]],u=t?t(...d):d,g=t?t(...m):m,h=t?t(...p):p,x=t?t(...r):r;r=p;let[v,y,w,C]=zM(x,u,g,h);s.minX=Math.min(s.minX,v),s.minY=Math.min(s.minY,y),s.maxX=Math.max(s.maxX,w),s.maxY=Math.max(s.maxY,C)}return s},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[o,n,i,a]},Ib=e=>{let t=1/0,r=1/0,o=-1/0,n=-1/0;for(let[i,a]of e)t=Math.min(t,i),r=Math.min(r,a),o=Math.max(o,i),n=Math.max(n,a);return[t,r,o,n]},HM=e=>{let[t,r,o,n]=Ib(e.points),i=t+e.x,a=r+e.y,s=o+e.x,l=n+e.y;return[i,a,s,l,(i+s)/2,(a+l)/2]},UM=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},GM=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},vb=(e,t,r,o)=>{let n=aa(t[0]);if(n.length<1)return null;let i=r==="start"?1:n.length-1,a=n[i].data,s=[a[4],a[5]],l=[a[2],a[3]],c=[a[0],a[1]],d=n[i-1],m=[0,0];d.op==="move"?m=d.data:d.op==="bcurveTo"&&(m=[d.data[4],d.data[5]]);let p=(q,re)=>Math.pow(1-q,3)*s[re]+3*q*Math.pow(1-q,2)*l[re]+3*Math.pow(q,2)*(1-q)*c[re]+m[re]*Math.pow(q,3),[u,g]=r==="start"?m:s,[h,x]=[p(.3,0),p(.3,1)],v=Math.hypot(u-h,g-x),y=(u-h)/v,w=(g-x)/v,C=UM(o),M=0;{let[q,re]=r==="end"?e.points[e.points.length-1]:e.points[0],[ge,le]=e.points.length>1?r==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];M=Math.hypot(q-ge,re-le)}let P=Math.min(C,M*(o==="diamond"||o==="diamond_outline"?.25:.5)),A=u-y*P,N=g-w*P;if(o==="dot"||o==="circle"||o==="circle_outline"){let q=Math.hypot(N-g,A-u)+e.strokeWidth-2;return[u,g,q]}let k=GM(o),[D,z]=xe(A,N,u,g,-k*Math.PI/180),[R,W]=xe(A,N,u,g,k*Math.PI/180);if(o==="diamond"||o==="diamond_outline"){let q,re;if(r==="start"){let[ge,le]=e.points.length>1?e.points[1]:[0,0];[q,re]=xe(u+P*2,g,u,g,Math.atan2(le-g,ge-u))}else{let[ge,le]=e.points.length>1?e.points[e.points.length-2]:[0,0];[q,re]=xe(u-P*2,g,u,g,Math.atan2(g-le,u-ge))}return[u,g,D,z,q,re,R,W]}return[u,g,D,z,R,W]},WM=e=>{let t=Sb.generator(),r=Jr(e),o=e.roundness?"curve":r.fill?"polygon":"linearPath";return t[o](e.points,r)},VM=(e,t,r,o)=>{let n=J(e,o);if(e.points.length<2){let[m,p]=e.points[0],[u,g]=xe(e.x+m,e.y+p,t,r,e.angle),h=[u,g,u,g];if(n){let x=K.getMinMaxXYWithBoundText(e,o,[u,g,u,g],n);h=[x[0],x[1],x[2],x[3]]}return h}let a=_e.get(e)?.[0]??WM(e),s=aa(a),c=Ed(s,(m,p)=>xe(e.x+m,e.y+p,t,r,e.angle)),d=[c[0],c[1],c[2],c[3]];if(n){let m=K.getMinMaxXYWithBoundText(e,o,d,n);d=[m[0],m[1],m[2],m[3]]}return d},ho=(e,t)=>Tb.getBounds(e,t),Te=e=>{if(!e.length)return[0,0,0,0];let t=1/0,r=-1/0,o=1/0,n=-1/0,i=Z(e);return e.forEach(a=>{let[s,l,c,d]=ho(a,i);t=Math.min(t,s),o=Math.min(o,l),r=Math.max(r,c),n=Math.max(n,d)}),[t,o,r,n]},Tu=(e,t)=>{let[r,o,n,i]=Te(e);return[r+t.x,o+t.y,n+t.x,i+t.y]},hi=(e,t,r,o)=>{if(!(ie(e)||Zt(e)))return[e.x,e.y,e.x+t,e.y+r];let n=Yi(0,t,Yi(1,r,e.points,o),o),i;if(Zt(e))i=Ib(n);else{let d=Sb.generator(),m=e.roundness?d.curve(n,Jr(e)):d.linearPath(n,Jr(e)),p=aa(m);i=Ed(p)}let[a,s,l,c]=i;return[a+e.x,s+e.y,l+e.x,c+e.y]},Cb=(e,t)=>{let r=Sb.generator(),o=e.roundness==null?r.linearPath(t,Jr(e)):r.curve(t,Jr(e)),n=aa(o),[i,a,s,l]=Ed(n);return[i+e.x,a+e.y,s+e.x,l+e.y]},Ab=(e,t)=>{if(!e.length)return[0,0,0,0];let r=1/0,o=e[0],n=Z(e);return e.forEach(i=>{let[a,s,l,c]=ho(i,n),d=Pt((a+l)/2,(s+c)/2,t.x,t.y);d<r&&(r=d,o=i)}),ho(o,n)},Qr=e=>{let[t,r,o,n]=Te(e);return{minX:t,minY:r,maxX:o,maxY:n,width:o-t,height:n-r,midX:(t+o)/2,midY:(r+n)/2}},Mb=({scrollX:e,scrollY:t,width:r,height:o,zoom:n})=>[-e,-t,-e+r/n.value,-t+o/n.value]});var xe,ce,z2,Pt,ul,Cl,Dr,Op,Ot,fo,Pb,Lb,YM,UT,GT,WT,gn,NT,Al,Ml,xd,yd,gd,Su,Db,fi,dn,kb,qa,ta,bi,Bp,Yp,Yf,mt=X(()=>{"use strict";f();Y();dt();Qo();xe=(e,t,r,o,n)=>[(e-r)*Math.cos(n)-(t-o)*Math.sin(n)+r,(e-r)*Math.sin(n)+(t-o)*Math.cos(n)+o],ce=(e,t,r)=>xe(e[0],e[1],t[0],t[1],r),z2=(e,t,r,o,n,i,a,s)=>{let l=Math.cos(o),c=Math.sin(o);return e.e&&e.w?t+=n+a:e.e?(t+=n*(1+l),r+=n*c,t+=a*(1-l),r+=a*-c):e.w&&(t+=n*(1-l),r+=n*-c,t+=a*(1+l),r+=a*c),e.n&&e.s?r+=i+s:e.n?(t+=i*c,r+=i*(1-l),t+=s*-c,r+=s*(1+l)):e.s&&(t+=i*-c,r+=i*(1+l),t+=s*c,r+=s*(1-l)),[t,r]},Pt=(e,t,r,o)=>{let n=r-e,i=o-t;return Math.hypot(n,i)},ul=(e,t)=>{let r=t[0]-e[0],o=t[1]-e[1];return r*r+o*o},Cl=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],Dr=(e,t=1)=>{if(e.length>=3){let[r,o]=[e[0],e[e.length-1]];return Pt(r[0],r[1],o[0],o[1])<=Ns/t}return!1},Op=(e,t,r)=>t[0]<=Math.max(e[0],r[0])&&t[0]>=Math.min(e[0],r[0])&&t[1]<=Math.max(e[1],r[1])&&t[1]>=Math.min(e[1],r[1]),Ot=(e,t,r)=>r?[Math.round(e/r)*r,Math.round(t/r)*r]:[e,t],fo=(e,t)=>{if(t.roundness?.type===ct.PROPORTIONAL_RADIUS||t.roundness?.type===ct.LEGACY)return e*Mm;if(t.roundness?.type===ct.ADAPTIVE_RADIUS){let r=t.roundness?.value??E0,o=r/Mm;return e<=o?e*Mm:r}return 0},Pb=(e,t)=>{let r=_e.generateElementShape(e,null);if(!r)return null;let o=aa(r[0]),n=[0,0],i=0,a=1/0,s=null;for(;i<o.length;){let{op:l,data:c}=o[i];if(l==="move"&&(n=c),l==="bcurveTo"){let d=n,m=[c[0],c[1]],p=[c[2],c[3]],u=[c[4],c[5]],g=Pt(u[0],u[1],t[0],t[1]);g<a&&(a=g,s=[d,m,p,u]),n=u}i++}return s},Lb=(e,t,r,o,n)=>{let i=(l,c)=>Math.pow(1-l,3)*o[c]+3*l*Math.pow(1-l,2)*r[c]+3*Math.pow(l,2)*(1-l)*t[c]+e[c]*Math.pow(l,3),a=i(n,0),s=i(n,1);return[a,s]},YM=(e,t)=>{let r=Pb(e,t);if(!r)return[];let o=[],n=1;for(;n>0;){let i=Lb(r[0],r[1],r[2],r[3],n);o.push([i[0],i[1]]),n-=.05}return o.length&&gn(o.at(-1),t)&&o.push([t[0],t[1]]),o},UT=(e,t)=>{let r=[];r[0]=0;let o=YM(e,t),n=0,i=0;for(;n<o.length-1;){let a=Pt(o[n][0],o[n][1],o[n+1][0],o[n+1][1]);i+=a,r.push(i),n++}return r},GT=(e,t)=>UT(e,t).at(-1),WT=(e,t,r)=>{let o=UT(e,t),n=o.length-1,i=o.at(-1),a=r*i,s=0,l=n,c=0;for(;s<l;)c=Math.floor(s+(l-s)/2),o[c]<a?s=c+1:l=c;return o[c]>a&&c--,o[c]===a?c/n:1-(c+(a-o[c])/(o[c+1]-o[c]))/n},gn=(e,t)=>e[0]===t[0]&&e[1]===t[1],NT=e=>Math.round(e/Math.PI*1e4)%5e3===0,Al=e=>e*180/Math.PI,Ml=e=>e/180*Math.PI,xd=([e,t],[r,o])=>e<=r?t>=r:e>=r?o>=e:!1,yd=(e,t)=>{let r=Math.max(e[0],t[0]),o=Math.min(e[1],t[1]);return r<=o?[r,o]:null},gd=(e,t,r)=>e>=t&&e<=r,Su=(e,t)=>[e[0]+t[0],e[1]+t[1]],Db=(e,t)=>[e[0]*t,e[1]*t],fi=(e,t=[0,0])=>[e[0]-t[0],e[1]-t[1]],dn=(e,t,r)=>Su(t,Db(fi(e,t),r)),kb=(e,t,r)=>(e[0]-r[0])*(t[1]-r[1])-(t[0]-r[0])*(e[1]-r[1]),qa=(e,t,r,o)=>{let n=kb(e,t,r),i=kb(e,r,o),a=kb(e,o,t),s=n<0||i<0||a<0,l=n>0||i>0||a>0;return!(s&&l)},ta=(e,t)=>e[0]>t[0]&&e[0]<t[2]&&e[1]>t[1]&&e[1]<t[3],bi=(e,t)=>{let r={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height,midX:e.x+e.width/2,midY:e.y+e.height/2},o=[r.midX,r.midY],[n,i]=ce([r.minX,r.minY],o,e.angle),[a,s]=ce([r.maxX,r.minY],o,e.angle),[l,c]=ce([r.maxX,r.maxY],o,e.angle),[d,m]=ce([r.minX,r.maxY],o,e.angle),p=[Math.min(n,a,l,d),Math.min(i,s,c,m),Math.max(n,a,l,d),Math.max(i,s,c,m)];if(t){let[u,g,h,x]=t;return[p[0]-x,p[1]-u,p[2]+g,p[3]+h]}return p},Bp=e=>[e[0]+(e[2]-e[0])/2,e[1]+(e[3]-e[1])/2],Yp=e=>[e.x+e.width/2,e.y+e.height/2],Yf=(e,t,r)=>Math.min(Math.max(e,t),r)});var wd,VT=X(()=>{"use strict";f();wd=class{constructor(t){this.scoreFunction=t}content=[];sinkDown(t){let r=this.content[t];for(;t>0;){let o=(t+1>>1)-1,n=this.content[o];if(this.scoreFunction(r)<this.scoreFunction(n))this.content[o]=r,this.content[t]=n,t=o;else break}}bubbleUp(t){let r=this.content.length,o=this.content[t],n=this.scoreFunction(o);for(;;){let i=t+1<<1,a=i-1,s=null,l=0;if(a<r){let c=this.content[a];l=this.scoreFunction(c),l<n&&(s=a)}if(i<r){let c=this.content[i];this.scoreFunction(c)<(s===null?n:l)&&(s=i)}if(s!==null)this.content[t]=this.content[s],this.content[s]=o,t=s;else break}}push(t){this.content.push(t),this.sinkDown(this.content.length-1)}pop(){if(this.content.length===0)return null;let t=this.content[0],r=this.content.pop();return this.content.length>0&&(this.content[0]=r,this.bubbleUp(0)),t}remove(t){if(this.content.length===0)return;let r=this.content.indexOf(t),o=this.content.pop();r<this.content.length&&(this.content[r]=o,this.scoreFunction(o)<this.scoreFunction(t)?this.sinkDown(r):this.bubbleUp(r))}size(){return this.content.length}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}}});var Hn,_o,sa,XM,KM,_b,$M,ZM,YT,jM,qM,vd,Iu,jT,XT,JM,QM,ek,tk,rk,KT,$T,ZT,kl=X(()=>{"use strict";f();al();VT();mt();Ha();V();yr();Wf();De();me();Hn=40,_o=(e,t,r,o,n,i)=>{let a=rk(t,i?.changedElements),s=tk(t,i?.changedElements),l=Su(r[0],[e.x+(o?o[0]:0),e.y+(o?o[1]:0)]),c=Su(r[r.length-1],[e.x+(o?o[0]:0),e.y+(o?o[1]:0)]),d=e.startBinding&&XT(e.startBinding.elementId,s),m=e.endBinding&&XT(e.endBinding.elementId,s),p=i?.isDragging?xr(ar(l),a,s,!0):d,u=i?.isDragging?xr(ar(c),a,s,!0):m,g=KT(e.startBinding?.fixedPoint,l,c,s,d,p,i?.isDragging),h=KT(e.endBinding?.fixedPoint,c,l,s,m,u,i?.isDragging),x=ZT(g,h,s,p,l),v=ZT(h,g,s,u,c),y=[g[0]-2,g[1]-2,g[0]+2,g[1]+2],w=[h[0]-2,h[1]-2,h[0]+2,h[1]+2],C=p?bi(p,sa(x,e.startArrowhead?at*6:at*2,1)):y,M=u?bi(u,sa(v,e.endArrowhead?at*6:at*2,1)):w,I=ta(g,u?bi(u,sa(v,Hn,Hn)):w)||ta(h,p?bi(p,sa(x,Hn,Hn)):y),P=jT(I?[y,w]:[C,M]),A=$M(I?y:C,I?w:M,P,I?sa(x,!p&&!u?0:Hn,0):sa(x,!p&&!u?0:Hn-(e.startArrowhead?at*6:at*2),Hn),I?sa(v,!p&&!u?0:Hn,0):sa(v,!p&&!u?0:Hn-(e.endArrowhead?at*6:at*2),Hn),I),N=YT(A[0],x,g),k=YT(A[1],v,h),D=ZM(A,N||g,x,k||h,v,P),z=N&&Iu(N,D),R=k&&Iu(k,D),W=Iu(h,D);W&&u&&(W.closed=!0);let q=Iu(g,D);q&&e.startBinding&&(q.closed=!0);let re=z&&R&&(ta(z.pos,A[1])||ta(R.pos,A[0])),ge=XM(z||q,R||W,D,x||Nt,v||Nt,re?[]:A);if(ge){let le=ge.map(U=>[U.pos[0],U.pos[1]]);z&&le.unshift(g),R&&le.push(h),F(e,{...n,...JM(QM(le),0,0),angle:0},i?.informMutation)}else console.error("Elbow arrow cannot find a route")},sa=(e,t,r)=>{switch(e){case Nr:return[t,r,r,r];case Nt:return[r,t,r,r];case _r:return[r,r,t,r]}return[r,r,r,t]},XM=(e,t,r,o,n,i)=>{let a=_b(e.pos,t.pos),s=new wd(l=>l.f);for(s.push(e);s.size()>0;){let l=s.pop();if(!l||l.closed)continue;if(l===t)return KM(e,l);l.closed=!0;let c=qM(l.addr,r);for(let d=0;d<4;d++){let m=c[d];if(!m||m.closed)continue;let p=dn(m.pos,l.pos,.5);if(F0(...i.map(C=>ta(p,C))))continue;let u=ek(d),g=l.parent?Ji(fi(l.pos,l.parent.pos)):o,h=Db(g,-1);if(gn(h,u)||gn(e.addr,m.addr)&&gn(u,o)||gn(t.addr,m.addr)&&gn(u,n))continue;let v=g!==u,y=l.g+_b(m.pos,l.pos)+(v?Math.pow(a,3):0),w=m.visited;if(!w||y<m.g){let C=jM(m,t,u,n);m.visited=!0,m.parent=l,m.h=_b(t.pos,m.pos)+C*Math.pow(a,2),m.g=y,m.f=m.g+m.h,w?s.rescoreElement(m):s.push(m)}}}return null},KM=(e,t)=>{let r=t,o=[];for(;r.parent;)o.unshift(r),r=r.parent;return o.unshift(e),o},_b=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),$M=(e,t,r,o,n,i)=>{let[a,s,l,c]=o??[0,0,0,0],[d,m,p,u]=n??[0,0,0,0],g=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((e[0]+t[2])/2,e[0]-c):(e[0]+t[2])/2:e[0]>t[0]?e[0]-c:r[0]-c,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((e[1]+t[3])/2,e[1]-a):(e[1]+t[3])/2:e[1]>t[1]?e[1]-a:r[1]-a,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((e[2]+t[0])/2,e[2]+s):(e[2]+t[0])/2:e[2]<t[2]?e[2]+s:r[2]+s,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((e[3]+t[1])/2,e[3]+l):(e[3]+t[1])/2:e[3]<t[3]?e[3]+l:r[3]+l],h=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((t[0]+e[2])/2,t[0]-u):(t[0]+e[2])/2:t[0]>e[0]?t[0]-u:r[0]-u,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((t[1]+e[3])/2,t[1]-d):(t[1]+e[3])/2:t[1]>e[1]?t[1]-d:r[1]-d,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((t[2]+e[0])/2,t[2]+m):(t[2]+e[0])/2:t[2]<e[2]?t[2]+m:r[2]+m,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((t[3]+e[1])/2,t[3]+p):(t[3]+e[1])/2:t[3]<e[3]?t[3]+p:r[3]+p],x=jT([g,h]);if(!i&&g[2]-g[0]+h[2]-h[0]>x[2]-x[0]+1e-11&&g[3]-g[1]+h[3]-h[1]>x[3]-x[1]+1e-11){let[v,y]=[(h[0]+h[2])/2,(h[1]+h[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let w=g[2]+(h[0]-g[2])/2,C=h[3]+(g[1]-h[3])/2;return Xc([e[2],e[1]],[e[0],e[3]],[v,y])>0?[[g[0],g[1],w,g[3]],[w,h[1],h[2],h[3]]]:[[g[0],C,g[2],g[3]],[h[0],h[1],h[2],C]]}else if(e[2]<t[0]&&e[3]<t[1]){let w=g[2]+(h[0]-g[2])/2,C=g[3]+(h[1]-g[3])/2;return Xc([e[0],e[1]],[e[2],e[3]],[v,y])>0?[[g[0],g[1],g[2],C],[h[0],C,h[2],h[3]]]:[[g[0],g[1],w,g[3]],[w,h[1],h[2],h[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let w=h[2]+(g[0]-h[2])/2,C=g[3]+(h[1]-g[3])/2;return Xc([e[2],e[1]],[e[0],e[3]],[v,y])>0?[[w,g[1],g[2],g[3]],[h[0],h[1],w,h[3]]]:[[g[0],g[1],g[2],C],[h[0],C,h[2],h[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let w=h[2]+(g[0]-h[2])/2,C=h[3]+(g[1]-h[3])/2;return Xc([e[0],e[1]],[e[2],e[3]],[v,y])>0?[[w,g[1],g[2],g[3]],[h[0],h[1],w,h[3]]]:[[g[0],C,g[2],g[3]],[h[0],h[1],h[2],C]]}}return[g,h]},ZM=(e,t,r,o,n,i)=>{let a=new Set,s=new Set;r===Rr||r===Nt?s.add(t[1]):a.add(t[0]),n===Rr||n===Nt?s.add(o[1]):a.add(o[0]),e.forEach(d=>{a.add(d[0]),a.add(d[2]),s.add(d[1]),s.add(d[3])}),a.add(i[0]),a.add(i[2]),s.add(i[1]),s.add(i[3]);let l=Array.from(s).sort((d,m)=>d-m),c=Array.from(a).sort((d,m)=>d-m);return{row:l.length,col:c.length,data:l.flatMap((d,m)=>c.map((p,u)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[u,m],pos:[p,d]})))}},YT=(e,t,r)=>{switch(t){case Nr:return[r[0],e[1]];case Nt:return[e[2],r[1]];case _r:return[r[0],e[3]]}return[e[0],r[1]]},jM=(e,t,r,o)=>{if(o===Nt)switch(r){case Nt:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case Nr:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case _r:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Rr:return e.pos[1]===t.pos[1]?4:2}else if(o===Rr)switch(r){case Nt:return e.pos[1]===t.pos[1]?4:2;case Nr:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case _r:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Rr:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(o===Nr)switch(r){case Nt:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Nr:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case _r:return e.pos[0]===t.pos[0]?4:2;case Rr:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(o===_r)switch(r){case Nt:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Nr:return e.pos[0]===t.pos[0]?4:2;case _r:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Rr:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},qM=([e,t],r)=>[vd([e,t-1],r),vd([e+1,t],r),vd([e,t+1],r),vd([e-1,t],r)],vd=([e,t],r)=>e<0||e>=r.col||t<0||t>=r.row?null:r.data[t*r.col+e]??null,Iu=(e,t)=>{for(let r=0;r<t.col;r++)for(let o=0;o<t.row;o++){let n=vd([r,o],t);if(n&&e[0]===n.pos[0]&&e[1]===n.pos[1])return n}return null},jT=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],XT=(e,t)=>{let r=t.get(e);return r&&An(r)?r:null},JM=(e,t,r)=>{let o=e[0][0],n=e[0][1],i=e.map((a,s)=>[a[0]-o,a[1]-n]);return{points:i,x:o+(t??0),y:n+(r??0),...pi(i)}},QM=e=>e.slice(2).reduce((t,r)=>gn(Ji(fi(t[t.length-1],t[t.length-2])),Ji(fi(r,t[t.length-1])))?[...t.slice(0,-1),r]:[...t,r],[e[0]??[0,0],e[1]??[1,0]]),ek=e=>{switch(e){case 0:return Nr;case 1:return Nt;case 2:return _r}return Rr},tk=(e,t)=>t?Mr(new Map([...e.getNonDeletedElementsMap(),...t])):e.getNonDeletedElementsMap(),rk=(e,t)=>t?[...e.getNonDeletedElements(),...[...t].map(([r,o])=>o)]:e.getNonDeletedElements(),KT=(e,t,r,o,n,i,a)=>{if(a){if(i){let s=$T(t,r,i,o);return Mv(i,s)}return t}if(n){let s=Up(e||[0,0],n);return Math.abs(Ja(n,s,o)-at)>.01?$T(t,r,n,o):s}return t},$T=(e,t,r,o)=>gl(z0(r)?Av(r,e):e,t,r,o),ZT=(e,t,r,o,n)=>Cv(e,t,o,o&&bi(o,Array(4).fill(Ja(o,e,r))),r,n)});var Ti,K,ok,Wt=X(()=>{"use strict";f();mt();we();dt();De();yr();V();me();ye();He();Y();Qo();kl();Ti={version:null,points:[],zoom:null},K=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;constructor(t){this.elementId=t.id,gn(t.points[0],[0,0])||console.error("Linear element is not normalized",Error().stack),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static POINT_HANDLE_SIZE=10;static getElement(t,r){let o=r.get(t);return o||null}static handleBoxSelection(t,r,o,n){if(!r.editingLinearElement||r.draggingElement?.type!=="selection")return!1;let{editingLinearElement:i}=r,{selectedPointsIndices:a,elementId:s}=i,l=e.getElement(s,n);if(!l)return!1;let[c,d,m,p]=ae(r.draggingElement,n),g=e.getPointsGlobalCoordinates(l,n).reduce((h,x,v)=>((x[0]>=c&&x[0]<=m&&x[1]>=d&&x[1]<=p||t.shiftKey&&a?.includes(v))&&h.push(v),h),[]).filter(h=>!(de(l)&&h!==0&&h!==l.points.length-1));o({editingLinearElement:{...i,selectedPointsIndices:g.length?g:null}})}static handlePointDragging(t,r,o,n,i,a,s){if(!a)return!1;let{elementId:l}=a,c=s.getNonDeletedElementsMap(),d=e.getElement(l,c);if(!d||de(d)&&!a.pointerDownState.lastClickedIsEndPoint&&a.pointerDownState.lastClickedPoint!==0)return!1;let m=de(d)?a.selectedPointsIndices?.reduce((g,h)=>h===0?[0,g[1]]:[g[0],d.points.length-1],[!1,!1]).filter(g=>typeof g=="number"):a.selectedPointsIndices,p=de(d)?a.pointerDownState.lastClickedPoint>0?d.points.length-1:0:a.pointerDownState.lastClickedPoint,u=d.points[p];if(m&&u){if(Za(t)&&m.length===1&&d.points.length>1){let h=m[0],x=d.points[h===0?1:h-1],[v,y]=e._getShiftLockedDelta(d,c,x,[o,n],t[S.CTRL_OR_CMD]?null:r.gridSize);e.movePoints(d,[{index:h,point:[v+x[0],y+x[1]],isDragging:h===p}],s)}else{let h=e.createPointAt(d,c,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize),x=h[0]-u[0],v=h[1]-u[1];e.movePoints(d,m.map(y=>{let w=y===p?e.createPointAt(d,c,o-a.pointerOffset.x,n-a.pointerOffset.y,t[S.CTRL_OR_CMD]?null:r.gridSize):[d.points[y][0]+x,d.points[y][1]+v];return{index:y,point:w,isDragging:y===p}}),s)}if(J(d,c)&&mn(d,c,!1),Kr(d,!1)){let h=[];m[0]===0&&h.push(ar(e.getPointGlobalCoordinates(d,d.points[0],c)));let v=m[m.length-1];v===d.points.length-1&&h.push(ar(e.getPointGlobalCoordinates(d,d.points[v],c))),h.length&&i(d,h)}return!0}return!1}static handlePointerUp(t,r,o,n){let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),{elementId:s,selectedPointsIndices:l,isDragging:c,pointerDownState:d}=r,m=e.getElement(s,i);if(!m)return r;let p={};if(c&&l){for(let u of l)if(u===0||u===m.points.length-1){Dr(m.points,o.zoom.value)&&e.movePoints(m,[{index:u,point:u===0?m.points[m.points.length-1]:m.points[0]}],n);let g=Fn(o)?xr(ar(e.getPointAtIndexGlobalCoordinates(m,u,i)),a,i):null;p[u===0?"startBindingElement":"endBindingElement"]=g}}return{...r,...p,selectedPointsIndices:c||t.shiftKey?!c&&t.shiftKey&&d.prevSelectedPointsIndices?.includes(d.lastClickedPoint)?l&&l.filter(u=>u!==d.lastClickedPoint):l:l?.includes(d.lastClickedPoint)?[d.lastClickedPoint]:l,isDragging:!1,pointerOffset:{x:0,y:0}}}static getEditorMidPoints=(t,r,o)=>{let n=J(t,r);return!o.editingLinearElement&&t.points.length>2&&!n?[]:(Ti.version===t.version&&Ti.zoom===o.zoom.value||e.updateEditorMidPointsCache(t,r,o),Ti.points)};static updateEditorMidPointsCache=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,r),i=0,a=[];for(;i<n.length-1;){if(e.isSegmentTooShort(t,t.points[i],t.points[i+1],o.zoom)){a.push(null),i++;continue}let s=e.getSegmentMidPoint(t,n[i],n[i+1],i+1,r);a.push(s),i++}Ti.points=a,Ti.version=t.version,Ti.zoom=o.zoom.value};static getSegmentMidpointHitCoords=(t,r,o,n)=>{let{elementId:i}=t,a=e.getElement(i,n);if(!a||e.getPointIndexUnderCursor(a,n,o.zoom,r.x,r.y)>=0||e.getPointsGlobalCoordinates(a,n).length>=3&&!o.editingLinearElement)return null;let c=e.POINT_HANDLE_SIZE/o.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&Pt(d[0],d[1],r.x,r.y)<=c)return d;let m=0,p=e.getEditorMidPoints(a,n,o);for(;m<p.length;){if(p[m]!==null&&Pt(p[m][0],p[m][1],r.x,r.y)<=c)return p[m];m++}return null};static isSegmentTooShort(t,r,o,n){let i=Pt(r[0],r[1],o[0],o[1]);return t.points.length>2&&t.roundness&&(i=GT(t,o)),i*n.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,r,o,n,i){let a=Cl(r,o);if(t.points.length>2&&t.roundness){let s=Pb(t,t.points[n]);if(s){let l=WT(t,t.points[n],.5),[c,d]=Lb(s[0],s[1],s[2],s[3],l);a=e.getPointGlobalCoordinates(t,[c,d],i)}}return a}static getSegmentMidPointIndex(t,r,o,n){let i=e.getElement(t.elementId,n);if(!i)return-1;let a=e.getEditorMidPoints(i,n,r),s=0;for(;s<a.length;){if(e.arePointsEqual(o,a[s]))return s+1;s++}return-1}static handlePointerDown(t,r,o,n,i,a){let s=a.getNonDeletedElementsMap(),l=a.getNonDeletedElements(),c={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return c;let{elementId:d}=i,m=e.getElement(d,s);if(!m)return c;let p=e.getSegmentMidpointHitCoords(i,n,r,s),u=null;if(p&&(u=e.getSegmentMidPointIndex(i,r,p,s)),t.altKey&&r.editingLinearElement)return(i.lastUncommittedPoint==null||!de(m))&&(F(m,{points:[...m.points,e.createPointAt(m,s,n.x,n.y,t[S.CTRL_OR_CMD]?null:r.gridSize)]}),c.didAddPoint=!0),o.shouldCaptureIncrement(),c.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:p,index:u,added:!1}},selectedPointsIndices:[m.points.length-1],lastUncommittedPoint:null,endBindingElement:xr(n,l,s)},c.didAddPoint=!0,c;let g=e.getPointIndexUnderCursor(m,s,r.zoom,n.x,n.y);if(g>=0||p)c.hitElement=m;else{let{startBindingElement:P,endBindingElement:A}=i;Fn(r)&&Kr(m)&&Qa(m,P,A,s,a)}let[h,x,v,y]=ae(m,s),w=(h+v)/2,C=(x+y)/2,M=g>-1&&xe(m.x+m.points[g][0],m.y+m.points[g][1],w,C,m.angle),I=g>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(g)?ok([...i.selectedPointsIndices||[],g]):[g]:null;return c.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:g,lastClickedIsEndPoint:g===m.points.length-1,origin:{x:n.x,y:n.y},segmentMidpoint:{value:p,index:u,added:!1}},selectedPointsIndices:I,pointerOffset:M?{x:n.x-M[0],y:n.y-M[1]}:{x:0,y:0}},c}static arePointsEqual(t,r){return!t&&!r?!0:!t||!r?!1:gn(t,r)}static handlePointerMove(t,r,o,n,i){if(!n.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:s}=n.editingLinearElement,l=i.getNonDeletedElementsMap(),c=e.getElement(a,l);if(!c)return n.editingLinearElement;let{points:d}=c,m=d[d.length-1];if(!t.altKey)return m===s&&e.deletePoints(c,[d.length-1],i),{...n.editingLinearElement,lastUncommittedPoint:null};let p;if(Za(t)&&d.length>=2){let u=d[d.length-2],[g,h]=e._getShiftLockedDelta(c,l,u,[r,o],t[S.CTRL_OR_CMD]?null:n.gridSize);p=[g+u[0],h+u[1]]}else p=e.createPointAt(c,l,r-n.editingLinearElement.pointerOffset.x,o-n.editingLinearElement.pointerOffset.y,t[S.CTRL_OR_CMD]||de(c)?null:n.gridSize);return m===s?e.movePoints(c,[{index:c.points.length-1,point:p}],i):e.addPoints(c,n,[{point:p}],i),{...n.editingLinearElement,lastUncommittedPoint:c.points[c.points.length-1]}}static getPointGlobalCoordinates(t,r,o){let[n,i,a,s]=ae(t,o),l=(n+a)/2,c=(i+s)/2,{x:d,y:m}=t;return[d,m]=xe(d+r[0],m+r[1],l,c,t.angle),[d,m]}static getPointsGlobalCoordinates(t,r){let[o,n,i,a]=ae(t,r),s=(o+i)/2,l=(n+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return[d,m]=xe(d+c[0],m+c[1],s,l,t.angle),[d,m]})}static getPointAtIndexGlobalCoordinates(t,r,o){let n=r<0?t.points.length+r:r,[i,a,s,l]=ae(t,o),c=(i+s)/2,d=(a+l)/2,m=t.points[n],{x:p,y:u}=t;return m?xe(p+m[0],u+m[1],c,d,t.angle):xe(p,u,c,d,t.angle)}static pointFromAbsoluteCoords(t,r,o){if(de(t))return[r[0]-t.x,r[1]-t.y];let[n,i,a,s]=ae(t,o),l=(n+a)/2,c=(i+s)/2,[d,m]=xe(r[0],r[1],l,c,-t.angle);return[d-t.x,m-t.y]}static getPointIndexUnderCursor(t,r,o,n,i){let a=e.getPointsGlobalCoordinates(t,r),s=a.length;for(;--s>-1;){let l=a[s];if(Pt(n,i,l[0],l[1])*o.value<e.POINT_HANDLE_SIZE+1)return s}return-1}static createPointAt(t,r,o,n,i){let a=Ot(o,n,i),[s,l,c,d]=ae(t,r),m=(s+c)/2,p=(l+d)/2,[u,g]=xe(a[0],a[1],m,p,-t.angle);return[u-t.x,g-t.y]}static getNormalizedPoints(t){let{points:r}=t,o=r[0][0],n=r[0][1];return{points:r.map((i,a)=>[i[0]-o,i[1]-n]),x:t.x+o,y:t.y+n}}static normalizePoints(t){F(t,e.getNormalizedPoints(t))}static duplicateSelectedPoints(t,r){if(!t.editingLinearElement)return!1;let{selectedPointsIndices:o,elementId:n}=t.editingLinearElement,i=r.getNonDeletedElementsMap(),a=e.getElement(n,i);if(!a||o===null)return!1;let{points:s}=a,l=[],c=!1,d=-1,m=s.reduce((p,u,g)=>{if(++d,p.push(u),o.includes(g)){let x=s[g+1];x||(c=!0),p.push(x?[(u[0]+x[0])/2,(u[1]+x[1])/2]:[u[0],u[1]]),l.push(d+1),++d}return p},[]);if(F(a,{points:m}),c){let p=a.points[a.points.length-1];e.movePoints(a,[{index:a.points.length-1,point:[p[0]+30,p[1]+30]}],r)}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:l}}}}static deletePoints(t,r,o){let n=0,i=0;if(r.includes(0)){let l=t.points.find((c,d)=>!r.includes(d));l&&(n=l[0],i=l[1])}let s=t.points.reduce((l,c,d)=>(r.includes(d)||l.push(l.length?[c[0]-n,c[1]-i]:[0,0]),l),[]);e._updatePoints(t,s,n,i,o)}static addPoints(t,r,o,n){let s=[...t.points,...o.map(l=>l.point)];e._updatePoints(t,s,0,0,n)}static movePoints(t,r,o,n,i){let{points:a}=t,s=0,l=0,c=r.find(({index:m})=>m===0);c&&(s=c.point[0]+a[c.index][0],l=c.point[1]+a[c.index][1]);let d=a.map((m,p)=>{let u=r.find(g=>g.index===p);if(u){if(u.index===0)return m;let g=u.point[0]-a[u.index][0],h=u.point[1]-a[u.index][1];return[m[0]+g-s,m[1]+h-l]}return s||l?[m[0]-s,m[1]-l]:m});e._updatePoints(t,d,s,l,o,n,{isDragging:r.reduce((m,p)=>m||p.isDragging===!0,!1),changedElements:i?.changedElements})}static shouldAddMidpoint(t,r,o,n){let i=e.getElement(t.elementId,n);if(i&&de(i)||!i)return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let s=t.pointerDownState.origin,l=Pt(s.x,s.y,r.x,r.y);return!(!o.editingLinearElement&&l<ri/o.zoom.value)}static addMidpoint(t,r,o,n,i){let a=e.getElement(t.elementId,i);if(!a)return;let{segmentMidpoint:s}=t.pointerDownState,l={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,i,r.x,r.y,n&&!de(a)?o.gridSize:null),d=[...a.points.slice(0,s.index),c,...a.points.slice(s.index)];return F(a,{points:d}),l.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:s.index},l.selectedPointsIndices=[s.index],l}static _updatePoints(t,r,o,n,i,a,s){if(de(t)){let l={};a?.startBinding!==void 0&&(l.startBinding=a.startBinding!==null&&Gh(a.startBinding)?a.startBinding:null),a?.endBinding!==void 0&&(l.endBinding=a.endBinding!==null&&Gh(a.endBinding)?a.endBinding:null),_o(t,i,r,[o,n],l,s)}else{let l=Cb(t,r),c=Cb(t,t.points),d=(l[0]+l[2])/2,m=(l[1]+l[3])/2,p=(c[0]+c[2])/2,u=(c[1]+c[3])/2,g=p-d,h=u-m,x=xe(o,n,g,h,t.angle);F(t,{...a,points:r,x:t.x+x[0],y:t.y+x[1]})}}static _getShiftLockedDelta(t,r,o,n,i){let a=e.getPointGlobalCoordinates(t,o,r);if(de(t))return[n[0]-a[0],n[1]-a[1]];let[s,l]=Ot(n[0],n[1],i),{width:c,height:d}=Pl(a[0],a[1],s,l);return ce([c,d],[0,0],-t.angle)}static getBoundTextElementPosition=(t,r,o)=>{let n=e.getPointsGlobalCoordinates(t,o);n.length<2&&F(r,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let s=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[s],o);i=l[0]-r.width/2,a=l[1]-r.height/2}else{let s=t.points.length/2-1,l=Ti.points[s];t.points.length===2&&(l=Cl(n[0],n[1])),(!l||Ti.version!==t.version)&&(l=e.getSegmentMidPoint(t,n[s],n[s+1],s+1,o)),i=l[0]-r.width/2,a=l[1]-r.height/2}return{x:i,y:a}};static getMinMaxXYWithBoundText=(t,r,o,n)=>{let[i,a,s,l]=o,c=(i+s)/2,d=(a+l)/2,{x:m,y:p}=e.getBoundTextElementPosition(t,n,r),u=m+n.width,g=p+n.height,h=ce([i,a],[c,d],t.angle),x=ce([s,a],[c,d],t.angle),v=ce([m,p],[c,d],-t.angle),y=ce([u,p],[c,d],-t.angle),w=ce([m,g],[c,d],-t.angle),C=ce([u,g],[c,d],-t.angle);return h[0]<x[0]&&h[1]>=x[1]?(i=Math.min(i,w[0]),s=Math.max(s,Math.max(y[0],C[0])),a=Math.min(a,v[1]),l=Math.max(l,C[1])):h[0]>=x[0]&&h[1]>x[1]?(i=Math.min(i,C[0]),s=Math.max(s,Math.max(v[0],y[0])),a=Math.min(a,w[1]),l=Math.max(l,y[1])):h[0]>=x[0]?(i=Math.min(i,y[0]),s=Math.max(s,w[0]),a=Math.min(a,C[1]),l=Math.max(l,v[1])):h[1]<=x[1]&&(i=Math.min(i,Math.min(y[0],v[0])),s=Math.max(s,C[0]),a=Math.min(a,y[1]),l=Math.max(l,w[1])),[i,a,s,l,c,d]};static getElementAbsoluteCoords=(t,r,o=!1)=>{let n,i,a,s,l;if(t.points.length<2||!_e.get(t)){let{minX:p,minY:u,maxX:g,maxY:h}=t.points.reduce((x,[v,y])=>(x.minY=Math.min(x.minY,y),x.minX=Math.min(x.minX,v),x.maxX=Math.max(x.maxX,v),x.maxY=Math.max(x.maxY,y),x),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,s=g+t.x,l=h+t.y}else{let p=_e.generateElementShape(t,null),u=aa(p[0]),[g,h,x,v]=Ed(u);i=g+t.x,a=h+t.y,s=x+t.x,l=v+t.y}let c=(i+s)/2,d=(a+l)/2;if(n=[i,a,s,l,c,d],!o)return n;let m=J(t,r);return m&&(n=e.getMinMaxXYWithBoundText(t,r,[i,a,s,l],m)),n}},ok=e=>{let t=[...new Set(e.filter(r=>r!==null&&r!==-1))];return t=t.sort((r,o)=>r-o),t.length?t:null}});var as,ss,Cu,qT,Au=X(()=>{"use strict";f();as={},ss=(e,t)=>{let r=as[e]||(as[e]={height:t});return r.height=t,r},Cu=e=>{as[e]&&delete as[e]},qT=e=>as[e]?.height??null});var Zi,Nb,ft,Mu,mn,Ll,Vt,jw,ra,Dl,Rb,ls,ku,nk,ik,Lo,JT,QT,_l,ak,pn,J,Et,Pu,xb,e3,t3,r3,sk,o3,Si,br,ns,n3,Rl,He=X(()=>{"use strict";f();V();De();Y();we();me();Wt();Au();Zi=e=>zm(e).replace(/\t/g," "),Nb=e=>Zi(e).split(`
43
+ `),ft=(e,t,r,o=!0)=>{let n,i={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height,angle:t?.angle??e.angle};i.text=e.text,(t||!e.autoResize)&&(n=t?br(t,e):e.width,i.text=Lo(e.originalText,Me(e),n));let a=Vt(i.text,Me(e),e.lineHeight);if(e.autoResize&&(i.width=a.width),i.height=a.height,t){let s=ns(t,e),l=br(t,e);if(!ne(t)&&a.height>s){let p=Si(a.height,t.type);F(t,{height:p},o),ss(t.id,p)}if(a.width>l){let p=Si(a.width,t.type);F(t,{width:p},o)}let c={...e,...i},{x:d,y:m}=Ll(t,c,r);i.x=d,i.y=m}F(e,i,o)},Mu=(e,t,r)=>{let o=Z(e);t.forEach(n=>{let i=r.get(n.id),a=pn(n);if(a){let s=r.get(a);if(s){let l=o.get(i);l&&F(l,{boundElements:(n.boundElements||[]).filter(d=>d.id!==s&&d.id!==a).concat({type:"text",id:s})});let c=o.get(s);c&&H(c)&&F(c,{containerId:l?i:null})}}})},mn=(e,t,r,o=!1)=>{if(!pn(e))return;Cu(e.id);let i=J(e,t);if(i&&i.text){if(!e)return;let a=i.text,s=i.height,l=i.width,c=br(e,i),d=ns(e,i),m=e.height;if(o||r!=="n"&&r!=="s"){a&&(a=Lo(i.originalText,Me(i),c));let p=Vt(a,Me(i),i.lineHeight);s=p.height,l=p.width}if(s>d){m=Si(s,e.type);let p=m-e.height,u=!ne(e)&&(r==="ne"||r==="nw"||r==="n")?e.y-p:e.y;F(e,{height:m,y:u})}F(i,{text:a,width:l,height:s}),ne(e)||F(i,Ll(e,i,t))}},Ll=(e,t,r)=>{if(ne(e))return K.getBoundTextElementPosition(e,t,r);let o=xb(e),n=ns(e,t),i=br(e,t),a,s;return t.verticalAlign===kt.TOP?s=o.y:t.verticalAlign===kt.BOTTOM?s=o.y+(n-t.height):s=o.y+(n/2-t.height/2),t.textAlign===Oi.LEFT?a=o.x:t.textAlign===Oi.RIGHT?a=o.x+(i-t.width):a=o.x+(i/2-t.width/2),{x:a,y:s}},Vt=(e,t,r)=>{e=e.split(`
44
+ `).map(a=>a||" ").join(`
45
+ `);let o=parseFloat(t),n=nk(e,o,r);return{width:ku(e,t),height:n}},jw=e=>{let t=Nb(e.text).length;return e.height/t/e.fontSize},ra=(e,t)=>e*t,Dl=(e,t)=>ra(e,t)+wt*2,ls=(e,t,r)=>{Rb||(Rb=document.createElement("canvas"));let o=Rb.getContext("2d");o.font=t;let n=o.measureText(e),i=n.width;if(!r&&window.TextMetrics&&"actualBoundingBoxLeft"in window.TextMetrics.prototype&&"actualBoundingBoxRight"in window.TextMetrics.prototype){let a=Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight);return Math.max(a,i)}return Yr()?i*10:i},ku=(e,t,r)=>{let o=Nb(e),n=0;return o.forEach(i=>{n=Math.max(n,ls(i,t,r))}),n},nk=(e,t,r)=>{let o=Nb(e).length;return ra(t,r)*o},ik=e=>{let t=e.split("-");return t.length>1&&t.forEach((r,o)=>{o!==t.length-1&&(t[o]=r+="-")}),t.join(" ").split(" ")},Lo=(e,t,r)=>{if(!Number.isFinite(r)||r<0)return e;let o=[],n=e.split(`
46
+ `),i=ls(" ",t,!0),a="",s=0,l=d=>{d.trim()&&o.push(d)},c=()=>{a="",s=0};for(let d of n){if(ls(d,t,!0)<=r){o.push(d);continue}let p=ik(d);c();let u=0;for(;u<p.length;){let g=ls(p[u],t,!0);if(g===r)l(p[u]),u++;else if(g>r){for(l(a),c();p[u].length>0;){let h=String.fromCodePoint(p[u].codePointAt(0)),x=a+h,v=ls(x,t,!0),y=JT.calculate(h,t);s=v,p[u]=p[u].slice(h.length),s>=r?(l(a),a=h,s=y):a=x}s+i>=r?(l(a),c()):a.endsWith("-")||(a+=" ",s+=i),u++}else for(;s<r&&u<p.length;){let h=p[u];if(s=ls(a+h,t,!0),s>r){l(a),c();break}u++;let x=!h.endsWith("-");if(a+=h,x&&(a+=" "),s+i>=r){x?o.push(a.slice(0,-1)):o.push(a),c();break}}}a.slice(-1)===" "&&(a=a.slice(0,-1),l(a))}return o.join(`
47
+ `)},JT=(()=>{let e={};return{calculate:(o,n)=>{let i=o.charCodeAt(0);if(e[n]||(e[n]=[]),!e[n][i]){let a=ls(o,n,!0);e[n][i]=a}return e[n][i]},getCache:o=>e[o]}})(),QT="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),_l=(e,t)=>{let r=ak(e);return r===0?Vt(QT.split("").join(`
48
+ `),e,t).width+wt*2:r+wt*2},ak=e=>{let t=JT.getCache(e);if(!t)return 0;let r=t.filter(o=>o!==void 0);return Math.max(...r)},pn=e=>e?.boundElements?.length&&e?.boundElements?.find(t=>t.type==="text")?.id||null,J=(e,t)=>{if(!e)return null;let r=pn(e);return r&&t.get(r)||null},Et=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Pu=(e,t,r)=>{if(!ne(e))return{x:e.x+e.width/2,y:e.y+e.height/2};let o=K.getPointsGlobalCoordinates(e,r);if(o.length%2===1){let a=Math.floor(e.points.length/2),s=K.getPointGlobalCoordinates(e,e.points[a],r);return{x:s[0],y:s[1]}}let n=e.points.length/2-1,i=K.getEditorMidPoints(e,r,t)[n];return i||(i=K.getSegmentMidPoint(e,o[n],o[n+1],n+1,r)),{x:i[0],y:i[1]}},xb=e=>{let t=wt,r=wt;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),r+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,r+=e.height/4),{x:e.x+t,y:e.y+r}},e3=(e,t)=>!t||ne(t)?e.angle:t.angle,t3=(e,t)=>e.some(r=>{if(ze(r)){let o=Et(r,t);return!ne(o)}return!1}),r3=(e,t)=>e.some(r=>{if(ze(r)){let o=Et(r,t);return!ne(o)}return H(r)}),sk=new Set(["rectangle","ellipse","diamond","arrow"]),o3=e=>sk.has(e.type),Si=(e,t)=>{e=Math.ceil(e);let r=wt*2;return t==="ellipse"?Math.round((e+r)/Math.sqrt(2)*2):t==="arrow"?e+r*8:t==="diamond"?2*(e+r):e+r},br=(e,t)=>{let{width:r}=e;if(ne(e)){let o=(t?.fontSize??ur)*f0;return Math.max(h0*r,o)}return e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-wt*2:e.type==="diamond"?Math.round(r/2)-wt*2:r-wt*2},ns=(e,t)=>{let{height:r}=e;return ne(e)?r-wt*8*2<=0?t.height:r:e.type==="ellipse"?Math.round(r/2*Math.sqrt(2))-wt*2:e.type==="diamond"?Math.round(r/2)-wt*2:r-wt*2},n3=()=>ku(QT,Me({fontSize:ur,fontFamily:gr}))>0,Rl=(e,t)=>Vt("",e,t).width+wt*2});import{generateNKeysBetween as lk}from"fractional-indexing";var Td,Xp,Jt,fr,ck,dk,Ob,a3,i3,ko=X(()=>{"use strict";f();De();Hi();me();He();V();Td=(e,{shouldThrow:t=!1,includeBoundTextValidation:r=!1,reconciliationContext:o})=>{let n=[],i=s=>`${s?.index}:${s?.id}:${s?.type}:${s?.isDeleted}:${s?.version}:${s?.versionNonce}`,a=e.map(s=>s.index);for(let[s,l]of a.entries()){let c=a[s-1],d=a[s+1];if(Ob(l,c,d)||n.push(`Fractional indices invariant has been compromised: "${i(e[s-1])}", "${i(e[s])}", "${i(e[s+1])}"`),r&&Ct(e[s])){let m=e[s],p=J(m,Z(e));p&&p.index<=m.index&&n.push(`Fractional indices invariant for bound elements has been compromised: "${i(p)}", "${i(m)}"`)}}if(n.length){let s=new Um,l=[];if(o&&(l.push("Additional reconciliation context:"),l.push(o.localElements.map(c=>i(c))),l.push(o.remoteElements.map(c=>i(c)))),console.error(n.join(`
49
+
50
+ `),s.stack,e.map(c=>i(c)),...l),t)throw s}},Xp=e=>e.sort((t,r)=>i3(t)&&i3(r)?t.index<r.index?-1:t.index>r.index?1:t.id<r.id?-1:1:1),Jt=(e,t)=>{try{let r=ck(e,t),o=a3(e,r),n=e.map(i=>o.has(i)?{...i,...o.get(i)}:i);Td(n,{includeBoundTextValidation:!1,shouldThrow:!0});for(let[i,a]of o)F(i,a,!1)}catch{fr(e)}return e},fr=e=>{let t=dk(e),r=a3(e,t);for(let[o,n]of r)F(o,n,!1);return e},ck=(e,t)=>{let r=[],o=0;for(;o<e.length;)if(t.has(e[o].id)){let n=[o-1,o];for(;++o<e.length&&t.has(e[o].id);)n.push(o);n.push(o),r.push(n)}else o++;return r},dk=e=>{let t=[],r,o,n=-1,i=0,a=c=>{let d=e[n]?e[n].index:void 0,m=e[c-1]?.index;return!d&&m||d&&m&&m>d?[m,c-1]:[d,n]},s=c=>{let d=e[i]?e[i].index:void 0;if(d&&c<i)return[d,i];let m=i;for(;++m<e.length;){let p=e[m]?.index;if(!d&&p||d&&p&&p>d)return[p,m]}return[void 0,m]},l=0;for(;l<e.length;){let c=e[l].index;if([r,n]=a(l),[o,i]=s(l),Ob(c,r,o))l++;else{let d=[n,l];for(;++l<e.length;){let m=e[l].index,[p,u]=a(l),[g,h]=s(l);if(Ob(m,p,g))break;[r,n]=[p,u],[o,i]=[g,h],d.push(l)}d.push(i),t.push(d)}}return t},Ob=(e,t,r)=>e?t&&r?t<e&&e<r:!t&&r?e<r:t&&!r?t<e:!!e:!1,a3=(e,t)=>{let r=new Map;for(let o of t){let n=o.shift(),i=o.pop(),a=lk(e[n]?.index,e[i]?.index,o.length);for(let s=0;s<o.length;s++){let l=e[o[s]];r.set(l,{index:a[s]})}}return r},i3=e=>!!e.index});var s3,mk,l3,Fb,er,cs=X(()=>{"use strict";f();we();me();Ui();Zo();ko();V();V();Y();s3=e=>{let t=new Map,r=[];for(let o of e)o.isDeleted||(r.push(o),t.set(o.id,o));return{elementsMap:t,elements:r}},mk=e=>{let t=["includeBoundTextElement","includeElementsInFrames"],r="";for(let o of t)r+=`${o}:${e[o]?"1":"0"}`;return r},l3=e=>typeof e=="string",Fb=class e{static sceneMapByElement=new WeakMap;static sceneMapById=new Map;static mapElementToScene(t,r){l3(t)?this.sceneMapById.set(t,r):(this.sceneMapByElement.set(t,r),this.sceneMapById.set(t.id,r))}static getScene(t){return l3(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}callbacks=new Set;nonDeletedElements=[];nonDeletedElementsMap=Mr(new Map);elements=[];nonDeletedFramesLikes=[];frames=[];elementsMap=Mr(new Map);selectedElementsCache={selectedElementIds:null,elements:null,cache:new Map};sceneNonce;getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){let r=mk(t),o=t?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===o&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){let i=this.selectedElementsCache.cache.get(r);if(i)return i}else t?.elements==null&&this.selectedElementsCache.cache.clear();let n=he(o,{selectedElementIds:t.selectedElementIds},t);return t?.elements==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(r,n)),n}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getNonDeletedElement(t){let r=this.getElement(t);return r&&Sd(r)?r:null}mapElements(t){let r=!1,o=this.elements.map(n=>{let i=t(n);return i!==n&&(r=!0),i});return r&&this.replaceAllElements(o),r}replaceAllElements(t){let r=t instanceof Array?t:Array.from(t.values()),o=[];(T.DEV||T.MODE===Kt.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&Td(r,{includeBoundTextValidation:!0,shouldThrow:T.DEV||T.MODE===Kt.TEST}),this.elements=fr(r),this.elementsMap.clear(),this.elements.forEach(i=>{Q(i)&&o.push(i),this.elementsMap.set(i.id,i),e.mapElementToScene(i,this)});let n=s3(this.elements);this.nonDeletedElements=n.elements,this.nonDeletedElementsMap=n.elementsMap,this.frames=o,this.nonDeletedFramesLikes=s3(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=Co();for(let t of Array.from(this.callbacks))t()}onUpdate(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,r)=>{t===this&&e.sceneMapById.delete(r)}),this.callbacks.clear()}insertElementAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),t,...this.elements.slice(r)];Jt(o,Z([t])),this.replaceAllElements(o)}insertElementsAtIndex(t,r){if(!Number.isFinite(r)||r<0)throw new Error("insertElementAtIndex can only be called with index >= 0");let o=[...this.elements.slice(0,r),...t,...this.elements.slice(r)];Jt(o,Z(t)),this.replaceAllElements(o)}insertElement=t=>{let r=t.frameId?this.getElementIndex(t.frameId):this.elements.length;this.insertElementAtIndex(t,r)};insertElements=t=>{let r=t[0].frameId?this.getElementIndex(t[0].frameId):this.elements.length;this.insertElementsAtIndex(t,r)};getElementIndex(t){return this.elements.findIndex(r=>r.id===t)}getContainerElement=t=>t&&t.containerId&&this.getElement(t.containerId)||null},er=Fb});var F,pe,Ki,De=X(()=>{"use strict";f();cs();Ha();Zo();V();Qo();F=(e,t,r=!0)=>{let o=!1,{points:n,fileId:i}=t;typeof n<"u"&&(t={...pi(n),...t});for(let a in t){let s=t[a];if(typeof s<"u"){if(e[a]===s&&(typeof s!="object"||s===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){let l=e[a],c=s;if(l[0]===c[0]&&l[1]===c[1])continue}else if(a==="points"){let l=e[a],c=s;if(l.length===c.length){let d=!1,m=l.length;for(;--m;){let p=l[m],u=c[m];if(p[0]!==u[0]||p[1]!==u[1]){d=!0;break}}if(!d)continue}}e[a]=s,o=!0}}return o&&((typeof t.height<"u"||typeof t.width<"u"||typeof i<"u"||typeof n<"u")&&_e.delete(e),e.version++,e.versionNonce=Co(),e.updated=si(),r&&er.getScene(e)?.triggerUpdate()),e},pe=(e,t,r=!1)=>{let o=!1;for(let n in t){let i=t[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!r?e:{...e,...t,updated:si(),version:e.version+1,versionNonce:Co()}},Ki=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=Co(),e.updated=si(),e)});var Po,ds,Lu,Pl,Fc,ms=X(()=>{"use strict";f();De();me();Y();dt();V();Po=e=>ie(e)||Zt(e)?e.points.length<2:e.width===0&&e.height===0,ds=(e,t,r,o,n)=>{let[i,a,s,l]=ho(e,n),c=Qe({clientX:o.offsetLeft,clientY:o.offsetTop},o),d=Qe({clientX:o.offsetLeft+t,clientY:o.offsetTop+r},o);return c.x<=s&&c.y<=l&&d.x>=i&&d.y>=a},Lu=(e,t,r)=>{let o=Math.abs(t),n=Math.abs(r);if(e==="line"||e==="arrow"||e==="freedraw"){let i=Math.round(Math.atan(n/o)/wn)*wn;i===0?r=0:i===Math.PI/2?t=0:r=o*Math.tan(i)*Math.sign(r)||r}else e!=="selection"&&(r=o*Math.sign(r));return{width:t,height:r}},Pl=(e,t,r,o)=>{let n=r-e,i=o-t,a=Math.round(Math.atan(i/n)/wn)*wn;if(a===0)i=0;else if(a===Math.PI/2)n=0;else{let s=Math.tan(a),l=-1,c=t-s*e,d=-1/s,m=-1,p=o-d*r,u=(l*p-m*c)/(s*m-d*l),g=(c*d-p*s)/(s*m-d*l);n=u-e,i=g-t}return{width:n,height:i}},Fc=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let r=Math.abs(e.width);t.width=r,t.x=e.x-r}if(e.height<0){let r=Math.abs(e.height);t.height=r,t.y=e.y-r}return t}});var c3,pk,m3,d3,Bb,Ii,Du,ps,Nl,Id,_u,Cd=X(()=>{"use strict";f();dt();mt();me();Y();c3={mouse:8,pen:16,touch:28},pk=16,m3={e:!0,s:!0,n:!0,w:!0},d3={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Bb={e:!0,s:!0,n:!0,w:!0},Ii=(e,t,r,o,n,i,a)=>{let[s,l]=xe(e+r/2,t+o/2,n,i,a);return[s-r/2,l-o/2,r,o]},Du=e=>!(e.viewport.isMobile||e.isTouchScreen&&($x||ym)),ps=e=>Du(e)?m3:{},Nl=([e,t,r,o,n,i],a,s,l,c={},d=4)=>{let m=c3[l],p=m/s.value,u=m/s.value,g=m/s.value,h=m/s.value,x=r-e,v=o-t,y=d/s.value,w=(m-oi*2)/(2*s.value),C={nw:c.nw?void 0:Ii(e-y-g+w,t-y-h+w,p,u,n,i,a),ne:c.ne?void 0:Ii(r+y-w,t-y-h+w,p,u,n,i,a),sw:c.sw?void 0:Ii(e-y-g+w,o+y-w,p,u,n,i,a),se:c.se?void 0:Ii(r+y-w,o+y-w,p,u,n,i,a),rotation:c.rotation?void 0:Ii(e+x/2-p/2,t-y-h+w-pk/s.value,p,u,n,i,a)},M=5*c3.mouse/s.value;return Math.abs(x)>M&&(c.n||(C.n=Ii(e+x/2-p/2,t-y-h+w,p,u,n,i,a)),c.s||(C.s=Ii(e+x/2-p/2,o+y-w,p,u,n,i,a))),Math.abs(v)>M&&(c.w||(C.w=Ii(e-y-g+w,t+v/2-u/2,p,u,n,i,a)),c.e||(C.e=Ii(r+y-w,t+v/2-u/2,p,u,n,i,a))),C},Id=(e,t,r,o="mouse",n=m3)=>{if(e.locked||de(e))return{};if(e.type==="freedraw"||ie(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=Bb:a[0]>0&&a[1]<0?n=d3:a[0]>0&&a[1]>0?n=Bb:a[0]<0&&a[1]>0?n=d3:a[0]<0&&a[1]<0&&(n=Bb)}}else Q(e)&&(n={...n,rotation:!0});let i=ie(e)?oi+8:oi;return Nl(ae(e,r,!0),e.angle,t,o,n,i)},_u=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let r=e[0];return de(r)?!1:ie(r)?r.points.length>2:!0}});var Hb,p3,Ru,Nu,zb,uk,Ou,u3,g3=X(()=>{"use strict";f();Cd();dt();Y();al();me();Hb=(e,t,r)=>t>=e[0]&&t<=e[0]+e[2]&&r>=e[1]&&r<=e[1]+e[3],p3=(e,t,r,o,n,i,a,s)=>{if(!r.selectedElementIds[e.id])return!1;let{rotation:l,...c}=Id(e,i,t,a,ps(s));if(l&&Hb(l,o,n))return"rotation";let d=Object.keys(c).filter(m=>{let p=c[m];return p?Hb(p,o,n):!1});if(d.length>0)return d[0];if(Du(s)){let[m,p,u,g,h,x]=ae(e,t);if(!(ie(e)&&e.points.length<=2)){let v=Sm/i.value,y=u3([m-v,p-v],[u+v,g+v],[h,x],ln(e.angle));for(let[w,C]of Object.entries(y))if($a([o,n],C,v))return w}}return!1},Ru=(e,t,r,o,n,i,a,s)=>e.reduce((l,c)=>{if(l)return l;let d=p3(c,a,t,r,o,n,i,s);return d?{element:c,transformHandleType:d}:null},null),Nu=([e,t,r,o],n,i,a,s,l)=>{let c=Nl([e,t,r,o,(e+r)/2,(t+o)/2],0,a,s,ps(l)),d=Object.keys(c).find(m=>{let p=c[m];return p&&Hb(p,n,i)});if(d)return d;if(Du(l)){let m=(e+r)/2,p=(t+o)/2,u=Sm/a.value,g=u3([e-u,t-u],[r+u,o+u],[m,p],ln(0));for(let[h,x]of Object.entries(g))if($a([n,i],x,u))return h}return!1},zb=["ns","nesw","ew","nwse"],uk=(e,t)=>{let r=zb.indexOf(e);if(r>=0){let o=Math.round(t/(Math.PI/4));e=zb[(r+o)%zb.length]}return e},Ou=e=>{let{element:t,transformHandleType:r}=e,o=t&&Math.sign(t.height)*Math.sign(t.width)===-1,n=null;switch(r){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":o?n="nesw":n="nwse";break;case"ne":case"sw":o?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&t&&(n=uk(n,t.angle)),n?`${n}-resize`:""},u3=([e,t],[r,o],n,i)=>{let a=At([e,t],i,n),s=At([r,t],i,n),l=At([e,o],i,n),c=At([r,o],i,n);return{n:[a,s],e:[s,c],s:[c,l],w:[l,a]}}});var Fu,Ub,gk,Ad,Md,hk,fk,Gb,bk,Wb,Vb,kd=X(()=>{"use strict";f();Y();Ha();mt();dt();me();De();V();yr();cs();He();Wt();Gt();kl();Fu=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,Ub=(e,t,r,o,n,i,a,s,l,c,d,m)=>{if(r.length===1){let[p]=r;return t==="rotation"?de(p)||(gk(p,o,s,l,n),qt(p,o,m)):H(p)&&t?(hk(e,p,o,t,i,s,l),qt(p,o,m)):t&&fk(e,a,p,o,t,i,s,l,m),!0}else if(r.length>1){if(t==="rotation")return bk(e,r,o,s,l,n,c,d,m),!0;if(t)return Gb(e,r,o,t,i,a,s,l,m),!0}return!1},gk=(e,t,r,o,n)=>{let[i,a,s,l]=ae(e,t),c=(i+s)/2,d=(a+l)/2,m;Q(e)?m=0:(m=5*Math.PI/2+Math.atan2(o-d,r-c),n&&(m+=wn/2,m-=m%wn),m=Fu(m));let p=pn(e);if(F(e,{angle:m}),p){let u=er.getScene(e)?.getElement(p);u&&!ne(e)&&F(u,{angle:m})}},Ad=(e,t,r,o)=>ie(e)||Zt(e)?{points:Yi(0,t,Yi(1,r,e.points,o),o)}:{},Md=(e,t,r)=>{let o=e.width;if(ze(e)){let a=Et(e,t);a&&(o=br(a,e))}let i=e.fontSize*(r/o);return i<Tm?null:{size:i}},hk=(e,t,r,o,n,i,a)=>{let[s,l,c,d,m,p]=ae(t,r),[u,g]=xe(i,a,m,p,-t.angle),h=0,x=0;o!=="e"&&o!=="w"&&(o.includes("e")&&(h=(u-s)/(c-s)),o.includes("w")&&(h=(c-u)/(c-s)),o.includes("n")&&(x=(d-g)/(d-l)),o.includes("s")&&(x=(g-l)/(d-l)));let v=Math.max(h,x);if(v>0){let y=t.width*v,w=t.height*v,C=Md(t,r,y);if(C===null)return;let M=[s,l],I=[c,d],P=[m,p],A=[s,l];if(["n","w","nw"].includes(o)&&(A=[I[0]-Math.abs(y),I[1]-Math.abs(w)]),o==="ne"){let q=[M[0],I[1]];A=[q[0],q[1]-Math.abs(w)]}if(o==="sw"){let q=[I[0],M[1]];A=[q[0]-Math.abs(y),q[1]]}["s","n"].includes(o)&&(A[0]=P[0]-y/2),["e","w"].includes(o)&&(A[1]=P[1]-w/2),n&&(A[0]=P[0]-Math.abs(y)/2,A[1]=P[1]-Math.abs(w)/2);let N=t.angle,k=ce(A,[m,p],N),D=[A[0]+Math.abs(y)/2,A[1]+Math.abs(w)/2],z=ce(D,[m,p],N);A=ce(k,z,-N);let[R,W]=A;F(t,{fontSize:C.size,width:y,height:w,x:R,y:W})}if(o==="e"||o==="w"){let y=e.get(t.id),[w,C,M,I]=hi(y,y.width,y.height,!0),P=[w,C],A=[M,I],N=Cl(P,A),k=ce([i,a],N,-y.angle),[D,,z]=hi(t,t.width,t.height,!0),R=z-D,W=A[0]-P[0],q=Rl(Me({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),re=W/R;o.includes("e")&&(re=(k[0]-P[0])/R),o.includes("w")&&(re=(A[0]-k[0])/R);let ge=t.width*re<q?q:t.width*re,le=Lo(t.originalText,Me(t),Math.abs(ge)),U=Vt(le,Me(t),t.lineHeight),oe=U.height,[Ie,Fe,lt,Je]=hi(y,ge,oe,!0),Gr=lt-Ie,Wo=Je-Fe,nr=[...P];["n","w","nw"].includes(o)&&(nr=[A[0]-Math.abs(Gr),P[1]]);let so=y.angle,Ri=ce(nr,N,so),Ca=[nr[0]+Math.abs(Gr)/2,nr[1]+Math.abs(Wo)/2],Vo=ce(Ca,N,so);nr=ce(Ri,Vo,-so);let vo={width:Math.abs(ge),height:Math.abs(U.height),x:nr[0],y:nr[1],text:le,autoResize:!1};F(t,vo)}},fk=(e,t,r,o,n,i,a,s,l)=>{if(ne(r)&&de(r)&&(r.startBinding||r.endBinding))return;let c=e.get(r.id),[d,m,p,u]=hi(c,c.width,c.height,!0),g=[d,m],h=[p,u],x=Cl(g,h),v=ce([a,s],x,-c.angle),[y,w,C,M]=hi(r,r.width,r.height,!0),I=C-y,P=M-w,A=h[0]-g[0],N=h[1]-g[1],k=A/I,D=N/P,z={},R=J(r,o);n.includes("e")&&(k=(v[0]-g[0])/I),n.includes("s")&&(D=(v[1]-g[1])/P),n.includes("w")&&(k=(h[0]-v[0])/I),n.includes("n")&&(D=(h[1]-v[1])/P);let W=c.width,q=c.height,re=r.width*k,ge=r.height*D;if(i&&(re=2*re-W,ge=2*ge-q),t){let Wr=Math.abs(re)/W,Ps=Math.abs(ge)/q;if(n.length===1&&(ge*=Wr,re*=Ps),n.length===2){let Aa=Math.max(Wr,Ps);re=W*Aa*Math.sign(re),ge=q*Aa*Math.sign(ge)}}if(R){let Wr=e.get(R.id);if(Wr&&(z={fontSize:Wr.fontSize}),t){let Ps={...r,width:re,height:ge},Aa=Md(R,o,br(Ps,R));if(Aa===null)return;z={fontSize:Aa.size}}else{let Ps=_l(Me(R),R.lineHeight),Aa=Dl(R.fontSize,R.lineHeight);re=Math.max(re,Ps),ge=Math.max(ge,Aa)}}let[le,U,oe,Ie]=hi(c,re,ge,!0),Fe=oe-le,lt=Ie-U,Je=[...g];if(["n","w","nw"].includes(n)&&(Je=[h[0]-Math.abs(Fe),h[1]-Math.abs(lt)]),n==="ne"){let Wr=[g[0],h[1]];Je=[Wr[0],Wr[1]-Math.abs(lt)]}if(n==="sw"){let Wr=[h[0],g[1]];Je=[Wr[0]-Math.abs(Fe),Wr[1]]}t&&(["s","n"].includes(n)&&(Je[0]=x[0]-Fe/2),["e","w"].includes(n)&&(Je[1]=x[1]-lt/2));let Gr=re<0,Wo=ge<0;Gr&&(n.includes("e")&&(Je[0]-=Math.abs(Fe)),n.includes("w")&&(Je[0]+=Math.abs(Fe))),Wo&&(n.includes("s")&&(Je[1]-=Math.abs(lt)),n.includes("n")&&(Je[1]+=Math.abs(lt))),i&&(Je[0]=x[0]-Math.abs(Fe)/2,Je[1]=x[1]-Math.abs(lt)/2);let nr=c.angle,so=ce(Je,x,nr),Ri=[Je[0]+Math.abs(Fe)/2,Je[1]+Math.abs(lt)/2],Ca=ce(Ri,x,nr);Je=ce(so,Ca,-nr);let Vo=[...Je],vo=c.x-le,En=c.y-U;Vo[0]+=vo,Vo[1]+=En;let lo=Vo[0],xn=Vo[1],Rx,Nx;(ie(r)||Zt(r))&&(Rx=Yi(1,ge,c.points,!0),Nx=Yi(0,re,Rx,!0));let ks={width:Math.abs(re),height:Math.abs(ge),x:lo,y:xn,points:Nx};if("scale"in r&&"scale"in c&&F(r,{scale:[(Math.sign(oe-c.x)||c.scale[0])*c.scale[0],(Math.sign(Ie-c.y)||c.scale[1])*c.scale[1]]}),ne(r)&&R&&t){let Wr=ks.width/r.width*R.fontSize;if(Wr<Tm)return;z.fontSize=Wr}ks.width!==0&&ks.height!==0&&Number.isFinite(ks.x)&&Number.isFinite(ks.y)&&(F(r,ks),qt(r,o,l,{oldSize:{width:c.width,height:c.height}}),R&&z!=null&&F(R,{fontSize:z.fontSize}),mn(r,o,n,t))},Gb=(e,t,r,o,n,i,a,s,l)=>{let c=t.reduce((U,oe)=>{let Ie=e.get(oe.id);return Ie&&U.push({orig:Ie,latest:oe}),U},[]),d=c.reduce((U,{orig:oe})=>{if(!ie(oe))return U;let Ie=pn(oe);if(!Ie)return U;let Fe=e.get(Ie)??null;if(!ze(Fe))return U;let lt=K.getBoundTextElementPosition(oe,Fe,r);return[...U,{...Fe,...lt}]},[]),{minX:m,minY:p,maxX:u,maxY:g,midX:h,midY:x}=Qr(c.map(({orig:U})=>U).concat(d)),v=u-m,y=g-p,w=o,C={ne:[m,g],se:[m,p],sw:[u,p],nw:[u,g],e:[m,p+y/2],w:[u,p+y/2],n:[m+v/2,g],s:[m+v/2,p]},[M,I]=n?[h,x]:C[w],P=n?2:1,A=Math.max(Math.abs(a-M)/v||0,Math.abs(s-I)/y||0)*P;if(A===0)return;let N=w.includes("e")||w.includes("w")?Math.abs(a-M)/v*P:1,k=w.includes("n")||w.includes("s")?Math.abs(s-I)/y*P:1,D=i||c.some(U=>U.latest.angle!==0||H(U.latest)||Ln(U.latest));D&&(N=A,k=A);let z={ne:[a<M,s>I],se:[a<M,s<I],sw:[a>M,s<I],nw:[a>M,s>I],e:[a<M,!1],w:[a>M,!1],n:[!1,s>I],s:[!1,s<I]},[R,W]=z[w].map(U=>U?-1:1),q=R<0,re=W<0,ge=[];for(let{orig:U,latest:oe}of c){if(H(U)&&ze(U))continue;let Ie=U.width*N,Fe=U.height*k,lt=Fu(U.angle*R*W),Je=ie(U)||Zt(U),Gr=U.x-M,Wo=U.y-I,nr=q&&!Je?Ie:0,so=re&&!Je?Fe:0,Ri=M+R*(Gr*N+nr),Ca=I+W*(Wo*k+so),Vo=Ad(U,Ie*R,Fe*W,!1),vo={x:Ri,y:Ca,width:Ie,height:Fe,angle:lt,...Vo};if(So(U)&&(vo.scale=[U.scale[0]*R,U.scale[1]*W]),H(U)){let lo=Md(U,r,Ie);if(!lo)return;vo.fontSize=lo.size}let En=e.get(pn(U)??"");if(En)if(D){let lo=En.fontSize*A;if(lo<Tm)return;vo.boundTextFontSize=lo}else vo.boundTextFontSize=En.fontSize;ge.push({element:oe,update:vo})}let le=ge.map(({element:U})=>U);for(let{element:U,update:{boundTextFontSize:oe,...Ie}}of ge){let{angle:Fe}=Ie,{width:lt,height:Je}=U;F(U,Ie,!1),ne(U)&&de(U)&&_o(U,l,U.points,void 0,void 0,{informMutation:!1}),qt(U,r,l,{simultaneouslyUpdated:le,oldSize:{width:lt,height:Je}});let Gr=J(U,r);Gr&&oe&&(F(Gr,{fontSize:oe,angle:ie(U)?void 0:Fe},!1),mn(U,r,o,!0))}er.getScene(ge[0].element)?.triggerUpdate()},bk=(e,t,r,o,n,i,a,s,l)=>{let c=5*Math.PI/2+Math.atan2(n-s,o-a);i&&(c+=wn/2,c-=c%wn),t.filter(d=>!Q(d)).forEach(d=>{let[m,p,u,g]=ae(d,r),h=(m+u)/2,x=(p+g)/2,v=e.get(d.id)?.angle??d.angle,[y,w]=xe(h,x,a,s,c+v-d.angle);if(ne(d)&&de(d)){let M=_v(d,r);_o(d,l,M)}else F(d,{x:d.x+(y-h),y:d.y+(w-x),angle:Fu(c+v)},!1);qt(d,r,l,{simultaneouslyUpdated:t});let C=J(d,r);C&&!ne(d)&&F(C,{x:C.x+(y-h),y:C.y+(w-x),angle:Fu(c+v)},!1)}),er.getScene(t[0])?.triggerUpdate()},Wb=(e,t,r,o,n)=>{let[i,a,s,l]=t.length===1?ae(t[0],r):Te(t),c=(i+s)/2,d=(a+l)/2,m=t.length===1?t[0].angle:0;switch([o,n]=xe(o,n,c,d,-m),e){case"n":return xe(o-(i+s)/2,n-a,0,0,m);case"s":return xe(o-(i+s)/2,n-l,0,0,m);case"w":return xe(o-i,n-(a+l)/2,0,0,m);case"e":return xe(o-s,n-(a+l)/2,0,0,m);case"nw":return xe(o-i,n-a,0,0,m);case"ne":return xe(o-s,n-a,0,0,m);case"sw":return xe(o-i,n-l,0,0,m);case"se":return xe(o-s,n-l,0,0,m);default:return[0,0]}},Vb=(e,t)=>{let[,[r,o]]=t.points;return e==="nw"&&(r<0||o<0)||e==="ne"&&r>=0||e==="sw"&&r<=0||e==="se"&&(r>0||o>0)?"end":"origin"}});var Yb,Ek,h3,Xb,Bu,f3=X(()=>{"use strict";f();yr();dt();De();ms();He();mt();me();V();Y();Yb=(e,t,r,o,n,i)=>{if(t.length===1&&ne(t[0])&&de(t[0])&&(t[0].startBinding||t[0].endBinding))return;let a=t.filter(m=>!(ne(m)&&de(m)&&m.startBinding&&m.endBinding)),s=new Set(a),l=a.filter(m=>Q(m)).map(m=>m.id);if(l.length>0)for(let m of o.getNonDeletedElements())m.frameId!==null&&l.includes(m.frameId)&&s.add(m);let c=Te(Array.from(s).map(m=>e.originalElements.get(m.id)??m)),d=Ek(c,r,n,i);s.forEach(m=>{if(h3(e,m,d),!ne(m)){let p=J(m,o.getNonDeletedElementsMap());p&&h3(e,p,d)}qt(m,o.getElementsMapIncludingDeleted(),o,{simultaneouslyUpdated:Array.from(s)})})},Ek=(e,t,r,o)=>{let[n,i]=e,a=n+t.x+r.x,s=i+t.y+r.y;if(r.x===0||r.y===0){let[l,c]=Ot(n+t.x,i+t.y,o);r.x===0&&(a=l),r.y===0&&(s=c)}return{x:a-n,y:s-i}},h3=(e,t,r)=>{let o=e.originalElements.get(t.id)??t,n=o.x+r.x,i=o.y+r.y;F(t,{x:n,y:i})},Xb=(e,t,r)=>{let[o,n]=Te(e);return[t-o,r-n]},Bu=(e,t,r,o,n,i,a,s,l,c,d,m,p=null)=>{l&&e.type!=="selection"&&(m?s=a/m:(Math.abs(i-o)>Math.abs(n-r)?{width:a,height:s}=Lu(t,s,n<r?-a:a):{width:a,height:s}=Lu(t,a,i<o?-s:s),s<0&&(s=-s)));let u=n<r?r-a:r,g=i<o?o-s:o;c&&(a+=a,s+=s,u=r-a/2,g=o-s/2);let h=null;if(H(e)){s=e.height;let x=Rl(Me({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,x),Math.abs(n-r)>qx/d&&(h={autoResize:!1}),g=o,c&&(u=r-a/2)}a!==0&&s!==0&&F(e,{x:u+(p?.x??0),y:g+(p?.y??0),width:a,height:s,...h})}});var us,b3=X(()=>{"use strict";f();et();us=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||he(t,e).length))});var xk,Kb,$b,E3,Ae,Sd,x3,Xw,fp,we=X(()=>{"use strict";f();ms();me();Nn();dt();Cd();g3();kd();f3();me();He();ms();b3();xk=e=>e.reduce((t,r)=>t+r.version,0),Kb=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e[r].versionNonce;return t>>>0},$b=e=>{let t=5381;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)+t+o}return t>>>0},E3=e=>e.filter(t=>!t.isDeleted&&!Po(t)),Ae=e=>e.filter(t=>!t.isDeleted),Sd=e=>!e.isDeleted,x3=e=>Ae(e).map(t=>Cc(t.type)?{...t,lastCommittedPoint:null}:t),Xw=e=>x3(e),fp=e=>x3(e)});var gs,Sl,Zb,qe,jb,he,Pd,Ge,Ui=X(()=>{"use strict";f();we();me();vr();V();ms();gs=e=>{let t=new Set;return e.forEach(r=>{Q(r)&&t.add(r.id)}),e.filter(r=>!(r.frameId&&t.has(r.frameId)))},Sl=(e,t,r,o=!0)=>{let[n,i,a,s]=ae(t,r),l=e.filter(c=>{let[d,m,p,u]=ho(c,r),g=Qt(c,r);if(g){let[h,x,v,y]=ho(g,r);d=Math.max(h,d),m=Math.max(x,m),p=Math.min(v,p),u=Math.min(y,u)}return c.locked===!1&&c.type!=="selection"&&!ze(c)&&n<=d&&i<=m&&a>=p&&s>=u});return l=o?gs(l):l,l=l.filter(c=>{let d=Qt(c,r);return d?Bn(c,d,r):!0}),l},Zb=(e,t,r,o)=>{let n=new Set(t.map(i=>i.id));return e.filter(i=>{let a=ds(i,r.width,r.height,r,o);return!n.has(i.id)&&a})},qe=function(){let e=null,t=null,r=null,o=(n,i)=>(r!=null&&n===e&&i.selectedElementIds===t||(r=n.some(a=>i.selectedElementIds[a.id]),e=n,t=i.selectedElementIds),r);return o.clearCache=()=>{e=null,t=null,r=null},o}(),jb=(e,t,r)=>{let o=Array.from(new Set(he(e,t).map(n=>r(n))));return o.length===1?o[0]:null},he=(e,t,r)=>{let o=[];for(let n of e.values()){if(t.selectedElementIds[n.id]){o.push(n);continue}if(r?.includeBoundTextElement&&ze(n)&&t.selectedElementIds[n?.containerId]){o.push(n);continue}}if(r?.includeElementsInFrames){let n=[];return o.forEach(i=>{Q(i)&&bo(e,i.id).forEach(a=>n.push(a)),n.push(i)}),n}return o},Pd=(e,t)=>t.editingElement?[t.editingElement]:he(e,t,{includeBoundTextElement:!0}),Ge=(e,t)=>it(t.selectedElementIds,e)?t.selectedElementIds:e});var yk,qb,_n,Jb=X(()=>{"use strict";f();we();V();yk=(e,t)=>{let[r,o,n,i]=t,{x:a,y:s}=$t({sceneX:r,sceneY:o},e),{x:l,y:c}=$t({sceneX:n,sceneY:i},e);return l-a>e.width||c-s>e.height},qb=({scenePoint:e,viewportDimensions:t,zoom:r})=>({scrollX:t.width/2/r.value-e.x,scrollY:t.height/2/r.value-e.y}),_n=(e,t)=>{if(e=E3(e),!e.length)return{scrollX:0,scrollY:0};let[r,o,n,i]=Te(e);yk(t,[r,o,n,i])&&([r,o,n,i]=Ab(e,Qe({clientX:t.scrollX,clientY:t.scrollY},t)));let a=(r+n)/2,s=(o+i)/2;return qb({scenePoint:{x:a,y:s},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})}});var Un,Ci,zu=X(()=>{"use strict";f();Y();Un=e=>Math.max(Os,Math.min(e,30)),Ci=({viewportX:e,viewportY:t,nextZoom:r},o)=>{let n=e-o.offsetLeft,i=t-o.offsetTop,a=o.zoom.value,s=o.scrollX+(n-n/a),l=o.scrollY+(i-i/a),c=-(n-n/r),d=-(i-i/r);return{scrollX:s+c,scrollY:l+d,zoom:{value:r}}}});var et=X(()=>{"use strict";f();Ui();Jb();bd();zu()});f();import N9,{useEffect as O9}from"react";f();import{useEffect as u6,useState as g6}from"react";f();f();import Bx from"./en-YNVBSAIL.json";import JA from"./percentages-UCQDHIQF.json";f();import{unstable_createStore as jA,useAtom as V9}from"jotai";import{useLayoutEffect as X9}from"react";var Xe=Symbol(),mr=jA();import{atom as QA,useAtomValue as e6}from"jotai";var qA=Ox({"./locales/ar-SA.json":()=>import("./ar-SA-JA6F2FMJ.json"),"./locales/az-AZ.json":()=>import("./az-AZ-GVIENQVH.json"),"./locales/bg-BG.json":()=>import("./bg-BG-YFNNHCEP.json"),"./locales/bn-BD.json":()=>import("./bn-BD-LMEIWSRD.json"),"./locales/ca-ES.json":()=>import("./ca-ES-C2WGCLOT.json"),"./locales/cs-CZ.json":()=>import("./cs-CZ-F2NDIQMB.json"),"./locales/da-DK.json":()=>import("./da-DK-WBEQB3CJ.json"),"./locales/de-DE.json":()=>import("./de-DE-VEIMCP7R.json"),"./locales/el-GR.json":()=>import("./el-GR-TKRKG5GQ.json"),"./locales/en.json":()=>import("./en-YNVBSAIL.json"),"./locales/es-ES.json":()=>import("./es-ES-TOLWEZNW.json"),"./locales/eu-ES.json":()=>import("./eu-ES-7CDRJQWJ.json"),"./locales/fa-IR.json":()=>import("./fa-IR-527E2XGU.json"),"./locales/fi-FI.json":()=>import("./fi-FI-NLQ7RQGZ.json"),"./locales/fr-FR.json":()=>import("./fr-FR-KUHO4FLU.json"),"./locales/gl-ES.json":()=>import("./gl-ES-NEXX3VBB.json"),"./locales/he-IL.json":()=>import("./he-IL-MED2VGBZ.json"),"./locales/hi-IN.json":()=>import("./hi-IN-5V633W7V.json"),"./locales/hu-HU.json":()=>import("./hu-HU-2FOZGVGR.json"),"./locales/id-ID.json":()=>import("./id-ID-I6BOLXTF.json"),"./locales/it-IT.json":()=>import("./it-IT-WKPQOK4P.json"),"./locales/ja-JP.json":()=>import("./ja-JP-VKA4ISRU.json"),"./locales/kaa.json":()=>import("./kaa-IKPRSBNY.json"),"./locales/kab-KAB.json":()=>import("./kab-KAB-IE4PHQTZ.json"),"./locales/kk-KZ.json":()=>import("./kk-KZ-MNJT6XSV.json"),"./locales/km-KH.json":()=>import("./km-KH-LADGDFXV.json"),"./locales/ko-KR.json":()=>import("./ko-KR-XD7AVF2F.json"),"./locales/ku-TR.json":()=>import("./ku-TR-4XBHKDQA.json"),"./locales/lt-LT.json":()=>import("./lt-LT-QC35R4YH.json"),"./locales/lv-LV.json":()=>import("./lv-LV-GSD5D3BA.json"),"./locales/mr-IN.json":()=>import("./mr-IN-KOLSWM7Y.json"),"./locales/my-MM.json":()=>import("./my-MM-M53KMUET.json"),"./locales/nb-NO.json":()=>import("./nb-NO-XXC6U37A.json"),"./locales/nl-NL.json":()=>import("./nl-NL-HCCJQEUO.json"),"./locales/nn-NO.json":()=>import("./nn-NO-6P7Z2PI2.json"),"./locales/oc-FR.json":()=>import("./oc-FR-JRJKPLNT.json"),"./locales/pa-IN.json":()=>import("./pa-IN-LZWLEPIB.json"),"./locales/percentages.json":()=>import("./percentages-UCQDHIQF.json"),"./locales/pl-PL.json":()=>import("./pl-PL-3WBLCXI2.json"),"./locales/pt-BR.json":()=>import("./pt-BR-O3ZPTUNW.json"),"./locales/pt-PT.json":()=>import("./pt-PT-7AQTSAFO.json"),"./locales/ro-RO.json":()=>import("./ro-RO-HJ65JYWV.json"),"./locales/ru-RU.json":()=>import("./ru-RU-P7ROIYNC.json"),"./locales/si-LK.json":()=>import("./si-LK-7ZSWVION.json"),"./locales/sk-SK.json":()=>import("./sk-SK-NXVBGLYY.json"),"./locales/sl-SI.json":()=>import("./sl-SI-VFTWOYNP.json"),"./locales/sv-SE.json":()=>import("./sv-SE-YONBLQNW.json"),"./locales/ta-IN.json":()=>import("./ta-IN-BSETPMLX.json"),"./locales/th-TH.json":()=>import("./th-TH-URTRDITB.json"),"./locales/tr-TR.json":()=>import("./tr-TR-N5SCAVTB.json"),"./locales/uk-UA.json":()=>import("./uk-UA-LBCYVSQZ.json"),"./locales/vi-VN.json":()=>import("./vi-VN-POZWLIUU.json"),"./locales/zh-CN.json":()=>import("./zh-CN-FUF5V3SC.json"),"./locales/zh-HK.json":()=>import("./zh-HK-OB4VW42C.json"),"./locales/zh-TW.json":()=>import("./zh-TW-5JPVKOM7.json")});var t6=85,yn={code:"en",label:"English"},Ds=[yn,...[{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=>JA[e.code]>=t6).sort((e,t)=>e.label>t.label?1:-1)],gm="__test__";T.DEV&&Ds.unshift({code:gm,label:"test language"},{code:`${gm}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ls=yn,um={},hm=async e=>{if(Ls=e,document.documentElement.dir=Ls.rtl?"rtl":"ltr",document.documentElement.lang=Ls.code,e.code.startsWith(gm))um={};else try{um=await qA(`./locales/${Ls.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),um=Bx}mr.set(zx,e.code)},ei=()=>Ls,Fx=(e,t)=>{for(let r=0;r<t.length;++r){let o=t[r];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},E=(e,t,r)=>{if(Ls.code.startsWith(gm))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),n=Fx(um,o)||Fx(Bx,o)||r;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},zx=QA(yn.code),Dt=()=>{let e=e6(zx,Xe);return{t:E,langCode:e}};import{useState as c6,useEffect as d6}from"react";f();import r6 from"react";import{jsx as Ah}from"react/jsx-runtime";var o6=({size:e="1em",circleWidth:t=8,synchronized:r=!1})=>{let n=-(r6.useRef(Date.now()).current%1600);return Ah("div",{className:"Spinner",children:Ah("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":r?`${n}ms`:0},children:Ah("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},ir=o6;Y();import m6 from"clsx";import{jsx as Nh,jsxs as p6}from"react/jsx-runtime";var Dm=({delay:e,theme:t})=>{let[r,o]=c6(!!e);return d6(()=>{if(!e)return;let n=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(n)},[e]),r?null:p6("div",{className:m6("LoadingMessage",{"LoadingMessage--dark":t===ue.DARK}),children:[Nh("div",{children:Nh(ir,{})}),Nh("div",{className:"LoadingMessage-text",children:E("labels.loadingScene")})]})};import{jsx as h6}from"react/jsx-runtime";var x0=e=>{let[t,r]=g6(!0);return u6(()=>{let o=async()=>{await hm(n),r(!1)},n=Ds.find(i=>i.code===e.langCode)||yn;o()},[e.langCode]),t?h6(Dm,{theme:e.theme}):e.children};f();import Qn,{useContext as Sa}from"react";import{flushSync as ux}from"react-dom";import f9 from"roughjs/bin/rough";import kA from"clsx";import{nanoid as b9}from"nanoid";f();f();et();ye();f();import Qb,{useEffect as wk,useRef as y3,useState as vk}from"react";import w3 from"clsx";Hi();V();import{jsx as Ld,jsxs as Dd}from"react/jsx-runtime";var fe=Qb.forwardRef((e,t)=>{let{id:r}=Ft(),o=Qb.useRef(null);Qb.useImperativeHandle(t,()=>o.current);let n=`ToolIcon_size_${e.size}`,[i,a]=vk(!1),s=y3(!0),l=async d=>{let m="onClick"in e&&e.onClick?.(d);if(Cn(m))try{a(!0),await m}catch(p){if(p instanceof Pn)console.warn(p);else throw p}finally{s.current&&a(!1)}};wk(()=>(s.current=!0,()=>{s.current=!1}),[]);let c=y3(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){let d=e.type==="icon"?"button":e.type;return Dd("button",{className:w3("ToolIcon_type_button",n,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:d,onClick:l,ref:o,disabled:i||e.isLoading||!!e.disabled,children:[(e.icon||e.label)&&Dd("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!e.disabled,children:[e.icon||e.label,e.keyBindingLabel&&Ld("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&Ld(ir,{})]}),e.showAriaLabel&&Dd("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",i&&Ld(ir,{})]}),e.children]})}return Dd("label",{className:w3("ToolIcon",e.className),title:e.title,onPointerDown:d=>{c.current=d.pointerType||null,e.onPointerDown?.({pointerType:d.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[Ld("input",{className:`ToolIcon_type_radio ${n}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${r}-${e.id}`,onChange:()=>{e.onChange?.({pointerType:c.current})},checked:e.checked,ref:o}),Dd("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&Ld("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});fe.defaultProps={visible:!0,className:"",size:"medium"};fe.displayName="ToolButton";$e();we();De();Gt();Wt();yr();me();V();ee();Re();kl();import{jsx as Sk}from"react/jsx-runtime";var Tk=(e,t,r)=>{let o=new Set(he(e.filter(n=>Q(n)),t).map(n=>n.id));return{elements:e.map(n=>t.selectedElementIds[n.id]?(n.boundElements&&n.boundElements.forEach(i=>{let a=r.scene.getNonDeletedElementsMap().get(i.id);a&&de(a)&&(F(a,{startBinding:n.id===a.startBinding?.elementId?null:a.startBinding,endBinding:n.id===a.endBinding?.elementId?null:a.endBinding}),_o(a,r.scene,a.points))}),pe(n,{isDeleted:!0})):n.frameId&&o.has(n.frameId)?pe(n,{isDeleted:!0}):ze(n)&&t.selectedElementIds[n.containerId]?pe(n,{isDeleted:!0}):n),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},v3=(e,t)=>{if(e.editingGroupId){let r=ot(Ae(t),e.editingGroupId);if(r.length)return{...e,selectedElementIds:{[r[0].id]:!0}}}return e},_d=G({name:"deleteSelectedElements",label:"labels.delete",icon:tn,trackEvent:{category:"element",action:"delete"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:s,startBindingElement:l,endBindingElement:c}=t.editingLinearElement,d=o.scene.getNonDeletedElementsMap(),m=K.getElement(a,d);if(!m||s==null)return!1;if(m.points.length<2){let u=e.map(h=>h.id===m.id?pe(h,{isDeleted:!0}):h),g=v3(t,u);return{elements:u,appState:{...g,editingLinearElement:null},storeAction:_.CAPTURE}}let p={startBindingElement:s?.includes(0)?null:l,endBindingElement:s?.includes(m.points.length-1)?null:c};return K.deletePoints(m,s,o.scene),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},storeAction:_.CAPTURE}}let{elements:n,appState:i}=Tk(e,t,o);return Vp(n,e.filter(({id:a})=>t.selectedElementIds[a])),i=v3(i,n),{elements:n,appState:{...i,activeTool:nt(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},storeAction:qe(Ae(e),t)?_.CAPTURE:_.NONE}},keyTest:(e,t,r)=>(e.key===S.BACKSPACE||e.key===S.DELETE)&&!e[S.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:r})=>Sk(fe,{type:"button",icon:tn,title:E("labels.delete"),"aria-label":E("labels.delete"),onClick:()=>r(null),visible:qe(Ae(e),t)})});f();f();me();ko();Gt();et();cs();V();var eE=(e,t)=>e.frameId===t||e.id===t,S3=(e,t,r)=>{let o=[],n=[],i=null,a=-1,s=Z(r||he(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let l=e[a];s.get(l.id)?(n.length&&(o=o.concat(n),n=[]),o.push(a),i=a+1):l.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return o},Ik=e=>{let t=0;return e.reduce((r,o,n)=>(n>0&&e[n-1]!==o-1&&(t=++t),(r[t]||(r[t]=[])).push(o),r),[])},T3=(e,t,r)=>{if("containerId"in e&&e.containerId)if(r==="left"){let o=er.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{let o=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(o){if(r==="left")return t.indexOf(e);let n=er.getScene(e).getElement(o);if(n)return t.indexOf(n)}}},Ck=(e,t)=>{let r=-1,o=-1;return e.forEach((n,i)=>{eE(n,t)&&(r===-1&&(r=i),o=i)}),r===-1?[]:e.slice(r,o+1)},Ak=(e,t,r,o,n)=>{let i=t[r],a=m=>m.isDeleted?!1:n?m.frameId===n:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,s=o==="left"?zh(t,m=>a(m),Math.max(0,r-1)):Bh(t,m=>a(m),r+1),l=t[s];if(!l)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===l?.groupIds.join(""))return T3(l,t,o)??s;if(!l?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(l.frameId||Q(l))){let m=Ck(t,l.frameId||l.id);return o==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!l.groupIds.length)return T3(l,t,o)??s;let c=e.editingGroupId?l.groupIds[l.groupIds.indexOf(e.editingGroupId)-1]:l.groupIds[l.groupIds.length-1],d=ot(t,c);return d.length?o==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1]):s},I3=(e,t)=>t.reduce((r,o)=>{let n=e[o];return r.set(n.id,n),r},new Map),C3=(e,t,r)=>{let o=S3(e,t),n=I3(e,o),i=Ik(o);r==="right"&&(i=i.reverse());let a=new Set(o.filter(s=>Q(e[s])).map(s=>e[s].id));return i.forEach((s,l)=>{let c=s[0],d=s[s.length-1],m=r==="left"?c:d,p=s.some(y=>{let w=e[y];return w.frameId&&a.has(w.frameId)})?null:e[m]?.frameId,u=Ak(t,e,m,r,p);if(u===-1||m===u)return;let g=r==="left"?e.slice(0,u):e.slice(0,c),h=e.slice(c,d+1),x=r==="left"?e.slice(u,c):e.slice(d+1,u+1),v=r==="left"?e.slice(d+1):e.slice(u+1);e=r==="left"?[...g,...h,...x,...v]:[...g,...x,...h,...v]}),Jt(e,n),e},A3=(e,t,r,o,n)=>{let i=S3(e,t,n),a=I3(e,i),s=[],l,c;if(r==="left"){if(o)l=Bh(e,g=>eE(g,o));else if(t.editingGroupId){let g=ot(e,t.editingGroupId);if(!g.length)return e;l=e.indexOf(g[0])}else l=0;c=i[i.length-1]}else{if(o)c=zh(e,g=>eE(g,o));else if(t.editingGroupId){let g=ot(e,t.editingGroupId);if(!g.length)return e;c=e.indexOf(g[g.length-1])}else c=e.length-1;l=i[0]}l===-1&&(l=0);for(let g=l;g<c+1;g++)i.includes(g)||s.push(e[g]);let d=Array.from(a.values()),m=e.slice(0,l),p=e.slice(c+1),u=r==="left"?[...m,...d,...s,...p]:[...m,...s,...d,...p];return Jt(u,a),u};function M3(e,t,r,o){let n=Z(he(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&Q(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(Q(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let d=i.frameChildren.get(c.frameId)||[];d.push(c),i.frameChildren.set(c.frameId,d)}let s=e,l=Array.from(i.frameChildren.entries());for(let[c,d]of l)s=o(e,t,r,c,d);return o(s,t,r,null,i.regularElements)}var k3=(e,t)=>C3(e,t,"left"),P3=(e,t)=>C3(e,t,"right"),L3=(e,t)=>M3(e,t,"left",A3),D3=(e,t)=>M3(e,t,"right",A3);ye();V();$e();ee();Y();Re();import{jsx as Hu}from"react/jsx-runtime";var tE=G({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Qh,trackEvent:{category:"element"},perform:(e,t)=>({elements:k3(e,t),appState:t,storeAction:_.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendBackward")} \u2014 ${O("CtrlOrCmd+[")}`,children:Qh})}),rE=G({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Jh,trackEvent:{category:"element"},perform:(e,t)=>({elements:P3(e,t),appState:t,storeAction:_.CAPTURE}),keyPriority:40,keyTest:e=>e[S.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.bringForward")} \u2014 ${O("CtrlOrCmd+]")}`,children:Jh})}),oE=G({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:tf,trackEvent:{category:"element"},perform:(e,t)=>({elements:L3(e,t),appState:t,storeAction:_.CAPTURE}),keyTest:e=>Cr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.BRACKET_LEFT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===Se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${E("labels.sendToBack")} \u2014 ${Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")}`,children:tf})}),nE=G({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ef,trackEvent:{category:"element"},perform:(e,t)=>({elements:D3(e,t),appState:t,storeAction:_.CAPTURE}),keyTest:e=>Cr?e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.BRACKET_RIGHT:e[S.CTRL_OR_CMD]&&e.shiftKey&&e.code===Se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Hu("button",{type:"button",className:"zIndexButton",onClick:r=>e(null),title:`${E("labels.bringToFront")} \u2014 ${Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")}`,children:ef})});f();ye();$e();Gt();we();me();Wt();Ui();ee();Re();var iE=G({name:"selectAll",label:"labels.selectAll",icon:Cw,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,r,o)=>{if(t.editingLinearElement)return!1;let n=gs(e.filter(i=>!i.isDeleted&&!(H(i)&&i.containerId)&&!i.locked)).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...cr({editingGroupId:null,selectedElementIds:n},Ae(e),t,o),selectedLinearElement:Object.keys(n).length===1&&ie(e[0])?new K(e[0]):null},storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.A});f();ye();$e();we();et();V();Wt();Gt();yr();Y();He();me();f();V();var Mk=e=>{let t=e.slice(),r=new Set,o=i=>{let a=i[0]?.groupIds?.join(""),s=[i[0]],l=[];for(let c of i.slice(1))c.groupIds?.join("")===a?s.push(c):l.push(c);return l.length?[...s,...o(l)]:s},n=new Map;return t.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let s=i.groupIds[i.groupIds.length-1],l=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===s);return d&&n.set(c.id,!0),d});for(let c of o(l))r.add(c)}else r.add(i)}),r.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...r]},kk=e=>{let t=L0(e),r=e.slice(),o=new Set;return r.forEach((n,i)=>{n&&(n.boundElements?.length?(o.add(n),r[i]=null,n.boundElements.forEach(a=>{let s=t.get(a.id);s&&a.type==="text"&&(o.add(s[0]),r[s[1]]=null)})):n.type==="text"&&n.containerId&&t.get(n.containerId)?.[0].boundElements?.find(s=>s.id===n.id)||(o.add(n),r[i]=null))}),o.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...o]},_3=e=>kk(Mk(e));ee();vr();Ui();ko();Re();import{jsx as Lk}from"react/jsx-runtime";var aE=G({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Mc,trackEvent:{category:"element"},perform:(e,t,r,o)=>{if(t.editingLinearElement){let n=K.duplicateSelectedPoints(t,o.scene);return n?{elements:e,appState:n.appState,storeAction:_.CAPTURE}:!1}return{...Pk(e,t),storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.D,PanelComponent:({elements:e,appState:t,updateData:r})=>Lk(fe,{type:"button",icon:Mc,title:`${E("labels.duplicateSelection")} \u2014 ${O("CtrlOrCmd+D")}`,"aria-label":E("labels.duplicateSelection"),onClick:()=>r(null),visible:qe(Ae(e),t)})}),Pk=(e,t)=>{let r=_3(e),o=new Map,n=[],i=[],a=new Map,s=new Map,l=y=>{let w=Vc(t.editingGroupId,o,y,{x:y.x+ni/2,y:y.y+ni/2});return s.set(w.id,w),a.set(y.id,w.id),i.push(y),n.push(w),w},c=Z(he(r,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),d=new Map,m=y=>{for(let w of y)d.set(w.id,!0);return y},p=[],u=-1;for(;++u<r.length;){let y=r[u];if(d.get(y.id))continue;let w=J(y,Z(e)),C=Q(y);if(c.get(y.id)){if(y.groupIds.length||w||C){let M=Vh(t,y);if(M){let I=ot(r,M).flatMap(P=>Q(P)?[...bo(e,P.id),P]:[P]);p.push(...m([...I,...I.map(P=>l(P))]));continue}if(w){p.push(...m([y,w,l(y),l(w)]));continue}if(C){let I=bo(r,y.id);p.push(...m([...I,y,...I.map(P=>l(P)),l(y)]));continue}}(!y.frameId||!c.has(y.frameId))&&p.push(...m([y,l(y)]))}else p.push(...m([y]))}let g=[],h=new Map;for(u=p.length;--u>=0;){let y=p[u];h.get(y.id)||(h.set(y.id,!0),g.push(y))}let x=Jt(g.reverse(),Z(n));Mu(p,i,a),Wp(p,i,a),fu(x,i,a);let v=gs(n);return{elements:x,appState:{...t,...cr({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((y,w)=>(ze(w)||(y[w.id]=!0),y),{})},Ae(x),t,null)}}};f();pr();import{useEffect as SE,useMemo as lL,useRef as IE,useState as cL}from"react";f();var Dk=new Set(["command_palette"]),Ce=(e,t,r,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!Dk.has(e)||T.DEV)return;T.PROD||console.info("trackEvent",{category:e,action:t,label:r,value:o}),window.sa_event&&window.sa_event(t,{category:e,label:r,value:o})}catch(n){console.error("error during analytics",n)}};f();import Ok from"clsx";f();import{forwardRef as _k}from"react";import Rk from"clsx";import{jsx as Nk}from"react/jsx-runtime";var Uu=_k((e,t)=>{let{title:r,className:o,testId:n,active:i,standalone:a,icon:s,onClick:l}=e;return Nk("button",{type:"button",ref:t,title:r,"data-testid":n,className:Rk(o,{standalone:a,active:i}),onClick:l,children:s},r)});import{jsx as sE,jsxs as Fk}from"react/jsx-runtime";var Ro=e=>sE("div",{className:"buttonList",children:e.options.map(t=>e.type==="button"?sE(Uu,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:r=>e.onClick(t.value,r)},t.text):Fk("label",{className:Ok({active:e.value===t.value}),title:t.text,children:[sE("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});f();V();f();pr();import Bk from"clsx";import{jsx as lE}from"react/jsx-runtime";var R3=({onChange:e,type:t,activeColor:r,topPicks:o})=>{let n;return t==="elementStroke"&&(n=fm),t==="elementBackground"&&(n=bm),t==="canvasBackground"&&(n=Em),o&&(n=o),n?lE("div",{className:"color-picker__top-picks",children:n.map(i=>lE("button",{className:Bk("color-picker__button",{active:i===r,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:lE("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};f();import{jsx as zk}from"react/jsx-runtime";var Gu=()=>zk("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});f();import W3,{useEffect as V3,useState as sP}from"react";f();import Wk from"clsx";import{useAtom as Vk}from"jotai";import{useEffect as Yk,useRef as Xk}from"react";f();pr();import{atom as Hk}from"jotai";var la=({palette:e,color:t})=>{for(let[r,o]of Object.entries(e))if(Array.isArray(o)){let n=o.indexOf(t);if(n>-1)return{colorName:r,shade:n}}else if(o===t)return{colorName:r,shade:null};return null},Rd=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),cE=({color:e,palette:t})=>!Object.values(t).flat().includes(e),O3=(e,t,r)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[t]];return cE({color:s,palette:r})}),i=new Map;return n.forEach(a=>{let s=a[o[t]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,Ux)},No=Hk(null),N3=(e,t,r)=>(e*299+t*587+r*114)/1e3>=160?"black":"white",F3=(e,t)=>{if(t){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(a[0]),l=parseInt(a[1]),c=parseInt(a[2]);return N3(s,l,c)}}if(e==="transparent")return"black";let r=parseInt(e.substring(1,3),16),o=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return N3(r,o,n)};f();import{jsxs as Gk}from"react/jsx-runtime";var Uk=({color:e,keyLabel:t,isCustomColor:r=!1,isShade:o=!1})=>Gk("div",{className:"color-picker__button__hotkey-label",style:{color:F3(e,r)},children:[o&&"\u21E7",t]}),Ol=Uk;import{jsx as Nd,jsxs as B3}from"react/jsx-runtime";var z3=({hex:e,onChange:t,palette:r})=>{let o=la({color:e||"transparent",palette:r}),[n,i]=Vk(No),a=Xk(null);if(Yk(()=>{a.current&&n==="shades"&&a.current.focus()},[o,n]),o){let{colorName:s,shade:l}=o,c=r[s];if(Array.isArray(c))return Nd("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>B3("button",{ref:m===l&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:Wk("color-picker__button color-picker__button--large",{active:m===l}),"aria-label":"Shade",title:`${s} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[Nd("div",{className:"color-picker__button-outline"}),Nd(Ol,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return B3("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Nd("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Nd("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:E("colorPicker.noShades")})]})};f();import Kk from"clsx";import{useAtom as $k}from"jotai";import{useEffect as Zk,useRef as jk}from"react";import{jsx as dE,jsxs as Jk}from"react/jsx-runtime";var qk=({palette:e,color:t,onChange:r,label:o,activeShade:n})=>{let i=la({color:t||"transparent",palette:e}),[a,s]=$k(No),l=jk(null);return Zk(()=>{l.current&&a==="baseColors"&&l.current.focus()},[i?.colorName,a]),dE("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],m)=>{let p=(Array.isArray(d)?d[n]:d)||"transparent",u=Rd[m],g=E(`colors.${c.replace(/\d+/,"")}`,null,"");return Jk("button",{ref:i?.colorName===c?l:void 0,tabIndex:-1,type:"button",className:Kk("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{r(p),s("baseColors")},title:`${g}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${g} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[dE("div",{className:"color-picker__button-outline"}),dE(Ol,{color:p,keyLabel:u})]},c)})})},H3=qk;import{useAtom as lP}from"jotai";f();import Qk from"clsx";import{useAtom as eP}from"jotai";import{useEffect as tP,useRef as rP}from"react";import{jsx as mE,jsxs as oP}from"react/jsx-runtime";var U3=({colors:e,color:t,onChange:r,label:o})=>{let[n,i]=eP(No),a=rP(null);return tP(()=>{a.current&&a.current.focus()},[t,n]),mE("div",{className:"color-picker-content--default",children:e.map((s,l)=>oP("button",{ref:t===s?a:void 0,tabIndex:-1,type:"button",className:Qk("color-picker__button color-picker__button--large",{active:t===s,"is-transparent":s==="transparent"||!s}),onClick:()=>{r(s),i("custom")},title:s,"aria-label":o,style:{"--swatch-color":s},children:[mE("div",{className:"color-picker__button-outline"}),mE(Ol,{color:s,keyLabel:l+1,isCustomColor:!0})]},l))})};f();ye();pr();var pE=(e,t,r)=>{let o=Math.ceil(r/Ma);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?r-1:n}case"ArrowRight":return(t+1)%r;case"ArrowDown":{let n=t+Ma;return n>=r?t%Ma:n}case"ArrowUp":{let n=t-Ma,i=n<0?Ma*o+n:n;return i>=r?void 0:i}}},nP=({e,colorObj:t,onChange:r,palette:o,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return r(o[t.colorName][s]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return r(n[Number(e.key)-1]),i("custom"),!0;if(Rd.includes(e.key)){let s=Rd.indexOf(e.key),l=Object.keys(o)[s],c=o[l],d=Array.isArray(c)?c[a]:c;return r(d),i("baseColors"),!0}return!1},G3=({event:e,activeColorPickerSection:t,palette:r,color:o,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d})=>{if(e[S.CTRL_OR_CMD])return!1;if(e.key===S.ESCAPE)return d(e),!0;if(e.key===S.ALT)return c(!0),!0;if(e.key===S.I)return c(),!0;let m=la({color:o,palette:r});if(e.key===S.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((y,[w,C])=>(C&&y.push(w),y),[]),g=u.indexOf(t),h=e.shiftKey?-1:1,x=g+h>u.length-1?0:g+h<0?u.length-1:g+h,v=u[x];return v&&a(v),v==="custom"?n(i[0]):v==="baseColors"&&(Object.entries(r).find(([w,C])=>Array.isArray(C)?C.includes(o):C===o?w:null)||n(Ee.black)),e.preventDefault(),e.stopPropagation(),!0}if(nP({e,colorObj:m,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:l}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=pE(e.key,p,Ma);if(u!==void 0)return n(r[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(r),g=u.indexOf(p),h=pE(e.key,g,u.length);if(h!==void 0){let x=u[h],v=r[x];return n(Array.isArray(v)?v[l]:v),!0}}if(t==="custom"){let p=i.indexOf(o),u=pE(e.key,p,i.length);if(u!==void 0){let g=i[u];return n(g),!0}}return!1};f();import{jsx as aP}from"react/jsx-runtime";var iP=({children:e})=>aP("div",{className:"color-picker__heading",children:e}),Fl=iP;pr();ye();Y();import{jsx as hs,jsxs as Wu}from"react/jsx-runtime";var Y3=({color:e,onChange:t,label:r,type:o,elements:n,palette:i,updateData:a,children:s,onEyeDropperToggle:l,onEscape:c})=>{let[d]=W3.useState(()=>o==="canvasBackground"?[]:O3(n,o,i)),[m,p]=lP(No),u=la({color:e,palette:i});V3(()=>{if(!m){let v=cE({color:e,palette:i}),y=v&&!d.includes(e);p(y?"hex":v?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,i,p,u,d]);let[g,h]=sP(u?.shade??(o==="elementBackground"?Rs:_s));V3(()=>{u?.shade!=null&&h(u.shade);let v=y=>{y.key===S.ALT&&l(!1)};return document.addEventListener("keyup",v,{capture:!0}),()=>{document.removeEventListener("keyup",v,{capture:!0})}},[u,l]);let x=W3.useRef(null);return hs("div",{role:"dialog","aria-modal":"true","aria-label":E("labels.colorPicker"),children:Wu("div",{ref:x,onKeyDown:v=>{G3({event:v,activeColorPickerSection:m,palette:i,color:e,onChange:t,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:a,activeShade:g,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&Wu("div",{children:[hs(Fl,{children:E("colorPicker.mostUsedCustomColors")}),hs(U3,{colors:d,color:e,label:E("colorPicker.mostUsedCustomColors"),onChange:t})]}),Wu("div",{children:[hs(Fl,{children:E("colorPicker.colors")}),hs(H3,{color:e,label:r,palette:i,onChange:t,activeShade:g})]}),Wu("div",{children:[hs(Fl,{children:E("colorPicker.shades")}),hs(z3,{hex:e,onChange:t,palette:i})]}),s]})})};import*as Ku from"@radix-ui/react-popover";import{useAtom as eS}from"jotai";pr();import AP from"clsx";import{useRef as MP}from"react";f();import{useCallback as bP,useEffect as gE,useRef as Z3,useState as EP}from"react";import{useAtom as j3}from"jotai";ee();ye();f();pr();Y();import{atom as pP}from"jotai";import{useEffect as uP,useRef as gP}from"react";import{createPortal as hP}from"react-dom";f();import X3 from"react";var uE=X3.createContext(null),Ue=()=>X3.useContext(uE);f();import{useState as cP,useLayoutEffect as K3}from"react";Y();var Vu=e=>{let[t,r]=cP(null),o=Ne(),{theme:n}=Ue(),{container:i}=Ft();return K3(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",o.editor.isMobile),t.classList.toggle("theme--dark",n===ue.DARK))},[t,n,o.editor.isMobile,e?.className]),K3(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),r(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),t};f();Y();import{useEffect as dP}from"react";function Bl(e,t,r){dP(()=>{function o(n){let i=n;if(!e.current)return;let a=r?.(i,e.current);if(a===!0)return;if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||t(i)}return document.addEventListener("pointerdown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("touchstart",o)}},[e,t,r])}ye();et();f();import{useRef as mP}from"react";var zl=e=>{let t=mP(e);return Object.assign(t.current,e),t.current};import{jsx as fP}from"react/jsx-runtime";var ca=pP(null),$3=({onCancel:e,onChange:t,onSelect:r,colorPickerType:o})=>{let n=Vu({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Ue(),a=da(),s=tr(),l=he(a,i),c=zl({app:s,onCancel:e,onChange:t,onSelect:r,selectedElements:l}),{container:d}=Ft();uP(()=>{let p=m.current;if(!p||!s.canvas||!n)return;let u=!1,g=s.canvas.getContext("2d"),h=({clientX:I,clientY:P})=>{let A=g.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return Kx(A[0],A[1],A[2])},x=({clientX:I,clientY:P,altKey:A})=>{p.style.top=`${P+20}px`,p.style.left=`${I+20}px`;let N=h({clientX:I,clientY:P});u&&c.onChange(o,N,c.selectedElements,{altKey:A}),p.style.background=N},v=()=>{c.onCancel()},y=(I,P)=>{c.onSelect(I,P)},w=I=>{u=!0,I.stopImmediatePropagation()},C=I=>{u=!1,d?.focus(),I.stopImmediatePropagation(),I.preventDefault(),y(h(I),I)},M=I=>{I.key===S.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",M),n.addEventListener("pointerdown",w),n.addEventListener("pointerup",C),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",v),()=>{u=!1,n.removeEventListener("keydown",M),n.removeEventListener("pointerdown",w),n.removeEventListener("pointerup",C),window.removeEventListener("pointermove",x),window.removeEventListener("blur",v)}},[c,s.canvas,n,o,d,i.offsetLeft,i.offsetTop]);let m=gP(null);return Bl(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?hP(fP("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import xP from"clsx";V();import{Fragment as yP,jsx as Yu,jsxs as q3}from"react/jsx-runtime";var J3=({color:e,onChange:t,label:r,colorPickerType:o})=>{let n=Ne(),[i,a]=EP(e),[s,l]=j3(No);gE(()=>{a(e)},[e]);let c=bP(g=>{let h=g.toLowerCase(),x=Q3(h);x&&t(x),a(h)},[t]),d=Z3(null),m=Z3(null);gE(()=>{d.current&&d.current.focus()},[s]);let[p,u]=j3(ca,Xe);return gE(()=>()=>{u(null)},[u]),q3("div",{className:"color-picker__input-label",children:[Yu("div",{className:"color-picker__input-hash",children:"#"}),Yu("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":r,onChange:g=>{c(g.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>l("hex"),onKeyDown:g=>{g.key!==S.TAB&&(g.key===S.ESCAPE&&m.current?.focus(),g.stopPropagation())}}),!n.editor.isMobile&&q3(yP,{children:[Yu("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Yu("div",{ref:m,className:xP("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(g=>g?null:{keepOpenOnAlt:!1,onSelect:h=>t(h),colorPickerType:o}),title:`${E("labels.eyeDropper")} \u2014 ${S.I.toLocaleUpperCase()} or ${O("Alt")} `,children:bw})]})]})};f();import SP from"react";import IP from"clsx";import*as Hl from"@radix-ui/react-popover";f();import wP from"react";import vP from"clsx";import{jsx as TP}from"react/jsx-runtime";var Yt=wP.forwardRef(({children:e,padding:t,className:r,style:o},n)=>TP("div",{className:vP("Island",r),style:{"--padding":t,...o},ref:n,children:e}));V();import{jsx as hE,jsxs as CP}from"react/jsx-runtime";var Xu=SP.forwardRef(({className:e,container:t,children:r,style:o,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l},c)=>{let d=Ne();return hE(Hl.Portal,{container:t,children:CP(Hl.Content,{ref:c,className:IP("focus-visible-none",e),"data-prevent-outside-click":!0,side:d.editor.isMobile&&!d.viewport.isLandscape?"bottom":"right",align:d.editor.isMobile&&!d.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onCloseAutoFocus:m=>{m.stopPropagation(),m.preventDefault(),t&&!S0(document.activeElement)&&t.focus(),n()},children:[hE(Yt,{padding:3,style:o,children:r}),hE(Hl.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{jsx as hn,jsxs as fE}from"react/jsx-runtime";var tS=e=>{let t=new Option().style;return t.color=e,!!t.color},Q3=e=>Ar(e)?e:tS(`#${e}`)?`#${e}`:tS(e)?e:null,kP=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=Ee,updateData:a})=>{let{container:s}=Ft(),[,l]=eS(No),[c,d]=eS(ca,Xe),m=fE("div",{children:[hn(Fl,{children:E("colorPicker.hexCode")}),hn(J3,{color:t,label:o,onChange:g=>{r(g)},colorPickerType:e})]}),p=MP(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return hn(Xu,{container:s,style:{maxWidth:"208px"},onFocusOutside:g=>{u(),g.preventDefault()},onPointerDownOutside:g=>{c&&g.preventDefault()},onClose:()=>{a({openPopup:null}),l(null)},children:i?hn(Y3,{palette:i,color:t,onChange:g=>{r(g)},onEyeDropperToggle:g=>{d(h=>g?(h=h||{keepOpenOnAlt:!0,onSelect:r,colorPickerType:e},h.keepOpenOnAlt=!0,h):g===!1||h?null:{keepOpenOnAlt:!1,onSelect:r,colorPickerType:e})},onEscape:g=>{c?d(null):a({openPopup:null})},label:o,type:e,elements:n,updateData:a,children:m}):m})},PP=({label:e,color:t,type:r})=>hn(Ku.Trigger,{type:"button",className:AP("color-picker__button active-color properties-trigger",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:r==="elementStroke"?E("labels.showStroke"):E("labels.showBackground"),children:hn("div",{className:"color-picker__button-outline"})}),Od=({type:e,color:t,onChange:r,label:o,elements:n,palette:i=Ee,topPicks:a,updateData:s,appState:l})=>hn("div",{children:fE("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[hn(R3,{activeColor:t,onChange:r,type:e,topPicks:a}),hn(Gu,{}),fE(Ku.Root,{open:l.openPopup===e,onOpenChange:c=>{s({openPopup:c?e:null})},children:[hn(PP,{color:t,label:o,type:e}),l.openPopup===e&&hn(kP,{type:e,color:t,onChange:r,label:o,elements:n,palette:i,updateData:s})]})]})});f();import fs from"react";f();import{useLayoutEffect as LP,useRef as rS,useEffect as oS}from"react";V();ye();import{unstable_batchedUpdates as DP}from"react-dom";import{jsx as _P}from"react/jsx-runtime";var $u=({children:e,left:t,top:r,onCloseRequest:o,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:s=window.innerWidth,viewportHeight:l=window.innerHeight})=>{let c=rS(null);oS(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===S.TAB){let g=Tc(m),{activeElement:h}=document,x=g.findIndex(v=>v===h);h===m?(u.shiftKey?g[g.length-1]?.focus():g[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(g[g.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===g.length-1&&!u.shiftKey&&(g[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=rS(null);return LP(()=>{if(n&&c.current&&r!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===r&&d.current?.left===t)return;d.current={top:r,left:t},p>=s?(m.style.width=`${s}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>s?m.style.left=`${s-p-10}px`:m.style.left=`${t}px`,u>=l?(m.style.height=`${l-20}px`,m.style.top="10px",m.style.overflowY="scroll"):r+u-a>l?m.style.top=`${l-u}px`:m.style.top=`${r}px`}},[r,t,n,s,l,i,a]),oS(()=>{if(o){let m=p=>{c.current?.contains(p.target)||DP(()=>o(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[o]),_P("div",{className:"popover",ref:c,tabIndex:-1,children:e})};ye();import RP from"clsx";import{Fragment as OP,jsx as ma,jsxs as bE}from"react/jsx-runtime";function NP({options:e,value:t,label:r,onChange:o,onClose:n}){let i=fs.useRef(),a=fs.useRef(),s=fs.useRef(null);return fs.useEffect(()=>{a.current?a.current.focus():s.current&&s.current.focus()},[]),ma("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,onKeyDown:c=>{let d=e.find(m=>m.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&d){let m=e.indexOf(d);s.current.children[m].focus(),c.preventDefault()}else if(c.key===S.TAB)setTimeout(()=>{let m=a.current,p=document.activeElement;m!==p&&n()},0);else if(ll(c.key)){let{activeElement:m}=document,p=ei().rtl,u=Array.prototype.indexOf.call(s.current.children,m);if(u!==-1){let g=e.length,h=u;switch(c.key){case(p?S.ARROW_LEFT:S.ARROW_RIGHT):case S.ARROW_DOWN:{h=(u+1)%g;break}case(p?S.ARROW_RIGHT:S.ARROW_LEFT):case S.ARROW_UP:{h=(g+u-1)%g;break}}s.current.children[h].focus()}c.preventDefault()}else(c.key===S.ESCAPE||c.key===S.ENTER)&&(c.preventDefault(),n());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:ma("div",{className:"picker-content",ref:s,children:e.map((c,d)=>bE("button",{type:"button",className:RP("picker-option",{active:t===c.value}),onClick:m=>{m.currentTarget.focus(),o(c.value)},title:`${c.text} ${c.keyBinding&&`\u2014 ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:m=>{m&&d===0&&(i.current=m),m&&c.value===t&&(a.current=m)},onFocus:()=>{o(c.value)},children:[c.icon,c.keyBinding&&ma("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function EE({value:e,label:t,options:r,onChange:o,group:n=""}){let[i,a]=fs.useState(!1),s=fs.useRef(null),l=ei().rtl;return bE("div",{children:[ma("button",{name:n,type:"button",className:i?"active":"","aria-label":t,onClick:()=>a(!i),ref:s,children:r.find(c=>c.value===e)?.icon}),ma(fs.Suspense,{fallback:"",children:i?bE(OP,{children:[ma($u,{onCloseRequest:c=>c.target!==s.current&&a(!1),...l?{right:5.5}:{left:-5.5},children:ma(NP,{options:r.filter(c=>c.showInPicker!==!1),value:e,label:t,onChange:o,onClose:()=>{a(!1),s.current?.focus()}})}),ma("div",{className:"picker-triangle"})]}):null})]})}f();import nL,{useCallback as iL,useMemo as aL}from"react";import*as uS from"@radix-ui/react-popover";f();import JP,{useMemo as pa,useState as QP,useRef as eL,useEffect as tL,useCallback as rL}from"react";f();ee();import FP from"clsx";import BP from"react";import{jsx as zP,jsxs as HP}from"react/jsx-runtime";var Zu=BP.forwardRef(({className:e,placeholder:t,onChange:r},o)=>HP("div",{className:FP("QuickSearch__wrapper",e),children:[dp,zP("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:t,onChange:n=>r(n.target.value.trim().toLowerCase())})]}));f();import UP from"clsx";import{Children as GP}from"react";import{jsx as nS}from"react/jsx-runtime";var ju=({className:e,placeholder:t,children:r})=>{let o=!GP.count(r);return nS("div",{className:UP("ScrollableList__wrapper",e),role:"menu",children:o?nS("div",{className:"empty",children:t}):r})};f();import{jsx as WP,jsxs as VP}from"react/jsx-runtime";var iS=({children:e,className:t="",style:r,title:o})=>VP("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&WP("p",{className:"dropdown-menu-group-title",children:o}),e]}),Fd=iS;iS.displayName="DropdownMenuGroup";f();import{useEffect as jP,useRef as qP}from"react";f();Y();V();import YP,{useContext as XP}from"react";var xE=YP.createContext({}),qu=(e="",t=!1,r=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
51
+ ${t?"dropdown-menu-item--selected":""} ${r?"dropdown-menu-item--hovered":""}`.trim(),Ju=(e,t)=>{let r=XP(xE);return zi(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as $P,jsx as yE,jsxs as ZP}from"react/jsx-runtime";var KP=({textStyle:e,icon:t,shortcut:r,children:o})=>{let n=Ne();return ZP($P,{children:[t&&yE("div",{className:"dropdown-menu-item__icon",children:t}),yE("div",{style:e,className:"dropdown-menu-item__text",children:o}),r&&!n.editor.isMobile&&yE("div",{className:"dropdown-menu-item__shortcut",children:r})]})},Qu=KP;Y();import{jsx as wE}from"react/jsx-runtime";var vE=({icon:e,value:t,order:r,children:o,shortcut:n,className:i,hovered:a,selected:s,textStyle:l,onSelect:c,onClick:d,...m})=>{let p=Ju(d,c),u=qP(null);return jP(()=>{a&&(r===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,r]),wE("button",{...m,ref:u,value:t,onClick:p,className:qu(i,s,a),title:m.title??m["aria-label"],children:wE(Qu,{textStyle:l,icon:e,shortcut:n,children:o})})};vE.displayName="DropdownMenuItem";var Ul={GREEN:"green",RED:"red",BLUE:"blue"},eg=({type:e=Ul.BLUE,children:t})=>{let{theme:r}=Gn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:r===ue.LIGHT?"1.5px solid white":"none"};switch(e){case Ul.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ul.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ul.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return wE("div",{className:"DropDownMenuItemBadge",style:o,children:t})};eg.displayName="DropdownMenuItemBadge";vE.Badge=eg;var eo=vE;V();f();ye();var aS=({event:e,inputRef:t,hoveredFont:r,filteredFonts:o,onClose:n,onSelect:i,onHover:a})=>{if(!e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===S.F)return t.current?.focus(),!0;if(e.key===S.ESCAPE)return n(),!0;if(e.key===S.ENTER)return r?.value&&i(r.value),!0;if(e.key===S.ARROW_DOWN)return r?.next?a(r.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===S.ARROW_UP)return r?.prev?a(r.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};on();import{jsx as Bd,jsxs as sS}from"react/jsx-runtime";var lS=JP.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:r,onHover:o,onLeave:n,onOpen:i,onClose:a})=>{let{container:s}=Ft(),{fonts:l}=tr(),{showDeprecatedFonts:c}=Wn(),[d,m]=QP(""),p=eL(null),u=pa(()=>Array.from(Lr.registered.entries()).filter(([A,{metadata:N}])=>!N.serverSide).map(([A,{metadata:N,fonts:k}])=>{let D={value:A,icon:N.icon,text:k[0].fontFace.family};return N.deprecated&&Object.assign(D,{deprecated:N.deprecated,badge:{type:Ul.RED,placeholder:E("fontList.badge.old")}}),D}).sort((A,N)=>A.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),g=pa(()=>new Set(l.getSceneFontFamilies()),[e]),h=pa(()=>u.filter(A=>g.has(A.value)),[u,g]),x=pa(()=>u.filter(A=>!g.has(A.value)&&(c||!A.deprecated)),[u,g,c]),v=pa(()=>D0([...h,...x].filter(A=>A.text?.toLowerCase().includes(d))),[h,x,d]),y=pa(()=>{let A;return t?A=v.find(N=>N.value===t):e&&(A=v.find(N=>N.value===e)),!A&&d&&(v[0]?.value?o(v[0].value):n()),A},[t,e,d,v,o,n]),w=rL(A=>{aS({event:A,inputRef:p,hoveredFont:y,filteredFonts:v,onSelect:r,onHover:o,onClose:a})&&(A.preventDefault(),A.stopPropagation())},[y,v,r,o,a]);tL(()=>(i(),()=>{a()}),[]);let C=pa(()=>v.filter(A=>g.has(A.value)),[v,g]),M=pa(()=>v.filter(A=>!g.has(A.value)),[v,g]),I=(A,N)=>sS(eo,{icon:A.icon,value:A.value,order:N,textStyle:{fontFamily:Sn({fontFamily:A.value})},hovered:A.value===y?.value,selected:A.value===e,tabIndex:A.value===e?0:-1,onClick:k=>{r(Number(k.currentTarget.value))},onMouseMove:()=>{y?.value!==A.value&&o(A.value)},children:[A.text,A.badge&&Bd(eg,{type:A.badge.type,children:A.badge.placeholder})]},A.value),P=[];return C.length&&P.push(Bd(Fd,{title:E("fontList.sceneFonts"),children:C.map(I)},"group_1")),M.length&&P.push(Bd(Fd,{title:E("fontList.availableFonts"),children:M.map((A,N)=>I(A,N+C.length))},"group_2")),sS(Xu,{className:"properties-content",container:s,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:w,children:[Bd(Zu,{ref:p,placeholder:E("quickSearch.placeholder"),onChange:ii(m,20)}),Bd(ju,{className:"dropdown-menu fonts manual-hover",placeholder:E("fontList.empty"),children:P.length?P:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);f();import*as cS from"@radix-ui/react-popover";import{useMemo as oL}from"react";ee();import{jsx as TE}from"react/jsx-runtime";var dS=({selectedFontFamily:e})=>{let t=oL(()=>!!(e&&!mS(e)),[e]);return TE(cS.Trigger,{asChild:!0,children:TE("div",{children:TE(Uu,{standalone:!0,icon:Jm,title:E("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{}})})})};ee();Y();import{jsx as tg,jsxs as pS}from"react/jsx-runtime";var gS=[{value:Le.Excalifont,icon:ci,text:E("labels.handDrawn"),testId:"font-family-handrawn"},{value:Le.Nunito,icon:Xs,text:E("labels.normal"),testId:"font-family-normal"},{value:Le["Comic Shanns"],icon:Dc,text:E("labels.code"),testId:"font-family-code"}],sL=new Set(gS.map(e=>e.value)),mS=e=>e?sL.has(e):!1,hS=nL.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:r,onSelect:o,onHover:n,onLeave:i,onPopupChange:a})=>{let s=aL(()=>gS,[]),l=iL(c=>{c&&o(c)},[o]);return pS("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[tg(Ro,{type:"button",options:s,value:t,onClick:l}),tg(Gu,{}),pS(uS.Root,{open:e,onOpenChange:a,children:[tg(dS,{selectedFontFamily:t}),e&&tg(lS,{selectedFontFamily:t,hoveredFontFamily:r,onSelect:l,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);ee();Y();we();De();He();me();ye();Zo();et();bd();V();$e();Re();on();yr();kl();Wt();import{Fragment as ES,jsx as ke,jsxs as to}from"react/jsx-runtime";var bS=.1,Or=(e,t,r,o=!1)=>{let n=Z(he(e,t,{includeBoundTextElement:o}));return e.map(i=>n.get(i.id)||i.id===t.editingElement?.id?r(i):i)},Fr=function(e,t,r,o,n){let i=t.editingElement,a=Ae(e),s=null;return i&&(s=r(i)),s||(qe(a,t)?s=jb(o===!0?a:a.filter(c=>o(c)),t,r)??(typeof n=="function"?n(!0):n):s=typeof n=="function"?n(!1):n),s},dL=(e,t)=>ze(t)||!t.autoResize?t:F(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),CE=(e,t,r,o,n)=>{let i=new Set;return{elements:Or(e,t,a=>{if(H(a)){let s=o(a);i.add(s);let l=pe(a,{fontSize:s});return ft(l,r.scene.getContainerElement(a),r.scene.getNonDeletedElementsMap()),l=dL(a,l),l}return a},!0),appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},storeAction:_.CAPTURE}},mL=G({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemStrokeColor&&{elements:Or(e,t,o=>fd(o.type)?pe(o,{strokeColor:r.currentItemStrokeColor}):o,!0)},appState:{...t,...r},storeAction:r.currentItemStrokeColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>to(ES,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.stroke")}),ke(Od,{topPicks:fm,palette:Vx,type:"elementStroke",label:E("labels.stroke"),color:Fr(e,t,n=>n.strokeColor,!0,t.currentItemStrokeColor),onChange:n=>r({currentItemStrokeColor:n}),elements:e,appState:t,updateData:r})]})}),pL=G({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,r)=>({...r.currentItemBackgroundColor&&{elements:Or(e,t,o=>pe(o,{backgroundColor:r.currentItemBackgroundColor}))},appState:{...t,...r},storeAction:r.currentItemBackgroundColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>to(ES,{children:[ke("h3",{"aria-hidden":"true",children:E("labels.background")}),ke(Od,{topPicks:bm,palette:Yx,type:"elementBackground",label:E("labels.background"),color:Fr(e,t,n=>n.backgroundColor,!0,t.currentItemBackgroundColor),onChange:n=>r({currentItemBackgroundColor:n}),elements:e,appState:t,updateData:r})]})}),uL=G({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,r,o)=>(Ce("element","changeFillStyle",`${r} (${o.device.editor.isMobile?"mobile":"desktop"})`),{elements:Or(e,t,n=>pe(n,{fillStyle:r})),appState:{...t,currentItemFillStyle:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=he(e,t),n=o.length>0&&o.every(i=>i.fillStyle==="zigzag");return to("fieldset",{children:[ke("legend",{children:E("labels.fill")}),ke(Ro,{type:"button",options:[{value:"hachure",text:`${n?E("labels.zigzag"):E("labels.hachure")} (${O("Alt-Click")})`,icon:n?Ny:Oy,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:E("labels.crossHatch"),icon:Fy,testId:"fill-cross-hatch"},{value:"solid",text:E("labels.solid"),icon:By,testId:"fill-solid"}],value:Fr(e,t,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:t.currentItemFillStyle),onClick:(i,a)=>{let s=a.altKey&&i==="hachure"&&o.every(l=>l.fillStyle==="hachure")?"zigzag":i;r(s)}})]})}}),gL=G({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{strokeWidth:r})),appState:{...t,currentItemStrokeWidth:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.strokeWidth")}),ke(Ro,{group:"stroke-width",options:[{value:km.thin,text:E("labels.thin"),icon:mf,testId:"strokeWidth-thin"},{value:km.bold,text:E("labels.bold"),icon:zy,testId:"strokeWidth-bold"},{value:km.extraBold,text:E("labels.extraBold"),icon:Hy,testId:"strokeWidth-extraBold"}],value:Fr(e,t,o=>o.strokeWidth,o=>o.hasOwnProperty("strokeWidth"),o=>o?null:t.currentItemStrokeWidth),onChange:o=>r(o)})]})}),hL=G({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{seed:Co(),roughness:r})),appState:{...t,currentItemRoughness:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.sloppiness")}),ke(Ro,{group:"sloppiness",options:[{value:0,text:E("labels.architect"),icon:Wy},{value:1,text:E("labels.artist"),icon:Vy},{value:2,text:E("labels.cartoonist"),icon:Yy}],value:Fr(e,t,o=>o.roughness,o=>o.hasOwnProperty("roughness"),o=>o?null:t.currentItemRoughness),onChange:o=>r(o)})]})}),Cee=G({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{strokeStyle:r})),appState:{...t,currentItemStrokeStyle:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.strokeStyle")}),ke(Ro,{group:"strokeStyle",options:[{value:"solid",text:E("labels.strokeStyle_solid"),icon:mf},{value:"dashed",text:E("labels.strokeStyle_dashed"),icon:Uy},{value:"dotted",text:E("labels.strokeStyle_dotted"),icon:Gy}],value:Fr(e,t,o=>o.strokeStyle,o=>o.hasOwnProperty("strokeStyle"),o=>o?null:t.currentItemStrokeStyle),onChange:o=>r(o)})]})}),fL=G({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>pe(o,{opacity:r}),!0),appState:{...t,currentItemOpacity:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("label",{className:"control-label",children:[E("labels.opacity"),ke("input",{type:"range",min:"0",max:"100",step:"10",onChange:o=>r(+o.target.value),value:Fr(e,t,o=>o.opacity,!0,t.currentItemOpacity)??void 0})]})}),bL=G({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,()=>r,r),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>to("fieldset",{children:[ke("legend",{children:E("labels.fontSize")}),ke(Ro,{group:"font-size",options:[{value:16,text:E("labels.small"),icon:rw,testId:"fontSize-small"},{value:20,text:E("labels.medium"),icon:ow,testId:"fontSize-medium"},{value:28,text:E("labels.large"),icon:nw,testId:"fontSize-large"},{value:36,text:E("labels.veryLarge"),icon:iw,testId:"fontSize-veryLarge"}],value:Fr(e,t,n=>{if(H(n))return n.fontSize;let i=J(n,o.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>H(n)||J(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:t.currentItemFontSize||ur),onChange:n=>r(n)})]})}),AE=G({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:za,trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,n=>Math.round(1/(1+bS)*n.fontSize)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_LEFT||e.key===S.COMMA)}),ME=G({name:"increaseFontSize",label:"labels.increaseFontSize",icon:za,trackEvent:!1,perform:(e,t,r,o)=>CE(e,t,o,n=>Math.round(n.fontSize*(1+bS))),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&(e.key===S.CHEVRON_RIGHT||e.key===S.PERIOD)}),EL=G({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,r,o)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...s}=r;if(i)return{elements:Or(e,t,h=>{let x=n?.get(h.id);return x?pe(h,{...x}):h},!0),appState:{...t,...s},storeAction:_.UPDATE};let{currentItemFontFamily:l,currentHoveredFontFamily:c}=r,d=_.NONE,m,p=!1;if(l)m=l,d=_.CAPTURE;else if(c){m=c,d=_.NONE;let g=he(e,t,{includeBoundTextElement:!0}).filter(h=>H(h));if(g.length>200)p=!0;else{let h=0,x=0;for(;h<g.length&&x<5e3;){let v=g[h];x+=v?.originalText.length||0,h++}x>5e3&&(p=!0)}}let u={appState:{...t,...s},storeAction:d};if(m&&!p){let g=new Map,h=new Set,x=!1,v=Array.from(Lr.loadedFontsCache.values()),y=Object.entries(Le).find(([M,I])=>I===m)?.[0];c&&y&&v.some(M=>M.startsWith(y))&&(x=!0),Object.assign(u,{elements:Or(e,t,M=>{if(H(M)&&(M.fontFamily!==m||l)){let I=pe(M,{fontFamily:m,lineHeight:uo(m)}),P=n?.get(M.containerId||"")||{},A=o.scene.getContainerElement(M);return a&&A&&P&&F(A,{...P},!1),x||(h=new Set([...h,...Array.from(I.originalText)])),g.set(I,A),I}return M},!0)});let w=`10px ${Sn({fontFamily:m})}`,C=Array.from(h.values()).join();if(x||window.document.fonts.check(w,C))for(let[M,I]of g)ft(M,I,o.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(w,C).then(M=>{for(let[I,P]of g){let A=o.scene.getElement(I.id),N=P?o.scene.getElement(P.id):null;A&&ft(A,N,o.scene.getNonDeletedElementsMap(),!1)}o.fonts.onLoaded(M)})}return u},PanelComponent:({elements:e,appState:t,app:r,updateData:o})=>{let n=IE(new Map),i=IE(null),[a,s]=cL({}),l=IE(!0),c=lL(()=>{let d=(m,p)=>Fr(m,t,u=>{if(H(u))return u.fontFamily;let g=J(u,p);return g?g.fontFamily:null},u=>H(u)||J(u,p)!==null,u=>u?null:t.currentItemFontFamily||gr);return a.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?d(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&t.openPopup!=="fontFamily"?d(e,r.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,t,e,r.scene]);return SE(()=>{i.current=c},[c]),SE(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),SE(()=>(l.current=!1,()=>{l.current=!0}),[]),to("fieldset",{children:[ke("legend",{children:E("labels.fontFamily")}),ke(hS,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:d=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),n.current.clear()},onHover:d=>{s({currentHoveredFontFamily:d,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:d=>{if(d){n.current.clear();let{editingElement:m}=t;if(m?.type==="text"){let p=r.scene.getElement(m.id);n.current.set(m.id,pe(p||m,{},!0))}else{let p=he(e,t,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,pe(u,{},!0))}s({openPopup:"fontFamily"})}else{let m={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};l.current?o({...a,...m}):s(m),n.current.clear()}}})]})}}),xL=G({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(H(n)){let i=pe(n,{textAlign:r});return ft(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t,currentItemTextAlign:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>{let n=o.scene.getNonDeletedElementsMap();return to("fieldset",{children:[ke("legend",{children:E("labels.textAlign")}),ke(Ro,{group:"text-align",options:[{value:"left",text:E("labels.left"),icon:sw,testId:"align-left"},{value:"center",text:E("labels.center"),icon:lw,testId:"align-horizontal-center"},{value:"right",text:E("labels.right"),icon:cw,testId:"align-right"}],value:Fr(e,t,i=>{if(H(i))return i.textAlign;let a=J(i,n);return a?a.textAlign:null},i=>H(i)||J(i,n)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>r(i)})]})}}),yL=G({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(H(n)){let i=pe(n,{verticalAlign:r});return ft(i,o.scene.getContainerElement(n),o.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...t},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>ke("fieldset",{children:ke(Ro,{group:"text-align",options:[{value:kt.TOP,text:E("labels.alignTop"),icon:ke(dw,{theme:t.theme}),testId:"align-top"},{value:kt.MIDDLE,text:E("labels.centerVertically"),icon:ke(pw,{theme:t.theme}),testId:"align-middle"},{value:kt.BOTTOM,text:E("labels.alignBottom"),icon:ke(mw,{theme:t.theme}),testId:"align-bottom"}],value:Fr(e,t,n=>{if(H(n)&&n.containerId)return n.verticalAlign;let i=J(n,o.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>H(n)||J(n,o.scene.getNonDeletedElementsMap())!==null,n=>n?null:kt.MIDDLE),onChange:n=>r(n)})})}),Aee=G({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>de(o)?o:pe(o,{roundness:r==="round"?{type:kn(o.type)?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let n=Pd(Ae(e),t).some(i=>i.roundness?.type===ct.LEGACY);return to("fieldset",{children:[ke("legend",{children:E("labels.edges")}),ke(Ro,{group:"edges",options:[{value:"sharp",text:E("labels.sharp"),icon:Xy},{value:"round",text:E("labels.round"),icon:Ky}],value:Fr(e,t,i=>n?null:i.roundness?"round":"sharp",i=>!ne(i)&&i.hasOwnProperty("roundness"),i=>i?null:t.currentItemRoundness),onChange:i=>r(i)})]})}}),fS=e=>[{value:null,text:E("labels.arrowhead_none"),keyBinding:"q",icon:$y},{value:"arrow",text:E("labels.arrowhead_arrow"),keyBinding:"w",icon:ke(Zy,{flip:e})},{value:"bar",text:E("labels.arrowhead_bar"),keyBinding:"e",icon:ke(qy,{flip:e})},{value:"dot",text:E("labels.arrowhead_circle"),keyBinding:null,icon:ke(pf,{flip:e}),showInPicker:!1},{value:"circle",text:E("labels.arrowhead_circle"),keyBinding:"r",icon:ke(pf,{flip:e}),showInPicker:!1},{value:"circle_outline",text:E("labels.arrowhead_circle_outline"),keyBinding:null,icon:ke(jy,{flip:e}),showInPicker:!1},{value:"triangle",text:E("labels.arrowhead_triangle"),icon:ke(Jy,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:E("labels.arrowhead_triangle_outline"),icon:ke(Qy,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:E("labels.arrowhead_diamond"),icon:ke(ew,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:E("labels.arrowhead_diamond_outline"),icon:ke(tw,{flip:e}),keyBinding:null,showInPicker:!1}],Mee=G({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,r)=>({elements:Or(e,t,o=>{if(ie(o)){let{position:n,type:i}=r;if(n==="start")return pe(o,{startArrowhead:i});if(n==="end")return pe(o,{endArrowhead:i})}return o}),appState:{...t,[r.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:r.type},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=ei().rtl;return to("fieldset",{children:[ke("legend",{children:E("labels.arrowheads")}),to("div",{className:"iconSelectList buttonList",children:[ke(EE,{label:"arrowhead_start",options:fS(!o),value:Fr(e,t,n=>ie(n)&&is(n.type)?n.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:n=>r({position:"start",type:n})}),ke(EE,{label:"arrowhead_end",group:"arrowheads",options:fS(!!o),value:Fr(e,t,n=>ie(n)&&is(n.type)?n.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:n=>r({position:"end",type:n})})]})]})}}),kee=G({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,r,o)=>({elements:Or(e,t,n=>{if(!ne(n))return n;let i=pe(n,{roundness:r===_t.round?{type:ct.PROPORTIONAL_RADIUS}:null,elbowed:r===_t.elbow,points:r===_t.elbow||n.elbowed?[n.points[0],n.points[n.points.length-1]]:n.points});if(de(i)){let a=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let s=K.getPointAtIndexGlobalCoordinates(i,0,a),l=K.getPointAtIndexGlobalCoordinates(i,-1,a),c=!i.startBinding&&xr(ar(s),e,a,!0),d=!i.endBinding&&xr(ar(l),e,a,!0),m=c||i.startBinding&&a.get(i.startBinding.elementId),p=d||i.endBinding&&a.get(i.endBinding.elementId),u=c?gl(s,l,c,a):s,g=d?gl(l,s,d,a):l;c&&On(i,c,"start",a),d&&On(i,d,"end",a),_o(i,o.scene,[u,g].map(h=>[h[0]-i.x,h[1]-i.y]),[0,0],{...m&&i.startBinding?{startBinding:{...i.startBinding,...Qc(i,m,"start",a)}}:{},...p&&i.endBinding?{endBinding:{...i.endBinding,...Qc(i,p,"end",a)}}:{}})}else F(i,{startBinding:i.startBinding?{...i.startBinding,fixedPoint:null}:null,endBinding:i.endBinding?{...i.endBinding,fixedPoint:null}:null},!1);return i}),appState:{...t,currentItemArrowType:r},storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r})=>to("fieldset",{children:[ke("legend",{children:E("labels.arrowtypes")}),ke(Ro,{group:"arrowtypes",options:[{value:_t.sharp,text:E("labels.arrowtype_sharp"),icon:Bw,testId:"sharp-arrow"},{value:_t.round,text:E("labels.arrowtype_round"),icon:Hw,testId:"round-arrow"},{value:_t.elbow,text:E("labels.arrowtype_elbowed"),icon:zw,testId:"elbow-arrow"}],value:Fr(e,t,o=>ne(o)?o.elbowed?_t.elbow:o.roundness?_t.round:_t.sharp:null,o=>ne(o),o=>o?null:t.currentItemArrowType),onChange:o=>r(o)})]})});f();ee();Y();we();ye();et();Jb();zu();V();$e();f();import{useEffect as wL}from"react";import{jsx as TL}from"react/jsx-runtime";var Gl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},kE=(e,t,r="bottom")=>{let o=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,s=t.left+t.width/2-o.width/2;s<0?s=a:s+o.width>=n&&(s=n-o.width-a);let l;r==="bottom"?(l=t.top+t.height+a,l+o.height>=i&&(l=t.top-o.height-a)):(l=t.top-o.height-a,l<0&&(l=t.top+t.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},vL=(e,t,r,o)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=o?"50ch":"10ch",t.style.maxWidth=o?"50ch":"15ch",t.textContent=r;let n=e.getBoundingClientRect();kE(t,n)},Eo=({children:e,label:t,long:r=!1,style:o,disabled:n})=>(wL(()=>()=>Gl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:TL("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>vL(i.currentTarget,Gl(),t,r),onPointerLeave:()=>Gl().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));De();Zr();pr();Gs();Re();import{jsx as ng,jsxs as ML}from"react/jsx-runtime";var SL=G({name:"changeViewBackgroundColor",label:"labels.canvasBackground",paletteName:"Change canvas background color",trackEvent:!1,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,r)=>({appState:{...t,...r},storeAction:r.viewBackgroundColor?_.CAPTURE:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r,appProps:o})=>ng(Od,{palette:null,topPicks:Em,label:E("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:n=>r({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:r})}),Ai=G({name:"clearCanvas",label:"labels.clearCanvas",paletteName:"Clear canvas",icon:tn,trackEvent:{category:"canvas"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,r,o)=>(o.imageCache.clear(),{elements:e.map(n=>pe(n,{isDeleted:!0})),appState:{...lr(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},storeAction:_.CAPTURE})}),rg=G({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Kh,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(t.zoom.value+La)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(fe,{type:"button",className:"zoom-in-button zoom-button",icon:Kh,title:`${E("buttons.zoomIn")} \u2014 ${O("CtrlOrCmd++")}`,"aria-label":E("buttons.zoomIn"),disabled:t.zoom.value>=Lh,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Se.EQUAL||e.code===Se.NUM_ADD)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),og=G({name:"zoomOut",label:"buttons.zoomOut",icon:$h,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(t.zoom.value-La)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(fe,{type:"button",className:"zoom-out-button zoom-button",icon:$h,title:`${E("buttons.zoomOut")} \u2014 ${O("CtrlOrCmd+-")}`,"aria-label":E("buttons.zoomOut"),disabled:t.zoom.value<=Os,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Se.MINUS||e.code===Se.NUM_SUBTRACT)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),IL=G({name:"resetZoom",label:"buttons.resetZoom",icon:Ey,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>({appState:{...t,...Ci({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Un(1)},t),userToFollow:null},storeAction:_.NONE}),PanelComponent:({updateData:e,appState:t})=>ng(Eo,{label:E("buttons.resetZoom"),style:{height:"100%"},children:ML(fe,{type:"button",className:"reset-zoom-button zoom-button",title:E("buttons.resetZoom"),"aria-label":E("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Se.ZERO||e.code===Se.NUM_ZERO)&&(e[S.CTRL_OR_CMD]||e.shiftKey)}),CL=(e,t)=>{let[r,o,n,i]=e,a=n-r,s=t.width/a,l=i-o,c=t.height/l,d=Math.min(s,c),m=Math.floor(d/La)*La;return Math.min(Math.max(m,Os),1)},xS=({bounds:e,appState:t,fitToViewport:r=!1,viewportZoomFactor:o=.7})=>{let[n,i,a,s]=e,l=(n+a)/2,c=(i+s)/2,d,m,p;if(r){let u=a-n,g=s-i;d=Math.min(t.width/u,t.height/g)*Math.min(1,Math.max(o,.1)),d=Math.min(Math.max(d,Os),Lh);let h=t.width;if(t.openSidebar){let v=document.querySelector(".sidebar")?.offsetWidth??0;h=document.documentElement.getAttribute("dir")==="rtl"?t.width+v:t.width-v}m=h/2*(1/d)-l,p=t.height/2*(1/d)-c}else{d=CL(e,{width:t.width,height:t.height});let u=qb({scenePoint:{x:l,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:d}});m=u.scrollX,p=u.scrollY}return{appState:{...t,scrollX:m,scrollY:p,zoom:{value:d}},storeAction:_.NONE}},zd=({targetElements:e,appState:t,fitToViewport:r,viewportZoomFactor:o})=>{let n=Te(Ae(e));return xS({bounds:n,appState:t,fitToViewport:r,viewportZoomFactor:o})},ite=G({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:pp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return zd({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===Se.TWO&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),ate=G({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:pp,trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return zd({targetElements:n.length?n:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===Se.THREE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),AL=G({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:pp,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>zd({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===Se.ONE&&e.shiftKey&&!e.altKey&&!e[S.CTRL_OR_CMD]}),bs=G({name:"toggleTheme",label:(e,t)=>t.theme===ue.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ue.LIGHT?kc:Pc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,r)=>({appState:{...t,theme:r||(t.theme===ue.LIGHT?ue.DARK:ue.LIGHT)},storeAction:_.NONE}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Se.D,predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.toggleTheme}),ste=G({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let r;return $r(t)?r=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):r=nt(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},storeAction:_.CAPTURE}},keyTest:e=>e.key===S.E}),yS=G({name:"toggleHandTool",label:"toolBar.hand",paletteName:"Toggle hand tool",trackEvent:{category:"toolbar"},icon:ip,viewMode:!1,perform:(e,t,r,o)=>{let n;return qo(t)?n=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=nt(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),Ze(o.interactiveCanvas,Be.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},storeAction:_.CAPTURE}},keyTest:e=>!e.altKey&&!e[S.CTRL_OR_CMD]&&e.key===S.H});f();ye();we();V();ee();$e();De();mt();Wt();yr();me();Gs();Re();import{jsx as kL}from"react/jsx-runtime";var xo=G({name:"finalize",label:"",trackEvent:!1,perform:(e,t,r,o)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=o,s=a.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:g}=t.editingLinearElement,h=K.getElement(p,s);if(h)return Kr(h)&&Qa(h,u,g,s,a),{elements:h.points.length<2||Po(h)?e.filter(x=>x.id!==h.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null,selectedLinearElement:null},storeAction:_.CAPTURE}}let l=e,c=t.pendingImageElementId&&a.getElement(t.pendingImageElementId);c&&F(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let d=t.multiElement?t.multiElement:t.editingElement?.type==="freedraw"?t.editingElement:null;if(d){if(d.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:g}=d;(!g||u[u.length-1]!==g)&&F(d,{points:d.points.slice(0,-1)})}Po(d)&&(l=l.filter(u=>u.id!==d.id));let p=Dr(d.points,t.zoom.value);if((d.type==="line"||d.type==="freedraw")&&p){let u=d.points,g=u[0];F(d,{points:u.map((h,x)=>x===u.length-1?[g[0],g[1]]:h)})}if(Kr(d)&&!p&&d.points.length>1){let[u,g]=K.getPointAtIndexGlobalCoordinates(d,-1,Z(e));Jc(d,t,{x:u,y:g},s,e)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!d)&&mo(n);let m;return t.activeTool.type==="eraser"?m=nt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):m=nt(t,{type:"selection"}),{elements:l,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&d?t.activeTool:m,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&ie(d)?new K(d):t.selectedLinearElement,pendingImageElementId:null},storeAction:_.CAPTURE}},keyTest:(e,t)=>e.key===S.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===S.ESCAPE||e.key===S.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:r})=>kL(fe,{type:"button",icon:My,title:E("buttons.done"),"aria-label":E("buttons.done"),onClick:t,visible:e.multiElement!=null,size:r?.size||"medium"})});f();ee();f();V();import{useState as PL}from"react";ye();import{jsx as wS,jsxs as LL}from"react/jsx-runtime";var vS=e=>{let{id:t}=Ft(),[r,o]=PL(e.value),n=a=>{e.ignoreFocus||M0(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===S.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return LL("div",{className:"ProjectName",children:[wS("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),wS("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:r,onChange:a=>o(a.target.value)})]})};f();Y();import{jsx as Hd}from"react/jsx-runtime";var SS=e=>{let t=e.title||(e.value===ue.DARK?E("buttons.lightMode"):E("buttons.darkMode"));return Hd(fe,{type:"icon",icon:e.value===ue.LIGHT?TS.MOON:TS.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===ue.DARK?ue.LIGHT:ue.DARK),"data-testid":"toggle-dark-mode"})},TS={SUN:Hd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hd("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:Hd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hd("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"})})};f();na();Y();we();me();et();md();V();qr();di();mi();vr();qr();mi();var Es=(e,{selectedElementIds:t},r)=>{e=Ae(e);let o=r&&qe(e,{selectedElementIds:t}),n=null,i=o?he(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return o&&(i.length===1&&Q(i[0])?(n=i[0],i=El(e,n)):i.length>1&&(i=he(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Xr(i)}},xs=async(e,t,r,o,{exportBackground:n,exportPadding:i=Ko,viewBackgroundColor:a,name:s=r.name||Lm,fileHandle:l=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(E("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=bl(t,{exportBackground:n,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return qs(m.then(p=>new Blob([p.outerHTML],{type:se.svg})),{description:"Export to SVG",name:s,extension:r.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await wi(p)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return}}let d=su(t,r,o,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=gi(d);return r.exportEmbedScene&&(m=m.then(p=>Promise.resolve().then(()=>(tl(),Bc)).then(({encodePngMetadata:u})=>u({blob:p,metadata:Vi(t,r,o,"local")})))),qs(m,{description:"Export to PNG",name:s,extension:"png",fileHandle:l})}else if(e==="clipboard")try{let m=gi(d);await uu(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):ti&&m.name==="TypeError"?new Error(`${E("alerts.couldNotCopyToClipboard")}
56
52
 
57
- ${b("hints.firefox_clipboard_write")}`):new Error(b("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();Cr();var Rv=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,l=mg(a);if(!a||!U0(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=Da(e,t,!1);return await _a(l,s,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ge();Xe();f();import yA from"clsx";import{jsx as Nv,jsxs as wA}from"react/jsx-runtime";var Ra=({children:e,checked:t,onChange:r,className:o})=>wA("div",{className:yA("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Nv("button",{className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Mw}),Nv("div",{className:"Checkbox-label",children:e})]});mc();Y();$e();be();Cr();Dn();Ne();import{Fragment as vA,jsx as Un,jsxs as TA}from"react/jsx-runtime";var Wf=z({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>Un(Pv,{label:b("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),Ov=z({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},storeAction:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=xe(e),i=Ve(o,t)?ue(o,t):o;return Un(vA,{children:Ja.map(a=>{let[l,s]=my(i,To,a),c=`${b("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Un(ce,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),Vf=z({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>Un(Ra,{checked:e.exportBackground,onChange:r=>t(r),children:b("imageExportDialog.label.withBackground")})}),Mp=z({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>TA(Ra,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[b("imageExportDialog.label.embedScene"),Un(Xr,{label:b("imageExportDialog.tooltip.embedScene"),long:!0,children:Un("div",{className:"excalidraw-tooltip-icon",children:Nw})})]})}),Lp=z({name:"saveToActiveFile",label:"buttons.save",icon:ka,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=vl(t.fileHandle)?await Rv(e,t,o.files,o.getName()):await vm(e,t,o.files,o.getName());return{storeAction:D.NONE,appState:{...t,fileHandle:i,toast:n?{message:i?.name?b("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):b("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{storeAction:D.NONE}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),Lc=z({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ka,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await vm(e,{...t,fileHandle:null},o.files,o.getName());return{storeAction:D.NONE,appState:{...t,openDialog:null,fileHandle:n,toast:{message:b("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{storeAction:D.NONE}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Un(ce,{type:"button",icon:Pw,title:b("buttons.saveAs"),"aria-label":b("buttons.saveAs"),showAriaLabel:Me().editor.isMobile,hidden:!fi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Kl=z({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await fg(t,e);return{elements:n,appState:i,files:a,storeAction:D.CAPTURE}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,storeAction:D.NONE}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),Bv=z({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>Un("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Un(_v,{value:e.exportWithDarkMode?ae.DARK:ae.LIGHT,onChange:r=>{t(r===ae.DARK)},title:b("imageExportDialog.label.darkMode")})})});f();be();ge();Xe();Ue();Y();st();se();$e();Ne();var Fv="{}",Yf=z({name:"copyStyles",label:"labels.copyStyles",icon:wf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&tr(i)){let a=me(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(Fv=JSON.stringify(n)),{appState:{...t,toast:{message:b("toast.copyStyles")}},storeAction:D.NONE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.C}),Kf=z({name:"pasteStyles",label:"labels.pasteStyles",icon:wf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(Fv),i=n[0],a=n[1];if(!As(i))return{elements:e,storeAction:D.NONE};let l=ue(e,t,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(G(c)&&c.containerId&&(d=a),!d)return c;let m=ie(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?KE(d.roundness.type,c)?d.roundness:$E(c):null});if(G(m)){let p=d.fontSize||Lt,u=d.fontFamily||Kt;m=ie(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||qn,lineHeight:d.lineHeight||Hr(u)});let h=null;m.containerId&&(h=l.find(E=>G(m)&&E.id===m.containerId)||null),Rt(m,h,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&we(d)&&(m=ie(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),ee(c)&&(m=ie(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),storeAction:D.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.V});f();be();Xe();ge();Ne();import{jsx as zv}from"react/jsx-runtime";var SA=z({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},storeAction:D.NONE}),PanelComponent:({appState:e,updateData:t})=>zv(ce,{type:"button",icon:lp,"aria-label":b("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),IA=z({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},storeAction:D.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>zv(ce,{visible:Sa(t,xe(e)),type:"button",icon:Dw,"aria-label":b("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),Na=z({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Cw,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},storeAction:D.NONE}),keyTest:e=>e.key===S.QUESTION_MARK});f();ge();U();Xe();Ue();$e();mr();be();Co();se();nr();no();Ne();import{jsx as $l}from"react/jsx-runtime";var CA=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&ua(n,r),!0))return!0}return!1},Hv=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!CA(o)},$f=z({name:"group",label:"labels.group",icon:e=>$l(gf,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,storeAction:D.NONE};let i=Cn(t);if(i.length===1){let x=i[0],w=new Set(tt(e,x).map(I=>I.id)),y=new Set(n.map(I=>I.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:t,elements:e,storeAction:D.NONE}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&Ny(n).forEach((w,y)=>{Pl(w,o.scene.getNonDeletedElementsMap())});let s=_t(),c=$(n);a=a.map(x=>c.get(x.id)?ie(x,{groupIds:a0(x.groupIds,s,t.editingGroupId)}):x);let d=tt(a,s),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),h=a.slice(0,p).filter(x=>!ua(x,s)),E=Bt([...h,...d,...u],$(d));return{appState:{...t,...Jh(s,{...t,selectedGroupIds:{}},xe(a))},elements:E,storeAction:D.CAPTURE}},predicate:(e,t,r,o)=>Hv(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>$l(ce,{hidden:!Hv(e,t,o),type:"button",icon:$l(gf,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":b("labels.group"),visible:Ve(xe(e),t)})}),Xf=z({name:"ungroup",label:"labels.ungroup",icon:e=>$l(ff,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=Cn(t),i=$(e);if(n.length===0)return{appState:t,elements:e,storeAction:D.NONE};let a=[...e],l=[];a=a.map(p=>{Ae(p)&&l.push(p.id);let u=l0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:ie(p,{groupIds:u})});let s=jt(t,xe(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return pc(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=Km(a,Ll(a,p,t,i),p,o))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,h])=>(h&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,storeAction:D.CAPTURE}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>Cn(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>$l(ce,{type:"button",hidden:Cn(t).length===0,icon:$l(ff,{theme:t.theme}),onClick:()=>r(null),title:`${b("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":b("labels.ungroup"),visible:Ve(xe(e),t)})});f();f();Y();f();var Pp=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function AA(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var Oa=(e,t)=>`hsl(${Math.abs(AA(t?.id||e))%37*10}, 100%, 83%)`,Uv=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},Gv=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,c=r.collaborators.get(i);l-=r.offsetLeft,s-=r.offsetTop;let d=11,m=14,p=l<0||l>o-d||s<0||s>n-m;l=Math.max(l,0),l=Math.min(l,o-d),s=Math.max(s,0),s=Math.min(s,n-m);let u=Oa(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let h=t.remotePointerUserStates.get(i),E=p||h==="idle"||h==="away";E&&(e.globalAlpha=.3),t.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=r.theme===ae.DARK?"#2f6330":mE,w=c?.isSpeaking;w&&(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=Es,e.strokeStyle=Es,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(),E?(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 y=t.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let v=(w?l+0:l)+d/2,I=(w?s+0:s)+m+2,L=5,C=3,M=e.measureText(y),_=M.actualBoundingBoxDescent+M.actualBoundingBoxAscent,H=Math.max(_,12),k=v-1,N=I-1,A=M.width+2+L*2+2,B=H+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,N,A,B,8),e.fillStyle=u,e.fill(),e.strokeStyle=Es,e.stroke(),w&&(e.beginPath(),e.roundRect(k-2,N-2,A+4,B+4,8),e.strokeStyle=x,e.stroke())):Pp(e,k,N,A,B,8,Es),e.fillStyle=dE,e.fillText(y,v+L+1,I+C+M.actualBoundingBoxAscent+Math.floor((H-_)/2)+2),w){e.fillStyle=x;let q=8,Z=8,oe=5;e.fillRect(k+A+Z,N+(B/2-q/2),2,q),e.fillRect(k+A+Z+oe,N+(B/2-q*2/2),2,q*2),e.fillRect(k+A+Z+oe*2,N+(B/2-q/2),2,q)}}e.restore(),e.closePath()}};f();import{useState as kA}from"react";import MA from"clsx";import{jsx as Wv}from"react/jsx-runtime";var Zf=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=Uv(r),[a,l]=kA(!1),s=!a&&o,c=s?void 0:{background:e};return Wv("div",{className:MA("Avatar",n),style:c,onClick:t,children:s?Wv("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};Ne();Xe();import LA from"clsx";import{jsx as an,jsxs as Dp}from"react/jsx-runtime";var PA=z({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},storeAction:D.NONE}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},storeAction:D.NONE},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,l=Oa(o,n),s=LA({"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?Dp("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:b("userList.hint.isSpeaking"),children:[an("div",{}),an("div",{}),an("div",{})]}):n.isMuted?an("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:b("userList.hint.micMuted"),children:L2}):an("div",{title:b("userList.hint.inCall"),children:M2}):null;return i?Dp("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[an(Zf,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),an("div",{className:"UserList__collaborator-name",children:n.username}),Dp("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&an("div",{className:"UserList__collaborator-status-icon-is-followed",title:b("userList.hint.followStatus"),children:Hl}),c]})]}):Dp("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[an(Zf,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&an("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();Xe();Mn();Co();Y();Ne();var jf=z({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of yd)if(n.some(a=>a.type===i))return{storeAction:D.NONE,appState:{...t,errorMessage:b(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:_t(),status:"unpublished",elements:n.map(kn),created:Date.now()},...i])).then(()=>({storeAction:D.NONE,appState:{...t,toast:{message:b("toast.addedToLibrary")}}})).catch(i=>({storeAction:D.NONE,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();Ue();lt();mr();var Vv=(e,t,r)=>{let o=ha(e,t),n=Tr(e);return o.flatMap(i=>{let a=DA(i,n,r);return i.map(l=>ie(l,{x:l.x+a.x,y:l.y+a.y}))})},DA=(e,t,{axis:r,position:o})=>{let n=Tr(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return o==="start"?{...l,[r]:t[i]-n[i]}:o==="end"?{...l,[r]:t[a]-n[a]}:{...l,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};be();se();nr();ge();$e();Ne();U();Xe();import{jsx as Zl}from"react/jsx-runtime";var ho=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>ee(i))},Xl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=$(e),a=Vv(n,i,o),l=$(a);return tn(e.map(s=>l.get(s.id)||s),t,r)},_A=z({name:"alignTop",label:"labels.alignTop",icon:cf,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"start",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:cf,onClick:()=>r(null),title:`${b("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":b("labels.alignTop"),visible:Ve(xe(e),t)})}),RA=z({name:"alignBottom",label:"labels.alignBottom",icon:df,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"end",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:df,onClick:()=>r(null),title:`${b("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":b("labels.alignBottom"),visible:Ve(xe(e),t)})}),NA=z({name:"alignLeft",label:"labels.alignLeft",icon:mf,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"start",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:mf,onClick:()=>r(null),title:`${b("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":b("labels.alignLeft"),visible:Ve(xe(e),t)})}),OA=z({name:"alignRight",label:"labels.alignRight",icon:pf,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"end",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:pf,onClick:()=>r(null),title:`${b("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":b("labels.alignRight"),visible:Ve(xe(e),t)})}),BA=z({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:uf,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"center",axis:"y"}),storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:uf,onClick:()=>r(null),title:b("labels.centerVertically"),"aria-label":b("labels.centerVertically"),visible:Ve(xe(e),t)})}),FA=z({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:hf,trackEvent:{category:"element"},predicate:ho,perform:(e,t,r,o)=>({appState:t,elements:Xl(e,t,o,{position:"center",axis:"x"}),storeAction:D.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Zl(ce,{hidden:!ho(e,t,null,o),type:"button",icon:hf,onClick:()=>r(null),title:b("labels.centerHorizontally"),"aria-label":b("labels.centerHorizontally"),visible:Ve(xe(e),t)})});f();f();Ue();mr();lt();var Yv=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Tr(e),s=ha(e,t).map(p=>[p,Tr(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let d=(l[a]-c)/(s.length-1);if(d<0){let p=s.findIndex(x=>x[1][o]===l[o]),u=s.findIndex(x=>x[1][i]===l[i]),h=(s[u][1][n]-s[p][1][n])/(s.length-1),E=s[p][1][n];return s.flatMap(([x,w],y)=>{let v={x:0,y:0};return y!==p&&y!==u&&(E+=h,v[r.axis]=E-w[n]),x.map(I=>ie(I,{x:I.x+v.x,y:I.y+v.y}))})}let m=l[o];return s.flatMap(([p,u])=>{let h={x:0,y:0};return h[r.axis]=m-u[o],m+=d,m+=u[a],p.map(E=>ie(E,{x:E.x+h.x,y:E.y+h.y}))})};be();se();nr();ge();$e();Ne();U();Xe();import{jsx as Xv}from"react/jsx-runtime";var Kv=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>ee(o))},$v=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=Yv(n,r.scene.getNonDeletedElementsMap(),o),a=$(i);return tn(e.map(l=>a.get(l.id)||l),t,r)},zA=z({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:$v(e,t,o,{space:"between",axis:"x"}),storeAction:D.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xv(ce,{hidden:!Kv(t,o),type:"button",icon:Bw,onClick:()=>r(null),title:`${b("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":b("labels.distributeHorizontally"),visible:Ve(xe(e),t)})}),HA=z({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:$v(e,t,o,{space:"between",axis:"y"}),storeAction:D.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xv(ce,{hidden:!Kv(t,o),type:"button",icon:Fw,onClick:()=>r(null),title:`${b("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":b("labels.distributeVertically"),visible:Ve(xe(e),t)})});f();Xe();$e();be();Wg();U();ge();lt();io();nr();Ne();se();var qf=z({name:"flipHorizontal",label:"labels.flipHorizontal",icon:R2,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:tn(Zv(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,storeAction:D.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===fe.H}),Jf=z({name:"flipVertical",label:"labels.flipVertical",icon:_2,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:tn(Zv(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,storeAction:D.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===fe.V&&!e[S.CTRL_OR_CMD]}),Zv=(e,t,r,o,n)=>{let i=ue(xe(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=UA(i,t,r,o,n),l=$(a);return e.map(s=>l.get(s.id)||s)},UA=(e,t,r,o,n)=>{let{minX:i,minY:a,maxX:l,maxY:s}=Tr(e);return Hg(t,e,t,"nw",!0,!0,o==="horizontal"?l:i,o==="horizontal"?a:s),Hs(e.filter(ne),n,jo(r),[]),e};f();ge();Xe();wi();be();Y();Ne();var jl=z({name:"copy",label:"labels.copy",icon:xc,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Hm(n,o.files,r)}catch(i){return{storeAction:D.NONE,appState:{...t,errorMessage:i.message}}}return{storeAction:D.NONE}},keyTest:void 0}),Qf=z({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await yy()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),bn?{storeAction:D.NONE,appState:{...t,errorMessage:b("hints.firefox_clipboard_write")}}:{storeAction:D.NONE,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(Ey({types:n}))}catch(i){return console.error(i),{storeAction:D.NONE,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnParse")}}}return{storeAction:D.NONE}},keyTest:void 0}),_p=z({name:"cut",label:"labels.cut",icon:x2,trackEvent:{category:"element"},perform:(e,t,r,o)=>(jl.perform(e,t,r,o),Sc.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),Rp=z({name:"copyAsSvg",label:"labels.copyAsSvg",icon:N2,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:D.NONE};let{exportedElements:n,exportingFrame:i}=Da(e,t,!0);try{return await _a("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{storeAction:D.NONE}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},storeAction:D.NONE}}},predicate:e=>zm&&e.length>0,keywords:["svg","clipboard","copy"]}),Np=z({name:"copyAsPng",label:"labels.copyAsPng",icon:O2,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:D.NONE};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Da(e,t,!0);try{return await _a("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:b("toast.copyToClipboardAsPng",{exportSelection:n.length?b("toast.selection"):b("toast.canvas"),exportColorScheme:t.exportWithDarkMode?b("buttons.darkMode"):b("buttons.lightMode")})}},storeAction:D.NONE}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},storeAction:D.NONE}}},predicate:e=>kl&&e.length>0,keyTest:e=>e.code===fe.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Op=z({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,l)=>(G(l)&&a.push(l.text),a),[]).join(`
53
+ ${E("hints.firefox_clipboard_write")}`):new Error(E("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};f();qr();var IS=async(e,t,r,o)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=t,s=vf(a);if(!a||!o2(s))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:c}=Es(e,t,!1);return await xs(s,l,t,r,{exportBackground:n,viewBackgroundColor:i,name:o,fileHandle:a,exportingFrame:c}),{fileHandle:a}};ye();$e();f();ee();import DL from"clsx";import{jsx as CS,jsxs as _L}from"react/jsx-runtime";var ys=({children:e,checked:t,onChange:r,className:o})=>_L("div",{className:DL("Checkbox",o,{"is-checked":t}),onClick:n=>{r(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[CS("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:Ty}),CS("div",{className:"Checkbox-label",children:e})]});md();Y();et();we();qr();di();Re();import{Fragment as RL,jsx as Mi,jsxs as NL}from"react/jsx-runtime";var PE=G({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,r)=>({appState:{...t,name:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t,appProps:r,data:o,app:n})=>Mi(vS,{label:E("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:o?.ignoreFocus??!1})}),AS=G({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,r)=>({appState:{...t,exportScale:r},storeAction:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=Ae(e),i=qe(o,t)?he(o,t):o;return Mi(RL,{children:zs.map(a=>{let[s,l]=qv(i,Ko,a),c=`${E("imageExportDialog.label.scale")} ${a}x (${s}x${l})`;return Mi(fe,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===t.exportScale,onChange:()=>r(a)},a)})})}}),LE=G({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,r)=>({appState:{...t,exportBackground:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>Mi(ys,{checked:e.exportBackground,onChange:r=>t(r),children:E("imageExportDialog.label.withBackground")})}),ig=G({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,r)=>({appState:{...t,exportEmbedScene:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>NL(ys,{checked:e.exportEmbedScene,onChange:r=>t(r),children:[E("imageExportDialog.label.embedScene"),Mi(Eo,{label:E("imageExportDialog.tooltip.embedScene"),long:!0,children:Mi("div",{className:"excalidraw-tooltip-icon",children:ky})})]})}),ag=G({name:"saveToActiveFile",label:"buttons.save",icon:Ba,trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{let n=!!t.fileHandle;try{let{fileHandle:i}=Js(t.fileHandle)?await IS(e,t,o.files,o.getName()):await gp(e,t,o.files,o.getName());return{storeAction:_.NONE,appState:{...t,fileHandle:i,toast:n?{message:i?.name?E("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):E("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{storeAction:_.NONE}}},keyTest:e=>e.key===S.S&&e[S.CTRL_OR_CMD]&&!e.shiftKey}),Ud=G({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Ba,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,r,o)=>{try{let{fileHandle:n}=await gp(e,{...t,fileHandle:null},o.files,o.getName());return{storeAction:_.NONE,appState:{...t,openDialog:null,fileHandle:n,toast:{message:E("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{storeAction:_.NONE}}},keyTest:e=>e.key===S.S&&e.shiftKey&&e[S.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Mi(fe,{type:"button",icon:Iy,title:E("buttons.saveAs"),"aria-label":E("buttons.saveAs"),showAriaLabel:Ne().editor.isMobile,hidden:!Wi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Wl=G({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,r,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,r,o)=>{try{let{elements:n,appState:i,files:a}=await ff(t,e);return{elements:n,appState:i,files:a,storeAction:_.CAPTURE}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:o.files,storeAction:_.NONE}}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.O}),MS=G({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,r)=>({appState:{...t,exportWithDarkMode:r},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>Mi("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Mi(SS,{value:e.exportWithDarkMode?ue.DARK:ue.LIGHT,onChange:r=>{t(r===ue.DARK)},title:E("imageExportDialog.label.darkMode")})})});f();we();ye();$e();De();Y();He();me();et();ee();Re();on();var kS="{}",DE=G({name:"copyStyles",label:"labels.copyStyles",icon:gf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=[],i=e.find(a=>t.selectedElementIds[a.id]);if(n.push(i),i&&Ct(i)){let a=J(i,o.scene.getNonDeletedElementsMap());n.push(a)}return i&&(kS=JSON.stringify(n)),{appState:{...t,toast:{message:E("toast.copyStyles")}},storeAction:_.NONE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.C}),_E=G({name:"pasteStyles",label:"labels.pasteStyles",icon:gf,trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=JSON.parse(kS),i=n[0],a=n[1];if(!Ac(i))return{elements:e,storeAction:_.NONE};let s=he(e,t,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(H(c)&&c.containerId&&(d=a),!d)return c;let m=pe(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?U0(d.roundness.type,c)?d.roundness:G0(c):null});if(H(m)){let p=d.fontSize||ur,u=d.fontFamily||gr;m=pe(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||vn,lineHeight:d.lineHeight||uo(u)});let g=null;m.containerId&&(g=s.find(h=>H(m)&&h.id===m.containerId)||null),ft(m,g,o.scene.getNonDeletedElementsMap())}return m.type==="arrow"&&ne(d)&&(m=pe(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),Q(c)&&(m=pe(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),storeAction:_.CAPTURE}},keyTest:e=>e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.V});f();ee();we();$e();ye();Re();import{jsx as PS}from"react/jsx-runtime";var OL=G({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},storeAction:_.NONE}),PanelComponent:({appState:e,updateData:t})=>PS(fe,{type:"button",icon:Qm,"aria-label":E("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),FL=G({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},storeAction:_.NONE}),PanelComponent:({elements:e,appState:t,updateData:r})=>PS(fe,{visible:us(t,Ae(e)),type:"button",icon:Cy,"aria-label":E("buttons.edit"),onClick:r,selected:t.openMenu==="shape"})}),ws=G({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:yy,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,r,{focusContainer:o})=>(t.openDialog?.name==="help"&&o(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},storeAction:_.NONE}),keyTest:e=>e.key===S.QUESTION_MARK});f();ye();V();$e();ee();De();et();Gt();we();Zo();me();vr();ko();Re();import{jsx as Vl}from"react/jsx-runtime";var BL=e=>{if(e.length>=2){let t=e[0].groupIds;for(let r of t)if(e.reduce((o,n)=>o&&Ra(n,r),!0))return!0}return!1},LS=(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return o.length>=2&&!BL(o)},RE=G({name:"group",label:"labels.group",icon:e=>Vl(cf,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(n.length<2)return{appState:t,elements:e,storeAction:_.NONE};let i=Jo(t);if(i.length===1){let x=i[0],v=new Set(ot(e,x).map(C=>C.id)),y=new Set(n.map(C=>C.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:t,elements:e,storeAction:_.NONE}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&wT(n).forEach((v,y)=>{Tl(v,o.scene.getNonDeletedElementsMap())});let l=Ut(),c=Z(n);a=a.map(x=>c.get(x.id)?pe(x,{groupIds:$0(x.groupIds,l,t.editingGroupId)}):x);let d=ot(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),g=a.slice(0,p).filter(x=>!Ra(x,l)),h=Jt([...g,...d,...u],Z(d));return{appState:{...t,...Wh(l,{...t,selectedGroupIds:{}},Ae(a))},elements:h,storeAction:_.CAPTURE}},predicate:(e,t,r,o)=>LS(e,t,o),keyTest:e=>!e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Vl(fe,{hidden:!LS(e,t,o),type:"button",icon:Vl(cf,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.group")} \u2014 ${O("CtrlOrCmd+G")}`,"aria-label":E("labels.group"),visible:qe(Ae(e),t)})}),NE=G({name:"ungroup",label:"labels.ungroup",icon:e=>Vl(df,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=Jo(t),i=Z(e);if(n.length===0)return{appState:t,elements:e,storeAction:_.NONE};let a=[...e],s=[];a=a.map(p=>{ze(p)&&s.push(p.id);let u=Z0(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:pe(p,{groupIds:u})});let l=cr(t,Ae(a),t,null),c=o.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return pd(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=bu(a,vl(a,p,t,i),p,o))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,g])=>(g&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...l},elements:a,storeAction:_.CAPTURE}},keyTest:e=>e.shiftKey&&e[S.CTRL_OR_CMD]&&e.key===S.G.toUpperCase(),predicate:(e,t)=>Jo(t).length>0,PanelComponent:({elements:e,appState:t,updateData:r})=>Vl(fe,{type:"button",hidden:Jo(t).length===0,icon:Vl(df,{theme:t.theme}),onClick:()=>r(null),title:`${E("labels.ungroup")} \u2014 ${O("CtrlOrCmd+Shift+G")}`,"aria-label":E("labels.ungroup"),visible:qe(Ae(e),t)})});f();f();Y();f();var sg=(e,t,r,o,n,i,a)=>{e.beginPath(),e.moveTo(t+i,r),e.lineTo(t+o-i,r),e.quadraticCurveTo(t+o,r,t+o,r+i),e.lineTo(t+o,r+n-i),e.quadraticCurveTo(t+o,r+n,t+o-i,r+n),e.lineTo(t+i,r+n),e.quadraticCurveTo(t,r+n,t,r+n-i),e.lineTo(t,r+i),e.quadraticCurveTo(t,r,t+i,r),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};f();function zL(e){let t=0;if(e.length===0)return t;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o}return t}var vs=(e,t)=>`hsl(${Math.abs(zL(t?.id||e))%37*10}, 100%, 83%)`,DS=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},_S=({context:e,renderConfig:t,appState:r,normalizedWidth:o,normalizedHeight:n})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:s,y:l}=a,c=r.collaborators.get(i);s-=r.offsetLeft,l-=r.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>n-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,n-m);let u=vs(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let g=t.remotePointerUserStates.get(i),h=p||g==="idle"||g==="away";h&&(e.globalAlpha=.3),t.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=r.theme===ue.DARK?"#2f6330":r0,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Ec,e.strokeStyle=Ec,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),h?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let y=t.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let w=(v?s+0:s)+d/2,C=(v?l+0:l)+m+2,M=5,I=3,P=e.measureText(y),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,N=Math.max(A,12),k=w-1,D=C-1,z=P.width+2+M*2+2,R=N+2+I*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,D,z,R,8),e.fillStyle=u,e.fill(),e.strokeStyle=Ec,e.stroke(),v&&(e.beginPath(),e.roundRect(k-2,D-2,z+4,R+4,8),e.strokeStyle=x,e.stroke())):sg(e,k,D,z,R,8,Ec),e.fillStyle=t0,e.fillText(y,w+M+1,C+I+P.actualBoundingBoxAscent+Math.floor((N-A)/2)+2),v){e.fillStyle=x;let W=8,q=8,re=5;e.fillRect(k+z+q,D+(R/2-W/2),2,W),e.fillRect(k+z+q+re,D+(R/2-W*2/2),2,W*2),e.fillRect(k+z+q+re*2,D+(R/2-W/2),2,W)}}e.restore(),e.closePath()}};f();import{useState as HL}from"react";import UL from"clsx";import{jsx as RS}from"react/jsx-runtime";var OE=({color:e,onClick:t,name:r,src:o,className:n})=>{let i=DS(r),[a,s]=HL(!1),l=!a&&o,c=l?void 0:{background:e};return RS("div",{className:UL("Avatar",n),style:c,onClick:t,children:l?RS("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};ee();Re();$e();import GL from"clsx";import{jsx as Vn,jsxs as lg}from"react/jsx-runtime";var WL=G({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,r)=>!r.socketId||t.userToFollow?.socketId===r.socketId||r.isCurrentUser?{appState:{...t,userToFollow:null},storeAction:_.NONE}:{appState:{...t,userToFollow:{socketId:r.socketId,username:r.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},storeAction:_.NONE},PanelComponent:({updateData:e,data:t,appState:r})=>{let{socketId:o,collaborator:n,withName:i,isBeingFollowed:a}=t,s=vs(o,n),l=GL({"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?lg("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:E("userList.hint.isSpeaking"),children:[Vn("div",{}),Vn("div",{}),Vn("div",{})]}):n.isMuted?Vn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:E("userList.hint.micMuted"),children:Iw}):Vn("div",{title:E("userList.hint.inCall"),children:Sw}):null;return i?lg("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Vn(OE,{color:s,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:l}),Vn("div",{className:"UserList__collaborator-name",children:n.username}),lg("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Vn("div",{className:"UserList__collaborator-status-icon-is-followed",title:E("userList.hint.followStatus"),children:Zs}),c]})]}):lg("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Vn(OE,{color:s,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:l}),c&&Vn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});f();$e();Nn();Zo();Y();Re();var FE=G({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of Pm)if(n.some(a=>a.type===i))return{storeAction:_.NONE,appState:{...t,errorMessage:E(`errors.libraryElementTypeError.${i}`)}};return o.library.getLatestLibrary().then(i=>o.library.setLibrary([{id:Ut(),status:"unpublished",elements:n.map(an),created:Date.now()},...i])).then(()=>({storeAction:_.NONE,appState:{...t,toast:{message:E("toast.addedToLibrary")}}})).catch(i=>({storeAction:_.NONE,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});f();f();De();dt();Gt();var NS=(e,t,r)=>{let o=Na(e,t),n=Qr(e);return o.flatMap(i=>{let a=VL(i,n,r);return i.map(s=>pe(s,{x:s.x+a.x,y:s.y+a.y}))})},VL=(e,t,{axis:r,position:o})=>{let n=Qr(e),[i,a]=r==="x"?["minX","maxX"]:["minY","maxY"],s={x:0,y:0};return o==="start"?{...s,[r]:t[i]-n[i]}:o==="end"?{...s,[r]:t[a]-n[a]}:{...s,[r]:(t[i]+t[a])/2-(n[i]+n[a])/2}};ee();we();me();vr();ye();et();Re();V();$e();import{jsx as Xl}from"react/jsx-runtime";var Oo=(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>1&&!n.some(i=>Q(i))},Yl=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=Z(e),a=NS(n,i,o),s=Z(a);return zn(e.map(l=>s.get(l.id)||l),t,r)},YL=G({name:"alignTop",label:"labels.alignTop",icon:rf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"start",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:rf,onClick:()=>r(null),title:`${E("labels.alignTop")} \u2014 ${O("CtrlOrCmd+Shift+Up")}`,"aria-label":E("labels.alignTop"),visible:qe(Ae(e),t)})}),XL=G({name:"alignBottom",label:"labels.alignBottom",icon:of,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"end",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:of,onClick:()=>r(null),title:`${E("labels.alignBottom")} \u2014 ${O("CtrlOrCmd+Shift+Down")}`,"aria-label":E("labels.alignBottom"),visible:qe(Ae(e),t)})}),KL=G({name:"alignLeft",label:"labels.alignLeft",icon:nf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"start",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:nf,onClick:()=>r(null),title:`${E("labels.alignLeft")} \u2014 ${O("CtrlOrCmd+Shift+Left")}`,"aria-label":E("labels.alignLeft"),visible:qe(Ae(e),t)})}),$L=G({name:"alignRight",label:"labels.alignRight",icon:af,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"end",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>e[S.CTRL_OR_CMD]&&e.shiftKey&&e.key===S.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:af,onClick:()=>r(null),title:`${E("labels.alignRight")} \u2014 ${O("CtrlOrCmd+Shift+Right")}`,"aria-label":E("labels.alignRight"),visible:qe(Ae(e),t)})}),ZL=G({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:sf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"center",axis:"y"}),storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:sf,onClick:()=>r(null),title:E("labels.centerVertically"),"aria-label":E("labels.centerVertically"),visible:qe(Ae(e),t)})}),jL=G({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:lf,trackEvent:{category:"element"},predicate:Oo,perform:(e,t,r,o)=>({appState:t,elements:Yl(e,t,o,{position:"center",axis:"x"}),storeAction:_.CAPTURE}),PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>Xl(fe,{hidden:!Oo(e,t,null,o),type:"button",icon:lf,onClick:()=>r(null),title:E("labels.centerHorizontally"),"aria-label":E("labels.centerHorizontally"),visible:qe(Ae(e),t)})});f();ee();f();De();Gt();dt();var OS=(e,t,r)=>{let[o,n,i,a]=r.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],s=Qr(e),l=Na(e,t).map(p=>[p,Qr(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of l)c+=p[1][a];let d=(s[a]-c)/(l.length-1);if(d<0){let p=l.findIndex(x=>x[1][o]===s[o]),u=l.findIndex(x=>x[1][i]===s[i]),g=(l[u][1][n]-l[p][1][n])/(l.length-1),h=l[p][1][n];return l.flatMap(([x,v],y)=>{let w={x:0,y:0};return y!==p&&y!==u&&(h+=g,w[r.axis]=h-v[n]),x.map(C=>pe(C,{x:C.x+w.x,y:C.y+w.y}))})}let m=s[o];return l.flatMap(([p,u])=>{let g={x:0,y:0};return g[r.axis]=m-u[o],m+=d,m+=u[a],p.map(h=>pe(h,{x:h.x+g.x,y:h.y+g.y}))})};we();me();vr();ye();et();Re();V();$e();import{jsx as zS}from"react/jsx-runtime";var FS=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length>1&&!r.some(o=>Q(o))},BS=(e,t,r,o)=>{let n=r.scene.getSelectedElements(t),i=OS(n,r.scene.getNonDeletedElementsMap(),o),a=Z(i);return zn(e.map(s=>a.get(s.id)||s),t,r)},qL=G({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:BS(e,t,o,{space:"between",axis:"x"}),storeAction:_.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.H,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zS(fe,{hidden:!FS(t,o),type:"button",icon:_y,onClick:()=>r(null),title:`${E("labels.distributeHorizontally")} \u2014 ${O("Alt+H")}`,"aria-label":E("labels.distributeHorizontally"),visible:qe(Ae(e),t)})}),JL=G({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,r,o)=>({appState:t,elements:BS(e,t,o,{space:"between",axis:"y"}),storeAction:_.CAPTURE}),keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.V,PanelComponent:({elements:e,appState:t,updateData:r,app:o})=>zS(fe,{hidden:!FS(t,o),type:"button",icon:Ry,onClick:()=>r(null),title:`${E("labels.distributeVertically")} \u2014 ${O("Alt+V")}`,"aria-label":E("labels.distributeVertically"),visible:qe(Ae(e),t)})});f();$e();et();we();kd();V();ye();dt();yr();vr();ee();Re();me();var BE=G({name:"flipHorizontal",label:"labels.flipHorizontal",icon:kw,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:zn(HS(e,o.scene.getNonDeletedElementsMap(),t,"horizontal",o),t,o),appState:t,storeAction:_.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===Se.H}),zE=G({name:"flipVertical",label:"labels.flipVertical",icon:Mw,trackEvent:{category:"element"},perform:(e,t,r,o)=>({elements:zn(HS(e,o.scene.getNonDeletedElementsMap(),t,"vertical",o),t,o),appState:t,storeAction:_.CAPTURE}),keyTest:e=>e.shiftKey&&e.code===Se.V&&!e[S.CTRL_OR_CMD]}),HS=(e,t,r,o,n)=>{let i=he(Ae(e),r,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=QL(i,t,r,o,n),s=Z(a);return e.map(l=>s.get(l.id)||l)},QL=(e,t,r,o,n)=>{let{minX:i,minY:a,maxX:s,maxY:l}=Qr(e);return Gb(t,e,t,"nw",!0,!0,o==="horizontal"?s:i,o==="horizontal"?a:l,n.scene),es(e.filter(ie),t,n.scene.getNonDeletedElements(),n.scene,Fn(r),[]),e};f();ye();$e();na();we();Y();ee();Re();var Kl=G({name:"copy",label:"labels.copy",icon:Mc,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await mu(n,o.files,r)}catch(i){return{storeAction:_.NONE,appState:{...t,errorMessage:i.message}}}return{storeAction:_.NONE}},keyTest:void 0}),HE=G({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,r,o)=>{let n;try{n=await aT()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),ti?{storeAction:_.NONE,appState:{...t,errorMessage:E("hints.firefox_clipboard_write")}}:{storeAction:_.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(nT({types:n}))}catch(i){return console.error(i),{storeAction:_.NONE,appState:{...t,errorMessage:E("errors.asyncPasteFailedOnParse")}}}return{storeAction:_.NONE}},keyTest:void 0}),cg=G({name:"cut",label:"labels.cut",icon:gw,trackEvent:{category:"element"},perform:(e,t,r,o)=>(Kl.perform(e,t,r,o),_d.perform(e,t,null,o)),keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.X}),dg=G({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Pw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:_.NONE};let{exportedElements:n,exportingFrame:i}=Es(e,t,!0);try{return await xs("clipboard-svg",n,t,o.files,{...t,exportingFrame:i,name:o.getName()}),{storeAction:_.NONE}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},storeAction:_.NONE}}},predicate:e=>du&&e.length>0,keywords:["svg","clipboard","copy"]}),mg=G({name:"copyAsPng",label:"labels.copyAsPng",icon:Lw,trackEvent:{category:"element"},perform:async(e,t,r,o)=>{if(!o.canvas)return{storeAction:_.NONE};let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Es(e,t,!0);try{return await xs("clipboard",i,t,o.files,{...t,exportingFrame:a,name:o.getName()}),{appState:{...t,toast:{message:E("toast.copyToClipboardAsPng",{exportSelection:n.length?E("toast.selection"):E("toast.canvas"),exportColorScheme:t.exportWithDarkMode?E("buttons.darkMode"):E("buttons.lightMode")})}},storeAction:_.NONE}}catch(s){return console.error(s),{appState:{...t,errorMessage:s.message},storeAction:_.NONE}}},predicate:e=>yl&&e.length>0,keyTest:e=>e.code===Se.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),pg=G({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,r,o)=>{let i=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((a,s)=>(H(s)&&a.push(s.text),a),[]).join(`
58
54
 
59
- `);try{Bn(i)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return{storeAction:D.NONE}},predicate:(e,t,r,o)=>zm&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(G),keywords:["text","clipboard","copy"]});f();ge();Xe();Y();Ne();var Bp=z({name:"gridMode",icon:U2,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:xn,objectsSnapModeEnabled:!1},storeAction:D.NONE}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===fe.QUOTE});f();ge();Ne();Xe();var ql=z({name:"zenMode",label:"buttons.zenMode",icon:F2,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},storeAction:D.NONE}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.Z});f();ge();Ne();Xe();var e1=z({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:B2,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},storeAction:D.NONE}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.S});f();Xe();ge();Ne();var Ai=z({name:"stats",label:"stats.title",icon:D2,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},perform(e,t){return{appState:{...t,showStats:!this.checked(t)},storeAction:D.NONE}},checked:e=>e.showStats,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.SLASH});f();Y();be();Ue();st();Xd();se();U();Xe();no();Ne();var t1=z({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>tr(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=me(a,i);if(l){let{width:s,height:c}=Lo(l.originalText,Ye(l),l.lineHeight),d=Wx(a.id);$d(a.id);let{x:m,y:p}=pl(a,l,i);F(l,{containerId:null,width:s,height:c,text:l.originalText,x:m,y:p}),F(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:t,storeAction:D.CAPTURE}}}),r1=z({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=G(n[0])||G(n[1]),a;if(Yo(n[0])?a=n[0]:Yo(n[1])&&(a=n[1]),i&&a&&me(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;G(n[0])&&Yo(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),F(i,{containerId:a.id,verticalAlign:yt.MIDDLE,textAlign:Qn.CENTER}),F(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Rt(i,a,o.scene.getNonDeletedElementsMap()),ma(a.id,l),{elements:GA(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},storeAction:D.CAPTURE}}}),GA=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),Bt(o,$([t,r])),o},WA=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),Bt(o,$([t,r])),o},jv=z({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>G(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of n)if(G(l)){let s=Vr({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:Ko("rectangle")?at.ADAPTIVE_RADIUS:at.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-bt,y:l.y-bt,width:In(l.width,"rectangle"),height:In(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&F(m,{startBinding:p,endBinding:u},!1)})}F(l,{containerId:s.id,verticalAlign:yt.MIDDLE,boundElements:null,textAlign:Qn.CENTER},!1),Rt(l,s,o.scene.getNonDeletedElementsMap()),i=WA([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},storeAction:D.CAPTURE}}});f();f();U();ec();Ue();ge();Y();lt();import{useCallback as qv,useEffect as VA,useLayoutEffect as YA,useRef as KA,useState as $A}from"react";import XA from"clsx";$e();km();ga();se();Lm();import{jsx as Pc,jsxs as Jv}from"react/jsx-runtime";var i1=320,Qv=85,o1=5,ZA=42,jA=500,n1=!1,Fp=new Map,e3=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Jl(),l=ki(),s=e.link||"",[c,d]=$A(s),m=KA(null),p=a.showHyperlinkPopup==="editor",u=qv(()=>{if(!m.current)return;let y=pr(m.current.value)||null;if(!e.link&&y&&Ee("hyperlink","create"),It(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!y){F(e,{link:null}),i(e,!1);return}if(!fl(y,l.validateEmbeddable))y&&n({message:b("toast.unableToEmbed"),closable:!0}),e.link&&Fp.set(e.id,e.link),F(e,{link:y}),i(e,!1);else{let{width:v,height:I}=e,L=Pn(y);L?.error instanceof URIError&&n({message:b("toast.unrecognizedLinkFormat"),closable:!0});let C=L?L.intrinsicSize.w/L.intrinsicSize.h:1,M=Fp.get(e.id)!==e.link;F(e,{...M?{width:L?.type==="video"?v>I?v:I*C:v,height:L?.type==="video"&&v>I?v/C:I}:{},link:y}),i(e,!0),Fp.has(e.id)&&Fp.delete(e.id)}}else F(e,{link:y})},[e,n,l.validateEmbeddable,a.activeEmbeddable,r,i]);YA(()=>()=>{u()},[u]),VA(()=>{let y=null,v=I=>{if(p)return;y&&clearTimeout(y),JA(e,t,a,[I.clientX,I.clientY])&&(y=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},jA))};return window.addEventListener("pointermove",v,!1),()=>{window.removeEventListener("pointermove",v,!1),y&&clearTimeout(y)}},[a,e,p,r,t]);let h=qv(()=>{Ee("hyperlink","delete"),F(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),E=()=>{Ee("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x,y:w}=t3(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:Jv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${x}px`,width:i1,padding:o1},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?Pc("input",{className:XA("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[S.CTRL_OR_CMD]&&y.key===S.K&&y.preventDefault(),(y.key===S.ENTER||y.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?Pc("a",{href:pr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:im(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&o){let v=Ad("excalidraw-link",y.nativeEvent);o({...e,link:pr(e.link)},v),v.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Pc("div",{className:"excalidraw-hyperlinkContainer-link",children:b("labels.link.empty")}),Jv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&Pc(ce,{type:"button",title:b("buttons.edit"),"aria-label":b("buttons.edit"),label:b("buttons.edit"),onClick:E,className:"excalidraw-hyperlinkContainer--edit",icon:Nl}),s&&!It(e)&&Pc(ce,{type:"button",title:b("buttons.remove"),"aria-label":b("buttons.remove"),label:b("buttons.remove"),onClick:h,className:"excalidraw-hyperlinkContainer--remove",icon:Oo})]})]})},t3=(e,t,r)=>{let[o,n]=re(e,r),{x:i,y:a}=Ot({sceneX:o+e.width/2,sceneY:n},t),l=i-t.offsetLeft-i1/2,s=a-t.offsetTop-Qv;return{x:l,y:s}},a1=(e,t)=>{let r=ue(e,t);return r[0]?.link?It(r[0])?"labels.link.editEmbed":"labels.link.edit":It(r[0])?"labels.link.createEmbed":"labels.link.create"},Dc=null,r3=(e,t,r)=>{Dc&&clearTimeout(Dc),Dc=window.setTimeout(()=>qA(e,t,r),bE)},qA=(e,t,r)=>{if(!e.link)return;let o=Yl();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,l]=re(e,r),[s,c,d,m]=cc([n,i,a,l],e.angle,t),p=Ot({sceneX:s,sceneY:c},t);Gf(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ee("hyperlink","tooltip","link-icon"),n1=!0},o3=()=>{Dc&&clearTimeout(Dc),n1&&(n1=!1,Yl().classList.remove("excalidraw-tooltip--visible"))},JA=(e,t,r,[o,n])=>{let{x:i,y:a}=Ke({clientX:o,clientY:n},r),l=15/r.zoom.value;if(sc(i,a,e,t))return!1;let[s,c,d]=re(e,t);if(i>=s&&i<=d&&a>=c-Qv&&a<=c)return!1;let{x:m,y:p}=t3(e,r,t);return!(o>=m-l&&o<=m+i1+o1*2+l&&n>=p-l&&n<=p+l+o1*2+ZA)};se();ge();$e();Ne();U();Xe();import{jsx as QA}from"react/jsx-runtime";var _c=z({name:"hyperlink",label:(e,t)=>a1(e,t),icon:vc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},storeAction:D.CAPTURE},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>ue(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=ue(e,t);return QA(ce,{type:"button",icon:vc,"aria-label":b(a1(e,t)),title:`${It(e[0])?b("labels.link.labelEmbed"):b("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();Ue();se();ge();$e();Ne();U();Xe();var l1=e=>e.every(t=>!t.locked),s1=z({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!ee(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":l1(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=ue(t,e);return l1(r)?Rl:Aa},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=l1(n),a=$(n);return{elements:e.map(l=>a.has(l.id)?ie(l,{locked:i}):l),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},storeAction:D.CAPTURE}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),n3=z({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:Aa,predicate:(e,t)=>ue(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?ie(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},storeAction:D.CAPTURE}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as su,useRef as sL,useState as lu}from"react";ge();f();import DM from"clsx";import{useEffect as _M,useState as RM}from"react";f();import{useCallback as ek,useState as tk}from"react";var i3=()=>{let[e,t]=tk(null),r=ek(o=>t(o),[]);return[e,r]};ge();f();import rk from"react";import ok from"clsx";import{jsx as nk}from"react/jsx-runtime";var qt=rk.forwardRef(({children:e,padding:t,className:r,style:o},n)=>nk("div",{className:ok("Island",r),style:{"--padding":t,...o},ref:n,children:e}));f();ge();import{createPortal as ik}from"react-dom";import ak from"clsx";import{useRef as lk}from"react";import{jsx as a3,jsxs as sk}from"react/jsx-runtime";var l3=e=>{let{closeOnClickOutside:t=!0}=e,r=vp({className:"excalidraw-modal-container"}),o=lk(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return ik(sk("div",{className:ak("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[a3("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),a3("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};U();import{useSetAtom as NM}from"jotai";f();import{useState as AM,useCallback as S1,useMemo as X3,useRef as T1}from"react";f();Cr();yl();import{atom as uk}from"jotai";lt();oi();Y();import{useEffect as d3,useRef as m3}from"react";f();Qt();import{atom as ck,useAtom as dk}from"jotai";import{useEffect as mk,useState as pk}from"react";ya();var c1=ck(new Map),s3=async e=>await Ml({elements:e,appState:{exportBackground:!1,viewBackgroundColor:de.white},files:null,renderEmbeddables:!1}),c3=(e,t,r)=>{let[o,n]=pk();return mk(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await s3(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await s3(t);n(i)})()},[e,t,r,n]),o},zp=()=>{let[e]=dk(c1,ze);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};U();Js();f();U();var Hp=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(Is(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=Cd();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};be();var u3=new or,Ba=uk({status:"loaded",isInitialized:!1,libraryItems:[]}),Rc=e=>Vo(e),hk=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),h3=(e,t)=>{let r=[];for(let o of t)hk(e,o)&&r.push(o);return[...r,...e]},g3=(e,t)=>{let r=$(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=$(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},d1=class{currLibraryItems=[];prevLibraryItems=Rc(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)Jt.set(Ba,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{Jt.set(Ba,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Rc(this.currLibraryItems);let r=Rc(this.currLibraryItems);this.app.props.onLibraryChange?.(r),u3.trigger(g3(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],Jt.set(c1,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Rc(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:Nr.name,tab:ws}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await ug(s,i):c=fa(s,i),!r||window.confirm(b("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?h3(this.currLibraryItems,c):c)):l(new $o)}catch(s){l(s)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Rc(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},f3=d1,Wp=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((E,x)=>{let{height:w}=Tr(x.elements);return Math.max(E,w)},0),i=u=>{let h=0,E=0,x=0;for(let w of e){if(h%r===0&&(E=0),E===u){let{width:y}=Tr(w.elements);x=Math.max(x,y)}h++,E++}return x},a=0,l=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(l+=s+50,a=0,m=0,p++),m===0&&(s=n(p)),c=i(m);let{minX:h,minY:E,width:x,height:w}=Tr(u.elements),y=(c-x)/2,v=(s-w)/2;o.push(...u.elements.map(I=>({...I,x:I.x+a+y-h,y:I.y+l+v-E}))),a+=c+50,d++,m++}return o},m1=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(bd.addLibrary)||new URLSearchParams(window.location.search).get(fd.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},Ql=class e{static queue=new Hp;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:r});i(fa(l?.libraryItems||[],"published"))}catch(l){a(l)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},Nc=0,Up=0,Gp=e=>$g(e.map(t=>`${t.id}:${Kg(t.elements)}`).sort().join()),p3=async(e,t)=>{try{return Up++,await Ql.run(e,async r=>{let o=$(await r.getLibraryItems("save"));for(let[l]of t.deletedItems)o.delete(l);let n=[];for(let[l,s]of t.addedItems)o.has(l)?o.set(l,s):n.push(s);let i=n.concat(Array.from(o.values())),a=Gp(i);return a!==Nc&&await e.save({libraryItems:i}),Nc=a,i})}finally{Up--}},gk=e=>{let{excalidrawAPI:t}=e,r=m3(e);r.current=e;let o=m3(!1);d3(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(m,p)=>{try{let h=await(await fetch(decodeURIComponent(l))).blob();m(h)}catch(u){p(u)}}),d=s!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(bd.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(bd.addLibrary),window.history.replaceState({},fs,`#${m.toString()}`)}else if(window.location.search.includes(fd.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(fd.addLibrary),window.history.replaceState({},fs,`?${m.toString()}`)}}},i=l=>{l.preventDefault();let s=m1();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=m1();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in r.current&&r.current.adapter){let l=r.current.adapter,s=r.current.migrationAdapter,c=Cd();s?c.resolve(Is(s.load).then(async d=>{let m=null;try{if(!d)return Ql.getLibraryItems(l,"load");m=fa(d.libraryItems||[],"published");let p=await p3(l,g3([],m));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),Ql.getLibraryItems(l,"load")))):c.resolve(Is(Ql.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Nc=Gp(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),d3(()=>{let n=u3.on(async(a,l)=>{let s=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&Nc!==Gp(l)&&await p3(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:b("errors.saveLibraryError")}})}}),i=a=>{Up&&FE(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Nc=0,Up=0}},[])};Co();f();Nn();import{useCallback as os,useEffect as vM,useMemo as V3,useRef as TM,useState as SM}from"react";U();f();import{forwardRef as b3}from"react";import E3 from"clsx";import{jsx as x3}from"react/jsx-runtime";var fk=b3(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>x3("div",{className:E3("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),bk=b3(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>x3("div",{className:E3("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),Gt={Row:fk,Col:bk};Y();Mn();f();f();Y();import{jsx as xk}from"react/jsx-runtime";var Ek=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return xk("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${Zi.excalidrawLibrary}`,target:"_excalidraw_libraries",children:b("labels.libraries")})},y3=Ek;import yk from"clsx";import{jsx as wk,jsxs as vk}from"react/jsx-runtime";var Vp=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>vk("div",{className:yk("library-menu-control-buttons",i),style:o,children:[wk(y3,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as tM,useState as E1}from"react";f();import Yp from"react";var Tk=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,Sk=/{{([\w-]+)}}/,Ik=/<([\w-]+)>/,Ck=/<\/([\w-]+)>/,Ak=(e,t)=>{let r=[{name:"",children:[]}];return e.split(Tk).filter(Boolean).forEach(o=>{let n=o.match(Ik),i=o.match(Ck),a=o.match(Sk);if(n!==null){let l=n[1];t.hasOwnProperty(l)?r.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let s=r.pop(),c=Yp.createElement(Yp.Fragment,{},...s.children),d=t[s.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let l=a[1];t.hasOwnProperty(l)?r[r.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},kk=({i18nKey:e,children:t,...r})=>{let{t:o}=St();return Yp.createElement(Yp.Fragment,{},...Ak(o(e),r))},ur=kk;Nn();Dn();U();import{useAtom as x1}from"jotai";f();f();import Mk from"clsx";import{jsx as Kp,jsxs as Pk}from"react/jsx-runtime";var Lk=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return Pk("button",{className:Mk("Dialog__action-button",s,r),type:i,"aria-label":e,onClick:t,...l,children:[o&&Kp("div",{style:a?{visibility:"hidden"}:{},children:o}),Kp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Kp("div",{style:{position:"absolute",inset:0},children:Kp(Yt,{})})]})},es=Lk;import{useSetAtom as Dk}from"jotai";import{jsx as w3,jsxs as v3}from"react/jsx-runtime";var _k=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=b("buttons.confirm"),cancelText:i=b("buttons.cancel"),className:a="",...l}=e,s=Oe(),c=Dk(ts,ze),{container:d}=Ut();return v3(ut,{onCloseRequest:r,size:"small",...l,className:`confirm-dialog ${a}`,children:[o,v3("div",{className:"confirm-dialog-buttons",children:[w3(es,{label:i,onClick:()=>{s({openMenu:null}),c(!1),r(),d?.focus()}}),w3(es,{label:n,onClick:()=>{s({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},$p=_k;f();import{useCallback as Rk,useEffect as u1,useRef as T3,useState as p1}from"react";import Xp from"open-color";ya();Y();Cr();U();f();var Lr=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as ve,jsxs as ir}from"react/jsx-runtime";var Nk=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=NE(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let l=a.getContext("2d");l.fillStyle=Xp.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let d=await vi({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+o*2),h=s%6*(128+o*2);l.drawImage(d,h+(128-m)/2+o,u+(128-p)/2+o),l.lineWidth=n,l.strokeStyle=Xp.gray[4],l.strokeRect(h+o/2,u+o/2,128+o,128+o)}return await ac(new File([await Rn(a)],"preview",{type:te.png}),{outputType:te.jpg,maxWidthOrHeight:5e3})},Ok=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=T3(null),a=T3(null);return u1(()=>{let l=i.current;l&&(async()=>{let s=await Ml({elements:e.elements,appState:{...t,viewBackgroundColor:Xp.white,exportBackground:!0},files:null});l.innerHTML=s.outerHTML})()},[e.elements,t]),ir("div",{className:"single-library-item",children:[e.status==="published"&&ve("span",{className:"single-library-item-status",children:b("labels.statusPublished")}),ve("div",{ref:i,className:"single-library-item__svg"}),ve(ce,{"aria-label":b("buttons.remove"),type:"button",icon:co,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:b("buttons.remove")}),ir("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ir("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ir("div",{style:{padding:"0.5em 0"},children:[ve("span",{style:{fontWeight:500,color:Xp.gray[6]},children:b("publishDialog.itemName")}),ve("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ve("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{o(l.target.value,r)}})]}),ve("span",{className:"error",children:e.error})]})]})},Bk=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=p1({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=p1(!1);u1(()=>{let v=Lr.get(Qr.PUBLISH_LIBRARY);v&&s(v)},[]);let[m,p]=p1(t.slice());u1(()=>{p(t.slice())},[t]);let u=v=>{s({...l,[v.target.name]:v.target.value})},h=async v=>{v.preventDefault(),d(!0);let I=[],L=!1;if(m.forEach(N=>{let A="";N.name||(A=b("publishDialog.errors.required"),L=!0),I.push({...N,error:A})}),L){p(I),d(!1);return}let C=await Nk(m),M={type:er.excalidrawLibrary,version:Zi.excalidrawLibrary,source:ys,libraryItems:m},_=JSON.stringify(M,null,2),H=new Blob([_],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",H),k.append("previewImage",C),k.append("previewImageType",C.type),k.append("title",l.name),k.append("authorName",l.authorName),k.append("githubHandle",l.githubHandle),k.append("name",l.name),k.append("description",l.description),k.append("twitterHandle",l.twitterHandle),k.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(N=>N.ok?N.json().then(({url:A})=>{Lr.delete(Qr.PUBLISH_LIBRARY),o({url:A,authorName:l.authorName,items:m})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(A=>{throw new Error(A.message||N.statusText||"something went wrong")}),N=>{console.error(N),n(N),d(!1)}).catch(N=>{console.error(N),n(N),d(!1)})},E=()=>{let v=[];return m.forEach((I,L)=>{v.push(ve("div",{className:"single-library-item-wrapper",children:ve(Ok,{libItem:I,appState:r,index:L,onChange:(C,M)=>{let _=m.slice();_[M].name=C,p(_)},onRemove:a})},L))}),ve("div",{className:"selected-library-items",children:v})},x=Rk(()=>{i(m),Lr.set(Qr.PUBLISH_LIBRARY,l),e()},[m,e,i,l]),w=!!t.length,y=t.some(v=>v.status==="published");return ve(ut,{onCloseRequest:x,title:b("publishDialog.title"),className:"publish-library",children:w?ir("form",{onSubmit:h,children:[ve("div",{className:"publish-library-note",children:ve(ur,{i18nKey:"publishDialog.noteDescription",link:v=>ve("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:v})})}),ve("span",{className:"publish-library-note",children:ve(ur,{i18nKey:"publishDialog.noteGuidelines",link:v=>ve("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:v})})}),ve("div",{className:"publish-library-note",children:b("publishDialog.noteItems")}),y&&ve("span",{className:"publish-library-note publish-library-warning",children:b("publishDialog.republishWarning")}),E(),ir("div",{className:"publish-library__fields",children:[ir("label",{children:[ir("div",{children:[ve("span",{children:b("publishDialog.libraryName")}),ve("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ve("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:b("publishDialog.placeholder.libraryName")})]}),ir("label",{style:{alignItems:"flex-start"},children:[ir("div",{children:[ve("span",{children:b("publishDialog.libraryDesc")}),ve("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ve("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:b("publishDialog.placeholder.libraryDesc")})]}),ir("label",{children:[ir("div",{children:[ve("span",{children:b("publishDialog.authorName")}),ve("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ve("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:b("publishDialog.placeholder.authorName")})]}),ir("label",{children:[ve("span",{children:b("publishDialog.githubUsername")}),ve("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:b("publishDialog.placeholder.githubHandle")})]}),ir("label",{children:[ve("span",{children:b("publishDialog.twitterUsername")}),ve("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:b("publishDialog.placeholder.twitterHandle")})]}),ir("label",{children:[ve("span",{children:b("publishDialog.website")}),ve("input",{type:"text",name:"website",pattern:"https?://.+",title:b("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:b("publishDialog.placeholder.website")})]}),ve("span",{className:"publish-library-note",children:ve(ur,{i18nKey:"publishDialog.noteLicense",link:v=>ve("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:v})})})]}),ir("div",{className:"publish-library__buttons",children:[ve(es,{label:b("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ve(es,{type:"submit",label:b("buttons.submit"),actionType:"primary",isLoading:c})]})]}):ve("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:b("publishDialog.atleastOneLibItem")})})},S3=Bk;f();f();import Fk from"clsx";import{jsx as zk}from"react/jsx-runtime";var I3=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=Me(),a=Fk(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return zk("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},C3=I3;I3.displayName="DropdownMenuTrigger";f();f();Y();U();import Hk,{useContext as Uk}from"react";var h1=Hk.createContext({}),Zp=(e="",t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""}`.trim(),jp=(e,t)=>{let r=Uk(h1);return ti(e,o=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});t?.(n),n.defaultPrevented||r.onSelect?.(n)})};f();import{Fragment as Wk,jsx as g1,jsxs as Vk}from"react/jsx-runtime";var Gk=({icon:e,shortcut:t,children:r})=>{let o=Me();return Vk(Wk,{children:[g1("div",{className:"dropdown-menu-item__icon",children:e}),g1("div",{className:"dropdown-menu-item__text",children:r}),t&&!o.editor.isMobile&&g1("div",{className:"dropdown-menu-item__shortcut",children:t})]})},qp=Gk;import{jsx as f1}from"react/jsx-runtime";var b1=({icon:e,onSelect:t,children:r,shortcut:o,className:n,selected:i,...a})=>{let l=jp(a.onClick,t);return f1("button",{...a,onClick:l,type:"button",className:Zp(n,i),title:a.title??a["aria-label"],children:f1(qp,{icon:e,shortcut:o,children:r})})};b1.displayName="DropdownMenuItem";var A3=({children:e})=>f1("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",background:"pink",borderRadius:6,fontSize:9,color:"black",fontFamily:"Cascadia, monospace"},children:e});A3.displayName="DropdownMenuItemBadge";b1.Badge=A3;var go=b1;f();import{jsx as Yk}from"react/jsx-runtime";var k3=()=>Yk("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),M3=k3;k3.displayName="DropdownMenuSeparator";f();import{jsx as Kk,jsxs as $k}from"react/jsx-runtime";var L3=({children:e,className:t="",style:r,title:o})=>$k("div",{className:`dropdown-menu-group ${t}`,style:r,children:[o&&Kk("p",{className:"dropdown-menu-group-title",children:o}),e]}),P3=L3;L3.displayName="DropdownMenuGroup";f();import Xk from"clsx";import{useEffect as Zk,useRef as jk}from"react";ge();Y();import{jsx as Jp}from"react/jsx-runtime";var D3=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=Me(),a=jk(null),l=Vl({onClickOutside:t});Wl(a,()=>{l.onClickOutside?.()}),Zk(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[l]);let s=Xk(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Jp(h1.Provider,{value:{onSelect:o},children:Jp("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Jp(Gt.Col,{className:"dropdown-menu-container",children:e}):Jp(qt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};D3.displayName="DropdownMenuContent";var _3=D3;f();import{jsx as R3}from"react/jsx-runtime";var N3=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...l})=>{let s=jp(l.onClick,n);return R3("a",{...l,href:r,target:"_blank",rel:"noreferrer",className:Zp(i,a),title:l.title??l["aria-label"],onClick:s,children:R3(qp,{icon:e,shortcut:t,children:o})})},rs=N3;N3.displayName="DropdownMenuItemLink";f();import{jsx as Jk}from"react/jsx-runtime";var qk=({children:e,className:t="",selected:r,...o})=>Jk("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),O3=qk;f();import Qp from"react";var B3=e=>{let t=Qp.Children.toArray(e).find(r=>Qp.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},F3=e=>{let t=Qp.Children.toArray(e).find(r=>Qp.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as Qk,jsxs as eM}from"react/jsx-runtime";var Gn=({children:e,open:t})=>{let r=B3(e),o=F3(e);return eM(Qk,{children:[r,t&&o]})};Gn.Trigger=C3;Gn.Content=_3;Gn.Item=go;Gn.ItemLink=rs;Gn.ItemCustom=O3;Gn.Group=P3;Gn.Separator=M3;var Fe=Gn;Gn.displayName="DropdownMenu";import rM from"clsx";import{jsx as Pr,jsxs as eu}from"react/jsx-runtime";var oM=(e,t)=>e.filter(r=>t.includes(r.id)),nM=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=x1(Ba,ze),[c,d]=x1(ts,ze),m=()=>{let k=t.length?b("alerts.removeItemsFromsLibrary",{count:t.length}):b("alerts.resetLibrary"),N=t.length?b("confirmDialog.removeItemsFromLib"):b("confirmDialog.resetLibrary");return Pr($p,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:N,children:Pr("p",{children:k})})},[p,u]=E1(!1),h=!!t.length,E=h?s.libraryItems.filter(k=>t.includes(k.id)):s.libraryItems,x=h?b("buttons.remove"):b("buttons.resetLibrary"),[w,y]=E1(!1),[v,I]=E1(null),L=tM(()=>eu(ut,{onCloseRequest:()=>I(null),title:b("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Pr("p",{children:Pr(ur,{i18nKey:"publishSuccessDialog.content",authorName:v.authorName,link:k=>Pr("a",{href:v?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),Pr(ce,{type:"button",title:b("buttons.close"),"aria-label":b("buttons.close"),label:b("buttons.close"),onClick:()=>I(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[I,v]),C=(k,N)=>{y(!1),I({url:k.url,authorName:k.authorName});let A=N.slice();A.forEach(B=>{t.includes(B.id)&&(B.status="published")}),r.setLibrary(A)},M=async()=>{try{await r.updateLibrary({libraryItems:bl({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:b("errors.importLibraryError")})}},_=async()=>{let k=h?E:await r.getLatestLibrary();$0(k).catch(Id).catch(N=>{e({errorMessage:N.message})})},H=()=>eu(Fe,{open:c,children:[Pr(Fe.Trigger,{onToggle:()=>d(!c),children:cw}),eu(Fe.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!h&&Pr(Fe.Item,{onSelect:M,icon:Bl,"data-testid":"lib-dropdown--load",children:b("buttons.load")}),!!E.length&&Pr(Fe.Item,{onSelect:_,icon:ka,"data-testid":"lib-dropdown--export",children:b("buttons.export")}),!!E.length&&Pr(Fe.Item,{onSelect:()=>u(!0),icon:Oo,children:x}),h&&Pr(Fe.Item,{icon:E2,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:b("buttons.publishLibrary")})]})]});return eu("div",{className:rM("library-menu-dropdown-container",l),children:[H(),t.length>0&&Pr("div",{className:"library-actions-counter",children:t.length}),p&&m(),w&&Pr(S3,{onClose:()=>y(!1),libraryItems:oM(s.libraryItems,t),appState:a,onSuccess:k=>C(k,s.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>r.setLibrary(s.libraryItems),onRemove:k=>i(t.filter(N=>N!==k))}),v&&L()]})},y1=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=kr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=zp(),a=_e(),l=Oe(),[s]=x1(Ba,ze),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{l({errorMessage:b("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Pr(nM,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as uM,useEffect as hM,useState as gM}from"react";f();import z3 from"clsx";import{memo as iM,useEffect as aM,useRef as lM,useState as sM}from"react";import{jsx as tu,jsxs as cM}from"react/jsx-runtime";var H3=iM(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=lM(null),c=c3(e,t,l);aM(()=>{let h=s.current;if(h)return c&&(h.innerHTML=c.outerHTML),()=>{h.innerHTML=""}},[c]);let[d,m]=sM(!1),p=Me().editor.isMobile,u=r&&tu("div",{className:"library-unit__adder",children:sw});return cM("div",{className:z3("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[tu("div",{className:z3("library-unit__dragger",{"library-unit__pulse":!!r}),ref:s,draggable:!!t,onClick:t||r?h=>{e&&h.shiftKey?i(e,h):o(e)}:void 0,onDragStart:h=>{if(!e){h.preventDefault();return}m(!1),a(e,h)}}),u,e&&t&&(d||p||n)&&tu(Ra,{checked:n,onChange:(h,E)=>i(e,E),className:"library-unit__checkbox"})]})}),U3=()=>tu("div",{className:"library-unit library-unit--skeleton"});f();import dM,{useCallback as mM}from"react";function pM(){return[!1,mM(t=>t(),[])]}var G3=dM.useTransition||pM;import{Fragment as fM,jsx as ru}from"react/jsx-runtime";var w1=({children:e})=>ru("div",{className:"library-menu-items-container__grid",children:e}),ou=uM(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=G3(),[s,c]=gM(0);return hM(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),ru(fM,{children:e.map((d,m)=>m<s?ru(H3,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):ru(U3,{},m))})});f();import{useEffect as bM}from"react";import{atom as EM,useAtom as xM}from"jotai";import yM from"lodash.throttle";var wM=EM(0),W3=e=>{let[t,r]=xM(wM);return bM(()=>{let{current:o}=e;if(!o)return;let n=yM(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as Y3,jsx as Dr,jsxs as ns}from"react/jsx-runtime";var IM=17,CM=64;function v1({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let d=TM(null),m=W3(d);vM(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=zp(),u=V3(()=>t.filter(k=>k.status!=="published"),[t]),h=V3(()=>t.filter(k=>k.status==="published"),[t]),E=!t.length&&!n.length,x=!n.length&&!u.length&&!h.length,[w,y]=SM(null),v=os((k,N)=>{let A=!c.includes(k),B=[...u,...h];if(A){if(N.shiftKey&&w){let q=B.findIndex(V=>V.id===w),Z=B.findIndex(V=>V.id===k);if(q===-1||Z===-1){s([...c,k]);return}let oe=$(c),Te=B.reduce((V,W,he)=>((he>=q&&he<=Z||oe.has(W.id))&&V.push(W.id),V),[]);s(Te)}else s([...c,k]);y(k)}else y(null),s(c.filter(q=>q!==k))},[w,s,h,c,u]),I=os(k=>{let N;return c.includes(k)?N=t.filter(A=>c.includes(A.id)):N=t.filter(A=>A.id===k),N.map(A=>({...A,elements:pm(A.elements,{randomizeSeed:!0})}))},[t,c]),L=os((k,N)=>{N.dataTransfer.setData(te.excalidrawlib,Tm(I(k)))},[I]),C=os(k=>k?c.includes(k):!1,[c]),M=os(()=>{r(n)},[n,r]),_=os(k=>{k&&o(I(k))},[I,o]),H=p.size>=t.length?CM:IM;return ns("div",{className:"library-menu-items-container",style:n.length||u.length||h.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&Dr(y1,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),ns(Gt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:h.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[ns(Y3,{children:[!x&&Dr("div",{className:"library-menu-items-container__header",children:b("labels.personalLib")}),e&&Dr("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Dr(Yt,{})}),!n.length&&!u.length?ns("div",{className:"library-menu-items__no-items",children:[Dr("div",{className:"library-menu-items__no-items__label",children:b("library.noItems")}),Dr("div",{className:"library-menu-items__no-items__hint",children:h.length>0?b("library.hint_emptyPrivateLibrary"):b("library.hint_emptyLibrary")})]}):ns(w1,{children:[n.length>0&&Dr(ou,{itemsRenderedPerBatch:H,items:[{id:null,elements:n}],onItemSelectToggle:v,onItemDrag:L,onClick:M,isItemSelected:C,svgCache:p}),Dr(ou,{itemsRenderedPerBatch:H,items:u,onItemSelectToggle:v,onItemDrag:L,onClick:_,isItemSelected:C,svgCache:p})]})]}),ns(Y3,{children:[(h.length>0||n.length>0||u.length>0)&&Dr("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:b("labels.excalidrawLib")}),h.length>0?Dr(w1,{children:Dr(ou,{itemsRenderedPerBatch:H,items:h,onItemSelectToggle:v,onItemDrag:L,onClick:_,isItemSelected:C,svgCache:p})}):u.length>0?Dr("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:b("library.noItems")}):null]}),E&&Dr(Vp,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Dr(y1,{selectedItems:c,onSelectItems:s})})]})]})}import{atom as kM,useAtom as MM}from"jotai";$e();U();Y();import{jsx as Mi,jsxs as $3}from"react/jsx-runtime";var ts=kM(!1),K3=({children:e})=>Mi("div",{className:"layer-ui__library",children:e}),LM=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[d]=MM(Ba,ze),m=S1(h=>{(async(x,w)=>{Ee("element","addToLibrary","ui");for(let v of yd)if(x.some(I=>I.type===v))return o({errorMessage:b(`errors.libraryElementTypeError.${v}`)});let y=[{status:"unpublished",elements:x,id:_t(),created:Date.now()},...w];r(),i.setLibrary(y).catch(()=>{o({errorMessage:b("alerts.errorAddingToLibrary")})})})(h,d.libraryItems)},[r,i,o,d.libraryItems]),p=X3(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return Mi(K3,{children:Mi("div",{className:"layer-ui__library-message",children:$3("div",{children:[Mi(Yt,{size:"2em"}),Mi("span",{children:b("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return $3(K3,{children:[Mi(v1,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&Mi(Vp,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})},PM=(e,t)=>{let r=()=>ue(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=T1(r()),n=T1(e),i=T1(t);return(!Je(e.selectedElementIds,n.current.selectedElementIds)||!Je(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},Z3=()=>{let{library:e,id:t,onInsertElements:r}=kr(),o=ki(),n=_e(),i=Oe(),a=Ii(),[l,s]=AM([]),c=X3(()=>e,[e]),d=PM(n,a),m=S1(u=>{r(Wp(u))},[r]),p=S1(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return Mi(LM,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:l,onSelectItems:s})};import{jsx as Oc,jsxs as BM}from"react/jsx-runtime";function OM(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ut=e=>{let[t,r]=i3(),[o]=RM(document.activeElement),{id:n}=Ut(),i=Me().viewport.isMobile;_M(()=>{if(!t)return;let c=Ts(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=Ts(t),{activeElement:u}=document,h=p.findIndex(E=>E===u);h===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):h===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=Oe(),l=NM(ts,ze),s=()=>{a({openMenu:null}),l(!1),o.focus(),e.onCloseRequest()};return Oc(l3,{className:DM("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:OM(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:BM(qt,{ref:r,children:[e.title&&Oc("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Oc("span",{className:"Dialog__titleContent",children:e.title})}),i&&Oc("button",{className:"Dialog__close",onClick:s,title:b("buttons.close"),"aria-label":b("buttons.close"),children:co}),Oc("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as HM,useRef as UM,useImperativeHandle as GM,useLayoutEffect as WM,useState as VM}from"react";import I1 from"clsx";f();U();import FM from"clsx";import{jsx as zM}from"react/jsx-runtime";var ln=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>zM("button",{onClick:ti(i.onClick,a=>{t()}),type:e,className:FM("excalidraw-button",n,{selected:r}),...i,children:o});import{jsx as C1,jsxs as j3}from"react/jsx-runtime";var nu=HM(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,...s},c)=>{let d=UM(null);GM(c,()=>d.current),WM(()=>{i&&d.current?.select()},[i]);let[m,p]=VM(!1);return j3("div",{className:I1("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[C1("div",{className:"ExcTextField__label",children:t}),j3("div",{className:I1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[C1("input",{className:I1({"is-redacted":"value"in s&&s.value&&l&&!m}),readOnly:n,value:"value"in s?s.value:void 0,defaultValue:"defaultValue"in s?s.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),l&&C1(ln,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?I2:Hl})]})]})});$e();import iT from"clsx";f();Y();U();var YM={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+${b("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[ar?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[ar?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],copyAsSvg:[],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("?")]},kt=(e,t=0)=>{let r=YM[e];return r&&r.length>0?r[t]||r[0]:""};Y();import cL from"fuzzy";U();import{atom as dL,useAtom as mL}from"jotai";f();var KM="\\u0300-\\u036f",$M="\\ufe20-\\ufe2f",XM="\\u20d0-\\u20ff",ZM=KM+$M+XM,jM=`[${ZM}]`,qM=RegExp(jM,"g"),JM=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,QM={\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"},A1=e=>e.replace(JM,t=>QM[t]||t).replace(qM,"");f();import{jsx as eL}from"react/jsx-runtime";var Li=({icon:e})=>eL("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});f();ge();var Bc=[{icon:hw,value:"selection",key:S.V,numericKey:S[1],fillable:!0},{icon:gw,value:"rectangle",key:S.R,numericKey:S[2],fillable:!0},{icon:fw,value:"diamond",key:S.D,numericKey:S[3],fillable:!0},{icon:bw,value:"ellipse",key:S.O,numericKey:S[4],fillable:!0},{icon:Ew,value:"arrow",key:S.A,numericKey:S[5],fillable:!0},{icon:xw,value:"line",key:S.L,numericKey:S[6],fillable:!0},{icon:Nl,value:"freedraw",key:[S.P,S.X],numericKey:S[7],fillable:!1},{icon:ww,value:"text",key:S.T,numericKey:S[8],fillable:!1},{icon:vw,value:"image",key:null,numericKey:S[9],fillable:!1},{icon:Tw,value:"eraser",key:S.E,numericKey:S[0],fillable:!1}],q3=e=>Bc.find((r,o)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;f();import{useState as tL}from"react";$e();U();Os();se();import L1 from"clsx";st();ge();f();import k1 from"react";import sn from"tunnel-rat";var M1=k1.createContext(null),ot=()=>k1.useContext(M1),J3=()=>k1.useMemo(()=>({MainMenuTunnel:sn(),WelcomeScreenMenuHintTunnel:sn(),WelcomeScreenToolbarHintTunnel:sn(),WelcomeScreenHelpHintTunnel:sn(),WelcomeScreenCenterTunnel:sn(),FooterCenterTunnel:sn(),DefaultSidebarTriggerTunnel:sn(),DefaultSidebarTabTriggersTunnel:sn(),OverwriteConfirmDialogTunnel:sn(),TTDDialogTriggerTunnel:sn(),jotaiScope:Symbol()}),[]);import{Fragment as Pi,jsx as ct,jsxs as Tt}from"react/jsx-runtime";var P1=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return Ns(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>Ns(o.type))},D1=(e,t)=>vn(e.activeTool.type)||t.some(r=>vn(r.type)),iu=({appState:e,elementsMap:t,renderAction:r})=>{let o=Ca(t,e),n=!1;o.length===2&&(tr(o[0])||tr(o[1]))&&(n=!0);let i=!!e.editingElement,a=Me(),l=document.documentElement.getAttribute("dir")==="rtl",s=vn(e.activeTool.type)&&!lr(e.currentItemBackgroundColor)||o.some(d=>vn(d.type)&&!lr(d.backgroundColor)),c=o.length===1||n;return Tt("div",{className:"panelColumn",children:[ct("div",{children:P1(e,o)&&r("changeStrokeColor")}),D1(e,o)&&ct("div",{children:r("changeBackgroundColor")}),s&&r("changeFillStyle"),(Nd(e.activeTool.type)||o.some(d=>Nd(d.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(d=>d.type==="freedraw"))&&r("changeStrokeShape"),(Od(e.activeTool.type)||o.some(d=>Od(d.type)))&&Tt(Pi,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(rl(e.activeTool.type)||o.some(d=>rl(d.type)))&&ct(Pi,{children:r("changeRoundness")}),(e.activeTool.type==="text"||o.some(G))&&Tt(Pi,{children:[r("changeFontSize"),r("changeFontFamily"),(e.activeTool.type==="text"||jx(o,t))&&r("changeTextAlign")]}),Zx(o,t)&&r("changeVerticalAlign"),(Qi(e.activeTool.type)||o.some(d=>Qi(d.type)))&&ct(Pi,{children:r("changeArrowhead")}),r("changeOpacity"),Tt("fieldset",{children:[ct("legend",{children:b("labels.layers")}),Tt("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringToFront"),r("bringForward")]})]}),o.length>1&&!n&&Tt("fieldset",{children:[ct("legend",{children:b("labels.align")}),Tt("div",{className:"buttonList",children:[l?Tt(Pi,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Tt(Pi,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),ct("div",{style:{flexBasis:"100%",height:0}}),Tt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Tt("fieldset",{children:[ct("legend",{children:b("labels.actions")}),Tt("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink")]})]})]})},au=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=tL(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=ot();return Tt(Pi,{children:[Bc.map(({value:d,icon:m,key:p,numericKey:u,fillable:h},E)=>{if(o.tools?.[d]===!1)return null;let x=b(`toolBar.${d}`),w=p&&ei(typeof p=="string"?p:p[0]),y=w?`${w} ${b("helpDialog.or")} ${u}`:`${u}`;return ct(ce,{className:L1("Shape",{fillable:h}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${ei(x)} \u2014 ${y}`,keyBindingLabel:u||w,"aria-label":ei(x),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!t.penDetected&&v==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:v})=>{t.activeTool.type!==d&&Ee("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:v!=="mouse"}):r.setActiveTool({type:d})}},d)}),ct("div",{className:"App-toolbar__divider"}),Tt(Fe,{open:n,children:[Tt(Fe.Trigger,{className:L1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||s||l&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:b("toolBar.extraTools"),children:[T2,r.props.aiEnabled!==!1&&ct("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"pink",color:"black",bottom:3,right:4},children:"AI"})]}),Tt(Fe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[ct(Fe.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:hp,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:b("toolBar.frame")}),ct(Fe.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:Iw,"data-testid":"toolbar-embeddable",selected:s,children:b("toolBar.embeddable")}),ct(Fe.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:fp,"data-testid":"toolbar-laser",selected:l,shortcut:S.K.toLocaleUpperCase(),children:b("toolBar.laser")}),ct("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&&ct(c.Out,{}),ct(Fe.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:gp,"data-testid":"toolbar-embeddable",children:b("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Tt(Pi,{children:[Tt(Fe.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:zl,"data-testid":"toolbar-magicframe",children:[b("toolBar.magicframe"),ct(Fe.Item.Badge,{children:"AI"})]}),ct(Fe.Item,{onSelect:()=>{Ee("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:Tc,"data-testid":"toolbar-magicSettings",children:b("toolBar.magicSettings")})]})]})]})]})},Q3=({renderAction:e,zoom:t})=>ct(Gt.Col,{gap:1,className:"zoom-actions",children:Tt(Gt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),eT=({renderAction:e,className:t})=>Tt("div",{className:`undo-redo-buttons ${t}`,children:[ct("div",{className:"undo-button-container",children:ct(Xr,{label:b("buttons.undo"),children:e("undo")})}),ct("div",{className:"redo-button-container",children:Tt(Xr,{label:b("buttons.redo"),children:[" ",e("redo")]})})]}),tT=({actionManager:e,showExitZenModeBtn:t})=>ct("button",{className:L1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(ql),children:b("buttons.exitZenMode")}),rT=({renderAction:e,className:t})=>ct("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as rL}from"react";var _1=e=>{let t=rL({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as oL,useAtom as nL}from"jotai";import{jsx as aL,jsxs as iL}from"react/jsx-runtime";var Fa=oL(null),oT=()=>{let[e,t]=nL(Fa,ze),r=Nt();return e&&e==="clearCanvas"?aL($p,{onConfirm:()=>{r.executeAction(Hn),t(null)},onCancel:()=>t(null),title:b("clearCanvasDialog.title"),children:iL("p",{className:"clear-canvas__content",children:[" ",b("alerts.clearReset")]})}):null};var R1={};Ju(R1,{toggleTheme:()=>lL});f();var lL={...Pa,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Pa,"commandPalette")}};import{jsx as hr,jsxs as cn}from"react/jsx-runtime";var pL=dL(null),xt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},uL=e=>{switch(e){case xt.app:return 1;case xt.export:return 2;case xt.editor:return 3;case xt.tools:return 4;case xt.elements:return 5;case xt.links:return 6;default:return 10}},cu=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return cn("div",{className:iT("shortcut",t),children:[o.map((n,i)=>hr("div",{className:"shortcut-wrapper",children:hr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),hr("div",{className:"shortcut-desc",children:r})]})},aT=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),Gae=Object.assign(e=>{let t=_e(),r=Oe();return su(()=>{let o=n=>{aT(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&Ee("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:hr(hL,{...e})},{defaultItems:R1});function hL({customCommandPaletteItems:e}){let t=kr(),r=_e(),o=Oe(),n=ki(),i=Nt(),[a,l]=mL(pL),[s,c]=lu(null),d=sL(null),m=Vl({uiAppState:r,customCommandPaletteItems:e,appProps:n});su(()=>{let{uiAppState:C,customCommandPaletteItems:M,appProps:_}=m,H=B=>{let q="";return B.label&&(typeof B.label=="function"?q=b(B.label(t.scene.getNonDeletedElements(),C,t)):q=b(B.label)),q},k=B=>typeof B.icon=="function"?B.icon(C,t.scene.getNonDeletedElements()):B.icon,N=[],A=(B,q,Z)=>{let oe={label:H(B),icon:k(B),category:q,shortcut:kt(B.name),keywords:B.keywords,predicate:B.predicate,viewMode:B.viewMode,perform:()=>{i.executeAction(B,"commandPalette")}};return Z?Z(oe,B):oe};if(C&&t.scene&&i){let B=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.copyStyles,i.actions.pasteStyles,i.actions.sendBackward,i.actions.sendToBack,i.actions.bringForward,i.actions.bringToFront,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,_c].map(W=>A(W,xt.elements,(he,Ie)=>({...he,predicate:Ie.predicate?Ie.predicate:(it,ke,Jr,$n)=>ue(it,ke).length>0}))),q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map(W=>A(W,xt.tools)),Z=[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(W=>A(W,xt.editor)),oe=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(W=>A(W,xt.export));N=[...B,...Z,{label:H(Hn),icon:k(Hn),shortcut:kt(Hn.name),category:xt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Jt.set(Fa,"clearCanvas")}},{label:b("buttons.exportImage"),category:xt.export,icon:dp,shortcut:kt("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...oe];let Te=[{label:b("toolBar.library"),category:xt.app,icon:ap,viewMode:!1,perform:()=>{C.openSidebar?o({openSidebar:null}):o({openSidebar:{name:Nr.name,tab:Nr.defaultTab}})}},{label:b("labels.changeStroke"),keywords:["color","outline"],category:xt.elements,icon:cp,viewMode:!1,predicate:(W,he)=>{let Ie=ue(W,he);return Ie.length>0&&P1(he,Ie)},perform:()=>{o(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:b("labels.changeBackground"),keywords:["color","fill"],icon:cp,category:xt.elements,viewMode:!1,predicate:(W,he)=>{let Ie=ue(W,he);return Ie.length>0&&D1(he,Ie)},perform:()=>{o(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:b("labels.canvasBackground"),keywords:["color"],icon:cp,category:xt.editor,viewMode:!1,perform:()=>{o(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Bc.reduce((W,he)=>{let{value:Ie,icon:it,key:ke,numericKey:Jr}=he;if(_.UIOptions.tools?.[Ie]===!1)return W;let zo=ke&&ei(typeof ke=="string"?ke:ke[0])||Jr,gn={label:b(`toolBar.${Ie}`),category:xt.tools,shortcut:zo,icon:it,keywords:["toolbar"],viewMode:!1,perform:({event:Xn})=>{Ie==="image"?t.setActiveTool({type:Ie,insertOnCanvasDirectly:Xn.type==="keydown"}):t.setActiveTool({type:Ie})}};return W.push(gn),W},[]),...q,{label:b("toolBar.lock"),category:xt.tools,icon:C.activeTool.locked?Rl:Aa,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${b("labels.textToDiagram")}...`,category:xt.tools,icon:A2,viewMode:!1,predicate:_.aiEnabled,perform:()=>{o(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${b("toolBar.mermaidToExcalidraw")}...`,category:xt.tools,icon:gp,viewMode:!1,predicate:_.aiEnabled,perform:()=>{o(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],V=[...N,...Te,...M||[]].map(W=>({...W,icon:W.icon||Ep,order:W.order??uL(W.category),haystack:`${A1(W.label)} ${W.keywords?.join(" ")||""}`}));c(V),l(V.find(W=>W.label===a?.label)??null)}},[m,t,i,c,a?.label,l,o]);let[p,u]=lu(""),[h,E]=lu(null),[x,w]=lu({}),y=C=>{o({openDialog:null},C),u("")},v=(C,M)=>{r.openDialog?.name==="commandPalette"&&(M.stopPropagation(),M.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),y(()=>{C.perform({actionManager:i,event:M}),l(C),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},I=_1(C=>C.viewMode===!1&&r.viewModeEnabled?!1:typeof C.predicate=="function"?C.predicate(t.scene.getNonDeletedElements(),r,n,t):C.predicate===void 0||C.predicate),L=_1(C=>{let M=eo(C.target)||aT(C)||C.key===S.ESCAPE;if(M&&C.key!==S.ARROW_UP&&C.key!==S.ARROW_DOWN&&C.key!==S.ENTER)return;let _=Object.values(x).flat(),H=a&&!p&&I(a);if(C.key===S.ARROW_UP){C.preventDefault();let k=_.findIndex(B=>B.label===h?.label);if(H){if(k===0){E(a);return}if(h===a){let B=_[_.length-1];B&&E(B);return}}let N;k===-1?N=_.length-1:N=k===0?_.length-1:(k-1)%_.length;let A=_[N];A&&E(A);return}if(C.key===S.ARROW_DOWN){C.preventDefault();let k=_.findIndex(B=>B.label===h?.label);if(H){if(!h||k===_.length-1){E(a);return}if(h===a){let B=_[0];B&&E(B);return}}let N=(k+1)%_.length,A=_[N];A&&E(A);return}if(C.key===S.ENTER&&h&&setTimeout(()=>{v(h,C)}),!M){if(C.stopPropagation(),/^[a-zA-Z0-9]$/.test(C.key)){d?.current?.focus();return}C.preventDefault()}});return su(()=>(window.addEventListener("keydown",L,{capture:!0}),()=>window.removeEventListener("keydown",L,{capture:!0})),[L]),su(()=>{if(!s)return;let C=k=>{let N={};for(let A of k)N[A.category]?N[A.category].push(A):N[A.category]=[A];return N},M=s.filter(I).sort((k,N)=>k.order-N.order),_=!p&&a&&I(a);if(!p){w(C(_?M.filter(k=>k.label!==a?.label):M)),E(_?a:M[0]||null);return}let H=A1(p.replace(/[<>-_| ]/g,""));M=cL.filter(H,M,{extract:k=>k.haystack}).sort((k,N)=>N.score-k.score).map(k=>k.original),w(C(M)),E(M[0]??null)},[p,s,I,a]),cn(ut,{onCloseRequest:()=>y(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[hr(nu,{value:p,placeholder:b("commandPalette.search.placeholder"),onChange:C=>{u(C)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&cn("div",{className:"shortcuts-wrapper",children:[hr(cu,{shortcut:"\u2191\u2193",children:b("commandPalette.shortcuts.select")}),hr(cu,{shortcut:"\u21B5",children:b("commandPalette.shortcuts.confirm")}),hr(cu,{shortcut:R("Esc"),children:b("commandPalette.shortcuts.close")})]}),cn("div",{className:"commands",children:[a&&!p&&cn("div",{className:"command-category",children:[cn("div",{className:"command-category-title",children:[b("commandPalette.recents"),hr("div",{className:"icon",style:{marginLeft:"6px"},children:k2})]}),hr(nT,{command:a,isSelected:a.label===h?.label,onClick:C=>v(a,C),disabled:!I(a),onMouseMove:()=>E(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(x).length>0?Object.keys(x).map((C,M)=>cn("div",{className:"command-category",children:[hr("div",{className:"command-category-title",children:C}),x[C].map(_=>hr(nT,{command:_,isSelected:_.label===h?.label,onClick:H=>v(_,H),onMouseMove:()=>E(_),showShortcut:!t.device.viewport.isMobile,appState:r},_.label))]},C)):s?cn("div",{className:"no-match",children:[hr("div",{className:"icon",children:bp})," ",b("commandPalette.search.noMatch")]}):null]})]})}var nT=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return cn("div",{className:iT("command-item",{"item-selected":t,"item-disabled":r}),ref:s=>{t&&!r&&s?.scrollIntoView?.({block:"nearest"})},onClick:r?l:n,onMouseMove:r?l:o,title:r?b("commandPalette.itemNotAvailable"):"",children:[cn("div",{className:"name",children:[e.icon&&hr(Li,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&hr(cu,{shortcut:e.shortcut})]})};Xt();se();Ne();Xe();var N1=z({name:"toggleLinearEditor",category:xt.elements,label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return t.editingLinearElement?.elementId===o?.id?"labels.lineEditor.exit":"labels.lineEditor.edit"},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(n.length===1&&ne(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new X(n);return{appState:{...t,editingLinearElement:i},storeAction:D.CAPTURE}}});f();f();Js();var za=class{constructor(t=!0,r=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=r}},Fc=class e{onHistoryChangedEmitter=new or;undoStack=[];redoStack=[];get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(t,r){let o=O1.create(r,t);o.isEmpty()||(this.undoStack.push(o.inverse()),o.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new za(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,r,o){return this.perform(t,r,o,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,t))}redo(t,r,o){return this.perform(t,r,o,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,t))}perform(t,r,o,n,i){try{let a=n();if(a===null)return;let l=t,s=r,c=!1;for(;a;){try{[l,s,c]=a.applyTo(l,s,o)}finally{i(a)}if(c)break;a=n()}return[l,s]}finally{this.onHistoryChangedEmitter.trigger(new za(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let r=t.pop();return r!==void 0?r:null}static push(t,r,o){let n=r.inverse().applyLatestChanges(o);return t.push(n)}},O1=class e{constructor(t,r){this.appStateChange=t;this.elementsChange=r}static create(t,r){return new e(t,r)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(t,r,o){let[n,i]=this.elementsChange.applyTo(t,o.elements),[a,l]=this.appStateChange.applyTo(r,n);return[n,a,i||l]}applyLatestChanges(t){let r=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};ge();U();Y();Ne();f();import{useEffect as gL,useState as fL}from"react";var B1=(e,t)=>{let[r,o]=fL(t);return gL(()=>{let n=e.on(i=>{o(i)});return()=>{n()}},[e]),r};import{jsx as dT}from"react/jsx-runtime";var lT=(e,t)=>{if(!e.multiElement&&!e.resizingElement&&!e.editingElement&&!e.draggingElement){let r=t();if(!r)return{storeAction:D.NONE};let[o,n]=r,i=Array.from(o.values());return{appState:n,elements:i,storeAction:D.UPDATE}}return{storeAction:D.NONE}},sT=(e,t)=>({name:"undo",label:"buttons.undo",icon:rf,trackEvent:{category:"history"},viewMode:!1,perform:(r,o)=>lT(o,()=>e.undo($(r),o,t.snapshot)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.key.toLowerCase()===S.Z&&!r.shiftKey,PanelComponent:({updateData:r,data:o})=>{let{isUndoStackEmpty:n}=B1(e.onHistoryChangedEmitter,new za);return dT(ce,{type:"button",icon:rf,"aria-label":b("buttons.undo"),onClick:r,size:o?.size||"medium",disabled:n})}}),cT=(e,t)=>({name:"redo",label:"buttons.redo",icon:of,trackEvent:{category:"history"},viewMode:!1,perform:(r,o)=>lT(o,()=>e.redo($(r),o,t.snapshot)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.shiftKey&&r.key.toLowerCase()===S.Z||dd&&r.ctrlKey&&!r.shiftKey&&r.key===S.Y,PanelComponent:({updateData:r,data:o})=>{let{isRedoStackEmpty:n}=B1(e.onHistoryChangedEmitter,new za);return dT(ce,{type:"button",icon:of,"aria-label":b("buttons.redo"),onClick:r,size:o?.size||"medium",disabled:n})}});f();U();import{jsx as bL}from"react/jsx-runtime";var F1=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&Ee(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},du=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(Wo(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in r?r[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return F1(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,l,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();F1(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{F1(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return bL(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};Xe();Ir();wi();Y();yl();be();io();Xt();Ue();Mn();se();f();var z1=e=>{let t=Array.from(e.values());return{x:mT(t,r=>r.x)/t.length,y:mT(t,r=>r.y)/t.length}},H1=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),mT=(e,t)=>e.reduce((r,o)=>r+t(o),0);mr();ge();va();Ft();$e();ni();ip();xg();Hd();U();ec();f();import EL from"clsx";import xL from"react";import{jsx as is,jsxs as yL}from"react/jsx-runtime";var gr="separator",pT=xL.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Jl(),a=Ii(),l=t.reduce((s,c)=>(c&&(c===gr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return is(Ip,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:is("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===gr)return!l[c-1]||l[c-1]===gr?null:is("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=b(s.label(a,i,e.app)):m=b(s.label)),is("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:yL("button",{className:EL("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[is("div",{className:"context-menu-item__label",children:m}),is("kbd",{className:"context-menu-item__shortcut",children:d?kt(d):""})]})},c)})})})});f();Y();be();import Xc from"clsx";import g8 from"react";$e();U();f();import wL,{useState as vL}from"react";import{Fragment as TL,jsx as U1}from"react/jsx-runtime";var uT=({children:e,onClose:t})=>{let[r,o]=vL(!!e),{container:n}=Ut(),i=wL.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return U1(TL,{children:r&&U1(ut,{size:"small",onCloseRequest:i,title:b("errorDialog.title"),children:U1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as PL,useRef as DL,useState as Di}from"react";wi();Y();Cr();Dn();$e();ya();f();import SL from"clsx";import{jsx as hT,jsxs as IL}from"react/jsx-runtime";var mu=function({onChange:e,value:t,choices:r,name:o}){return hT("div",{className:"RadioGroup",children:r.map(n=>IL("div",{className:SL("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[hT("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import CL from"clsx";import{jsx as gT}from"react/jsx-runtime";var zc=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>gT("div",{className:CL("Switch",{toggled:r,disabled:n}),children:gT("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as AL,useState as kL}from"react";import ML from"clsx";oi();U();import{jsx as G1,jsxs as LL}from"react/jsx-runtime";var dn=AL(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s},c)=>{let[d,m]=kL(!1),p=async u=>{let h=r?.(u);if(Wo(h))try{m(!0),await h}catch(E){if(E instanceof $o)console.warn(E);else throw E}finally{m(!1)}};return G1("button",{className:ML("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":l},s),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:LL("div",{className:"ExcButton__contents",children:[d&&G1(Yt,{}),t&&G1("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});U();import{jsx as nt,jsxs as _i}from"react/jsx-runtime";var _L="filter"in document.createElement("canvas").getContext("2d"),RL=()=>_i("div",{children:[nt("h3",{children:b("canvasError.cannotShowPreview")}),nt("p",{children:nt("span",{children:b("canvasError.canvasTooBig")})}),_i("em",{children:["(",b("canvasError.canvasTooBigTip"),")"]})]}),NL=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=Ve(t,e),[l,s]=Di(i),[c,d]=Di(a),[m,p]=Di(e.exportBackground),[u,h]=Di(e.exportWithDarkMode),[E,x]=Di(e.exportEmbedScene),[w,y]=Di(e.exportScale),v=DL(null),[I,L]=Di(null),{exportedElements:C,exportingFrame:M}=Da(t,e,c);return PL(()=>{let _=v.current;if(!_)return;let H=_.offsetWidth,k=_.offsetHeight;H&&vi({elements:C,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:u,exportScale:w,exportEmbedScene:E},files:r,exportPadding:To,maxWidthOrHeight:Math.max(H,k),exportingFrame:M}).then(N=>(L(null),Rn(N).then(()=>{_.replaceChildren(N)}).catch(A=>{throw A.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):A}))).catch(N=>{console.error(N),L(N)})},[e,r,C,M,l,m,u,w,E]),_i("div",{className:"ImageExportModal",children:[nt("h3",{children:b("imageExportDialog.header")}),_i("div",{className:"ImageExportModal__preview",children:[nt("div",{className:"ImageExportModal__preview__canvas",ref:v,children:I&&nt(RL,{})}),nt("div",{className:"ImageExportModal__preview__filename",children:!fi&&nt("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:_=>{s(_.target.value),o.executeAction(Wf,"ui",_.target.value)}})})]}),_i("div",{className:"ImageExportModal__settings",children:[nt("h3",{children:b("imageExportDialog.header")}),a&&nt(Hc,{label:b("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:nt(zc,{name:"exportOnlySelected",checked:c,onChange:_=>{d(_)}})}),nt(Hc,{label:b("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:nt(zc,{name:"exportBackgroundSwitch",checked:m,onChange:_=>{p(_),o.executeAction(Vf,"ui",_)}})}),_L&&nt(Hc,{label:b("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:nt(zc,{name:"exportDarkModeSwitch",checked:u,onChange:_=>{h(_),o.executeAction(Bv,"ui",_)}})}),nt(Hc,{label:b("imageExportDialog.label.embedScene"),tooltip:b("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:nt(zc,{name:"exportEmbedSwitch",checked:E,onChange:_=>{x(_),o.executeAction(Mp,"ui",_)}})}),nt(Hc,{label:b("imageExportDialog.label.scale"),name:"exportScale",children:nt(mu,{name:"exportScale",value:w,onChange:_=>{y(_),o.executeAction(Ov,"ui",_)},choices:Ja.map(_=>({value:_,label:`${_}\xD7`}))})}),_i("div",{className:"ImageExportModal__settings__buttons",children:[nt(dn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToPng"),onClick:()=>n(gd.png,C,{exportingFrame:M}),icon:yf,children:b("imageExportDialog.button.exportToPng")}),nt(dn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToSvg"),onClick:()=>n(gd.svg,C,{exportingFrame:M}),icon:yf,children:b("imageExportDialog.button.exportToSvg")}),(kl||bn)&&nt(dn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(gd.clipboard,C,{exportingFrame:M}),icon:up,children:b("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Hc=({label:e,children:t,tooltip:r,name:o})=>_i("div",{className:"ImageExportModal__settings__setting",title:e,children:[_i("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&nt(Xr,{label:r,long:!0,children:y2})]}),nt("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),fT=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Di(()=>({appStateSnapshot:Vo(t),elementsSnapshot:Vo(e)}));return nt(ut,{onCloseRequest:i,size:"wide",title:!1,children:nt(NL,{elementsSnapshot:s,appStateSnapshot:l,files:r,actionManager:o,onExportImage:n,name:a})})};f();import OL from"clsx";import{jsx as BL}from"react/jsx-runtime";var pu=({children:e,side:t,className:r})=>BL("div",{className:OL("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();se();U();Ir();import{jsx as bT}from"react/jsx-runtime";var FL=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if(Sr(e))return b("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?b("hints.linearElementMulti"):b("hints.linearElement");if(n.type==="freedraw")return b("hints.freeDraw");if(n.type==="text")return b("hints.text");if(n.type==="embeddable")return b("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return b("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let d=c[0];return ne(d)&&d.points.length===2?b("hints.lockAngle"):to(d)?b("hints.resizeImage"):b("hints.resize")}if(a&&l==="mouse")return b("hints.rotate");if(c.length===1&&G(c[0]))return b("hints.text_selected");if(e.editingElement&&G(e.editingElement))return b("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return b("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return b("hints.disableSnapping");if(!c.length&&!t)return b("hints.canvasPanning");if(c.length===1){if(ne(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?b("hints.lineEditor_pointSelected"):b("hints.lineEditor_nothingSelected"):b("hints.lineEditor_info");if(!e.draggingElement&&Yo(c[0]))return b("hints.bindTextToElement")}}return null},uu=({appState:e,isMobile:t,device:r,app:o})=>{let n=FL({appState:e,isMobile:t,device:r,app:o});return n?(n=R(n),bT("div",{className:"HintViewer",children:bT("span",{children:n})})):null};f();import zL from"clsx";import{jsx as xT,jsxs as UL}from"react/jsx-runtime";var HL="medium",ET={CHECKED:Rl,UNCHECKED:Aa},hu=e=>UL("label",{className:zL("ToolIcon ToolIcon__lock",`ToolIcon_size_${HL}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[xT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),xT("div",{className:"ToolIcon__icon",children:e.checked?ET.CHECKED:ET.UNCHECKED})]});f();be();$e();f();import{Fragment as GL,jsx as yT,jsxs as WL}from"react/jsx-runtime";var Ri=({heading:e,children:t,...r})=>{let{id:o}=Ut(),n=yT("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:b(`headings.${e}`)});return yT("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):WL(GL,{children:[n,t]})})};f();be();U();var Bo=4,mn=6,wT="rgba(0,0,0,0.3)",vT=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=Se(e),s=t/o.zoom.value,c=r/o.zoom.value,d=t-s,m=r-c,p={top:parseInt(vs("sat"))||0,bottom:parseInt(vs("sab"))||0,left:parseInt(vs("sal"))||0,right:parseInt(vs("sar"))||0},u=fn().rtl,h=-o.scrollX+d/2+p.left,E=-o.scrollY+m/2+p.top,x=h+s-p.right,w=E+c-p.bottom,y=Math.min(n,h),v=Math.min(i,E),I=Math.max(a,x),L=Math.max(l,w);return{horizontal:h===y&&x===I?null:{x:Math.max(p.left,Bo)+(h-y)/(I-y)*t,y:r-mn-Math.max(Bo,p.bottom),width:(x-h)/(I-y)*t-Math.max(Bo*2,p.left+p.right),height:mn},vertical:E===v&&w===L?null:{x:u?Math.max(p.left,Bo):t-mn-Math.max(p.right,Bo),y:(E-v)/(L-v)*r+Math.max(p.top,Bo),width:mn,height:(w-E)/(L-v)*r-Math.max(Bo*2,p.top+p.bottom)}}},W1=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();import VL from"clsx";import{jsx as TT,jsxs as KL}from"react/jsx-runtime";var YL="medium",gu=e=>e.penDetected?KL("label",{className:VL("ToolIcon ToolIcon__penMode",`ToolIcon_size_${YL}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[TT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),TT("div",{className:"ToolIcon__icon",children:yw})]}):null;f();lt();$e();import{Fragment as ST,jsx as et,jsxs as Zr}from"react/jsx-runtime";var fu=e=>{let t=Se(e.elements),r=Ca(e.elements,e.appState),o=Se(r);return et("div",{className:"Stats",children:Zr(qt,{padding:2,children:[et("div",{className:"close",onClick:e.onClose,children:co}),et("h3",{children:b("stats.title")}),et("table",{children:Zr("tbody",{children:[et("tr",{children:et("th",{colSpan:2,children:b("stats.scene")})}),Zr("tr",{children:[et("td",{children:b("stats.elements")}),et("td",{children:e.elements.length})]}),Zr("tr",{children:[et("td",{children:b("stats.width")}),et("td",{children:Math.round(t[2])-Math.round(t[0])})]}),Zr("tr",{children:[et("td",{children:b("stats.height")}),et("td",{children:Math.round(t[3])-Math.round(t[1])})]}),r.length===1&&et("tr",{children:et("th",{colSpan:2,children:b("stats.element")})}),r.length>1&&Zr(ST,{children:[et("tr",{children:et("th",{colSpan:2,children:b("stats.selected")})}),Zr("tr",{children:[et("td",{children:b("stats.elements")}),et("td",{children:r.length})]})]}),r.length>0&&Zr(ST,{children:[Zr("tr",{children:[et("td",{children:"x"}),et("td",{children:Math.round(o[0])})]}),Zr("tr",{children:[et("td",{children:"y"}),et("td",{children:Math.round(o[1])})]}),Zr("tr",{children:[et("td",{children:b("stats.width")}),et("td",{children:Math.round(o[2]-o[0])})]}),Zr("tr",{children:[et("td",{children:b("stats.height")}),et("td",{children:Math.round(o[3]-o[1])})]})]}),r.length===1&&Zr("tr",{children:[et("td",{children:b("stats.angle")}),et("td",{children:`${Math.round(r[0].angle*180/Math.PI)}\xB0`})]}),e.renderCustomStats?.(e.elements,e.appState)]})})]})})};f();import $L from"clsx";ge();import{jsx as XL}from"react/jsx-runtime";var bu=e=>XL(ce,{className:$L("Shape",{fillable:!1}),type:"radio",icon:pp,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Ir();import{Fragment as ZL,jsx as Wt,jsxs as Ni}from"react/jsx-runtime";var IT=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:h,MainMenuTunnel:E,DefaultSidebarTriggerTunnel:x}=ot(),w=()=>Ni(pu,{side:"top",className:"App-top-bar",children:[m&&Wt(h.Out,{}),Wt(Ri,{heading:"shapes",children:v=>Wt(Gt.Col,{gap:4,align:"center",children:Ni(Gt.Row,{gap:1,className:"App-toolbar-container",children:[Ni(qt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,Wt(Gt.Row,{gap:1,children:Wt(au,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Ni("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&Wt(x.Out,{}),Wt(gu,{checked:e.penMode,onChange:()=>a(null),title:b("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Wt(hu,{checked:e.activeTool.locked,onChange:n,title:b("toolBar.lock"),isMobile:!0}),Wt(bu,{checked:Do(e),onChange:()=>i(),title:b("toolBar.hand"),isMobile:!0})]})]})})}),Wt(uu,{appState:e,isMobile:!0,device:d,app:u})]}),y=()=>e.viewModeEnabled?Wt("div",{className:"App-toolbar-content",children:Wt(E.Out,{})}):Ni("div",{className:"App-toolbar-content",children:[Wt(E.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return Ni(ZL,{children:[c(),!e.viewModeEnabled&&w(),!e.openMenu&&e.showStats&&Wt(fu,{appState:e,setAppState:o,elements:t,onClose:()=>{r.executeAction(Ai)},renderCustomStats:s}),Wt("div",{className:"App-bottom-bar",style:{marginBottom:mn+Bo*2,marginLeft:mn+Bo*2,marginRight:mn+Bo*2},children:Ni(qt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&Sa(e,t)?Wt(Ri,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Wt(iu,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,Ni("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Wt("button",{className:"scroll-back-to-content",onClick:()=>{o(v=>({...Qo(t,v)}))},children:b("buttons.scrollBackToContent")})]})]})})]})};f();import jL from"open-color";import qL,{useLayoutEffect as JL,useRef as QL,useState as eP}from"react";Ag();mc();import{jsx as Uc,jsxs as tP}from"react/jsx-runtime";var CT=e=>{let t=QL(null),[r,o]=eP(null);return JL(()=>{if(!e.spreadsheet)return;let n=by(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await Il(n,{exportBackground:!1,viewBackgroundColor:jL.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Uc("button",{className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:Uc("div",{ref:t})})},AT=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=kr(),n=qL.useCallback(()=>{r&&r()},[r]),i=(a,l)=>{o(l),Ee("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Uc(ut,{size:"small",onCloseRequest:n,title:b("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:tP("div",{className:"container",children:[Uc(CT,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),Uc(CT,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import rP from"react";ge();U();wi();Y();import{Fragment as MT,jsx as K,jsxs as jr}from"react/jsx-runtime";var oP=()=>jr("div",{className:"HelpDialog__header",children:[jr("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:tf}),b("helpDialog.documentation")]}),jr("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:tf}),b("helpDialog.blog")]}),jr("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:sp}),b("helpDialog.github")]}),jr("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[K("div",{className:"HelpDialog__link-icon",children:H2}),"YouTube"]})]}),nP=e=>jr(MT,{children:[K("h3",{children:e.title}),K("div",{className:"HelpDialog__islands-container",children:e.children})]}),V1=e=>jr("div",{className:`HelpDialog__island ${e.className}`,children:[K("h4",{className:"HelpDialog__island-title",children:e.caption}),K("div",{className:"HelpDialog__island-content",children:e.children})]});function*iP(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var aP=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),J=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>K(lP,{children:aP(a)},a)));return jr("div",{className:"HelpDialog__shortcut",children:[K("div",{children:e}),K("div",{className:"HelpDialog__key-container",children:[...iP(o,r?b("helpDialog.or"):null)]})]})},lP=e=>K("kbd",{className:"HelpDialog__key",...e}),kT=({onClose:e})=>{let t=rP.useCallback(()=>{e&&e()},[e]);return K(MT,{children:jr(ut,{onCloseRequest:t,title:b("helpDialog.title"),className:"HelpDialog",children:[K(oP,{}),jr(nP,{title:b("helpDialog.shortcuts"),children:[jr(V1,{className:"HelpDialog__island--tools",caption:b("helpDialog.tools"),children:[K(J,{label:b("toolBar.hand"),shortcuts:[S.H]}),K(J,{label:b("toolBar.selection"),shortcuts:[S.V,S[1]]}),K(J,{label:b("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),K(J,{label:b("toolBar.diamond"),shortcuts:[S.D,S[3]]}),K(J,{label:b("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),K(J,{label:b("toolBar.arrow"),shortcuts:[S.A,S[5]]}),K(J,{label:b("toolBar.line"),shortcuts:[S.L,S[6]]}),K(J,{label:b("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),K(J,{label:b("toolBar.text"),shortcuts:[S.T,S[8]]}),K(J,{label:b("toolBar.image"),shortcuts:[S[9]]}),K(J,{label:b("toolBar.eraser"),shortcuts:[S.E,S[0]]}),K(J,{label:b("toolBar.frame"),shortcuts:[S.F]}),K(J,{label:b("toolBar.laser"),shortcuts:[S.K]}),K(J,{label:b("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),K(J,{label:b("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),K(J,{label:b("helpDialog.editText"),shortcuts:[R("Enter")]}),K(J,{label:b("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),K(J,{label:b("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),K(J,{label:b("helpDialog.curvedArrow"),shortcuts:["A",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),K(J,{label:b("helpDialog.curvedLine"),shortcuts:["L",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),K(J,{label:b("toolBar.lock"),shortcuts:[S.Q]}),K(J,{label:b("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),K(J,{label:b("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),jr(V1,{className:"HelpDialog__island--view",caption:b("helpDialog.view"),children:[K(J,{label:b("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),K(J,{label:b("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),K(J,{label:b("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),K(J,{label:b("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),K(J,{label:b("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),K(J,{label:b("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),K(J,{label:b("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),K(J,{label:b("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),K(J,{label:b("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),K(J,{label:b("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),K(J,{label:b("labels.viewMode"),shortcuts:[R("Alt+R")]}),K(J,{label:b("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),K(J,{label:b("stats.title"),shortcuts:[R("Alt+/")]}),K(J,{label:b("commandPalette.title"),shortcuts:bn?[kt("commandPalette")]:[kt("commandPalette"),kt("commandPalette",1)]})]}),jr(V1,{className:"HelpDialog__island--editor",caption:b("helpDialog.editor"),children:[K(J,{label:b("labels.moveCanvas"),shortcuts:[R(`Space+${b("helpDialog.drag")}`),R(`Wheel+${b("helpDialog.drag")}`)],isOr:!0}),K(J,{label:b("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),K(J,{label:b("labels.delete"),shortcuts:[R("Delete")]}),K(J,{label:b("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),K(J,{label:b("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),K(J,{label:b("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),K(J,{label:b("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),K(J,{label:b("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),K(J,{label:b("labels.multiSelect"),shortcuts:[R(`Shift+${b("helpDialog.click")}`)]}),K(J,{label:b("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.click")}`)]}),K(J,{label:b("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${b("helpDialog.drag")}`)]}),(kl||bn)&&K(J,{label:b("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),K(J,{label:b("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),K(J,{label:b("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),K(J,{label:b("labels.sendToBack"),shortcuts:[ar?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),K(J,{label:b("labels.bringToFront"),shortcuts:[ar?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),K(J,{label:b("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),K(J,{label:b("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),K(J,{label:b("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),K(J,{label:b("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),K(J,{label:b("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),K(J,{label:b("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),K(J,{label:b("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${b("helpDialog.drag")}`)]}),K(J,{label:b("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),K(J,{label:b("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),K(J,{label:b("buttons.redo"),shortcuts:dd?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),K(J,{label:b("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),K(J,{label:b("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),K(J,{label:b("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),K(J,{label:b("labels.flipVertical"),shortcuts:[R("Shift+V")]}),K(J,{label:b("labels.showStroke"),shortcuts:[R("S")]}),K(J,{label:b("labels.showBackground"),shortcuts:[R("G")]}),K(J,{label:b("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),K(J,{label:b("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import Gc,{useLayoutEffect as sP}from"react";import LT from"clsx";import*as ls from"@radix-ui/react-popover";U();Y();import{jsx as Wn,jsxs as as}from"react/jsx-runtime";var cP=4,dP=8,mP=({shouldWrap:e,children:t,username:r})=>e?Wn(Xr,{label:r||"Unknown user",children:t}):Wn(Gc.Fragment,{children:t}),Y1=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Wn(mP,{username:t.username,shouldWrap:n,children:l},r)},pP=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Eu=Gc.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=Nt(),i=new Map;r.forEach((x,w)=>{let y=x.id||w;i.set(y,{...x,socketId:w})});let a=Array.from(i.values()).filter(x=>x.username?.trim()),[l,s]=Gc.useState(""),c=Gc.useRef(null);sP(()=>{if(c.current){let x=y=>{let v=Math.max(1,Math.min(8,Math.floor(y/38)));m(v)};if(x(c.current.clientWidth),!gs)return;let w=new ResizeObserver(y=>{for(let v of y){let{width:I}=v.contentRect;x(I)}});return w.observe(c.current),()=>{w.disconnect()}}},[]);let[d,m]=Gc.useState(cP),u=l.trim().toLowerCase()?a.filter(x=>x.username?.toLowerCase().includes(l)):a,E=a.slice(0,d-1).map(x=>Y1({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===o}));return t?Wn("div",{className:LT("UserList UserList_mobile",e),children:a.map(x=>Y1({actionManager:n,collaborator:x,socketId:x.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:x.socketId===o}))}):Wn("div",{className:"UserList-wrapper",ref:c,children:as("div",{className:LT("UserList",e),style:{"--max-avatars":d},children:[E,a.length>d-1&&as(ls.Root,{onOpenChange:x=>{x||s("")},children:[as(ls.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Wn(ls.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:as(qt,{style:{overflow:"hidden"},children:[a.length>=dP&&as("div",{className:"UserList__search-wrapper",children:[bp,Wn("input",{className:"UserList__search",type:"text",placeholder:b("userList.search.placeholder"),value:l,onChange:x=>{s(x.target.value)}})]}),as("div",{className:"dropdown-menu UserList__collaborators",children:[u.length===0&&Wn("div",{className:"UserList__collaborators__empty",children:b("userList.search.empty")}),Wn("div",{className:"UserList__hint",children:b("userList.hint.text")}),u.map(x=>Y1({actionManager:n,collaborator:x,socketId:x.socketId,withName:!0,isBeingFollowed:x.socketId===o}))]})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!Je(n,i,pP))return!1}return!0});f();import hP from"react";f();import K1 from"open-color";import{jsx as uP}from"react/jsx-runtime";var $1=({children:e,color:t})=>uP("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":K1[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":K1[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":K1[t][9]},children:e});Dn();U();import{Fragment as fP,jsx as Fo,jsxs as xu}from"react/jsx-runtime";var gP=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Fo("div",{className:"ExportDialog ExportDialog--json",children:xu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&xu($1,{color:"lime",children:[Fo("div",{className:"Card-icon",children:_w}),Fo("h2",{children:b("exportDialog.disk_title")}),xu("div",{className:"Card-details",children:[b("exportDialog.disk_details"),!fi&&n.renderAction("changeProjectName")]}),Fo(ce,{className:"Card-button",type:"button",title:b("exportDialog.disk_button"),"aria-label":b("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Lc,"ui")}})]}),s&&xu($1,{color:"pink",children:[Fo("div",{className:"Card-icon",children:vc}),Fo("h2",{children:b("exportDialog.link_title")}),Fo("div",{className:"Card-details",children:b("exportDialog.link_details")}),Fo(ce,{className:"Card-button",type:"button",title:b("exportDialog.link_button"),"aria-label":b("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ee("export","link",`ui (${GE()})`),await s(e,t,o),l()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},PT=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let l=hP.useCallback(()=>{a({openDialog:null})},[a]);return Fo(fP,{children:t.openDialog?.name==="jsonExport"&&Fo(ut,{onCloseRequest:l,title:b("buttons.export"),children:Fo(gP,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:l,exportOpts:n,canvas:i})})})};f();import yu from"clsx";f();import{jsx as bP}from"react/jsx-runtime";var DT=e=>bP("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${b("helpDialog.title")} \u2014 ?`,"aria-label":b("helpDialog.title"),children:Ol});import{jsx as pn,jsxs as X1}from"react/jsx-runtime";var _T=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ot(),a=Me(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return X1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[pn("div",{className:yu("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:pn(Gt.Col,{gap:2,children:X1(Ri,{heading:"canvasActions",children:[pn(Q3,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&pn(eT,{renderAction:t.renderAction,className:yu("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&pn(rT,{renderAction:t.renderAction,className:yu("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),pn(n.Out,{}),pn("div",{className:yu("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:X1("div",{style:{position:"relative"},children:[o&&pn(i.Out,{}),pn(DT,{onClick:()=>t.executeAction(Na)})]})}),pn(tT,{actionManager:t,showExitZenModeBtn:r})]})},RT=_T;_T.displayName="Footer";f();import{useEffect as VT,useLayoutEffect as YT,useRef as ob,useState as IP,forwardRef as KT,useImperativeHandle as CP,useCallback as GT}from"react";import{atom as AP,useSetAtom as kP}from"jotai";f();import EP from"react";var wu=EP.createContext({});f();import xP from"clsx";import{useContext as yP}from"react";import{jsx as Z1,jsxs as NT}from"react/jsx-runtime";var j1=({children:e,className:t})=>{let r=Me(),o=yP(wu),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return NT("div",{className:xP("sidebar__header",t),"data-testid":"sidebar-header",children:[e,NT("div",{className:"sidebar__header__buttons",children:[n&&Z1(Xr,{label:b("labels.sidebarLock"),children:Z1(ln,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":b("labels.sidebarLock"),children:dw})}),Z1(ln,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":b("buttons.close"),children:co})]})]})};j1.displayName="SidebarHeader";import MP from"clsx";U();ge();Y();f();import wP from"clsx";import{jsx as q1,jsxs as OT}from"react/jsx-runtime";var J1=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:l})=>{let s=Oe(),c=_e();return OT("label",{title:o,className:"sidebar-trigger__label-element",children:[q1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;s({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),OT("div",{className:wP("sidebar-trigger",a),style:l,children:[r&&q1("div",{children:r}),n&&q1("div",{className:"sidebar-trigger__label",children:n})]})]})};J1.displayName="SidebarTrigger";f();import*as BT from"@radix-ui/react-tabs";import{jsx as vP}from"react/jsx-runtime";var Q1=({children:e,...t})=>vP(BT.List,{className:"sidebar-triggers",...t,children:e});Q1.displayName="SidebarTabTriggers";f();import*as zT from"@radix-ui/react-tabs";import{jsx as FT}from"react/jsx-runtime";var eb=({children:e,tab:t,onSelect:r,...o})=>FT(zT.Trigger,{value:t,asChild:!0,onSelect:r,children:FT("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});eb.displayName="SidebarTabTrigger";f();import*as HT from"@radix-ui/react-tabs";import{jsx as TP}from"react/jsx-runtime";var tb=({children:e,...t})=>{let r=_e(),o=Oe();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return TP(HT.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};tb.displayName="SidebarTabs";f();import*as UT from"@radix-ui/react-tabs";import{jsx as SP}from"react/jsx-runtime";var rb=({tab:e,children:t,...r})=>SP(UT.Content,{...r,value:e,"data-testid":e,children:t});rb.displayName="SidebarTab";import{jsx as WT}from"react/jsx-runtime";import{createElement as LP}from"react";var Wc=AP(!1),$T=KT(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==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=Oe(),s=kP(Wc,ze);YT(()=>(s(!!o),()=>{s(!1)}),[s,o]);let c=ob({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=tl(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=ob(null);CP(a,()=>d.current);let m=Me(),p=GT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Wl(d,GT(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),VT(()=>{let u=h=>{h.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),WT(qt,{...i,className:MP("sidebar",{"sidebar--docked":o},n),ref:d,children:WT(wu.Provider,{value:c.current,children:t})})});$T.displayName="SidebarInner";var Vn=Object.assign(KT((e,t)=>{let r=_e(),{onStateChange:o}=e,n=ob(r.openSidebar);VT(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=IP(!1);return YT(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?LP($T,{...e,ref:t,key:e.name}):null}),{Header:j1,TabTriggers:Q1,TabTrigger:eb,Tabs:tb,Tab:rb,Trigger:J1});Vn.displayName="Sidebar";import{Provider as f8,useAtom as b8,useAtomValue as E8}from"jotai";f();var ab={};Ju(ab,{ChangeCanvasBackground:()=>iS,ClearCanvas:()=>oS,CommandPalette:()=>tS,Export:()=>aS,Help:()=>rS,LiveCollaborationTrigger:()=>sS,LoadScene:()=>JT,SaveAsImage:()=>eS,SaveToActiveFile:()=>QT,Socials:()=>lS,ToggleTheme:()=>nS});f();import _P from"clsx";import{useSetAtom as RP}from"jotai";f();import{atom as PP}from"jotai";var nb=PP({active:!1});async function XT({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{Jt.set(nb,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as DP,jsx as ib,jsxs as ZT}from"react/jsx-runtime";var jT=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=Me();return ZT(DP,{children:[ZT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[ib("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),ib(mu,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&ib("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};jT.displayName="DropdownMenuItemContentRadio";var qT=jT;Y();import{Fragment as NP,jsx as Vt,jsxs as cS}from"react/jsx-runtime";var JT=()=>{let{t:e}=St(),t=Nt(),r=Ii();return t.isActionEnabled(Kl)?Vt(go,{icon:Bl,onSelect:async()=>{(!r.length||await XT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Vt(ur,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>Vt("strong",{children:n}),br:()=>Vt("br",{})})}))&&t.executeAction(Kl)},"data-testid":"load-button",shortcut:kt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};JT.displayName="LoadScene";var QT=()=>{let{t:e}=St(),t=Nt();return t.isActionEnabled(Lp)?Vt(go,{shortcut:kt("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(Lp),icon:Lw,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};QT.displayName="SaveToActiveFile";var eS=()=>{let e=Oe(),{t}=St();return Vt(go,{icon:dp,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:kt("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};eS.displayName="SaveAsImage";var tS=e=>{let t=Oe(),{t:r}=St();return Vt(go,{icon:Ep,"data-testid":"command-palette-button",onSelect:()=>{Ee("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:kt("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};tS.displayName="CommandPalette";var rS=()=>{let{t:e}=St(),t=Nt();return Vt(go,{"data-testid":"help-menu-item",icon:Ol,onSelect:()=>t.executeAction(Na),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};rS.displayName="Help";var oS=()=>{let{t:e}=St(),t=RP(Fa,ze);return Nt().isActionEnabled(Hn)?Vt(go,{icon:Oo,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};oS.displayName="ClearCanvas";var nS=e=>{let{t}=St(),r=_e(),o=Nt(),n=kt("toggleTheme");return o.isActionEnabled(Pa)?e?.allowSystemTheme?Vt(qT,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ae.LIGHT,label:wc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:ae.DARK,label:yc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:z2,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):Vt(go,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===ae.DARK?ae.LIGHT:ae.DARK);else return o.executeAction(Pa)},icon:r.theme===ae.DARK?wc:yc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===ae.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===ae.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};nS.displayName="ToggleTheme";var iS=()=>{let{t:e}=St(),t=_e(),r=Nt(),o=ki();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:cS("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:r.renderAction("changeViewBackgroundColor")})]})};iS.displayName="ChangeCanvasBackground";var aS=()=>{let{t:e}=St(),t=Oe();return Vt(go,{icon:ka,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};aS.displayName="Export";var lS=()=>{let{t:e}=St();return cS(NP,{children:[Vt(rs,{icon:sp,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Vt(rs,{icon:kw,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Vt(rs,{icon:Aw,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};lS.displayName="Socials";var sS=({onSelect:e,isCollaborating:t})=>{let{t:r}=St();return Vt(go,{"data-testid":"collab-button",icon:mp,className:_P({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};sS.displayName="LiveCollaborationTrigger";f();import{atom as OP,useAtom as BP}from"jotai";import{useLayoutEffect as FP,useRef as zP}from"react";import{jsx as HP}from"react/jsx-runtime";var Yn=(e,t)=>{let r=OP(0),o=n=>{let{jotaiScope:i}=ot(),[,a]=BP(r,i),l=zP({preferHost:!1,counter:0});return FP(()=>{let s=l.current;return a(c=>{let d=c+1;return s.counter=d,d}),()=>{a(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:HP(t,{...n})};return o.displayName=e,o};U();import{jsx as vu,jsxs as lb}from"react/jsx-runtime";var UP=Object.assign(Yn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=ot(),o=Me(),n=_e(),i=Oe(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return vu(r.In,{children:lb(Fe,{open:n.openMenu==="canvas",children:[vu(Fe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:lp}),lb(Fe.Content,{onClickOutside:a,onSelect:ti(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&lb("fieldset",{className:"UserList-Wrapper",children:[vu("legend",{children:b("labels.collaborators")}),vu(Eu,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Fe.Trigger,Item:Fe.Item,ItemLink:Fe.ItemLink,ItemCustom:Fe.ItemCustom,Group:Fe.Group,Separator:Fe.Separator,DefaultItems:ab}),fr=UP;f();import{useAtom as YP}from"jotai";f();import{jsx as ss,jsxs as VP}from"react/jsx-runtime";var Tu=({title:e,children:t,actionLabel:r,onClick:o})=>VP("div",{className:"OverwriteConfirm__Actions__Action",children:[ss("h4",{children:e}),ss("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),ss(dn,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),GP=()=>{let{t:e}=St(),t=Nt(),r=Oe();return ss(Tu,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(Mp,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},WP=()=>{let{t:e}=St(),t=Nt();return ss(Tu,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(Lc,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},sb=Object.assign(({children:e})=>ss("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:GP,SaveToDisk:WP});import{jsx as Oi,jsxs as dS}from"react/jsx-runtime";var Su=Object.assign(Yn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=ot(),[r,o]=YP(nb,ze);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return Oi(t.In,{children:Oi(ut,{onCloseRequest:n,title:!1,size:916,children:dS("div",{className:"OverwriteConfirm",children:[Oi("h3",{children:r.title}),dS("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[Oi("div",{className:"OverwriteConfirm__Description__icon",children:w2}),Oi("div",{children:r.description}),Oi("div",{className:"OverwriteConfirm__Description__spacer"}),Oi(dn,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),Oi(sb,{children:e})]})})})}),{Actions:sb,Action:Tu});Ir();f();Y();import KP from"clsx";U();import{jsx as Bi,jsxs as mS}from"react/jsx-runtime";import{createElement as $P}from"react";var pS=Yn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=ot();return Bi(t.In,{children:Bi(Vn.Trigger,{...e,className:"default-sidebar-trigger",name:Nr.name})})});pS.displayName="DefaultSidebarTrigger";var uS=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=ot();return Bi(r.In,{children:Bi(Vn.TabTriggers,{...t,children:e})})};uS.displayName="DefaultTabTriggers";var Iu=Object.assign(Yn("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=_e(),a=Oe(),{DefaultSidebarTabTriggersTunnel:l}=ot();return $P(Vn,{...n,name:"default",key:"default",className:KP("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:ti(r,s=>{a({defaultSidebarDockedPreference:s})})},mS(Vn.Tabs,{children:[mS(Vn.Header,{children:[n.__fallback&&Bi("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:b("toolBar.library")}),Bi(l.Out,{})]}),Bi(Vn.Tab,{tab:ws,children:Bi(Z3,{})}),e]}))}),{Trigger:pS,TabTriggers:uS});Ue();Xo();ni();f();import XP from"clsx";import{jsx as hS,jsxs as jP}from"react/jsx-runtime";var ZP="small",gS=e=>jP("label",{className:XP("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${ZP}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[hS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),hS("div",{className:"ToolIcon__icon",children:fp})]});f();import{useState as yS}from"react";ge();f();import{jsx as qP}from"react/jsx-runtime";var cs=e=>qP("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as bS from"@radix-ui/react-tabs";import{useRef as fS}from"react";U();import{jsx as JP}from"react/jsx-runtime";var ES=e=>{let t=Oe(),r=fS(null),o=fS(0);return JP(bS.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&Ss(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&Ss(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};ES.displayName="TTDDialogTabs";var Cu=ES;f();import*as xS from"@radix-ui/react-tabs";import{jsx as QP}from"react/jsx-runtime";var ds=({tab:e,children:t,...r})=>QP(xS.Content,{...r,value:e,children:t});ds.displayName="TTDDialogTab";import{jsx as _r,jsxs as Vc}from"react/jsx-runtime";var wS=e=>{let[t,r]=yS(e.openAIKey||""),[o,n]=yS(e.isPersisted),i=_e(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:_r(ut,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:Vc("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",_r("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",color:"#000",background:"pink"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:_r(Cu,{dialog:"settings",tab:i.openDialog.tab,children:Vc(ds,{tab:"diagram-to-code",children:[Vc(cs,{children:["For the diagram-to-code feature we use"," ",_r(Li,{icon:Tc}),"OpenAI."]}),Vc(cs,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",_r("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",_r("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),_r(cs,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),_r(nu,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:l=>{r(l),e.onChange(l.trim(),o)},selectOnRender:!0,onKeyDown:l=>l.key===S.ENTER&&a()}),_r(cs,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),_r(Ra,{checked:o,onChange:n,children:"Persist API key in browser storage"}),Vc(cs,{children:["Once API key is set, you can use the ",_r(Li,{icon:zl})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",_r("b",{children:"AI Settings"})," ",_r(Li,{icon:Tc}),"."]}),_r(dn,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as CS,useRef as AS,useEffect as kS,useDeferredValue as a8}from"react";f();Y();Cr();var e8=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},Au=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){e8({canvasRef:e,setError:o});return}try{let l=await t.api,s;try{s=await l.parseMermaidToExcalidraw(r,{fontSize:Lt})}catch{s=await l.parseMermaidToExcalidraw(r.replace(/"/g,"'"),{fontSize:Lt})}let{elements:c,files:d}=s;o(null),n.current={elements:Kc(c,{regenerateIds:!0}),files:d};let m=await vi({elements:n.current.elements,files:n.current.files,exportPadding:To,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Rn(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(l){throw a.style.background="var(--default-bg-color)",r&&o(l),l}}},Yc=e=>{Lr.set(Qr.MERMAID_TO_EXCALIDRAW,e)},ku=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&Yc(r))};f();import{jsx as t8}from"react/jsx-runtime";var Mu=({children:e})=>t8("div",{className:"ttd-dialog-panels",children:e});f();import vS from"clsx";import{jsx as cb,jsxs as $c}from"react/jsx-runtime";var ms=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>$c("div",{className:"ttd-dialog-panel",children:[$c("div",{className:"ttd-dialog-panel__header",children:[cb("label",{children:e}),i?.()]}),t,$c("div",{className:vS("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[$c(ln,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[$c("div",{className:vS({invisible:n}),children:[r?.label,r?.icon&&cb("span",{children:r.icon})]}),n&&cb(Yt,{})]}),!o&&!n&&a?.(),l?.()]})]});f();Y();ge();import{useEffect as r8,useRef as TS}from"react";import{jsx as o8}from"react/jsx-runtime";var Lu=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=TS(null),i=TS(o);return i.current=o,r8(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[S.CTRL_OR_CMD]&&s.key===S.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),o8("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as Pu,jsxs as SS}from"react/jsx-runtime";var n8=({error:e})=>SS("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Pu("p",{children:e})]}),Du=({error:e,canvasRef:t,loaded:r})=>SS("div",{className:"ttd-dialog-output-wrapper",children:[e&&Pu(n8,{error:e.message}),r?Pu("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Pu(Yt,{size:"2rem"})]});Y();U();f();U();import{jsx as IS,jsxs as i8}from"react/jsx-runtime";var _u=()=>i8("div",{className:"ttd-dialog-submit-shortcut",children:[IS("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),IS("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});import{Fragment as c8,jsx as un,jsxs as LS}from"react/jsx-runtime";var l8=`flowchart TD
55
+ `);try{wi(i)}catch{throw new Error(E("errors.copyToSystemClipboardFailed"))}return{storeAction:_.NONE}},predicate:(e,t,r,o)=>du&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(H),keywords:["text","clipboard","copy"]});f();ye();$e();Y();ee();Re();var ug=G({name:"gridMode",icon:Ow,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:ni,objectsSnapModeEnabled:!1},storeAction:_.NONE}},checked:e=>e.gridSize!==null,predicate:(e,t,r)=>typeof r.gridModeEnabled>"u",keyTest:e=>e[S.CTRL_OR_CMD]&&e.code===Se.QUOTE});f();ee();ye();Re();$e();var $l=G({name:"zenMode",label:"buttons.zenMode",icon:_w,paletteName:"Toggle zen mode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},storeAction:_.NONE}},checked:e=>e.zenModeEnabled,predicate:(e,t,r)=>typeof r.zenModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.Z});f();ee();ye();Re();$e();var UE=G({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Dw,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},storeAction:_.NONE}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,r)=>typeof r.objectsSnapModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.S});f();$e();ye();ee();Re();var Zl=G({name:"stats",label:"stats.fullTitle",icon:Aw,paletteName:"Toggle stats",viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},storeAction:_.NONE}},checked:e=>e.stats.open,keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.SLASH});f();Y();we();De();He();Au();me();V();$e();ko();Re();var GE=G({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>o.scene.getSelectedElements(t).some(i=>Ct(i)),perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=o.scene.getNonDeletedElementsMap();return n.forEach(a=>{let s=J(a,i);if(s){let{width:l,height:c}=Vt(s.originalText,Me(s),s.lineHeight),d=qT(a.id);Cu(a.id);let{x:m,y:p}=Ll(a,s,i);F(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),F(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:t,storeAction:_.CAPTURE}}}),WE=G({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);if(n.length===2){let i=H(n[0])||H(n[1]),a;if(Mn(n[0])?a=n[0]:Mn(n[1])&&(a=n[1]),i&&a&&J(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i,a;H(n[0])&&Mn(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),F(i,{containerId:a.id,verticalAlign:kt.MIDDLE,textAlign:Oi.CENTER,autoResize:!0}),F(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return ft(i,a,o.scene.getNonDeletedElementsMap()),ss(a.id,s),{elements:eD(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},storeAction:_.CAPTURE}}}),eD=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===r.id);o.splice(n,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i+1,0,r),Jt(o,Z([t,r])),o},tD=(e,t,r)=>{let o=e.slice(),n=o.findIndex(a=>a.id===t.id);o.splice(n,1);let i=o.findIndex(a=>a.id===r.id);return o.splice(i,0,t),Jt(o,Z([t,r])),o},US=G({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=n.every(a=>H(a));return n.length>0&&i},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t),i=e.slice(),a={};for(let s of n)if(H(s)){let l=go({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:kn("rectangle")?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-wt,y:s.y-wt,width:Si(s.width,"rectangle"),height:Si(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&F(m,{startBinding:p,endBinding:u},!1)})}F(s,{containerId:l.id,verticalAlign:kt.MIDDLE,boundElements:null,textAlign:Oi.CENTER,autoResize:!0},!1),ft(s,l,o.scene.getNonDeletedElementsMap()),i=tD([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},storeAction:_.CAPTURE}}});f();f();V();ad();De();ee();ye();Y();dt();import{useCallback as GS,useEffect as rD,useLayoutEffect as oD,useRef as nD,useState as iD}from"react";import aD from"clsx";et();Zc();Oa();me();tu();import{jsx as Gd,jsxs as WS}from"react/jsx-runtime";var XE=320,VS=85,VE=5,sD=42,lD=500,YE=!1,gg=new Map,YS=({element:e,elementsMap:t,setAppState:r,onLinkOpen:o,setToast:n,updateEmbedValidationStatus:i})=>{let a=Gn(),s=Wn(),l=e.link||"",[c,d]=iD(l),m=nD(null),p=a.showHyperlinkPopup==="editor",u=GS(()=>{if(!m.current)return;let y=Pr(m.current.value)||null;if(!e.link&&y&&Ce("hyperlink","create"),Rt(e)){if(a.activeEmbeddable?.element===e&&r({activeEmbeddable:null}),!y){F(e,{link:null}),i(e,!1);return}if(!hl(y,s.validateEmbeddable))y&&n({message:E("toast.unableToEmbed"),closable:!0}),e.link&&gg.set(e.id,e.link),F(e,{link:y}),i(e,!1);else{let{width:w,height:C}=e,M=xi(y);M?.error instanceof URIError&&n({message:E("toast.unrecognizedLinkFormat"),closable:!0});let I=M?M.intrinsicSize.w/M.intrinsicSize.h:1,P=gg.get(e.id)!==e.link;F(e,{...P?{width:M?.type==="video"?w>C?w:C*I:w,height:M?.type==="video"&&w>C?w/I:C}:{},link:y}),i(e,!0),gg.has(e.id)&&gg.delete(e.id)}}else F(e,{link:y})},[e,n,s.validateEmbeddable,a.activeEmbeddable,r,i]);oD(()=>()=>{u()},[u]),rD(()=>{let y=null,w=C=>{if(p)return;y&&clearTimeout(y),dD(e,t,a,[C.clientX,C.clientY])&&(y=window.setTimeout(()=>{r({showHyperlinkPopup:!1})},lD))};return window.addEventListener("pointermove",w,!1),()=>{window.removeEventListener("pointermove",w,!1),y&&clearTimeout(y)}},[a,e,p,r,t]);let g=GS(()=>{Ce("hyperlink","delete"),F(e,{link:null}),p&&(m.current.value=""),r({showHyperlinkPopup:!1})},[r,e,p]),h=()=>{Ce("hyperlink","edit","popup-ui"),r({showHyperlinkPopup:"editor"})},{x,y:v}=XS(e,a,t);return a.contextMenu||a.draggingElement||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:WS("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${x}px`,width:XE,padding:VE},onClick:()=>{!e.link&&!p&&r({showHyperlinkPopup:"editor"})},children:[p?Gd("input",{className:aD("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:m,value:c,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[S.CTRL_OR_CMD]&&y.key===S.K&&y.preventDefault(),(y.key===S.ENTER||y.key===S.ESCAPE)&&(u(),r({showHyperlinkPopup:"info"}))}}):e.link?Gd("a",{href:Pr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Xm(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&o){let w=Fm("excalidraw-link",y.nativeEvent);o({...e,link:Pr(e.link)},w),w.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Gd("div",{className:"excalidraw-hyperlinkContainer-link",children:E("labels.link.empty")}),WS("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!p&&Gd(fe,{type:"button",title:E("buttons.edit"),"aria-label":E("buttons.edit"),label:E("buttons.edit"),onClick:h,className:"excalidraw-hyperlinkContainer--edit",icon:ci}),l&&!Rt(e)&&Gd(fe,{type:"button",title:E("buttons.remove"),"aria-label":E("buttons.remove"),label:E("buttons.remove"),onClick:g,className:"excalidraw-hyperlinkContainer--remove",icon:tn})]})]})},XS=(e,t,r)=>{let[o,n]=ae(e,r),{x:i,y:a}=$t({sceneX:o+e.width/2,sceneY:n},t),s=i-t.offsetLeft-XE/2,l=a-t.offsetTop-VS;return{x:s,y:l}},KE=(e,t)=>{let r=he(e,t);return r[0]?.link?Rt(r[0])?"labels.link.editEmbed":"labels.link.edit":Rt(r[0])?"labels.link.createEmbed":"labels.link.create"},Wd=null,KS=(e,t,r)=>{Wd&&clearTimeout(Wd),Wd=window.setTimeout(()=>cD(e,t,r),l0)},cD=(e,t,r)=>{if(!e.link)return;let o=Gl();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=e.link;let[n,i,a,s]=ae(e,r),[l,c,d,m]=cd([n,i,a,s],e.angle,t),p=$t({sceneX:l,sceneY:c},t);kE(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ce("hyperlink","tooltip","link-icon"),YE=!0},$S=()=>{Wd&&clearTimeout(Wd),YE&&(YE=!1,Gl().classList.remove("excalidraw-tooltip--visible"))},dD=(e,t,r,[o,n])=>{let{x:i,y:a}=Qe({clientX:o,clientY:n},r),s=15/r.zoom.value;if($c(i,a,e,t))return!1;let[l,c,d]=ae(e,t);if(i>=l&&i<=d&&a>=c-VS&&a<=c)return!1;let{x:m,y:p}=XS(e,r,t);return!(o>=m-s&&o<=m+XE+VE*2+s&&n>=p-s&&n<=p+s+VE*2+sD)};ee();me();ye();et();Re();V();$e();import{jsx as mD}from"react/jsx-runtime";var Vd=G({name:"hyperlink",label:(e,t)=>KE(e,t),icon:Lc,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},storeAction:_.CAPTURE},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[S.CTRL_OR_CMD]&&e.key===S.K,predicate:(e,t)=>he(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:r})=>{let o=he(e,t);return mD(fe,{type:"button",icon:Lc,"aria-label":E(KE(e,t)),title:`${Rt(e[0])?E("labels.link.labelEmbed"):E("labels.link.label")} - ${O("CtrlOrCmd+K")}`,onClick:()=>r(null),selected:o.length===1&&!!o[0].link})}});f();ee();De();me();ye();et();Re();V();$e();var $E=e=>e.every(t=>!t.locked),ZE=G({name:"toggleElementLock",label:(e,t,r)=>{let o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return o.length===1&&!Q(o[0])?o[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":$E(o)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,t)=>{let r=he(t,e);return $E(r)?Ws:Fa},trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=$E(n),a=Z(n);return{elements:e.map(s=>a.has(s.id)?pe(s,{locked:i}):s),appState:{...t,selectedLinearElement:i?null:t.selectedLinearElement},storeAction:_.CAPTURE}},keyTest:(e,t,r,o)=>e.key.toLocaleLowerCase()===S.L&&e[S.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),ZS=G({name:"unlockAllElements",paletteName:"Unlock all elements",trackEvent:{category:"canvas"},viewMode:!1,icon:Fa,predicate:(e,t)=>he(e,t).length===0&&e.some(o=>o.locked),perform:(e,t)=>{let r=e.filter(o=>o.locked);return{elements:e.map(o=>o.locked?pe(o,{locked:!1}):o),appState:{...t,selectedElementIds:Object.fromEntries(r.map(o=>[o.id,!0]))},storeAction:_.CAPTURE}},label:"labels.elementLock.unlockAll"});f();f();import{useEffect as Ng,useRef as d7,useState as Rg}from"react";ye();f();import R8 from"clsx";import{useEffect as N8,useState as O8}from"react";f();import{useCallback as pD,useState as uD}from"react";var jS=()=>{let[e,t]=uD(null),r=pD(o=>t(o),[]);return[e,r]};ye();f();ye();import{createPortal as gD}from"react-dom";import hD from"clsx";import{useRef as fD}from"react";import{jsx as qS,jsxs as bD}from"react/jsx-runtime";var JS=e=>{let{closeOnClickOutside:t=!0}=e,r=Vu({className:"excalidraw-modal-container"}),o=fD(document.body.classList.contains("excalidraw-animations-disabled"));if(!r)return null;let n=i=>{i.key===S.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return gD(bD("div",{className:hD("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[qS("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),qS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),r)};V();import{useSetAtom as F8}from"jotai";f();import{useState as k8,useCallback as s1,useMemo as OI,useRef as a1}from"react";f();qr();el();import{atom as vD}from"jotai";dt();Hi();Y();import{useEffect as tI,useRef as rI}from"react";f();pr();import{atom as ED,useAtom as xD}from"jotai";import{useEffect as yD,useState as wD}from"react";os();var jE=ED(new Map),QS=async e=>await wl({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Ee.white},files:null,renderEmbeddables:!1}),eI=(e,t,r)=>{let[o,n]=wD();return yD(()=>{if(t)if(e){let i=r.get(e);i?n(i):(async()=>{let a=await QS(t);a.querySelector(".style-fonts")?.remove(),a&&(r.set(e,a),n(a))})()}else(async()=>{let i=await QS(t);n(i)})()},[e,t,r,n]),o},hg=()=>{let[e]=xD(jE,Xe);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:o=>{o.forEach(n=>e.delete(n))},svgCache:e}};V();nd();f();V();var fg=class{jobs=[];running=!1;tick(){if(this.running)return;let t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(Ic(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...r){let o=Om();return this.jobs.push({jobFactory:t,promise:o,args:r}),this.tick(),o}};we();var nI=new wr,Ts=vD({status:"loaded",isInitialized:!1,libraryItems:[]}),Yd=e=>Xr(e),TD=(e,t)=>!e.find(r=>r.elements.length!==t.elements.length?!1:r.elements.every((o,n)=>o.id===t.elements[n].id&&o.versionNonce===t.elements[n].versionNonce)),iI=(e,t)=>{let r=[];for(let o of t)TD(e,o)&&r.push(o);return[...r,...e]},aI=(e,t)=>{let r=Z(t),o={deletedItems:new Map,addedItems:new Map};for(let i of e)r.has(i.id)||o.deletedItems.set(i.id,i);let n=Z(e);for(let i of t)n.has(i.id)||o.addedItems.set(i.id,i);return o},qE=class{currLibraryItems=[];prevLibraryItems=Yd(this.currLibraryItems);app;constructor(t){this.app=t}updateQueue=[];getLastUpdateTask=()=>this.updateQueue[this.updateQueue.length-1];notifyListeners=()=>{if(this.updateQueue.length>0)mr.set(Ts,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{mr.set(Ts,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Yd(this.currLibraryItems);let r=Yd(this.currLibraryItems);this.app.props.onLibraryChange?.(r),nI.trigger(aI(t,r),r)}catch(t){console.error(t)}}};destroy=()=>{this.updateQueue=[],this.currLibraryItems=[],mr.set(jE,new Map)};resetLibrary=()=>this.setLibrary([]);getLatestLibrary=()=>new Promise(async t=>{try{let r=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Yd(r))}catch{return t(this.currLibraryItems)}});updateLibrary=async({libraryItems:t,prompt:r=!1,merge:o=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:co.name,tab:wc}}),this.setLibrary(()=>new Promise(async(a,s)=>{try{let l=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;l instanceof Blob?c=await Sf(l,i):c=Ga(l,i),!r||window.confirm(E("alerts.confirmAddLibrary",{numShapes:c.length}))?(r&&this.app.focusContainer(),a(o?iI(this.currLibraryItems,c):c)):s(new Pn)}catch(l){s(l)}})));setLibrary=t=>{let r=new Promise(async(o,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Yd(await t),o(this.currLibraryItems)}catch(i){n(i)}}).catch(o=>{if(o.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw o}).finally(()=>{this.updateQueue=this.updateQueue.filter(o=>o!==r),this.notifyListeners()});return this.updateQueue.push(r),this.notifyListeners(),r}},sI=qE,xg=e=>{let r=Math.ceil(Math.sqrt(e.length)),o=[],n=u=>e.slice(u*r,u*r+r).reduce((h,x)=>{let{height:v}=Qr(x.elements);return Math.max(h,v)},0),i=u=>{let g=0,h=0,x=0;for(let v of e){if(g%r===0&&(h=0),h===u){let{width:y}=Qr(v.elements);x=Math.max(x,y)}g++,h++}return x},a=0,s=0,l=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%r===0&&(s+=l+50,a=0,m=0,p++),m===0&&(l=n(p)),c=i(m);let{minX:g,minY:h,width:x,height:v}=Qr(u.elements),y=(c-x)/2,w=(l-v)/2;o.push(...u.elements.map(C=>({...C,x:C.x+a+y-g,y:C.y+s+w-h}))),a+=c+50,d++,m++}return o},JE=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Am.addLibrary)||new URLSearchParams(window.location.search).get(Cm.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},jl=class e{static queue=new fg;static async getLibraryItems(t,r,o=!0){let n=()=>new Promise(async(i,a)=>{try{let s=await t.load({source:r});i(Ga(s?.libraryItems||[],"published"))}catch(s){a(s)}});return o?e.queue.push(n):n()}static run=async(t,r)=>{let o=new e(t);return e.queue.push(()=>r(o))};adapter;constructor(t){this.adapter=t}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}},Xd=0,bg=0,Eg=e=>$b(e.map(t=>`${t.id}:${Kb(t.elements)}`).sort().join()),oI=async(e,t)=>{try{return bg++,await jl.run(e,async r=>{let o=Z(await r.getLibraryItems("save"));for(let[s]of t.deletedItems)o.delete(s);let n=[];for(let[s,l]of t.addedItems)o.has(s)?o.set(s,l):n.push(l);let i=n.concat(Array.from(o.values())),a=Eg(i);return a!==Xd&&await e.save({libraryItems:i}),Xd=a,i})}finally{bg--}},SD=e=>{let{excalidrawAPI:t}=e,r=rI(e);r.current=e;let o=rI(!1);tI(()=>{if(!t)return;o.current=!1;let n=async({libraryUrl:s,idToken:l})=>{let c=new Promise(async(m,p)=>{try{let g=await(await fetch(decodeURIComponent(s))).blob();m(g)}catch(u){p(u)}}),d=l!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw m}finally{if(window.location.hash.includes(Am.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(Am.addLibrary),window.history.replaceState({},fc,`#${m.toString()}`)}else if(window.location.search.includes(Cm.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(Cm.addLibrary),window.history.replaceState({},fc,`?${m.toString()}`)}}},i=s=>{s.preventDefault();let l=JE();l&&(s.stopImmediatePropagation(),window.history.replaceState({},"",s.oldURL),n(l))},a=JE();if(a&&n(a),"getInitialLibraryItems"in r.current&&r.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(r.current.getInitialLibraryItems()).then(s=>{t.updateLibrary({libraryItems:s,merge:!0})}).catch(s=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${s?.message}`)})),"adapter"in r.current&&r.current.adapter){let s=r.current.adapter,l=r.current.migrationAdapter,c=Om();l?c.resolve(Ic(l.load).then(async d=>{let m=null;try{if(!d)return jl.getLibraryItems(s,"load");m=Ga(d.libraryItems||[],"published");let p=await oI(s,aI([],m));try{await l.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),jl.getLibraryItems(s,"load")))):c.resolve(Ic(jl.getLibraryItems,s,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Xd=Eg(m),m}),merge:!0}).finally(()=>{o.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),tI(()=>{let n=nI.on(async(a,s)=>{let l=o.current,c="adapter"in r.current&&r.current.adapter||null;try{c&&Xd!==Eg(s)&&await oI(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),l&&r.current.excalidrawAPI&&r.current.excalidrawAPI.updateScene({appState:{errorMessage:E("errors.saveLibraryError")}})}}),i=a=>{bg&&k0(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Xd=0,bg=0}},[])};Zo();f();mi();import{useCallback as ec,useEffect as S8,useMemo as DI,useRef as I8,useState as C8}from"react";V();f();import{forwardRef as lI}from"react";import cI from"clsx";import{jsx as dI}from"react/jsx-runtime";var ID=lI(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>dI("div",{className:cI("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:r,justifyContent:o,...i},ref:a,children:e})),CD=lI(({children:e,gap:t,align:r,justifyContent:o,className:n,style:i},a)=>dI("div",{className:cI("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:r,justifyContent:o,...i},ref:a,children:e})),rr={Row:ID,Col:CD};Y();Nn();f();f();Y();import{jsx as MD}from"react/jsx-runtime";var AD=({theme:e,id:t,libraryReturnUrl:r})=>{let o=r||window.location.origin+window.location.pathname;return MD("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${o}&useHash=true&token=${t}&theme=${e}&version=${Da.excalidrawLibrary}`,target:"_excalidraw_libraries",children:E("labels.libraries")})},mI=AD;import kD from"clsx";import{jsx as PD,jsxs as LD}from"react/jsx-runtime";var yg=({libraryReturnUrl:e,theme:t,id:r,style:o,children:n,className:i})=>LD("div",{className:kD("library-menu-control-buttons",i),style:o,children:[PD(mI,{id:r,libraryReturnUrl:e,theme:t}),n]});f();import{useCallback as o8,useState as t1}from"react";f();import wg from"react";var DD=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,_D=/{{([\w-]+)}}/,RD=/<([\w-]+)>/,ND=/<\/([\w-]+)>/,OD=(e,t)=>{let r=[{name:"",children:[]}];return e.split(DD).filter(Boolean).forEach(o=>{let n=o.match(RD),i=o.match(ND),a=o.match(_D);if(n!==null){let s=n[1];t.hasOwnProperty(s)?r.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===r[r.length-1].name){let l=r.pop(),c=wg.createElement(wg.Fragment,{},...l.children),d=t[l.name];typeof d=="function"&&r[r.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];t.hasOwnProperty(s)?r[r.length-1].children.push(t[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else r[r.length-1].children.push(o)}),r.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),r[0].children},FD=({i18nKey:e,children:t,...r})=>{let{t:o}=Dt();return wg.createElement(wg.Fragment,{},...OD(o(e),r))},Br=FD;mi();ee();di();V();import{useAtom as r1}from"jotai";f();f();import BD from"clsx";import{jsx as vg,jsxs as HD}from"react/jsx-runtime";var zD=({label:e,onClick:t,className:r,children:o,actionType:n,type:i="button",isLoading:a,...s})=>{let l=n?`Dialog__action-button--${n}`:"";return HD("button",{className:BD("Dialog__action-button",l,r),type:i,"aria-label":e,onClick:t,...s,children:[o&&vg("div",{style:a?{visibility:"hidden"}:{},children:o}),vg("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&vg("div",{style:{position:"absolute",inset:0},children:vg(ir,{})})]})},ql=zD;import{useSetAtom as UD}from"jotai";import{jsx as pI,jsxs as uI}from"react/jsx-runtime";var GD=e=>{let{onConfirm:t,onCancel:r,children:o,confirmText:n=E("buttons.confirm"),cancelText:i=E("buttons.cancel"),className:a="",...s}=e,l=Oe(),c=UD(Jl,Xe),{container:d}=Ft();return uI(xt,{onCloseRequest:r,size:"small",...s,className:`confirm-dialog ${a}`,children:[o,uI("div",{className:"confirm-dialog-buttons",children:[pI(ql,{label:i,onClick:()=>{l({openMenu:null}),c(!1),r(),d?.focus()}}),pI(ql,{label:n,onClick:()=>{l({openMenu:null}),c(!1),t(),d?.focus()},actionType:"danger"})]})]})},Tg=GD;f();import{useCallback as WD,useEffect as e1,useRef as gI,useState as QE}from"react";import Sg from"open-color";os();Y();qr();V();ee();f();var ro=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),!1}}static get(t){try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):null}catch(r){return console.warn(`localStorage.getItem error: ${r.message}`),null}}static set=(t,r)=>{try{return window.localStorage.setItem(t,JSON.stringify(r)),!0}catch(o){return console.warn(`localStorage.setItem error: ${o.message}`),!1}};static delete=t=>{try{window.localStorage.removeItem(t)}catch(r){console.warn(`localStorage.removeItem error: ${r.message}`)}}};import{jsx as Pe,jsxs as Tr}from"react/jsx-runtime";var VD=async e=>{let o=Math.round(8),n=Math.max(Math.round(128/64),2),i=C0(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(o*2)-o*2,a.height=i.length*128+(i.length+1)*(o*2)-o*2;let s=a.getContext("2d");s.fillStyle=Sg.white,s.fillRect(0,0,a.width,a.height);for(let[l,c]of e.entries()){let d=await ia({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:m,height:p}=d,u=Math.floor(l/6)*(128+o*2),g=l%6*(128+o*2);s.drawImage(d,g+(128-m)/2+o,u+(128-p)/2+o),s.lineWidth=n,s.strokeStyle=Sg.gray[4],s.strokeRect(g+o/2,u+o/2,128+o,128+o)}return await zc(new File([await gi(a)],"preview",{type:se.png}),{outputType:se.jpg,maxWidthOrHeight:5e3})},YD=({libItem:e,appState:t,index:r,onChange:o,onRemove:n})=>{let i=gI(null),a=gI(null);return e1(()=>{let s=i.current;s&&(async()=>{let l=await wl({elements:e.elements,appState:{...t,viewBackgroundColor:Sg.white,exportBackground:!0},files:null});s.innerHTML=l.outerHTML})()},[e.elements,t]),Tr("div",{className:"single-library-item",children:[e.status==="published"&&Pe("span",{className:"single-library-item-status",children:E("labels.statusPublished")}),Pe("div",{ref:i,className:"single-library-item__svg"}),Pe(fe,{"aria-label":E("buttons.remove"),type:"button",icon:Ao,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:E("buttons.remove")}),Tr("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Tr("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Tr("div",{style:{padding:"0.5em 0"},children:[Pe("span",{style:{fontWeight:500,color:Sg.gray[6]},children:E("publishDialog.itemName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:s=>{o(s.target.value,r)}})]}),Pe("span",{className:"error",children:e.error})]})]})},XD=({onClose:e,libraryItems:t,appState:r,onSuccess:o,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[s,l]=QE({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=QE(!1);e1(()=>{let w=ro.get(To.PUBLISH_LIBRARY);w&&l(w)},[]);let[m,p]=QE(t.slice());e1(()=>{p(t.slice())},[t]);let u=w=>{l({...s,[w.target.name]:w.target.value})},g=async w=>{w.preventDefault(),d(!0);let C=[],M=!1;if(m.forEach(D=>{let z="";D.name||(z=E("publishDialog.errors.required"),M=!0),C.push({...D,error:z})}),M){p(C),d(!1);return}let I=await VD(m),P={type:hr.excalidrawLibrary,version:Da.excalidrawLibrary,source:yc,libraryItems:m},A=JSON.stringify(P,null,2),N=new Blob([A],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",N),k.append("previewImage",I),k.append("previewImageType",I.type),k.append("title",s.name),k.append("authorName",s.authorName),k.append("githubHandle",s.githubHandle),k.append("name",s.name),k.append("description",s.description),k.append("twitterHandle",s.twitterHandle),k.append("website",s.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(D=>D.ok?D.json().then(({url:z})=>{ro.delete(To.PUBLISH_LIBRARY),o({url:z,authorName:s.authorName,items:m})}):D.json().catch(()=>{throw new Error(D.statusText||"something went wrong")}).then(z=>{throw new Error(z.message||D.statusText||"something went wrong")}),D=>{console.error(D),n(D),d(!1)}).catch(D=>{console.error(D),n(D),d(!1)})},h=()=>{let w=[];return m.forEach((C,M)=>{w.push(Pe("div",{className:"single-library-item-wrapper",children:Pe(YD,{libItem:C,appState:r,index:M,onChange:(I,P)=>{let A=m.slice();A[P].name=I,p(A)},onRemove:a})},M))}),Pe("div",{className:"selected-library-items",children:w})},x=WD(()=>{i(m),ro.set(To.PUBLISH_LIBRARY,s),e()},[m,e,i,s]),v=!!t.length,y=t.some(w=>w.status==="published");return Pe(xt,{onCloseRequest:x,title:E("publishDialog.title"),className:"publish-library",children:v?Tr("form",{onSubmit:g,children:[Pe("div",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteDescription",link:w=>Pe("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:w})})}),Pe("span",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteGuidelines",link:w=>Pe("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),Pe("div",{className:"publish-library-note",children:E("publishDialog.noteItems")}),y&&Pe("span",{className:"publish-library-note publish-library-warning",children:E("publishDialog.republishWarning")}),h(),Tr("div",{className:"publish-library__fields",children:[Tr("label",{children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.libraryName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",name:"name",required:!0,value:s.name,onChange:u,placeholder:E("publishDialog.placeholder.libraryName")})]}),Tr("label",{style:{alignItems:"flex-start"},children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.libraryDesc")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("textarea",{name:"description",rows:4,required:!0,value:s.description,onChange:u,placeholder:E("publishDialog.placeholder.libraryDesc")})]}),Tr("label",{children:[Tr("div",{children:[Pe("span",{children:E("publishDialog.authorName")}),Pe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Pe("input",{type:"text",name:"authorName",required:!0,value:s.authorName,onChange:u,placeholder:E("publishDialog.placeholder.authorName")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.githubUsername")}),Pe("input",{type:"text",name:"githubHandle",value:s.githubHandle,onChange:u,placeholder:E("publishDialog.placeholder.githubHandle")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.twitterUsername")}),Pe("input",{type:"text",name:"twitterHandle",value:s.twitterHandle,onChange:u,placeholder:E("publishDialog.placeholder.twitterHandle")})]}),Tr("label",{children:[Pe("span",{children:E("publishDialog.website")}),Pe("input",{type:"text",name:"website",pattern:"https?://.+",title:E("publishDialog.errors.website"),value:s.website,onChange:u,placeholder:E("publishDialog.placeholder.website")})]}),Pe("span",{className:"publish-library-note",children:Pe(Br,{i18nKey:"publishDialog.noteLicense",link:w=>Pe("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),Tr("div",{className:"publish-library__buttons",children:[Pe(ql,{label:E("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),Pe(ql,{type:"submit",label:E("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Pe("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:E("publishDialog.atleastOneLibItem")})})},hI=XD;f();f();import KD from"clsx";import{jsx as $D}from"react/jsx-runtime";var fI=({className:e="",children:t,onToggle:r,title:o,...n})=>{let i=Ne(),a=KD(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return $D("button",{"data-prevent-outside-click":!0,className:a,onClick:r,type:"button","data-testid":"dropdown-menu-button",title:o,...n,children:t})},bI=fI;fI.displayName="DropdownMenuTrigger";f();import{jsx as ZD}from"react/jsx-runtime";var EI=()=>ZD("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),xI=EI;EI.displayName="DropdownMenuSeparator";f();import jD from"clsx";import{useEffect as qD,useRef as JD}from"react";ye();Y();import{jsx as Ig}from"react/jsx-runtime";var yI=({children:e,onClickOutside:t,className:r="",onSelect:o,style:n})=>{let i=Ne(),a=JD(null),s=zl({onClickOutside:t});Bl(a,()=>{s.onClickOutside?.()}),qD(()=>{let c=m=>{m.key===S.ESCAPE&&(m.stopImmediatePropagation(),s.onClickOutside?.())},d={capture:!0};return document.addEventListener("keydown",c,d),()=>{document.removeEventListener("keydown",c,d)}},[s]);let l=jD(`dropdown-menu ${r}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ig(xE.Provider,{value:{onSelect:o},children:Ig("div",{ref:a,className:l,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ig(rr.Col,{className:"dropdown-menu-container",children:e}):Ig(Yt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};yI.displayName="DropdownMenuContent";var wI=yI;f();import{jsx as vI}from"react/jsx-runtime";var TI=({icon:e,shortcut:t,href:r,children:o,onSelect:n,className:i="",selected:a,...s})=>{let l=Ju(s.onClick,n);return vI("a",{...s,href:r,target:"_blank",rel:"noreferrer",className:qu(i,a),title:s.title??s["aria-label"],onClick:l,children:vI(Qu,{icon:e,shortcut:t,children:o})})},Ql=TI;TI.displayName="DropdownMenuItemLink";f();import{jsx as e8}from"react/jsx-runtime";var QD=({children:e,className:t="",selected:r,...o})=>e8("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${r?"dropdown-menu-item--selected":""}`.trim(),children:e}),SI=QD;f();import Cg from"react";var II=e=>{let t=Cg.Children.toArray(e).find(r=>Cg.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuTrigger");return t||null},CI=e=>{let t=Cg.Children.toArray(e).find(r=>Cg.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as t8,jsxs as r8}from"react/jsx-runtime";var ki=({children:e,open:t})=>{let r=II(e),o=CI(e);return r8(t8,{children:[r,t&&o]})};ki.Trigger=bI;ki.Content=wI;ki.Item=eo;ki.ItemLink=Ql;ki.ItemCustom=SI;ki.Group=Fd;ki.Separator=xI;var Ye=ki;ki.displayName="DropdownMenu";import n8 from"clsx";import{jsx as oo,jsxs as Ag}from"react/jsx-runtime";var i8=(e,t)=>e.filter(r=>t.includes(r.id)),a8=({setAppState:e,selectedItems:t,library:r,onRemoveFromLibrary:o,resetLibrary:n,onSelectItems:i,appState:a,className:s})=>{let[l]=r1(Ts,Xe),[c,d]=r1(Jl,Xe),m=()=>{let k=t.length?E("alerts.removeItemsFromsLibrary",{count:t.length}):E("alerts.resetLibrary"),D=t.length?E("confirmDialog.removeItemsFromLib"):E("confirmDialog.resetLibrary");return oo(Tg,{onConfirm:()=>{t.length?o():n(),u(!1)},onCancel:()=>{u(!1)},title:D,children:oo("p",{children:k})})},[p,u]=t1(!1),g=!!t.length,h=g?l.libraryItems.filter(k=>t.includes(k.id)):l.libraryItems,x=g?E("buttons.remove"):E("buttons.resetLibrary"),[v,y]=t1(!1),[w,C]=t1(null),M=o8(()=>Ag(xt,{onCloseRequest:()=>C(null),title:E("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[oo("p",{children:oo(Br,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:k=>oo("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),oo(fe,{type:"button",title:E("buttons.close"),"aria-label":E("buttons.close"),label:E("buttons.close"),onClick:()=>C(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[C,w]),I=(k,D)=>{y(!1),C({url:k.url,authorName:k.authorName});let z=D.slice();z.forEach(R=>{t.includes(R.id)&&(R.status="published")}),r.setLibrary(z)},P=async()=>{try{await r.updateLibrary({libraryItems:js({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:E("errors.importLibraryError")})}},A=async()=>{let k=g?h:await r.getLatestLibrary();Yw(k).catch(Nm).catch(D=>{e({errorMessage:D.message})})},N=()=>Ag(Ye,{open:c,children:[oo(Ye.Trigger,{onToggle:()=>d(!c),children:ny}),Ag(Ye.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!g&&oo(Ye.Item,{onSelect:P,icon:Ys,"data-testid":"lib-dropdown--load",children:E("buttons.load")}),!!h.length&&oo(Ye.Item,{onSelect:A,icon:Ba,"data-testid":"lib-dropdown--export",children:E("buttons.export")}),!!h.length&&oo(Ye.Item,{onSelect:()=>u(!0),icon:tn,children:x}),g&&oo(Ye.Item,{icon:uw,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:E("buttons.publishLibrary")})]})]});return Ag("div",{className:n8("library-menu-dropdown-container",s),children:[N(),t.length>0&&oo("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&oo(hI,{onClose:()=>y(!1),libraryItems:i8(l.libraryItems,t),appState:a,onSuccess:k=>I(k,l.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>r.setLibrary(l.libraryItems),onRemove:k=>i(t.filter(D=>D!==k))}),w&&M()]})},o1=({selectedItems:e,onSelectItems:t,className:r})=>{let{library:o}=tr(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=hg(),a=Ue(),s=Oe(),[l]=r1(Ts,Xe),c=async m=>{let p=m.filter(u=>!e.includes(u.id));o.setLibrary(p).catch(()=>{s({errorMessage:E("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return oo(a8,{appState:a,setAppState:s,selectedItems:e,onSelectItems:t,library:o,onRemoveFromLibrary:()=>c(l.libraryItems),resetLibrary:()=>{o.resetLibrary(),n()},className:r})};f();import{memo as h8,useEffect as f8,useState as b8}from"react";f();import AI from"clsx";import{memo as s8,useEffect as l8,useRef as c8,useState as d8}from"react";ee();import{jsx as Mg,jsxs as m8}from"react/jsx-runtime";var MI=s8(({id:e,elements:t,isPending:r,onClick:o,selected:n,onToggle:i,onDrag:a,svgCache:s})=>{let l=c8(null),c=eI(e,t,s);l8(()=>{let g=l.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[d,m]=d8(!1),p=Ne().editor.isMobile,u=r&&Mg("div",{className:"library-unit__adder",children:oy});return m8("div",{className:AI("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[Mg("div",{className:AI("library-unit__dragger",{"library-unit__pulse":!!r}),ref:l,draggable:!!t,onClick:t||r?g=>{e&&g.shiftKey?i(e,g):o(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}m(!1),a(e,g)}}),u,e&&t&&(d||p||n)&&Mg(ys,{checked:n,onChange:(g,h)=>i(e,h),className:"library-unit__checkbox"})]})}),kI=()=>Mg("div",{className:"library-unit library-unit--skeleton"});f();import p8,{useCallback as u8}from"react";function g8(){return[!1,u8(t=>t(),[])]}var PI=p8.useTransition||g8;import{Fragment as E8,jsx as kg}from"react/jsx-runtime";var n1=({children:e})=>kg("div",{className:"library-menu-items-container__grid",children:e}),Pg=h8(({items:e,onItemSelectToggle:t,onItemDrag:r,isItemSelected:o,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,s]=PI(),[l,c]=b8(0);return f8(()=>{l<e.length&&s(()=>{c(l+a)})},[l,e.length,s,a]),kg(E8,{children:e.map((d,m)=>m<l?kg(MI,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:o(d.id),onToggle:t,onDrag:r},d?.id??m):kg(kI,{},m))})});f();import{useEffect as x8}from"react";import{atom as y8,useAtom as w8}from"jotai";import v8 from"lodash.throttle";var T8=y8(0),LI=e=>{let[t,r]=w8(T8);return x8(()=>{let{current:o}=e;if(!o)return;let n=v8(()=>{let{scrollTop:i}=o;r(i)},200);return o.addEventListener("scroll",n),()=>{n.cancel(),o.removeEventListener("scroll",n)}},[e,r]),t};import{Fragment as _I,jsx as no,jsxs as tc}from"react/jsx-runtime";var A8=17,M8=64;function i1({isLoading:e,libraryItems:t,onAddToLibrary:r,onInsertLibraryItems:o,pendingElements:n,theme:i,id:a,libraryReturnUrl:s,onSelectItems:l,selectedItems:c}){let d=I8(null),m=LI(d);S8(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=hg(),u=DI(()=>t.filter(k=>k.status!=="published"),[t]),g=DI(()=>t.filter(k=>k.status==="published"),[t]),h=!t.length&&!n.length,x=!n.length&&!u.length&&!g.length,[v,y]=C8(null),w=ec((k,D)=>{let z=!c.includes(k),R=[...u,...g];if(z){if(D.shiftKey&&v){let W=R.findIndex(le=>le.id===v),q=R.findIndex(le=>le.id===k);if(W===-1||q===-1){l([...c,k]);return}let re=Z(c),ge=R.reduce((le,U,oe)=>((oe>=W&&oe<=q||re.has(U.id))&&le.push(U.id),le),[]);l(ge)}else l([...c,k]);y(k)}else y(null),l(c.filter(W=>W!==k))},[v,l,g,c,u]),C=ec(k=>{let D;return c.includes(k)?D=t.filter(z=>c.includes(z.id)):D=t.filter(z=>z.id===k),D.map(z=>({...z,elements:Ap(z.elements,{randomizeSeed:!0})}))},[t,c]),M=ec((k,D)=>{D.dataTransfer.setData(se.excalidrawlib,hp(C(k)))},[C]),I=ec(k=>k?c.includes(k):!1,[c]),P=ec(()=>{r(n)},[n,r]),A=ec(k=>{k&&o(C(k))},[C,o]),N=p.size>=t.length?M8:A8;return tc("div",{className:"library-menu-items-container",style:n.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&no(o1,{selectedItems:c,onSelectItems:l,className:"library-menu-dropdown-container--in-heading"}),tc(rr.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[tc(_I,{children:[!x&&no("div",{className:"library-menu-items-container__header",children:E("labels.personalLib")}),e&&no("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:no(ir,{})}),!n.length&&!u.length?tc("div",{className:"library-menu-items__no-items",children:[no("div",{className:"library-menu-items__no-items__label",children:E("library.noItems")}),no("div",{className:"library-menu-items__no-items__hint",children:g.length>0?E("library.hint_emptyPrivateLibrary"):E("library.hint_emptyLibrary")})]}):tc(n1,{children:[n.length>0&&no(Pg,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:w,onItemDrag:M,onClick:P,isItemSelected:I,svgCache:p}),no(Pg,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:w,onItemDrag:M,onClick:A,isItemSelected:I,svgCache:p})]})]}),tc(_I,{children:[(g.length>0||n.length>0||u.length>0)&&no("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:E("labels.excalidrawLib")}),g.length>0?no(n1,{children:no(Pg,{itemsRenderedPerBatch:N,items:g,onItemSelectToggle:w,onItemDrag:M,onClick:A,isItemSelected:I,svgCache:p})}):u.length>0?no("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:E("library.noItems")}):null]}),h&&no(yg,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:s,theme:i,children:no(o1,{selectedItems:c,onSelectItems:l})})]})]})}import{atom as P8,useAtom as L8}from"jotai";et();V();Y();import{jsx as ua,jsxs as NI}from"react/jsx-runtime";var Jl=P8(!1),RI=({children:e})=>ua("div",{className:"layer-ui__library",children:e}),D8=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:r,setAppState:o,libraryReturnUrl:n,library:i,id:a,theme:s,selectedItems:l,onSelectItems:c})=>{let[d]=L8(Ts,Xe),m=s1(g=>{(async(x,v)=>{Ce("element","addToLibrary","ui");for(let w of Pm)if(x.some(C=>C.type===w))return o({errorMessage:E(`errors.libraryElementTypeError.${w}`)});let y=[{status:"unpublished",elements:x,id:Ut(),created:Date.now()},...v];r(),i.setLibrary(y).catch(()=>{o({errorMessage:E("alerts.errorAddingToLibrary")})})})(g,d.libraryItems)},[r,i,o,d.libraryItems]),p=OI(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return ua(RI,{children:ua("div",{className:"layer-ui__library-message",children:NI("div",{children:[ua(ir,{size:"2em"}),ua("span",{children:E("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return NI(RI,{children:[ua(i1,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:n,theme:s,onSelectItems:c,selectedItems:l}),u&&ua(yg,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:s})]})},_8=(e,t)=>{let r=()=>he(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=a1(r()),n=a1(e),i=a1(t);return(!it(e.selectedElementIds,n.current.selectedElementIds)||!it(t,i.current))&&(o.current=r(),n.current=e,i.current=t),o.current},FI=()=>{let{library:e,id:t,onInsertElements:r}=tr(),o=Wn(),n=Ue(),i=Oe(),a=da(),[s,l]=k8([]),c=OI(()=>e,[e]),d=_8(n,a),m=s1(u=>{r(xg(u))},[r]),p=s1(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return ua(D8,{pendingElements:d,onInsertLibraryItems:m,onAddToLibrary:p,setAppState:i,libraryReturnUrl:o.libraryReturnUrl,library:c,id:t,theme:n.theme,selectedItems:s,onSelectItems:l})};ee();import{jsx as Kd,jsxs as z8}from"react/jsx-runtime";function B8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var xt=e=>{let[t,r]=jS(),[o]=O8(document.activeElement),{id:n}=Ft(),i=Ne().viewport.isMobile;N8(()=>{if(!t)return;let c=Tc(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===S.TAB){let p=Tc(t),{activeElement:u}=document,g=p.findIndex(h=>h===u);g===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):g===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=Oe(),s=F8(Jl,Xe),l=()=>{a({openMenu:null}),s(!1),o.focus(),e.onCloseRequest()};return Kd(JS,{className:R8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:B8(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,children:z8(Yt,{ref:r,children:[e.title&&Kd("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Kd("span",{className:"Dialog__titleContent",children:e.title})}),i&&Kd("button",{className:"Dialog__close",onClick:l,title:E("buttons.close"),"aria-label":E("buttons.close"),type:"button",children:Ao}),Kd("div",{className:"Dialog__content",children:e.children})]})})};f();import{forwardRef as G8,useRef as W8,useImperativeHandle as V8,useLayoutEffect as Y8,useState as X8}from"react";import l1 from"clsx";f();V();import H8 from"clsx";import{jsx as U8}from"react/jsx-runtime";var Yn=({type:e="button",onSelect:t,selected:r,children:o,className:n="",...i})=>U8("button",{onClick:zi(i.onClick,a=>{t()}),type:e,className:H8("excalidraw-button",n,{selected:r}),...i,children:o});ee();import{jsx as c1,jsxs as BI}from"react/jsx-runtime";var Lg=G8(({onChange:e,label:t,fullWidth:r,placeholder:o,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,...l},c)=>{let d=W8(null);V8(c,()=>d.current),Y8(()=>{i&&d.current?.select()},[i]);let[m,p]=X8(!1);return BI("div",{className:l1("ExcTextField",{"ExcTextField--fullWidth":r}),onClick:()=>{d.current?.focus()},children:[c1("div",{className:"ExcTextField__label",children:t}),BI("div",{className:l1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[c1("input",{className:l1({"is-redacted":"value"in l&&l.value&&s&&!m}),readOnly:n,value:"value"in l?l.value:void 0,defaultValue:"defaultValue"in l?l.defaultValue:void 0,placeholder:o,ref:d,onChange:u=>e?.(u.target.value),onKeyDown:a}),s&&c1(Yn,{onSelect:()=>p(!m),style:{border:0,userSelect:"none"},children:m?yw:Zs})]})]})});et();import XI from"clsx";f();Y();V();var K8={toggleTheme:[O("Shift+Alt+D")],saveScene:[O("CtrlOrCmd+S")],loadScene:[O("CtrlOrCmd+O")],clearCanvas:[O("CtrlOrCmd+Delete")],imageExport:[O("CtrlOrCmd+Shift+E")],commandPalette:[O("CtrlOrCmd+/"),O("CtrlOrCmd+Shift+P")],cut:[O("CtrlOrCmd+X")],copy:[O("CtrlOrCmd+C")],paste:[O("CtrlOrCmd+V")],copyStyles:[O("CtrlOrCmd+Alt+C")],pasteStyles:[O("CtrlOrCmd+Alt+V")],selectAll:[O("CtrlOrCmd+A")],deleteSelectedElements:[O("Delete")],duplicateSelection:[O("CtrlOrCmd+D"),O(`Alt+${E("helpDialog.drag")}`)],sendBackward:[O("CtrlOrCmd+[")],bringForward:[O("CtrlOrCmd+]")],sendToBack:[Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")],bringToFront:[Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")],copyAsPng:[O("Shift+Alt+C")],copyAsSvg:[],group:[O("CtrlOrCmd+G")],ungroup:[O("CtrlOrCmd+Shift+G")],gridMode:[O("CtrlOrCmd+'")],zenMode:[O("Alt+Z")],objectsSnapMode:[O("Alt+S")],stats:[O("Alt+/")],addToLibrary:[],flipHorizontal:[O("Shift+H")],flipVertical:[O("Shift+V")],viewMode:[O("Alt+R")],hyperlink:[O("CtrlOrCmd+K")],toggleElementLock:[O("CtrlOrCmd+Shift+L")],resetZoom:[O("CtrlOrCmd+0")],zoomOut:[O("CtrlOrCmd+-")],zoomIn:[O("CtrlOrCmd++")],zoomToFitSelection:[O("Shift+3")],zoomToFit:[O("Shift+1")],zoomToFitSelectionInViewport:[O("Shift+2")],toggleEraserTool:[O("E")],toggleHandTool:[O("H")],setFrameAsActiveTool:[O("F")],saveFileToDisk:[O("CtrlOrCmd+S")],saveToActiveFile:[O("CtrlOrCmd+S")],toggleShortcuts:[O("?")]},Bt=(e,t=0)=>{let r=K8[e];return r&&r.length>0?r[t]||r[0]:""};Y();ee();import m7 from"fuzzy";V();import{atom as p7,useAtom as u7}from"jotai";f();var $8="\\u0300-\\u036f",Z8="\\ufe20-\\ufe2f",j8="\\u20d0-\\u20ff",q8=$8+Z8+j8,J8=`[${q8}]`,Q8=RegExp(J8,"g"),e7=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,t7={\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"},d1=e=>e.replace(e7,t=>t7[t]||t).replace(Q8,"");f();import{jsx as r7}from"react/jsx-runtime";var Fo=({icon:e})=>r7("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});dl();f();import{useState as o7}from"react";et();dl();V();bd();me();import u1 from"clsx";He();ee();ye();f();import m1 from"react";import Xn from"tunnel-rat";var p1=m1.createContext(null),ut=()=>m1.useContext(p1),zI=()=>m1.useMemo(()=>({MainMenuTunnel:Xn(),WelcomeScreenMenuHintTunnel:Xn(),WelcomeScreenToolbarHintTunnel:Xn(),WelcomeScreenHelpHintTunnel:Xn(),WelcomeScreenCenterTunnel:Xn(),FooterCenterTunnel:Xn(),DefaultSidebarTriggerTunnel:Xn(),DefaultSidebarTabTriggersTunnel:Xn(),OverwriteConfirmDialogTunnel:Xn(),TTDDialogTriggerTunnel:Xn(),jotaiScope:Symbol()}),[]);import{Fragment as Pi,jsx as gt,jsxs as Lt}from"react/jsx-runtime";var g1=(e,t)=>{let r=t[0]?.type||null;for(let o of t)if(o.type!==r){r=null;break}return fd(e.activeTool.type)&&e.activeTool.type!=="image"&&r!=="image"&&r!=="frame"&&r!=="magicframe"||t.some(o=>fd(o.type))},h1=(e,t)=>vi(e.activeTool.type)||t.some(r=>vi(r.type)),Dg=({appState:e,elementsMap:t,renderAction:r})=>{let o=Pd(t,e),n=!1;o.length===2&&(Ct(o[0])||Ct(o[1]))&&(n=!0);let i=!!e.editingElement,a=Ne(),s=document.documentElement.getAttribute("dir")==="rtl",l=vi(e.activeTool.type)&&!Ar(e.currentItemBackgroundColor)||o.some(m=>vi(m.type)&&!Ar(m.backgroundColor)),c=o.length===1||n,d=!e.editingLinearElement&&o.length===1&&ie(o[0])&&!de(o[0]);return Lt("div",{className:"panelColumn",children:[gt("div",{children:g1(e,o)&&r("changeStrokeColor")}),h1(e,o)&&gt("div",{children:r("changeBackgroundColor")}),l&&r("changeFillStyle"),(wu(e.activeTool.type)||o.some(m=>wu(m.type)))&&r("changeStrokeWidth"),(e.activeTool.type==="freedraw"||o.some(m=>m.type==="freedraw"))&&r("changeStrokeShape"),(vu(e.activeTool.type)||o.some(m=>vu(m.type)))&&Lt(Pi,{children:[r("changeStrokeStyle"),r("changeSloppiness")]}),(Il(e.activeTool.type)||o.some(m=>Il(m.type)))&&gt(Pi,{children:r("changeRoundness")}),(yb(e.activeTool.type)||o.some(m=>yb(m.type)))&&gt(Pi,{children:r("changeArrowType")}),(e.activeTool.type==="text"||o.some(H))&&Lt(Pi,{children:[r("changeFontFamily"),r("changeFontSize"),(e.activeTool.type==="text"||r3(o,t))&&r("changeTextAlign")]}),t3(o,t)&&r("changeVerticalAlign"),(is(e.activeTool.type)||o.some(m=>is(m.type)))&&gt(Pi,{children:r("changeArrowhead")}),r("changeOpacity"),Lt("fieldset",{children:[gt("legend",{children:E("labels.layers")}),Lt("div",{className:"buttonList",children:[r("sendToBack"),r("sendBackward"),r("bringForward"),r("bringToFront")]})]}),o.length>1&&!n&&Lt("fieldset",{children:[gt("legend",{children:E("labels.align")}),Lt("div",{className:"buttonList",children:[s?Lt(Pi,{children:[r("alignRight"),r("alignHorizontallyCentered"),r("alignLeft")]}):Lt(Pi,{children:[r("alignLeft"),r("alignHorizontallyCentered"),r("alignRight")]}),o.length>2&&r("distributeHorizontally"),gt("div",{style:{flexBasis:"100%",height:0}}),Lt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[r("alignTop"),r("alignVerticallyCentered"),r("alignBottom"),o.length>2&&r("distributeVertically")]})]})]}),!i&&o.length>0&&Lt("fieldset",{children:[gt("legend",{children:E("labels.actions")}),Lt("div",{className:"buttonList",children:[!a.editor.isMobile&&r("duplicateSelection"),!a.editor.isMobile&&r("deleteSelectedElements"),r("group"),r("ungroup"),c&&r("hyperlink"),d&&r("toggleLinearEditor")]})]})]})},_g=({activeTool:e,appState:t,app:r,UIOptions:o})=>{let[n,i]=o7(!1),a=e.type==="frame",s=e.type==="laser",l=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=ut();return Lt(Pi,{children:[jc.map(({value:d,icon:m,key:p,numericKey:u,fillable:g},h)=>{if(o.tools?.[d]===!1)return null;let x=E(`toolBar.${d}`),v=p&&Bi(typeof p=="string"?p:p[0]),y=v?`${v} ${E("helpDialog.or")} ${u}`:`${u}`;return gt(fe,{className:u1("Shape",{fillable:g}),type:"radio",icon:m,checked:e.type===d,name:"editor-current-shape",title:`${Bi(x)} \u2014 ${y}`,keyBindingLabel:u||v,"aria-label":Bi(x),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:w})=>{!t.penDetected&&w==="pen"&&r.togglePenMode(!0)},onChange:({pointerType:w})=>{t.activeTool.type!==d&&Ce("toolbar",d,"ui"),d==="image"?r.setActiveTool({type:d,insertOnCanvasDirectly:w!=="mouse"}):r.setActiveTool({type:d})}},d)}),gt("div",{className:"App-toolbar__divider"}),Lt(Ye,{open:n,children:[Lt(Ye.Trigger,{className:u1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||l||s&&!r.props.isCollaborating}),onToggle:()=>i(!n),title:E("toolBar.extraTools"),children:[Ew,r.props.aiEnabled!==!1&&gt("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"var(--color-promo)",color:"var(--color-surface-lowest)",bottom:3,right:4},children:"AI"})]}),Lt(Ye.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"frame"}),icon:sp,shortcut:S.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:E("toolBar.frame")}),gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"embeddable"}),icon:xy,"data-testid":"toolbar-embeddable",selected:l,children:E("toolBar.embeddable")}),gt(Ye.Item,{onSelect:()=>r.setActiveTool({type:"laser"}),icon:cp,"data-testid":"toolbar-laser",selected:s,shortcut:S.K.toLocaleUpperCase(),children:E("toolBar.laser")}),gt("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),r.props.aiEnabled!==!1&&gt(c.Out,{}),gt(Ye.Item,{onSelect:()=>r.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:lp,"data-testid":"toolbar-embeddable",children:E("toolBar.mermaidToExcalidraw")}),r.props.aiEnabled!==!1&&Lt(Pi,{children:[Lt(Ye.Item,{onSelect:()=>r.onMagicframeToolSelect(),icon:$s,"data-testid":"toolbar-magicframe",children:[E("toolBar.magicframe"),gt(Ye.Item.Badge,{children:"AI"})]}),gt(Ye.Item,{onSelect:()=>{Ce("ai","open-settings","d2c"),r.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:_c,"data-testid":"toolbar-magicSettings",children:E("toolBar.magicSettings")})]})]})]})]})},HI=({renderAction:e,zoom:t})=>gt(rr.Col,{gap:1,className:"zoom-actions",children:Lt(rr.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),UI=({renderAction:e,className:t})=>Lt("div",{className:`undo-redo-buttons ${t}`,children:[gt("div",{className:"undo-button-container",children:gt(Eo,{label:E("buttons.undo"),children:e("undo")})}),gt("div",{className:"redo-button-container",children:Lt(Eo,{label:E("buttons.redo"),children:[" ",e("redo")]})})]}),GI=({actionManager:e,showExitZenModeBtn:t})=>gt("button",{type:"button",className:u1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction($l),children:E("buttons.exitZenMode")}),WI=({renderAction:e,className:t})=>gt("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});f();import{useRef as n7}from"react";var f1=e=>{let t=n7({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...r)=>t.current.userFn(...r)),t.current.stableFn};f();import{atom as i7,useAtom as a7}from"jotai";import{jsx as l7,jsxs as s7}from"react/jsx-runtime";var Ss=i7(null),VI=()=>{let[e,t]=a7(Ss,Xe),r=Xt();return e&&e==="clearCanvas"?l7(Tg,{onConfirm:()=>{r.executeAction(Ai),t(null)},onCancel:()=>t(null),title:E("clearCanvasDialog.title"),children:s7("p",{className:"clear-canvas__content",children:[" ",E("alerts.clearReset")]})}):null};var b1={};Ch(b1,{toggleTheme:()=>c7});f();var c7={...bs,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(bs,"commandPalette")}};import{jsx as zr,jsxs as Kn}from"react/jsx-runtime";var g7=p7(null),Mt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},h7=e=>{switch(e){case Mt.app:return 1;case Mt.export:return 2;case Mt.editor:return 3;case Mt.tools:return 4;case Mt.elements:return 5;case Mt.links:return 6;default:return 10}},Og=({shortcut:e,className:t,children:r})=>{let o=e.replace("++","+$").split("+");return Kn("div",{className:XI("shortcut",t),children:[o.map((n,i)=>zr("div",{className:"shortcut-wrapper",children:zr("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),zr("div",{className:"shortcut-desc",children:r})]})},KI=e=>!e.altKey&&e[S.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===S.P||e.key===S.SLASH),Xue=Object.assign(e=>{let t=Ue(),r=Oe();return Ng(()=>{let o=n=>{KI(n)&&(n.preventDefault(),n.stopPropagation(),r(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&Ce("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[r]),t.openDialog?.name!=="commandPalette"?null:zr(f7,{...e})},{defaultItems:b1});function f7({customCommandPaletteItems:e}){let t=tr(),r=Ue(),o=Oe(),n=Wn(),i=Xt(),[a,s]=u7(g7),[l,c]=Rg(null),d=d7(null),m=zl({uiAppState:r,customCommandPaletteItems:e,appProps:n});Ng(()=>{let{uiAppState:I,customCommandPaletteItems:P,appProps:A}=m,N=R=>{let W="";return R.label&&(typeof R.label=="function"?W=E(R.label(t.scene.getNonDeletedElements(),I,t)):W=E(R.label)),W},k=R=>typeof R.icon=="function"?R.icon(I,t.scene.getNonDeletedElements()):R.icon,D=[],z=(R,W,q)=>{let re={label:N(R),icon:k(R),category:W,shortcut:Bt(R.name),keywords:R.keywords,predicate:R.predicate,viewMode:R.viewMode,perform:()=>{i.executeAction(R,"commandPalette")}};return q?q(re,R):re};if(I&&t.scene&&i){let R=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,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,Vd].map(U=>z(U,Mt.elements,(oe,Ie)=>({...oe,predicate:Ie.predicate?Ie.predicate:(Fe,lt,Je,Gr)=>he(Fe,lt).length>0}))),W=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool].map(U=>z(U,Mt.tools)),q=[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(U=>z(U,Mt.editor)),re=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(U=>z(U,Mt.export));D=[...R,...q,{label:N(Ai),icon:k(Ai),shortcut:Bt(Ai.name),category:Mt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{mr.set(Ss,"clearCanvas")}},{label:E("buttons.exportImage"),category:Mt.export,icon:rp,shortcut:Bt("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{o({openDialog:{name:"imageExport"}})}},...re];let ge=[{label:E("toolBar.library"),category:Mt.app,icon:qm,viewMode:!1,perform:()=>{I.openSidebar?o({openSidebar:null}):o({openSidebar:{name:co.name,tab:co.defaultTab}})}},{label:E("labels.changeStroke"),keywords:["color","outline"],category:Mt.elements,icon:tp,viewMode:!1,predicate:(U,oe)=>{let Ie=he(U,oe);return Ie.length>0&&g1(oe,Ie)},perform:()=>{o(U=>({openMenu:U.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:E("labels.changeBackground"),keywords:["color","fill"],icon:tp,category:Mt.elements,viewMode:!1,predicate:(U,oe)=>{let Ie=he(U,oe);return Ie.length>0&&h1(oe,Ie)},perform:()=>{o(U=>({openMenu:U.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:E("labels.canvasBackground"),keywords:["color"],icon:tp,category:Mt.editor,viewMode:!1,perform:()=>{o(U=>({openMenu:U.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...jc.reduce((U,oe)=>{let{value:Ie,icon:Fe,key:lt,numericKey:Je}=oe;if(A.UIOptions.tools?.[Ie]===!1)return U;let Wo=lt&&Bi(typeof lt=="string"?lt:lt[0])||Je,nr={label:E(`toolBar.${Ie}`),category:Mt.tools,shortcut:Wo,icon:Fe,keywords:["toolbar"],viewMode:!1,perform:({event:so})=>{Ie==="image"?t.setActiveTool({type:Ie,insertOnCanvasDirectly:so.type==="keydown"}):t.setActiveTool({type:Ie})}};return U.push(nr),U},[]),...W,{label:E("toolBar.lock"),category:Mt.tools,icon:I.activeTool.locked?Ws:Fa,shortcut:S.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${E("labels.textToDiagram")}...`,category:Mt.tools,icon:vw,viewMode:!1,predicate:A.aiEnabled,perform:()=>{o(U=>({...U,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${E("toolBar.mermaidToExcalidraw")}...`,category:Mt.tools,icon:lp,viewMode:!1,predicate:A.aiEnabled,perform:()=>{o(U=>({...U,openDialog:{name:"ttd",tab:"mermaid"}}))}}],le=[...D,...ge,...P||[]].map(U=>({...U,icon:U.icon||mp,order:U.order??h7(U.category),haystack:`${d1(U.label.toLocaleLowerCase())} ${U.keywords?.join(" ")||""}`}));c(le),s(le.find(U=>U.label===a?.label)??null)}},[m,t,i,c,a?.label,s,o]);let[p,u]=Rg(""),[g,h]=Rg(null),[x,v]=Rg({}),y=I=>{o({openDialog:null},I),u("")},w=(I,P)=>{r.openDialog?.name==="commandPalette"&&(P.stopPropagation(),P.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),y(()=>{I.perform({actionManager:i,event:P}),s(I),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},C=f1(I=>I.viewMode===!1&&r.viewModeEnabled?!1:typeof I.predicate=="function"?I.predicate(t.scene.getNonDeletedElements(),r,n,t):I.predicate===void 0||I.predicate),M=f1(I=>{let P=Tn(I.target)||KI(I)||I.key===S.ESCAPE;if(P&&I.key!==S.ARROW_UP&&I.key!==S.ARROW_DOWN&&I.key!==S.ENTER)return;let A=Object.values(x).flat(),N=a&&!p&&C(a);if(I.key===S.ARROW_UP){I.preventDefault();let k=A.findIndex(R=>R.label===g?.label);if(N){if(k===0){h(a);return}if(g===a){let R=A[A.length-1];R&&h(R);return}}let D;k===-1?D=A.length-1:D=k===0?A.length-1:(k-1)%A.length;let z=A[D];z&&h(z);return}if(I.key===S.ARROW_DOWN){I.preventDefault();let k=A.findIndex(R=>R.label===g?.label);if(N){if(!g||k===A.length-1){h(a);return}if(g===a){let R=A[0];R&&h(R);return}}let D=(k+1)%A.length,z=A[D];z&&h(z);return}if(I.key===S.ENTER&&g&&setTimeout(()=>{w(g,I)}),!P){if(I.stopPropagation(),/^[a-zA-Z0-9]$/.test(I.key)){d?.current?.focus();return}I.preventDefault()}});return Ng(()=>(window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})),[M]),Ng(()=>{if(!l)return;let I=k=>{let D={};for(let z of k)D[z.category]?D[z.category].push(z):D[z.category]=[z];return D},P=l.filter(C).sort((k,D)=>k.order-D.order),A=!p&&a&&C(a);if(!p){v(I(A?P.filter(k=>k.label!==a?.label):P)),h(A?a:P[0]||null);return}let N=d1(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));P=m7.filter(N,P,{extract:k=>k.haystack}).sort((k,D)=>D.score-k.score).map(k=>k.original),v(I(P)),h(P[0]??null)},[p,l,C,a]),Kn(xt,{onCloseRequest:()=>y(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[zr(Lg,{value:p,placeholder:E("commandPalette.search.placeholder"),onChange:I=>{u(I)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&Kn("div",{className:"shortcuts-wrapper",children:[zr(Og,{shortcut:"\u2191\u2193",children:E("commandPalette.shortcuts.select")}),zr(Og,{shortcut:"\u21B5",children:E("commandPalette.shortcuts.confirm")}),zr(Og,{shortcut:O("Esc"),children:E("commandPalette.shortcuts.close")})]}),Kn("div",{className:"commands",children:[a&&!p&&Kn("div",{className:"command-category",children:[Kn("div",{className:"command-category-title",children:[E("commandPalette.recents"),zr("div",{className:"icon",style:{marginLeft:"6px"},children:Tw})]}),zr(YI,{command:a,isSelected:a.label===g?.label,onClick:I=>w(a,I),disabled:!C(a),onMouseMove:()=>h(a),showShortcut:!t.device.viewport.isMobile,appState:r})]}),Object.keys(x).length>0?Object.keys(x).map((I,P)=>Kn("div",{className:"command-category",children:[zr("div",{className:"command-category-title",children:I}),x[I].map(A=>zr(YI,{command:A,isSelected:A.label===g?.label,onClick:N=>w(A,N),onMouseMove:()=>h(A),showShortcut:!t.device.viewport.isMobile,appState:r},A.label))]},I)):l?Kn("div",{className:"no-match",children:[zr("div",{className:"icon",children:dp})," ",E("commandPalette.search.noMatch")]}):null]})]})}var YI=({command:e,isSelected:t,disabled:r,onMouseMove:o,onClick:n,showShortcut:i,appState:a})=>{let s=()=>{};return Kn("div",{className:XI("command-item",{"item-selected":t,"item-disabled":r}),ref:l=>{t&&!r&&l?.scrollIntoView?.({block:"nearest"})},onClick:r?s:n,onMouseMove:r?s:o,title:r?E("commandPalette.itemNotAvailable"):"",children:[Kn("div",{className:"name",children:[e.icon&&zr(Fo,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&zr(Og,{shortcut:e.shortcut})]})};Wt();me();Re();$e();ee();import{jsx as b7}from"react/jsx-runtime";var E1=G({name:"toggleLinearEditor",category:Mt.elements,label:(e,t,r)=>r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&n.length===1&&ie(n[0])&&!de(n[0]))},perform(e,t,r,o){let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===n.id?null:new K(n);return{appState:{...t,editingLinearElement:i},storeAction:_.CAPTURE}},PanelComponent:({appState:e,updateData:t,app:r})=>{let o=r.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=E(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return b7(fe,{type:"button",icon:Fw,title:n,"aria-label":n,onClick:()=>t(null)})}});f();ee();f();nd();var Is=class{constructor(t=!0,r=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=r}},$d=class e{onHistoryChangedEmitter=new wr;undoStack=[];redoStack=[];get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(t,r){let o=x1.create(r,t);o.isEmpty()||(this.undoStack.push(o.inverse()),o.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Is(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,r,o,n){return this.perform(t,r,o,()=>e.pop(this.undoStack),i=>e.push(this.redoStack,i,t),n)}redo(t,r,o,n){return this.perform(t,r,o,()=>e.pop(this.redoStack),i=>e.push(this.undoStack,i,t),n)}perform(t,r,o,n,i,a){try{let s=n();if(s===null)return;let l=t,c=r,d=!1;for(;s;){try{[l,c,d]=s.applyTo(l,c,o,a)}finally{i(s)}if(d)break;s=n()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new Is(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let r=t.pop();return r!==void 0?r:null}static push(t,r,o){let n=r.inverse().applyLatestChanges(o);return t.push(n)}},x1=class e{constructor(t,r){this.appStateChange=t;this.elementsChange=r}static create(t,r){return new e(t,r)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(t,r,o,n){let[i,a]=this.elementsChange.applyTo(t,o.elements,n),[s,l]=this.appStateChange.applyTo(r,i);return[i,s,a||l]}applyLatestChanges(t){let r=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};ye();V();Y();Re();f();import{useEffect as E7,useState as x7}from"react";var y1=(e,t)=>{let[r,o]=x7(t);return E7(()=>{let n=e.on(i=>{o(i)});return()=>{n()}},[e]),r};import{jsx as qI}from"react/jsx-runtime";var $I=(e,t)=>{if(!e.multiElement&&!e.resizingElement&&!e.editingElement&&!e.draggingElement){let r=t();if(!r)return{storeAction:_.NONE};let[o,n]=r,i=Array.from(o.values());return{appState:n,elements:i,storeAction:_.UPDATE}}return{storeAction:_.NONE}},ZI=(e,t)=>({name:"undo",label:"buttons.undo",icon:jh,trackEvent:{category:"history"},viewMode:!1,perform:(r,o,n,i)=>$I(o,()=>e.undo(Z(r),o,t.snapshot,i.scene)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.key.toLowerCase()===S.Z&&!r.shiftKey,PanelComponent:({updateData:r,data:o})=>{let{isUndoStackEmpty:n}=y1(e.onHistoryChangedEmitter,new Is(e.isUndoStackEmpty,e.isRedoStackEmpty));return qI(fe,{type:"button",icon:jh,"aria-label":E("buttons.undo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),jI=(e,t)=>({name:"redo",label:"buttons.redo",icon:qh,trackEvent:{category:"history"},viewMode:!1,perform:(r,o,n,i)=>$I(o,()=>e.redo(Z(r),o,t.snapshot,i.scene)),keyTest:r=>r[S.CTRL_OR_CMD]&&r.shiftKey&&r.key.toLowerCase()===S.Z||xm&&r.ctrlKey&&!r.shiftKey&&r.key===S.Y,PanelComponent:({updateData:r,data:o})=>{let{isRedoStackEmpty:n}=y1(e.onHistoryChangedEmitter,new Is(e.isUndoStackEmpty,e.isRedoStackEmpty));return qI(fe,{type:"button",icon:qh,"aria-label":E("buttons.redo"),onClick:r,size:o?.size||"medium",disabled:n,"data-testid":"button-redo"})}});f();V();import{jsx as y7}from"react/jsx-runtime";var w1=(e,t,r,o,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(r,o,i))&&Ce(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Fg=class{actions={};updater;getAppState;getElementsIncludingDeleted;app;constructor(t,r,o,n){this.updater=i=>{if(Cn(i))i.then(a=>t(a));else return t(i)},this.getAppState=r,this.getElementsIncludingDeleted=o,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(r=>this.registerAction(r))}handleKeyDown(t){let r=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in r?r[l.name]:!0)&&l.keyTest&&l.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let n=o[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return w1(n,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(t,r="api",o=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();w1(t,r,i,n,this.app,o),this.updater(t.perform(n,i,o,this.app))}renderAction=(t,r)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in o)||o[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),s=this.getAppState(),l=c=>{w1(n,"ui",s,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return y7(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:l,appProps:this.app.props,app:this.app,data:r})}return null};isActionEnabled=t=>{let r=this.getElementsIncludingDeleted(),o=this.getAppState();return!t.predicate||t.predicate(r,o,this.app.props,this.app)}};$e();Zr();na();Y();Y();el();we();yr();Wt();De();Nn();me();f();var v1=e=>{let t=Array.from(e.values());return{x:JI(t,r=>r.x)/t.length,y:JI(t,r=>r.y)/t.length}},T1=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),JI=(e,t)=>e.reduce((r,o)=>r+t(o),0);Gt();ye();ms();mt();et();cs();zu();dl();_p();Pp();V();ad();f();import w7 from"clsx";import v7 from"react";import{jsx as rc,jsxs as T7}from"react/jsx-runtime";var Sr="separator",QI=v7.memo(({actionManager:e,items:t,top:r,left:o,onClose:n})=>{let i=Gn(),a=da(),s=t.reduce((l,c)=>(c&&(c===Sr||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l),[]);return rc($u,{onCloseRequest:()=>{n()},top:r,left:o,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:rc("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===Sr)return!s[c-1]||s[c-1]===Sr?null:rc("hr",{className:"context-menu-item-separator"},c);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=E(l.label(a,i,e.app)):m=E(l.label)),rc("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(l,"contextMenu")})},children:T7("button",{type:"button",className:w7("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[rc("div",{className:"context-menu-item__label",children:m}),rc("kbd",{className:"context-menu-item__shortcut",children:d?Bt(d):""})]})},c)})})})});f();Y();we();import om from"clsx";import uN from"react";et();V();f();import S7,{useState as I7}from"react";import{Fragment as C7,jsx as S1}from"react/jsx-runtime";var eC=({children:e,onClose:t})=>{let[r,o]=I7(!!e),{container:n}=Ft(),i=S7.useCallback(()=>{o(!1),t&&t(),n?.focus()},[t,n]);return S1(C7,{children:r&&S1(xt,{size:"small",onCloseRequest:i,title:E("errorDialog.title"),children:S1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};f();import{useEffect as R7,useRef as N7,useState as ga}from"react";na();Y();qr();di();et();os();ee();f();import A7 from"clsx";import{jsx as tC,jsxs as M7}from"react/jsx-runtime";var Bg=function({onChange:e,value:t,choices:r,name:o}){return tC("div",{className:"RadioGroup",children:r.map(n=>M7("div",{className:A7("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[tC("input",{name:o,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};f();import k7 from"clsx";import{jsx as rC}from"react/jsx-runtime";var Zd=({title:e,name:t,checked:r,onChange:o,disabled:n=!1})=>rC("div",{className:k7("Switch",{toggled:r,disabled:n}),children:rC("input",{name:t,id:t,title:e,type:"checkbox",checked:r,disabled:n,onChange:()=>o(!r),onKeyDown:i=>{i.key===" "&&o(!r)}})});f();import{forwardRef as P7,useState as L7}from"react";import D7 from"clsx";Hi();V();import{jsx as I1,jsxs as _7}from"react/jsx-runtime";var $n=P7(({children:e,icon:t,onClick:r,label:o,variant:n="filled",color:i="primary",size:a="medium",fullWidth:s,className:l},c)=>{let[d,m]=L7(!1),p=async u=>{let g=r?.(u);if(Cn(g))try{m(!0),await g}catch(h){if(h instanceof Pn)console.warn(h);else throw h}finally{m(!1)}};return I1("button",{className:D7("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,{"ExcButton--fullWidth":s},l),onClick:p,type:"button","aria-label":o,ref:c,disabled:d,children:_7("div",{className:"ExcButton__contents",children:[d&&I1(ir,{}),t&&I1("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??o)]})})});V();import{jsx as ht,jsxs as ha}from"react/jsx-runtime";var O7="filter"in document.createElement("canvas").getContext("2d"),F7=()=>ha("div",{children:[ht("h3",{children:E("canvasError.cannotShowPreview")}),ht("p",{children:ht("span",{children:E("canvasError.canvasTooBig")})}),ha("em",{children:["(",E("canvasError.canvasTooBigTip"),")"]})]}),B7=({appStateSnapshot:e,elementsSnapshot:t,files:r,actionManager:o,onExportImage:n,name:i})=>{let a=qe(t,e),[s,l]=ga(i),[c,d]=ga(a),[m,p]=ga(e.exportBackground),[u,g]=ga(e.exportWithDarkMode),[h,x]=ga(e.exportEmbedScene),[v,y]=ga(e.exportScale),w=N7(null),[C,M]=ga(null),{exportedElements:I,exportingFrame:P}=Es(t,e,c);return R7(()=>{let A=w.current;if(!A)return;let N=A.offsetWidth,k=A.offsetHeight;N&&ia({elements:I,appState:{...e,name:s,exportBackground:m,exportWithDarkMode:u,exportScale:v,exportEmbedScene:h},files:r,exportPadding:Ko,maxWidthOrHeight:Math.max(N,k),exportingFrame:P}).then(D=>(M(null),gi(D).then(()=>{A.replaceChildren(D)}).catch(z=>{throw z.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):z}))).catch(D=>{console.error(D),M(D)})},[e,r,I,P,s,m,u,v,h]),ha("div",{className:"ImageExportModal",children:[ht("h3",{children:E("imageExportDialog.header")}),ha("div",{className:"ImageExportModal__preview",children:[ht("div",{className:"ImageExportModal__preview__canvas",ref:w,children:C&&ht(F7,{})}),ht("div",{className:"ImageExportModal__preview__filename",children:!Wi&&ht("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:A=>{l(A.target.value),o.executeAction(PE,"ui",A.target.value)}})})]}),ha("div",{className:"ImageExportModal__settings",children:[ht("h3",{children:E("imageExportDialog.header")}),a&&ht(jd,{label:E("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ht(Zd,{name:"exportOnlySelected",checked:c,onChange:A=>{d(A)}})}),ht(jd,{label:E("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ht(Zd,{name:"exportBackgroundSwitch",checked:m,onChange:A=>{p(A),o.executeAction(LE,"ui",A)}})}),O7&&ht(jd,{label:E("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ht(Zd,{name:"exportDarkModeSwitch",checked:u,onChange:A=>{g(A),o.executeAction(MS,"ui",A)}})}),ht(jd,{label:E("imageExportDialog.label.embedScene"),tooltip:E("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ht(Zd,{name:"exportEmbedSwitch",checked:h,onChange:A=>{x(A),o.executeAction(ig,"ui",A)}})}),ht(jd,{label:E("imageExportDialog.label.scale"),name:"exportScale",children:ht(Bg,{name:"exportScale",value:v,onChange:A=>{y(A),o.executeAction(AS,"ui",A)},choices:zs.map(A=>({value:A,label:`${A}\xD7`}))})}),ha("div",{className:"ImageExportModal__settings__buttons",children:[ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToPng"),onClick:()=>n(Im.png,I,{exportingFrame:P}),icon:uf,children:E("imageExportDialog.button.exportToPng")}),ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.exportToSvg"),onClick:()=>n(Im.svg,I,{exportingFrame:P}),icon:uf,children:E("imageExportDialog.button.exportToSvg")}),(yl||ti)&&ht($n,{className:"ImageExportModal__settings__buttons__button",label:E("imageExportDialog.title.copyPngToClipboard"),onClick:()=>n(Im.clipboard,I,{exportingFrame:P}),icon:ap,children:E("imageExportDialog.button.copyPngToClipboard")})]})]})]})},jd=({label:e,children:t,tooltip:r,name:o})=>ha("div",{className:"ImageExportModal__settings__setting",title:e,children:[ha("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,r&&ht(Eo,{label:r,long:!0,children:hw})]}),ht("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),oC=({elements:e,appState:t,files:r,actionManager:o,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ga(()=>({appStateSnapshot:Xr(t),elementsSnapshot:Xr(e)}));return ht(xt,{onCloseRequest:i,size:"wide",title:!1,children:ht(B7,{elementsSnapshot:l,appStateSnapshot:s,files:r,actionManager:o,onExportImage:n,name:a})})};f();import z7 from"clsx";import{jsx as H7}from"react/jsx-runtime";var zg=({children:e,side:t,className:r})=>H7("div",{className:z7("FixedSideContainer",`FixedSideContainer_side_${t}`,r),children:e});f();me();V();Zr();import{jsx as nC}from"react/jsx-runtime";var U7=({appState:e,isMobile:t,device:r,app:o})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar&&!r.editor.canFitSidebar)return null;if($r(e))return E("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return l?E("hints.linearElementMulti"):n.type==="arrow"?E("hints.arrowTool",{arrowShortcut:O("A")}):E("hints.linearElement");if(n.type==="freedraw")return E("hints.freeDraw");if(n.type==="text")return E("hints.text");if(n.type==="embeddable")return E("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return E("hints.placeImage");let c=o.scene.getSelectedElements(e);if(i&&s==="mouse"&&c.length===1){let d=c[0];return ie(d)&&d.points.length===2?E("hints.lockAngle"):So(d)?E("hints.resizeImage"):E("hints.resize")}if(a&&s==="mouse")return E("hints.rotate");if(c.length===1&&H(c[0]))return E("hints.text_selected");if(e.editingElement&&H(e.editingElement))return E("hints.text_editing");if(n.type==="selection"){if(e.draggingElement?.type==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return E("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return E("hints.disableSnapping");if(!c.length&&!t)return E("hints.canvasPanning");if(c.length===1){if(ie(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?E("hints.lineEditor_pointSelected"):E("hints.lineEditor_nothingSelected"):E("hints.lineEditor_info");if(!e.draggingElement&&Mn(c[0]))return E("hints.bindTextToElement")}}return null},Hg=({appState:e,isMobile:t,device:r,app:o})=>{let n=U7({appState:e,isMobile:t,device:r,app:o});return n?(n=O(n),nC("div",{className:"HintViewer",children:nC("span",{children:n})})):null};f();ee();import G7 from"clsx";import{jsx as aC,jsxs as V7}from"react/jsx-runtime";var W7="medium",iC={CHECKED:Ws,UNCHECKED:Fa},Ug=e=>V7("label",{className:G7("ToolIcon ToolIcon__lock",`ToolIcon_size_${W7}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[aC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),aC("div",{className:"ToolIcon__icon",children:e.checked?iC.CHECKED:iC.UNCHECKED})]});f();we();et();f();import{Fragment as Y7,jsx as sC,jsxs as X7}from"react/jsx-runtime";var fa=({heading:e,children:t,...r})=>{let{id:o}=Ft(),n=sC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:E(`headings.${e}`)});return sC("section",{...r,"aria-labelledby":`${o}-${e}-title`,children:typeof t=="function"?t(n):X7(Y7,{children:[n,t]})})};f();we();V();var fn=4,Zn=6,lC="rgba(0,0,0,0.3)",cC=(e,t,r,o)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,s]=Te(e),l=t/o.zoom.value,c=r/o.zoom.value,d=t-l,m=r-c,p={top:parseInt(vc("sat"))||0,bottom:parseInt(vc("sab"))||0,left:parseInt(vc("sal"))||0,right:parseInt(vc("sar"))||0},u=ei().rtl,g=-o.scrollX+d/2+p.left,h=-o.scrollY+m/2+p.top,x=g+l-p.right,v=h+c-p.bottom,y=Math.min(n,g),w=Math.min(i,h),C=Math.max(a,x),M=Math.max(s,v);return{horizontal:g===y&&x===C?null:{x:Math.max(p.left,fn)+(g-y)/(C-y)*t,y:r-Zn-Math.max(fn,p.bottom),width:(x-g)/(C-y)*t-Math.max(fn*2,p.left+p.right),height:Zn},vertical:h===w&&v===M?null:{x:u?Math.max(p.left,fn):t-Zn-Math.max(p.right,fn),y:(h-w)/(M-w)*r+Math.max(p.top,fn),width:Zn,height:(v-h)/(M-w)*r-Math.max(fn*2,p.top+p.bottom)}}},C1=(e,t,r)=>{let[o,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=r&&r<=a.y+a.height);return{isOverEither:o||n,isOverHorizontal:o,isOverVertical:n}};f();ee();import K7 from"clsx";import{jsx as dC,jsxs as Z7}from"react/jsx-runtime";var $7="medium",Gg=e=>e.penDetected?Z7("label",{className:K7("ToolIcon ToolIcon__penMode",`ToolIcon_size_${$7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[dC("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),dC("div",{className:"ToolIcon__icon",children:hy})]}):null;f();import j7 from"clsx";ee();ye();import{jsx as q7}from"react/jsx-runtime";var Wg=e=>q7(fe,{className:j7("Shape",{fillable:!1}),type:"radio",icon:ip,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:S.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":S.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});Zr();import{Fragment as J7,jsx as dr,jsxs as ba}from"react/jsx-runtime";var mC=({appState:e,elements:t,actionManager:r,setAppState:o,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:s,renderCustomStats:l,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:g,MainMenuTunnel:h,DefaultSidebarTriggerTunnel:x}=ut(),v=()=>ba(zg,{side:"top",className:"App-top-bar",children:[m&&dr(g.Out,{}),dr(fa,{heading:"shapes",children:w=>dr(rr.Col,{gap:4,align:"center",children:ba(rr.Row,{gap:1,className:"App-toolbar-container",children:[ba(Yt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,dr(rr.Row,{gap:1,children:dr(_g,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),s&&s(!0,e),ba("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&dr(x.Out,{}),dr(Gg,{checked:e.penMode,onChange:()=>a(null),title:E("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),dr(Ug,{checked:e.activeTool.locked,onChange:n,title:E("toolBar.lock"),isMobile:!0}),dr(Wg,{checked:qo(e),onChange:()=>i(),title:E("toolBar.hand"),isMobile:!0})]})]})})}),dr(Hg,{appState:e,isMobile:!0,device:d,app:u})]}),y=()=>e.viewModeEnabled?dr("div",{className:"App-toolbar-content",children:dr(h.Out,{})}):ba("div",{className:"App-toolbar-content",children:[dr(h.Out,{}),r.renderAction("toggleEditMenu"),r.renderAction("undo"),r.renderAction("redo"),r.renderAction(e.multiElement?"finalize":"duplicateSelection"),r.renderAction("deleteSelectedElements")]});return ba(J7,{children:[c(),!e.viewModeEnabled&&v(),dr("div",{className:"App-bottom-bar",style:{marginBottom:Zn+fn*2,marginLeft:Zn+fn*2,marginRight:Zn+fn*2},children:ba(Yt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&us(e,t)?dr(fa,{className:"App-mobile-menu",heading:"selectedShapeActions",children:dr(Dg,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:r.renderAction})}):null,ba("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&dr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(w=>({..._n(t,w)}))},children:E("buttons.scrollBackToContent")})]})]})})]})};f();import Q7 from"open-color";import e_,{useLayoutEffect as t_,useRef as r_,useState as o_}from"react";db();md();import{jsx as qd,jsxs as n_}from"react/jsx-runtime";var pC=e=>{let t=r_(null),[r,o]=o_(null);return t_(()=>{if(!e.spreadsheet)return;let n=oT(e.chartType,e.spreadsheet,0,0);o(n);let i,a=t.current;return(async()=>(i=await bl(n,{exportBackground:!1,viewBackgroundColor:Q7.white},null),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),qd("button",{type:"button",className:"ChartPreview",onClick:()=>{r&&e.onClick(e.chartType,r)},children:qd("div",{ref:t})})},uC=({setAppState:e,appState:t,onClose:r})=>{let{onInsertElements:o}=tr(),n=e_.useCallback(()=>{r&&r()},[r]),i=(a,s)=>{o(s),Ce("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return qd(xt,{size:"small",onCloseRequest:n,title:E("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:n_("div",{className:"container",children:[qd(pC,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),qd(pC,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};f();import i_ from"react";ye();V();ee();na();Y();import{Fragment as hC,jsx as $,jsxs as yo}from"react/jsx-runtime";var a_=()=>yo("div",{className:"HelpDialog__header",children:[yo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Zh}),E("helpDialog.documentation")]}),yo("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Zh}),E("helpDialog.blog")]}),yo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:ep}),E("helpDialog.github")]}),yo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[$("div",{className:"HelpDialog__link-icon",children:Nw}),"YouTube"]})]}),s_=e=>yo(hC,{children:[$("h3",{children:e.title}),$("div",{className:"HelpDialog__islands-container",children:e.children})]}),A1=e=>yo("div",{className:`HelpDialog__island ${e.className}`,children:[$("h4",{className:"HelpDialog__island-title",children:e.caption}),$("div",{className:"HelpDialog__island-content",children:e.children})]});function*l_(e,t){let r=!0;for(let o of e)r||(yield t),r=!1,yield o}var c_=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),te=({label:e,shortcuts:t,isOr:r=!0})=>{let o=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>$(d_,{children:c_(a)},a)));return yo("div",{className:"HelpDialog__shortcut",children:[$("div",{children:e}),$("div",{className:"HelpDialog__key-container",children:[...l_(o,r?E("helpDialog.or"):null)]})]})},d_=e=>$("kbd",{className:"HelpDialog__key",...e}),gC=({onClose:e})=>{let t=i_.useCallback(()=>{e&&e()},[e]);return $(hC,{children:yo(xt,{onCloseRequest:t,title:E("helpDialog.title"),className:"HelpDialog",children:[$(a_,{}),yo(s_,{title:E("helpDialog.shortcuts"),children:[yo(A1,{className:"HelpDialog__island--tools",caption:E("helpDialog.tools"),children:[$(te,{label:E("toolBar.hand"),shortcuts:[S.H]}),$(te,{label:E("toolBar.selection"),shortcuts:[S.V,S[1]]}),$(te,{label:E("toolBar.rectangle"),shortcuts:[S.R,S[2]]}),$(te,{label:E("toolBar.diamond"),shortcuts:[S.D,S[3]]}),$(te,{label:E("toolBar.ellipse"),shortcuts:[S.O,S[4]]}),$(te,{label:E("toolBar.arrow"),shortcuts:[S.A,S[5]]}),$(te,{label:E("toolBar.line"),shortcuts:[S.L,S[6]]}),$(te,{label:E("toolBar.freedraw"),shortcuts:[S.P,S[7]]}),$(te,{label:E("toolBar.text"),shortcuts:[S.T,S[8]]}),$(te,{label:E("toolBar.image"),shortcuts:[S[9]]}),$(te,{label:E("toolBar.eraser"),shortcuts:[S.E,S[0]]}),$(te,{label:E("toolBar.frame"),shortcuts:[S.F]}),$(te,{label:E("toolBar.laser"),shortcuts:[S.K]}),$(te,{label:E("labels.eyeDropper"),shortcuts:[S.I,"Shift+S","Shift+G"]}),$(te,{label:E("helpDialog.editLineArrowPoints"),shortcuts:[O("CtrlOrCmd+Enter")]}),$(te,{label:E("helpDialog.editText"),shortcuts:[O("Enter")]}),$(te,{label:E("helpDialog.textNewLine"),shortcuts:[O("Enter"),O("Shift+Enter")]}),$(te,{label:E("helpDialog.textFinish"),shortcuts:[O("Esc"),O("CtrlOrCmd+Enter")]}),$(te,{label:E("helpDialog.curvedArrow"),shortcuts:["A",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),$(te,{label:E("helpDialog.curvedLine"),shortcuts:["L",E("helpDialog.click"),E("helpDialog.click"),E("helpDialog.click")],isOr:!1}),$(te,{label:E("toolBar.lock"),shortcuts:[S.Q]}),$(te,{label:E("helpDialog.preventBinding"),shortcuts:[O("CtrlOrCmd")]}),$(te,{label:E("toolBar.link"),shortcuts:[O("CtrlOrCmd+K")]})]}),yo(A1,{className:"HelpDialog__island--view",caption:E("helpDialog.view"),children:[$(te,{label:E("buttons.zoomIn"),shortcuts:[O("CtrlOrCmd++")]}),$(te,{label:E("buttons.zoomOut"),shortcuts:[O("CtrlOrCmd+-")]}),$(te,{label:E("buttons.resetZoom"),shortcuts:[O("CtrlOrCmd+0")]}),$(te,{label:E("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),$(te,{label:E("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),$(te,{label:E("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),$(te,{label:E("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),$(te,{label:E("buttons.zenMode"),shortcuts:[O("Alt+Z")]}),$(te,{label:E("buttons.objectsSnapMode"),shortcuts:[O("Alt+S")]}),$(te,{label:E("labels.toggleGrid"),shortcuts:[O("CtrlOrCmd+'")]}),$(te,{label:E("labels.viewMode"),shortcuts:[O("Alt+R")]}),$(te,{label:E("labels.toggleTheme"),shortcuts:[O("Alt+Shift+D")]}),$(te,{label:E("stats.fullTitle"),shortcuts:[O("Alt+/")]}),$(te,{label:E("commandPalette.title"),shortcuts:ti?[Bt("commandPalette")]:[Bt("commandPalette"),Bt("commandPalette",1)]})]}),yo(A1,{className:"HelpDialog__island--editor",caption:E("helpDialog.editor"),children:[$(te,{label:E("labels.moveCanvas"),shortcuts:[O(`Space+${E("helpDialog.drag")}`),O(`Wheel+${E("helpDialog.drag")}`)],isOr:!0}),$(te,{label:E("buttons.clearReset"),shortcuts:[O("CtrlOrCmd+Delete")]}),$(te,{label:E("labels.delete"),shortcuts:[O("Delete")]}),$(te,{label:E("labels.cut"),shortcuts:[O("CtrlOrCmd+X")]}),$(te,{label:E("labels.copy"),shortcuts:[O("CtrlOrCmd+C")]}),$(te,{label:E("labels.paste"),shortcuts:[O("CtrlOrCmd+V")]}),$(te,{label:E("labels.pasteAsPlaintext"),shortcuts:[O("CtrlOrCmd+Shift+V")]}),$(te,{label:E("labels.selectAll"),shortcuts:[O("CtrlOrCmd+A")]}),$(te,{label:E("labels.multiSelect"),shortcuts:[O(`Shift+${E("helpDialog.click")}`)]}),$(te,{label:E("helpDialog.deepSelect"),shortcuts:[O(`CtrlOrCmd+${E("helpDialog.click")}`)]}),$(te,{label:E("helpDialog.deepBoxSelect"),shortcuts:[O(`CtrlOrCmd+${E("helpDialog.drag")}`)]}),(yl||ti)&&$(te,{label:E("labels.copyAsPng"),shortcuts:[O("Shift+Alt+C")]}),$(te,{label:E("labels.copyStyles"),shortcuts:[O("CtrlOrCmd+Alt+C")]}),$(te,{label:E("labels.pasteStyles"),shortcuts:[O("CtrlOrCmd+Alt+V")]}),$(te,{label:E("labels.sendToBack"),shortcuts:[Cr?O("CtrlOrCmd+Alt+["):O("CtrlOrCmd+Shift+[")]}),$(te,{label:E("labels.bringToFront"),shortcuts:[Cr?O("CtrlOrCmd+Alt+]"):O("CtrlOrCmd+Shift+]")]}),$(te,{label:E("labels.sendBackward"),shortcuts:[O("CtrlOrCmd+[")]}),$(te,{label:E("labels.bringForward"),shortcuts:[O("CtrlOrCmd+]")]}),$(te,{label:E("labels.alignTop"),shortcuts:[O("CtrlOrCmd+Shift+Up")]}),$(te,{label:E("labels.alignBottom"),shortcuts:[O("CtrlOrCmd+Shift+Down")]}),$(te,{label:E("labels.alignLeft"),shortcuts:[O("CtrlOrCmd+Shift+Left")]}),$(te,{label:E("labels.alignRight"),shortcuts:[O("CtrlOrCmd+Shift+Right")]}),$(te,{label:E("labels.duplicateSelection"),shortcuts:[O("CtrlOrCmd+D"),O(`Alt+${E("helpDialog.drag")}`)]}),$(te,{label:E("helpDialog.toggleElementLock"),shortcuts:[O("CtrlOrCmd+Shift+L")]}),$(te,{label:E("buttons.undo"),shortcuts:[O("CtrlOrCmd+Z")]}),$(te,{label:E("buttons.redo"),shortcuts:xm?[O("CtrlOrCmd+Y"),O("CtrlOrCmd+Shift+Z")]:[O("CtrlOrCmd+Shift+Z")]}),$(te,{label:E("labels.group"),shortcuts:[O("CtrlOrCmd+G")]}),$(te,{label:E("labels.ungroup"),shortcuts:[O("CtrlOrCmd+Shift+G")]}),$(te,{label:E("labels.flipHorizontal"),shortcuts:[O("Shift+H")]}),$(te,{label:E("labels.flipVertical"),shortcuts:[O("Shift+V")]}),$(te,{label:E("labels.showStroke"),shortcuts:[O("S")]}),$(te,{label:E("labels.showBackground"),shortcuts:[O("G")]}),$(te,{label:E("labels.showFonts"),shortcuts:[O("Shift+F")]}),$(te,{label:E("labels.decreaseFontSize"),shortcuts:[O("CtrlOrCmd+Shift+<")]}),$(te,{label:E("labels.increaseFontSize"),shortcuts:[O("CtrlOrCmd+Shift+>")]})]})]})]})})};f();import Vg,{useLayoutEffect as m_}from"react";import fC from"clsx";import*as Ea from"@radix-ui/react-popover";V();Y();import{Fragment as f_,jsx as jn,jsxs as Yg}from"react/jsx-runtime";var p_=4,u_=8,g_=({shouldWrap:e,children:t,username:r})=>e?jn(Eo,{label:r||"Unknown user",children:t}):jn(f_,{children:t}),M1=({actionManager:e,collaborator:t,socketId:r,withName:o=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:r,collaborator:t,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return jn(g_,{username:t.username,shouldWrap:n,children:s},r)},h_=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Xg=Vg.memo(({className:e,mobile:t,collaborators:r,userToFollow:o})=>{let n=Xt(),i=new Map;r.forEach((h,x)=>{let v=h.id||x;i.set(v,{...h,socketId:x})});let a=Array.from(i.values()).filter(h=>h.username?.trim()),[s,l]=Vg.useState(""),c=a.filter(h=>h.username?.toLowerCase().includes(s)),d=Vg.useRef(null);m_(()=>{if(d.current){let h=v=>{let y=Math.max(1,Math.min(8,Math.floor(v/38)));p(y)};if(h(d.current.clientWidth),!hc)return;let x=new ResizeObserver(v=>{for(let y of v){let{width:w}=y.contentRect;h(w)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[m,p]=Vg.useState(p_),g=a.slice(0,m-1).map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===o}));return t?jn("div",{className:fC("UserList UserList_mobile",e),children:a.map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===o}))}):jn("div",{className:"UserList__wrapper",ref:d,children:Yg("div",{className:fC("UserList",e),style:{"--max-avatars":m},children:[g,a.length>m-1&&Yg(Ea.Root,{children:[Yg(Ea.Trigger,{className:"UserList__more",children:["+",a.length-m+1]}),jn(Ea.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Yg(Yt,{padding:2,children:[a.length>=u_&&jn(Zu,{placeholder:E("quickSearch.placeholder"),onChange:l}),jn(ju,{className:"dropdown-menu UserList__collaborators",placeholder:E("userList.empty"),children:c.length>0?[jn("div",{className:"hint",children:E("userList.hint.text")}),c.map(h=>M1({actionManager:n,collaborator:h,socketId:h.socketId,withName:!0,isBeingFollowed:h.socketId===o}))]:[]}),jn(Ea.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let r=t.collaborators.keys();for(let[o,n]of e.collaborators){let i=t.collaborators.get(o);if(!i||o!==r.next().value||!it(n,i,h_))return!1}return!0});f();import E_ from"react";ee();f();import k1 from"open-color";import{jsx as b_}from"react/jsx-runtime";var P1=({children:e,color:t})=>b_("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":k1[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":k1[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":k1[t][9]},children:e});di();V();import{Fragment as y_,jsx as bn,jsxs as Kg}from"react/jsx-runtime";var x_=({elements:e,appState:t,setAppState:r,files:o,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return bn("div",{className:"ExportDialog ExportDialog--json",children:Kg("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Kg(P1,{color:"lime",children:[bn("div",{className:"Card-icon",children:Ay}),bn("h2",{children:E("exportDialog.disk_title")}),Kg("div",{className:"Card-details",children:[E("exportDialog.disk_details"),!Wi&&n.renderAction("changeProjectName")]}),bn(fe,{className:"Card-button",type:"button",title:E("exportDialog.disk_button"),"aria-label":E("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Ud,"ui")}})]}),l&&Kg(P1,{color:"pink",children:[bn("div",{className:"Card-icon",children:Lc}),bn("h2",{children:E("exportDialog.link_title")}),bn("div",{className:"Card-details",children:E("exportDialog.link_details")}),bn(fe,{className:"Card-button",type:"button",title:E("exportDialog.link_button"),"aria-label":E("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ce("export","link",`ui (${R0()})`),await l(e,t,o),s()}catch(c){r({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,o,a)]})})},bC=({elements:e,appState:t,files:r,actionManager:o,exportOpts:n,canvas:i,setAppState:a})=>{let s=E_.useCallback(()=>{a({openDialog:null})},[a]);return bn(y_,{children:t.openDialog?.name==="jsonExport"&&bn(xt,{onCloseRequest:s,title:E("buttons.export"),children:bn(x_,{elements:e,appState:t,setAppState:a,files:r,actionManager:o,onCloseRequest:s,exportOpts:n,canvas:i})})})};f();import $g from"clsx";f();ee();import{jsx as w_}from"react/jsx-runtime";var EC=e=>w_("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${E("helpDialog.title")} \u2014 ?`,"aria-label":E("helpDialog.title"),children:Vs});import{jsx as qn,jsxs as L1}from"react/jsx-runtime";var xC=({appState:e,actionManager:t,showExitZenModeBtn:r,renderWelcomeScreen:o})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ut(),a=Ne(),s=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return L1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[qn("div",{className:$g("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:qn(rr.Col,{gap:2,children:L1(fa,{heading:"canvasActions",children:[qn(HI,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&qn(UI,{renderAction:t.renderAction,className:$g("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),s&&qn(WI,{renderAction:t.renderAction,className:$g("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),qn(n.Out,{}),qn("div",{className:$g("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:L1("div",{style:{position:"relative"},children:[o&&qn(i.Out,{}),qn(EC,{onClick:()=>t.executeAction(ws)})]})}),qn(GI,{actionManager:t,showExitZenModeBtn:r})]})},yC=xC;xC.displayName="Footer";f();import{useEffect as PC,useLayoutEffect as LC,useRef as H1,useState as k_,forwardRef as DC,useImperativeHandle as P_,useCallback as MC}from"react";import{atom as L_,useSetAtom as D_}from"jotai";f();import v_ from"react";var Zg=v_.createContext({});f();import T_ from"clsx";import{useContext as S_}from"react";ee();import{jsx as D1,jsxs as wC}from"react/jsx-runtime";var _1=({children:e,className:t})=>{let r=Ne(),o=S_(Zg),n=!!(r.editor.canFitSidebar&&o.shouldRenderDockButton);return wC("div",{className:T_("sidebar__header",t),"data-testid":"sidebar-header",children:[e,wC("div",{className:"sidebar__header__buttons",children:[n&&D1(Eo,{label:E("labels.sidebarLock"),children:D1(Yn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":E("labels.sidebarLock"),children:iy})}),D1(Yn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":E("buttons.close"),children:Ao})]})]})};_1.displayName="SidebarHeader";import __ from"clsx";V();ye();Y();f();import I_ from"clsx";import{jsx as R1,jsxs as vC}from"react/jsx-runtime";var N1=({name:e,tab:t,icon:r,title:o,children:n,onToggle:i,className:a,style:s})=>{let l=Oe(),c=Ue();return vC("label",{title:o,className:"sidebar-trigger__label-element",children:[R1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;l({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":o,"aria-keyshortcuts":"0"}),vC("div",{className:I_("sidebar-trigger",a),style:s,children:[r&&R1("div",{children:r}),n&&R1("div",{className:"sidebar-trigger__label",children:n})]})]})};N1.displayName="SidebarTrigger";f();import*as TC from"@radix-ui/react-tabs";import{jsx as C_}from"react/jsx-runtime";var O1=({children:e,...t})=>C_(TC.List,{className:"sidebar-triggers",...t,children:e});O1.displayName="SidebarTabTriggers";f();import*as IC from"@radix-ui/react-tabs";import{jsx as SC}from"react/jsx-runtime";var F1=({children:e,tab:t,onSelect:r,...o})=>SC(IC.Trigger,{value:t,asChild:!0,onSelect:r,children:SC("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});F1.displayName="SidebarTabTrigger";f();import*as CC from"@radix-ui/react-tabs";import{jsx as A_}from"react/jsx-runtime";var B1=({children:e,...t})=>{let r=Ue(),o=Oe();if(!r.openSidebar)return null;let{name:n}=r.openSidebar;return A_(CC.Root,{className:"sidebar-tabs-root",value:r.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...t,children:e})};B1.displayName="SidebarTabs";f();import*as AC from"@radix-ui/react-tabs";import{jsx as M_}from"react/jsx-runtime";var z1=({tab:e,children:t,...r})=>M_(AC.Content,{...r,value:e,"data-testid":e,children:t});z1.displayName="SidebarTab";import{jsx as kC}from"react/jsx-runtime";import{createElement as R_}from"react";var Jd=L_(!1),_C=DC(({name:e,children:t,onDock:r,docked:o,className:n,...i},a)=>{T.DEV&&r&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Oe(),l=D_(Jd,Xe);LC(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=H1({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>r?.(u),c.current=Us(c.current,{docked:o,shouldRenderDockButton:!!r&&o!=null});let d=H1(null);P_(a,()=>d.current);let m=Ne(),p=MC(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Bl(d,MC(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.editor.canFitSidebar)&&p()},[p,o,m.editor.canFitSidebar])),PC(()=>{let u=g=>{g.key===S.ESCAPE&&(!o||!m.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,o,m.editor.canFitSidebar]),kC(Yt,{...i,className:__("sidebar",{"sidebar--docked":o},n),ref:d,children:kC(Zg.Provider,{value:c.current,children:t})})});_C.displayName="SidebarInner";var Li=Object.assign(DC((e,t)=>{let r=Ue(),{onStateChange:o}=e,n=H1(r.openSidebar);PC(()=>{(!r.openSidebar&&n?.current?.name===e.name||r.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&r.openSidebar!==n.current&&o?.(r.openSidebar?.name!==e.name?null:r.openSidebar),n.current=r.openSidebar},[r.openSidebar,o,e.name]);let[i,a]=k_(!1);return LC(()=>(a(!0),()=>a(!1)),[]),i&&r.openSidebar?.name===e.name?R_(_C,{...e,ref:t,key:e.name}):null}),{Header:_1,TabTriggers:O1,TabTrigger:F1,Tabs:B1,Tab:z1,Trigger:N1});Li.displayName="Sidebar";import{Provider as gN,useAtom as hN,useAtomValue as fN}from"jotai";f();var W1={};Ch(W1,{ChangeCanvasBackground:()=>YC,ClearCanvas:()=>WC,CommandPalette:()=>UC,Export:()=>XC,Help:()=>GC,LiveCollaborationTrigger:()=>$C,LoadScene:()=>BC,SaveAsImage:()=>HC,SaveToActiveFile:()=>zC,Socials:()=>KC,ToggleTheme:()=>VC});f();ee();ee();import F_ from"clsx";import{useSetAtom as B_}from"jotai";f();import{atom as N_}from"jotai";var U1=N_({active:!1});async function RC({title:e,description:t,actionLabel:r,color:o}){return new Promise(n=>{mr.set(U1,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:r,color:o})})}f();import{Fragment as O_,jsx as G1,jsxs as NC}from"react/jsx-runtime";var OC=({value:e,shortcut:t,onChange:r,choices:o,children:n,name:i})=>{let a=Ne();return NC(O_,{children:[NC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[G1("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),G1(Bg,{name:i,value:e,onChange:r,choices:o})]}),t&&!a.editor.isMobile&&G1("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};OC.displayName="DropdownMenuItemContentRadio";var FC=OC;Y();import{Fragment as z_,jsx as or,jsxs as ZC}from"react/jsx-runtime";var BC=()=>{let{t:e}=Dt(),t=Xt(),r=da();return t.isActionEnabled(Wl)?or(eo,{icon:Ys,onSelect:async()=>{(!r.length||await RC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:or(Br,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>or("strong",{children:n}),br:()=>or("br",{})})}))&&t.executeAction(Wl)},"data-testid":"load-button",shortcut:Bt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};BC.displayName="LoadScene";var zC=()=>{let{t:e}=Dt(),t=Xt();return t.isActionEnabled(ag)?or(eo,{shortcut:Bt("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(ag),icon:Sy,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};zC.displayName="SaveToActiveFile";var HC=()=>{let e=Oe(),{t}=Dt();return or(eo,{icon:rp,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Bt("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};HC.displayName="SaveAsImage";var UC=e=>{let t=Oe(),{t:r}=Dt();return or(eo,{icon:mp,"data-testid":"command-palette-button",onSelect:()=>{Ce("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:Bt("commandPalette"),"aria-label":r("commandPalette.title"),className:e?.className,children:r("commandPalette.title")})};UC.displayName="CommandPalette";var GC=()=>{let{t:e}=Dt(),t=Xt();return or(eo,{"data-testid":"help-menu-item",icon:Vs,onSelect:()=>t.executeAction(ws),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};GC.displayName="Help";var WC=()=>{let{t:e}=Dt(),t=B_(Ss,Xe);return Xt().isActionEnabled(Ai)?or(eo,{icon:tn,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};WC.displayName="ClearCanvas";var VC=e=>{let{t}=Dt(),r=Ue(),o=Xt(),n=Bt("toggleTheme");return o.isActionEnabled(bs)?e?.allowSystemTheme?or(FC,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ue.LIGHT,label:Pc,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:ue.DARK,label:kc,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:Rw,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):or(eo,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(r.theme===ue.DARK?ue.LIGHT:ue.DARK);else return o.executeAction(bs)},icon:r.theme===ue.DARK?Pc:kc,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":r.theme===ue.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:r.theme===ue.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};VC.displayName="ToggleTheme";var YC=()=>{let{t:e}=Dt(),t=Ue(),r=Xt(),o=Wn();return t.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:ZC("div",{style:{marginTop:"0.5rem"},children:[or("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),or("div",{style:{padding:"0 0.625rem"},children:r.renderAction("changeViewBackgroundColor")})]})};YC.displayName="ChangeCanvasBackground";var XC=()=>{let{t:e}=Dt(),t=Oe();return or(eo,{icon:Ba,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};XC.displayName="Export";var KC=()=>{let{t:e}=Dt();return ZC(z_,{children:[or(Ql,{icon:ep,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),or(Ql,{icon:vy,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),or(Ql,{icon:wy,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};KC.displayName="Socials";var $C=({onSelect:e,isCollaborating:t})=>{let{t:r}=Dt();return or(eo,{"data-testid":"collab-button",icon:op,className:F_({"active-collab":t}),onSelect:e,children:r("labels.liveCollaboration")})};$C.displayName="LiveCollaborationTrigger";ee();f();import{atom as H_,useAtom as U_}from"jotai";import{useLayoutEffect as G_,useRef as W_}from"react";import{jsx as V_}from"react/jsx-runtime";var Di=(e,t)=>{let r=H_(0),o=n=>{let{jotaiScope:i}=ut(),[,a]=U_(r,i),s=W_({preferHost:!1,counter:0});return G_(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),n.__fallback||(s.current.preferHost=!0),!s.current.counter&&n.__fallback&&s.current.preferHost||s.current.counter>1&&n.__fallback?null:V_(t,{...n})};return o.displayName=e,o};V();import{jsx as jg,jsxs as V1}from"react/jsx-runtime";var Y_=Object.assign(Di("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:r}=ut(),o=Ne(),n=Ue(),i=Oe(),a=o.editor.isMobile?void 0:()=>i({openMenu:null});return jg(r.In,{children:V1(Ye,{open:n.openMenu==="canvas",children:[jg(Ye.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Qm}),V1(Ye.Content,{onClickOutside:a,onSelect:zi(t,()=>{i({openMenu:null})}),children:[e,o.editor.isMobile&&n.collaborators.size>0&&V1("fieldset",{className:"UserList-Wrapper",children:[jg("legend",{children:E("labels.collaborators")}),jg(Xg,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ye.Trigger,Item:Ye.Item,ItemLink:Ye.ItemLink,ItemCustom:Ye.ItemCustom,Group:Ye.Group,Separator:Ye.Separator,DefaultItems:W1}),Hr=Y_;f();import{useAtom as Z_}from"jotai";ee();f();import{jsx as oc,jsxs as $_}from"react/jsx-runtime";var qg=({title:e,children:t,actionLabel:r,onClick:o})=>$_("div",{className:"OverwriteConfirm__Actions__Action",children:[oc("h4",{children:e}),oc("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),oc($n,{variant:"outlined",color:"muted",label:r,size:"large",fullWidth:!0,onClick:o})]}),X_=()=>{let{t:e}=Dt(),t=Xt(),r=Oe();return oc(qg,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(ig,"ui",!0),r({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},K_=()=>{let{t:e}=Dt(),t=Xt();return oc(qg,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(Ud,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Y1=Object.assign(({children:e})=>oc("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:X_,SaveToDisk:K_});import{jsx as xa,jsxs as jC}from"react/jsx-runtime";var Jg=Object.assign(Di("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=ut(),[r,o]=Z_(U1,Xe);if(!r.active)return null;let n=()=>{r.onClose(),o(a=>({...a,active:!1}))},i=()=>{r.onConfirm(),o(a=>({...a,active:!1}))};return xa(t.In,{children:xa(xt,{onCloseRequest:n,title:!1,size:916,children:jC("div",{className:"OverwriteConfirm",children:[xa("h3",{children:r.title}),jC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${r.color}`,children:[xa("div",{className:"OverwriteConfirm__Description__icon",children:fw}),xa("div",{children:r.description}),xa("div",{className:"OverwriteConfirm__Description__spacer"}),xa($n,{color:r.color,size:"large",label:r.actionLabel,onClick:i})]}),xa(Y1,{children:e})]})})})}),{Actions:Y1,Action:qg});Zr();ee();f();Y();import j_ from"clsx";V();import{jsx as ya,jsxs as qC}from"react/jsx-runtime";import{createElement as q_}from"react";var JC=Di("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=ut();return ya(t.In,{children:ya(Li.Trigger,{...e,className:"default-sidebar-trigger",name:co.name})})});JC.displayName="DefaultSidebarTrigger";var QC=({children:e,...t})=>{let{DefaultSidebarTabTriggersTunnel:r}=ut();return ya(r.In,{children:ya(Li.TabTriggers,{...t,children:e})})};QC.displayName="DefaultTabTriggers";var Qg=Object.assign(Di("DefaultSidebar",({children:e,className:t,onDock:r,docked:o,...n})=>{let i=Ue(),a=Oe(),{DefaultSidebarTabTriggersTunnel:s}=ut();return q_(Li,{...n,name:"default",key:"default",className:j_("default-sidebar",t),docked:o??i.defaultSidebarDockedPreference,onDock:r===!1||!r&&o!=null?void 0:zi(r,l=>{a({defaultSidebarDockedPreference:l})})},qC(Li.Tabs,{children:[qC(Li.Header,{children:[n.__fallback&&ya("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:E("toolBar.library")}),ya(s.Out,{})]}),ya(Li.Tab,{tab:wc,children:ya(FI,{})}),e]}))}),{Trigger:JC,TabTriggers:QC});De();Qo();cs();f();ee();import J_ from"clsx";import{jsx as e5,jsxs as eR}from"react/jsx-runtime";var Q_="small",t5=e=>eR("label",{className:J_("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${Q_}`,{"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:cp})]});f();import{useState as a5}from"react";ee();ye();f();import{jsx as tR}from"react/jsx-runtime";var nc=e=>tR("p",{className:"excalidraw__paragraph",style:e.style,children:e.children});f();import*as o5 from"@radix-ui/react-tabs";import{useRef as r5}from"react";V();import{jsx as rR}from"react/jsx-runtime";var n5=e=>{let t=Oe(),r=r5(null),o=r5(0);return rR(o5.Root,{ref:r,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=r.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>o.current&&(o.current=a,i.style.minHeight=`min(${o.current}px, 100%)`)}e.dialog==="settings"&&Sc(["text-to-diagram","diagram-to-code"],n)?t({openDialog:{name:e.dialog,tab:n,source:"settings"}}):e.dialog==="ttd"&&Sc(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};n5.displayName="TTDDialogTabs";var eh=n5;f();import*as i5 from"@radix-ui/react-tabs";import{jsx as oR}from"react/jsx-runtime";var ic=({tab:e,children:t,...r})=>oR(i5.Content,{...r,value:e,children:t});ic.displayName="TTDDialogTab";import{jsx as io,jsxs as Qd}from"react/jsx-runtime";var s5=e=>{let[t,r]=a5(e.openAIKey||""),[o,n]=a5(e.isPersisted),i=Ue(),a=()=>{e.onConfirm(t.trim(),o)};return i.openDialog?.name!=="settings"?null:io(xt,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),o)},title:Qd("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",io("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:io(eh,{dialog:"settings",tab:i.openDialog.tab,children:Qd(ic,{tab:"diagram-to-code",children:[Qd(nc,{children:["For the diagram-to-code feature we use"," ",io(Fo,{icon:_c}),"OpenAI."]}),Qd(nc,{children:["While the OpenAI API is in beta, its use is strictly limited \u2014 as such we require you use your own API key. You can create an"," ",io("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",io("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),io(nc,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),io(Lg,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:s=>{r(s),e.onChange(s.trim(),o)},selectOnRender:!0,onKeyDown:s=>s.key===S.ENTER&&a()}),io(nc,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),io(ys,{checked:o,onChange:n,children:"Persist API key in browser storage"}),Qd(nc,{children:["Once API key is set, you can use the ",io(Fo,{icon:$s})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",io("b",{children:"AI Settings"})," ",io(Fo,{icon:_c}),"."]}),io($n,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:a})]})})})};f();f();import{useState as p5,useRef as u5,useEffect as g5,useDeferredValue as dR}from"react";ee();f();Y();qr();var nR=({canvasRef:e,setError:t})=>{let r=e.current;if(!r)return;let o=r.parentElement;o&&(o.style.background="",t(null),r.replaceChildren())},th=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:r,setError:o,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!r){nR({canvasRef:e,setError:o});return}try{let s=await t.api,l;try{l=await s.parseMermaidToExcalidraw(r)}catch{l=await s.parseMermaidToExcalidraw(r.replace(/"/g,"'"))}let{elements:c,files:d}=l;o(null),n.current={elements:ac(c,{regenerateIds:!0}),files:d};let m=await ia({elements:n.current.elements,files:n.current.files,exportPadding:Ko,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await gi(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(E("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(s){throw a.style.background="var(--default-bg-color)",r&&o(s),s}}},em=e=>{ro.set(To.MERMAID_TO_EXCALIDRAW,e)},rh=({app:e,data:t,text:r,shouldSaveMermaidDataToStorage:o})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),o&&r&&em(r))};f();import{jsx as iR}from"react/jsx-runtime";var oh=({children:e})=>iR("div",{className:"ttd-dialog-panels",children:e});f();import l5 from"clsx";import{jsx as X1,jsxs as tm}from"react/jsx-runtime";var sc=({label:e,children:t,panelAction:r,panelActionDisabled:o=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:s})=>tm("div",{className:"ttd-dialog-panel",children:[tm("div",{className:"ttd-dialog-panel__header",children:[X1("label",{children:e}),i?.()]}),t,tm("div",{className:l5("ttd-dialog-panel-button-container",{invisible:!r}),style:{display:"flex",alignItems:"center"},children:[tm(Yn,{className:"ttd-dialog-panel-button",onSelect:r?r.action:()=>{},disabled:o||n,children:[tm("div",{className:l5({invisible:n}),children:[r?.label,r?.icon&&X1("span",{children:r.icon})]}),n&&X1(ir,{})]}),!o&&!n&&a?.(),s?.()]})]});f();Y();ye();import{useEffect as aR,useRef as c5}from"react";import{jsx as sR}from"react/jsx-runtime";var nh=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:o})=>{let n=c5(null),i=c5(o);return i.current=o,aR(()=>{if(!i.current)return;let a=n.current;if(a){let s=l=>{l[S.CTRL_OR_CMD]&&l.key===S.ENTER&&(l.preventDefault(),i.current?.())};return a.addEventListener("keydown",s),()=>{a.removeEventListener("keydown",s)}}},[]),sR("textarea",{className:"ttd-dialog-input",onChange:r,value:e,placeholder:t,autoFocus:!0,ref:n})};f();import{jsx as ih,jsxs as d5}from"react/jsx-runtime";var lR=({error:e})=>d5("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",ih("p",{children:e})]}),ah=({error:e,canvasRef:t,loaded:r})=>d5("div",{className:"ttd-dialog-output-wrapper",children:[e&&ih(lR,{error:e.message}),r?ih("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):ih(ir,{size:"2rem"})]});Y();V();f();V();import{jsx as m5,jsxs as cR}from"react/jsx-runtime";var sh=()=>cR("div",{className:"ttd-dialog-submit-shortcut",children:[m5("div",{className:"ttd-dialog-submit-shortcut__key",children:O("CtrlOrCmd")}),m5("div",{className:"ttd-dialog-submit-shortcut__key",children:O("Enter")})]});import{Fragment as uR,jsx as Jn,jsxs as f5}from"react/jsx-runtime";var mR=`flowchart TD
60
56
  A[Christmas] -->|Get money| B(Go shopping)
61
57
  B --> C{Let me think}
62
58
  C -->|One| D[Laptop]
63
59
  C -->|Two| E[iPhone]
64
- C -->|Three| F[Car]`,MS=ji(Yc,300),s8=({mermaidToExcalidrawLib:e})=>{let[t,r]=CS(()=>Lr.get(Qr.MERMAID_TO_EXCALIDRAW)||l8),o=a8(t.trim()),[n,i]=CS(null),a=AS(null),l=AS({elements:[],files:null}),s=kr();kS(()=>{Au({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:o}).catch(d=>{UE()&&console.error("Failed to parse mermaid definition",d)}),MS(o)},[o,e]),kS(()=>()=>{MS.flush()},[]);let c=()=>{ku({app:s,data:l,text:t,shouldSaveMermaidDataToStorage:!0})};return LS(c8,{children:[un("div",{className:"ttd-dialog-desc",children:un(ur,{i18nKey:"mermaid.description",flowchartLink:d=>un("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>un("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>un("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),LS(Mu,{children:[un(ms,{label:b("mermaid.syntax"),children:un(Lu,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{c()}})}),un(ms,{label:b("mermaid.preview"),panelAction:{action:()=>{c()},label:b("mermaid.button"),icon:Fl},renderSubmitShortcut:()=>un(_u,{}),children:un(Du,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},PS=s8;import{useEffect as m8,useRef as mb,useState as Nu}from"react";f();import*as DS from"@radix-ui/react-tabs";import{jsx as d8}from"react/jsx-runtime";var db=({children:e,...t})=>d8(DS.List,{className:"ttd-dialog-triggers",...t,children:e});db.displayName="TTDDialogTabTriggers";f();import*as RS from"@radix-ui/react-tabs";import{jsx as _S}from"react/jsx-runtime";var Ru=({children:e,tab:t,onSelect:r,...o})=>_S(RS.Trigger,{value:t,asChild:!0,onSelect:r,children:_S("button",{type:"button",className:"ttd-dialog-tab-trigger",...o,children:e})});Ru.displayName="TTDDialogTabTrigger";U();import{atom as OS,useAtom as NS}from"jotai";import{jsx as br,jsxs as Fi}from"react/jsx-runtime";var pb=3,ps=1e3,p8=OS(null),u8=OS(null),ub=e=>{let t=_e();return t.openDialog?.name!=="ttd"?null:br(h8,{...e,tab:t.openDialog.tab})},h8=Yn("TTDDialogBase",({tab:e,...t})=>{let r=kr(),o=Oe(),n=mb(null),[i,a]=NS(u8),[l,s]=Nu(i?.prompt??""),c=l.trim(),d=C=>{s(C.target.value),a(M=>({generatedResponse:M?.generatedResponse??null,prompt:C.target.value}))},[m,p]=Nu(!1),[u,h]=NS(p8),E=async()=>{if(c.length>ps||c.length<pb||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<pb&&L(new Error(`Prompt is too short (min ${pb} characters)`)),c.length>ps&&L(new Error(`Prompt is too long (max ${ps} characters)`));return}try{p(!0),Ee("ai","generate","ttd");let{generatedResponse:C,error:M,rateLimit:_,rateLimitRemaining:H}=await t.onTextSubmit(c);if(typeof C=="string"&&a(k=>({generatedResponse:C,prompt:k?.prompt??null})),uh(_)&&uh(H)&&h({rateLimit:_,rateLimitRemaining:H}),M){L(M);return}if(!C){L(new Error("Generation failed"));return}try{await Au({canvasRef:n,data:v,mermaidToExcalidrawLib:w,setError:L,mermaidDefinition:C}),Ee("ai","mermaid parse success","ttd")}catch(k){console.info(`%cTTD mermaid render errror: ${k.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
65
- TTD mermaid definition render errror: ${k.message}`,"color: yellow"),Ee("ai","mermaid parse failed","ttd"),L(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(C){let M=C.message;(!M||M==="Failed to fetch")&&(M="Request failed"),L(new Error(M))}finally{p(!1)}},x=mb(E);x.current=E;let[w,y]=Nu({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});m8(()=>{(async()=>{await w.api,y(M=>({...M,loaded:!0}))})()},[w.api]);let v=mb({elements:[],files:null}),[I,L]=Nu(null);return br(ut,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Fi(Cu,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?br("p",{className:"dialog-mermaid-title",children:b("mermaid.title")}):Fi(db,{children:[br(Ru,{tab:"text-to-diagram",children:Fi("div",{style:{display:"flex",alignItems:"center"},children:[b("labels.textToDiagram"),br("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"pink",color:"#000"},children:"AI Beta"})]})}),br(Ru,{tab:"mermaid",children:"Mermaid"})]}),br(ds,{className:"ttd-dialog-content",tab:"mermaid",children:br(PS,{mermaidToExcalidrawLib:w})}),!("__fallback"in t)&&Fi(ds,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[br("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."}),Fi(Mu,{children:[br(ms,{label:b("labels.prompt"),panelAction:{action:E,label:"Generate",icon:Fl},onTextSubmitInProgess:m,panelActionDisabled:c.length>ps||u?.rateLimitRemaining===0,renderTopRight:()=>u?Fi("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:()=>br(_u,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Fi("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Yc(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",br(Li,{icon:Fl})]});let C=c.length/ps;return C>.8?Fi("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:C>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",ps]}):null},children:br(Lu,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),br(ms,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),ku({app:r,data:v})},label:"Insert",icon:Fl},children:br(Du,{canvasRef:n,error:I,loaded:w.loaded})})]})]})]})})});import{Fragment as FS,jsx as le,jsxs as qr}from"react/jsx-runtime";var x8=({UIOptions:e})=>qr(fr,{__fallback:!0,children:[le(fr.DefaultItems.LoadScene,{}),le(fr.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&le(fr.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&le(fr.DefaultItems.SaveAsImage,{}),le(fr.DefaultItems.Help,{}),le(fr.DefaultItems.ClearCanvas,{}),le(fr.Separator,{}),le(fr.Group,{title:"Excalidraw links",children:le(fr.DefaultItems.Socials,{})}),le(fr.Separator,{}),le(fr.DefaultItems.ToggleTheme,{}),le(fr.DefaultItems.ChangeCanvasBackground,{})]}),y8=()=>qr(Su,{__fallback:!0,children:[le(Su.Actions.SaveToDisk,{}),le(Su.Actions.ExportToImage,{})]}),w8=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:h,children:E,app:x,isCollaborating:w,openAIKey:y,isOpenAIKeyPersisted:v,onOpenAIAPIKeyChange:I,onMagicSettingsConfirm:L})=>{let C=Me(),M=J3(),[_,H]=b8(Si,ze),k=()=>p.canvasActions.export?le(PT,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,N=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:le(fT,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:x.getName()}),A=()=>qr("div",{style:{position:"relative"},children:[le(M.MainMenuTunnel.Out,{}),h&&le(M.WelcomeScreenMenuHintTunnel.Out,{})]}),B=()=>le(Ri,{heading:"selectedShapeActions",className:Xc("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:le(qt,{className:pd.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:le(iu,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),q=()=>{let V=Sa(t,n);return le(pu,{side:"top",children:qr("div",{className:"App-menu App-menu_top",children:[qr(Gt.Col,{gap:6,className:Xc("App-menu_top__left"),children:[A(),V&&B()]}),!t.viewModeEnabled&&le(Ri,{heading:"shapes",className:"shapes-section",children:W=>qr("div",{style:{position:"relative"},children:[h&&le(M.WelcomeScreenToolbarHintTunnel.Out,{}),le(Gt.Col,{gap:4,align:"start",children:qr(Gt.Row,{gap:1,className:Xc("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[qr(qt,{padding:1,className:Xc("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[le(uu,{appState:t,isMobile:C.editor.isMobile,device:C,app:x}),W,qr(Gt.Row,{gap:1,children:[le(gu,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:b("toolBar.penMode"),penDetected:t.penDetected}),le(hu,{checked:t.activeTool.locked,onChange:a,title:b("toolBar.lock")}),le("div",{className:"App-toolbar__divider"}),le(bu,{checked:Do(t),onChange:()=>l(),title:b("toolBar.hand"),isMobile:!0}),le(au,{appState:t,activeTool:t.activeTool,UIOptions:p,app:x})]})]}),w&&le(qt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:le(gS,{title:b("toolBar.laser"),checked:t.activeTool.type===wt.laser,onChange:()=>x.setActiveTool({type:wt.laser}),isMobile:!0})})]})})]})}),qr("div",{className:Xc("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&le(Eu,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(C.editor.isMobile,t),!t.viewModeEnabled&&(!oe||t.openSidebar?.name!==Nr.name)&&le(M.DefaultSidebarTriggerTunnel.Out,{})]})]})})},Z=()=>le(Iu,{__fallback:!0,onDock:V=>{Ee("sidebar",`toggleDock (${V?"dock":"undock"})`,`(${C.editor.isMobile?"mobile":"desktop"})`)}}),oe=E8(Wc,ze),Te=qr(FS,{children:[E,le(x8,{UIOptions:p}),le(Iu.Trigger,{__fallback:!0,icon:ap,title:ei(b("toolBar.library")),onToggle:V=>{V&&Ee("sidebar",`${Nr.name} (open)`,`button (${C.editor.isMobile?"mobile":"desktop"})`)},tab:Nr.defaultTab,children:b("toolBar.library")}),le(y8,{}),t.openDialog?.name==="ttd"&&le(ub,{__fallback:!0}),t.isLoading&&le(vd,{delay:250}),t.errorMessage&&le(uT,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),_&&!C.editor.isMobile&&le(gv,{colorPickerType:_.colorPickerType,onCancel:()=>{H(null)},onChange:(V,W,he,{altKey:Ie})=>{if(!(V!=="elementBackground"&&V!=="elementStroke"))if(he.length){for(let it of he)F(it,{[Ie&&_.swapPreviewOnAlt?V==="elementBackground"?"strokeColor":"backgroundColor":V==="elementBackground"?"backgroundColor":"strokeColor"]:W},!1),Pe.delete(it);Ct.getScene(he[0])?.informMutation()}else o(V==="elementBackground"?{currentItemBackgroundColor:W}:{currentItemStrokeColor:W})},onSelect:(V,W)=>{H(he=>he?.keepOpenOnAlt&&W.altKey?he:null),_?.onSelect?.(V,W)}}),t.openDialog?.name==="help"&&le(kT,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&le(wS,{openAIKey:y,isPersisted:v,onChange:I,onConfirm:(V,W)=>{let he=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{L(V,W,he)})},onClose:()=>{o({openDialog:null})}}),le(oT,{}),le(M.OverwriteConfirmDialogTunnel.Out,{}),N(),k(),t.pasteDialog.shown&&le(AT,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),C.editor.isMobile&&le(IT,{app:x,appState:t,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:N,setAppState:o,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:m,renderSidebars:Z,device:C,renderWelcomeScreen:h,UIOptions:p}),!C.editor.isMobile&&qr(FS,{children:[qr("div",{className:"layer-ui__wrapper",style:t.openSidebar&&oe&&C.editor.canFitSidebar?{width:`calc(100% - ${vE}px)`}:{},children:[h&&le(M.WelcomeScreenCenterTunnel.Out,{}),q(),le(RT,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),t.showStats&&le(fu,{appState:t,setAppState:o,elements:n,onClose:()=>{e.executeAction(Ai)},renderCustomStats:m}),t.scrolledOutside&&le("button",{className:"scroll-back-to-content",onClick:()=>{o(V=>({...Qo(n,V)}))},children:b("buttons.scrollBackToContent")})]}),Z()]})]});return le(Nf.Provider,{value:t,children:le(f8,{scope:M.jotaiScope,children:le(M1.Provider,{value:M,children:Te})})})},BS=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},v8=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...l}=t;return Je(BS(o),BS(a),{selectedElementIds:Je,selectedGroupIds:Je})&&Je(n,l)},zS=g8.memo(w8,v8);f();import{useCallback as T8,useEffect as S8,useRef as I8}from"react";import{jsx as HS,jsxs as A8}from"react/jsx-runtime";var C8=5e3,US=({message:e,onClose:t,closable:r=!1,duration:o=C8,style:n})=>{let i=I8(0),a=o!==1/0,l=T8(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return S8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,o,a]),A8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[HS("p",{className:"Toast__message",children:e}),r&&HS(ce,{icon:co,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ge();Ne();Xe();var hb=z({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:Hl,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},storeAction:D.NONE}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===fe.R});Cr();Eg();Dn();st();import xD from"lodash.throttle";ga();fc();f();be();Ue();st();se();U();Xo();var Ou=class e{scene;onSceneUpdated;constructor({scene:t,onSceneUpdated:r}){this.scene=t,this.onSceneUpdated=r}static loadedFontFaces=new Set;onFontsLoaded=t=>{if(t.every(o=>{let n=`${o.family}-${o.style}-${o.weight}`;return e.loadedFontFaces.has(n)?!0:(e.loadedFontFaces.add(n),!1)}))return!1;let r=!1;this.scene.mapElements(o=>G(o)&&!Ae(o)?(Pe.delete(o),r=!0,ie(o,{...gl(o,pt(o,this.scene.getNonDeletedElementsMap()),this.scene.getNonDeletedElementsMap())})):o),r&&this.onSceneUpdated()};loadFontsForElements=async t=>{let r=await Promise.all([...new Set(t.filter(o=>G(o)).map(o=>o.fontFamily))].map(o=>{let n=Ye({fontFamily:o,fontSize:16});if(!document.fonts?.check?.(n))return document.fonts?.load?.(n)}));this.onFontsLoaded(r.flat().filter(Boolean))}};nr();ii();f();be();nr();nr();ge();U();hl();Xe();se();Ne();var GS=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&ee(r[0])},WS=z({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(ee(n)){let i=Yr(xe(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},storeAction:D.CAPTURE}}return{elements:e,appState:t,storeAction:D.NONE}},predicate:(e,t,r,o)=>GS(t,o)}),VS=z({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return ee(n)?{elements:_g(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},storeAction:D.CAPTURE}:{elements:e,appState:t,storeAction:D.NONE}},predicate:(e,t,r,o)=>GS(t,o)}),sEe=z({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},storeAction:D.NONE}),checked:e=>e.frameRendering.enabled}),cEe=z({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:hp,viewMode:!1,perform:(e,t,r,o)=>{let n=qe(t,{type:"frame"});return Wr(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:qe(t,{type:"frame"})},storeAction:D.NONE}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});oi();f();Y();lt();se();mr();ge();Ft();ii();var k8=8,YS=99999,Bu=e=>k8/e,fo=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},Kn=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,M8=(e,t,r=.01)=>Math.abs(e-t)<=r,Zc=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,d,m,p]=re(a,t);n&&(l+=n.x,c+=n.x,m+=n.x,s+=n.y,d+=n.y,p+=n.y);let u=(c-l)/2,h=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let E=Ge([l,s+h],[m,p],a.angle),x=Ge([l+u,s],[m,p],a.angle),w=Ge([c,s+h],[m,p],a.angle),y=Ge([l+u,d],[m,p],a.angle);i=r?[E,x,w,y]:[E,x,w,y,[m,p]]}else{let E=Ge([l,s],[m,p],a.angle),x=Ge([c,s],[m,p],a.angle),w=Ge([l,d],[m,p],a.angle),y=Ge([c,d],[m,p],a.angle);i=r?[E,x,w,y]:[E,x,w,y,[m,p]]}}else if(e.length>1){let[a,l,s,c]=em(e,n??{x:0,y:0}),d=s-a,m=c-l,p=[a,l],u=[s,l],h=[a,c],E=[s,c],x=[a+d/2,l+m/2];i=r?[p,u,h,E]:[p,u,h,E,x]}return i.map(a=>[ht(a[0]),ht(a[1])])},XS=(e,t,r,o)=>{let n=t.filter(i=>ee(i)).map(i=>i.id);return Xg(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},ZS=(e,t,r,o)=>{let n=XS(e,t,r,o),i=ha(n,o).filter(m=>!(m.length===1&&Ae(m[0]))).map(m=>Se(m).map(p=>ht(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>YS)break e;let h=a[u],[,E,x,w]=p,[y,v,,I]=h;x<y&&Ds([E,w],[v,I])&&l.push({startBounds:p,endBounds:h,startSide:[[x,E],[x,w]],endSide:[[y,v],[y,I]],length:y-x,overlap:_s([E,w],[v,I])})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>YS)break e;let h=c[u],[E,,x,w]=p,[y,v,I]=h;w<v&&Ds([E,x],[y,I])&&d.push({startBounds:p,endBounds:h,startSide:[[E,w],[x,w]],endSide:[[y,v],[I,v]],length:v-w,overlap:_s([E,x],[y,I])})}}return{horizontalGaps:l,verticalGaps:d}},KS=(e,t,r,o,n,i,a)=>{if(!Kn({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let l=fo.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[d,m,p,u]=em(e,t).map(x=>ht(x)),h=(d+p)/2,E=(m+u)/2;for(let x of s){if(!Ds([m,u],x.overlap))continue;let w=x.startSide[0][0]+x.length/2,y=ht(w-h);if(x.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(n.length=0),a.x=Math.abs(y);let k={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(k);continue}let[,,I]=x.endBounds,L=d-I,C=ht(x.length-L);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(n.length=0),a.x=Math.abs(C);let k={type:"gap",direction:"side_right",gap:x,offset:C};n.push(k);continue}let[M,,,]=x.startBounds,_=M-p,H=ht(_-x.length);if(Math.abs(H)<=a.x){Math.abs(H)<a.x&&(n.length=0),a.x=Math.abs(H);let k={type:"gap",direction:"side_left",gap:x,offset:H};n.push(k);continue}}for(let x of c){if(!Ds([d,p],x.overlap))continue;let w=x.startSide[0][1]+x.length/2,y=ht(w-E);if(x.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let k={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(k);continue}let[,I,,]=x.startBounds,L=I-u,C=ht(L-x.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let k={type:"gap",direction:"side_top",gap:x,offset:C};i.push(k);continue}let[,,,M]=x.endBounds,_=ht(m-M),H=x.length-_;if(Math.abs(H)<=a.y){Math.abs(H)<a.y&&(i.length=0),a.y=Math.abs(H);let k={type:"gap",direction:"side_bottom",gap:x,offset:H};i.push(k);continue}}}},jS=(e,t,r,o)=>{let n=XS(e,t,r,o);return ha(n,o).filter(i=>!(i.length===1&&Ae(i[0]))).flatMap(i=>Zc(i,o))},us=(e,t,r,o,n,i,a)=>{if(!Kn({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let l=fo.getReferenceSnapPoints();if(l)for(let s of t)for(let c of l){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),a.y=Math.abs(m))}},qS=(e,t,r,o,n)=>{let i=ue(e,r);if(!Kn({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=ht(t.x),t.y=ht(t.y);let a=[],l=[],s=Bu(r.zoom.value),c={x:s,y:s},d=Zc(i,n,{dragOffset:t});us(i,d,r,o,a,l,c),KS(i,t,r,o,a,l,c);let m={x:a[0]?.offset??0,y:l[0]?.offset??0};c.x=0,c.y=0,a.length=0,l.length=0;let p={x:ht(t.x+m.x),y:ht(t.y+m.y)};us(i,Zc(i,n,{dragOffset:p}),r,o,a,l,c),KS(i,p,r,o,a,l,c);let u=gb(a,l),h=P8(i,p,[...a,...l].filter(E=>E.type==="gap"));return{snapOffset:m,snapLines:[...u,...h]}},ht=e=>Math.round(e*10**6)/10**6,$S=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},gb=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=ht(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[ht(a[0]),ht(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=ht(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[ht(a[0]),ht(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:$S(i.map(a=>[Number(n),a[1]]).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:$S(i.map(a=>[a[0],Number(n)]).sort((a,l)=>a[0]-l[0]))})))},L8=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[ht(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},P8=(e,t,r)=>{let[o,n,i,a]=em(e,t),l=[];for(let s of r){let[c,d,m,p]=s.gap.startBounds,[u,h,E,x]=s.gap.endBounds,w=_s([n,a],s.gap.overlap),y=_s([o,i],s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[[s.gap.startSide[0][0],v],[o,v]]},{type:"gap",direction:"horizontal",points:[[i,v],[s.gap.endSide[0][0],v]]})}break}case"center_vertical":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[[v,s.gap.startSide[0][1]],[v,n]]},{type:"gap",direction:"vertical",points:[[v,a],[v,s.gap.endSide[0][1]]]})}break}case"side_right":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[[m,v],[u,v]]},{type:"gap",direction:"horizontal",points:[[E,v],[o,v]]})}break}case"side_left":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[[i,v],[c,v]]},{type:"gap",direction:"horizontal",points:[[m,v],[u,v]]})}break}case"side_top":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[[v,a],[v,d]]},{type:"gap",direction:"vertical",points:[[v,p],[v,h]]})}break}case"side_bottom":{if(y){let v=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[[v,p],[v,h]]},{type:"gap",direction:"vertical",points:[[v,x],[v,n]]})}break}}}return L8(l.map(s=>({...s,points:s.points.map(c=>[ht(c[0]),ht(c[1])])})))},JS=(e,t,r,o,n,i)=>{if(!Kn({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!M8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=Se(t);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 d=[];if(i)switch(i){case"e":{d.push([s,l],[s,c]);break}case"w":{d.push([a,l],[a,c]);break}case"n":{d.push([a,l],[s,l]);break}case"s":{d.push([a,c],[s,c]);break}case"ne":{d.push([s,l]);break}case"nw":{d.push([a,l]);break}case"se":{d.push([s,c]);break}case"sw":{d.push([a,c]);break}}let m=Bu(r.zoom.value),p={x:m,y:m},u=[],h=[];us(t,d,r,o,u,h,p);let E={x:u[0]?.offset??0,y:h[0]?.offset??0};p.x=0,p.y=0,u.length=0,h.length=0;let[x,w,y,v]=Se(e).map(C=>ht(C));us(e,[[x,w],[x,v],[y,w],[y,v]],r,o,u,h,p);let L=gb(u,h);return{snapOffset:E,snapLines:L}},QS=(e,t,r,o,n,i)=>{if(!Kn({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],l=Bu(t.zoom.value),s={x:l,y:l},c=[],d=[];us([e],a,t,r,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=Zc([e],i,{boundingBoxCorners:!0,omitCenter:!0});us([e],p,t,r,c,d,s);let u=gb(c,d);return{snapOffset:m,snapLines:u}},eI=(e,t,r,o,n)=>{if(!Kn({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Xg(e,[],t,n),a=Bu(t.zoom.value),l={x:a,y:a},s=[],c=[];for(let d of i){let m=Zc([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),l.x=u);let h=p[1]-r.y;Math.abs(h)<=Math.abs(l.y)&&(Math.abs(h)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),l.y=h)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:s.length>0?s[0].points[0][1]-r.y:0},snapLines:[...c,...s]}},tI=e=>e===wt.rectangle||e===wt.ellipse||e===wt.diamond||e===wt.frame||e===wt.magicframe||e===wt.image;f();import{jsx as bo,jsxs as rI}from"react/jsx-runtime";var D8=()=>rI("div",{"data-testid":"brave-measure-text-error",children:[bo("p",{children:bo(ur,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>bo("span",{style:{fontWeight:600},children:e})})}),bo("p",{children:bo(ur,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>bo("span",{style:{fontWeight:600},children:e})})}),bo("p",{children:bo(ur,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>bo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),bo("p",{children:bo(ur,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>bo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>rI("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),oI=D8;f();Y();be();io();Mn();st();U();Ls();Co();no();var Fu={width:100,height:0},zi=100,_8=(e,t,r)=>{let o=zt({x:0,y:0,textAlign:Qn.CENTER,verticalAlign:yt.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),Rt(o,e,r),[e,o]},nI=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??zi,m=t?.height??zi,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,h=t.y||e.y-m/2,E=p?p.type:t.type;if(E){if(E==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=zt({x:u,y:h,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(E){case"rectangle":case"ellipse":case"diamond":{i=Vr({x:u,y:h,width:d,height:m,...p,...t,type:E});break}default:Io(e,`Unhandled element start type "${t.type}"`,!0)}la(e,i,"start",n)}}if(r){let d=r?.height??zi,m=r?.width??zi,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,h=r.y||e.y-d/2,E=p?p.type:r.type;if(E){if(E==="text"){let x="";p&&p.type==="text"?x=p.text:r.type==="text"&&(x=r.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=zt({x:u,y:h,type:"text",...p,...r,text:x}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(E){case"rectangle":case"ellipse":case"diamond":{a=Vr({x:u,y:h,width:m,height:d,...p,...r,type:E});break}default:Io(e,`Unhandled element end type "${E}"`,!0)}la(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=Vo(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}},fb=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>cr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>Br($(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},Kc=(e,t)=>{if(!e)return[];let r=Vo(e),o=new fb,n=new Map,i=new Map;for(let l of r){let s,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:_t()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||zi,p=l?.label?.text&&l.height===void 0?0:l?.height||zi;s=Vr({...l,width:m,height:p});break}case"line":{let m=l.width||Fu.width,p=l.height||Fu.height;s=ao({width:m,height:p,points:[[0,0],[m,p]],...l});break}case"arrow":{let m=l.width||Fu.width,p=l.height||Fu.height;s=ao({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...l}),Object.assign(s,_d(s.points));break}case"text":{let m=l?.fontFamily||Kt,p=l?.fontSize||Lt,u=l?.lineHeight||Hr(m),h=l.text??"",E=pi(h),x=Lo(E,Ye({fontFamily:m,fontSize:p}),u);s=zt({width:x.width,height:x.height,fontFamily:m,fontSize:p,...l});break}case"image":{s=$s({width:l?.width||zi,height:l?.height||zi,...l});break}case"frame":{s=mm({x:0,y:0,...l});break}case"magicframe":{s=Ks({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Io(l,`Unhandled element type "${l.type}"`,!0)}o.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(o.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=o.getElementsMap();for(let[l,s]of n){let c=o.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[d,m]=_8(c,s?.label,a);if(o.add(d),o.add(m),d.type==="arrow"){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let w=i.get(p.id);w&&Object.assign(p,{id:w})}if(u&&u.id){let w=i.get(u.id);w&&Object.assign(u,{id:w})}let{linearElement:h,startBoundElement:E,endBoundElement:x}=nI(d,p,u,o,a);d=h,o.add(h),o.add(E),o.add(x)}}else switch(s.type){case"arrow":{let{start:d,end:m}=s;if(d&&d.id){let E=i.get(d.id);Object.assign(d,{id:E})}if(m&&m.id){let E=i.get(m.id);Object.assign(m,{id:E})}let{linearElement:p,startBoundElement:u,endBoundElement:h}=nI(c,d,m,o,a);o.add(p),o.add(u),o.add(h);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=o.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let d=[];s.children.forEach(y=>{let v=i.get(y);if(!v)throw new Error(`Element with ${y} wasn't mapped correctly`);let I=o.getElement(v);if(!I)throw new Error(`Frame element with id ${v} doesn't exist`);Object.assign(I,{frameId:c.id}),I?.boundElements?.forEach(L=>{let C=o.getElement(L.id);if(!C)throw new Error(`Bound element with id ${L.id} doesn't exist`);Object.assign(C,{frameId:c.id}),d.push(C)}),d.push(I)});let[m,p,u,h]=Se(d),E=10;m=m-E,p=p-E,u=u+E,h=h+E;let x=Math.max(c?.width,u-m),w=Math.max(c?.height,h-p);Object.assign(c,{x:m,y:p,width:x,height:w})}return o.getElements()};f();f();U();Y();import X8,{useEffect as Z8,useRef as j8}from"react";f();U();import{unstable_batchedUpdates as iI}from"react-dom";import{version as R8}from"react";var dt=e=>t=>{iI(e,t)},zu=e=>el(t=>{iI(e,t)}),Hu=(()=>{let e;try{let r=R8.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();be();Tn();mr();fc();U();Y();f();Y();var N8="#ff6b6b",O8="#ff0000",aI=1,lI=2,sI=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===ae.LIGHT||t.zenModeEnabled?N8:O8,o=(t.zenModeEnabled?aI*1.5:aI)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,F8(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,z8(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,B8(n,e,t));e.restore()},B8=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];Eo(o,n,t)}for(let o of e.points)cI(o,r,t)},F8=(e,t,r)=>{cI(e.points[0],r,t),r.zenModeEnabled||Eo(e.points[0],e.points[1],t)},cI=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?lI*1.5:lI)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},Eo=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},z8=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,l=i/4;if(r==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||Eo([e[0],e[1]-i],[e[0],e[1]+i],n),Eo([s[0]-l,s[1]-a],[s[0]-l,s[1]+a],n),Eo([s[0]+l,s[1]-a],[s[0]+l,s[1]+a],n),o.zenModeEnabled||(Eo([t[0],t[1]-i],[t[0],t[1]+i],n),Eo(e,t,n))}else{let s=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||Eo([e[0]-i,e[1]],[e[0]+i,e[1]],n),Eo([s[0]-a,s[1]-l],[s[0]+a,s[1]-l],n),Eo([s[0]-a,s[1]+l],[s[0]+a,s[1]+l],n),o.zenModeEnabled||(Eo([t[0]-i,t[1]],[t[0]+i,t[1]],n),Eo(e,t,n))}};io();Xt();vg();se();import Uu from"open-color";var H8=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=X.getElement(o,r);if(!i)return;let a=X.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),Eb(a,e,t),e.restore()},Eb=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",dc(t,e[0],e[1],X.POINT_HANDLE_SIZE/r.zoom.value,!1)},jc=(e,t,r,o,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},U8=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},Gu=(e,t,r,o,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)"),dc(e,r[0],r[1],o/t.zoom.value,!i)},G8=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},W8=(e,t,r)=>{let[o,n,i,a]=re(t,r),l=i-o,s=a-n,c=Gs(t,l,s),d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2;switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":jc(e,o-m,n-m,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break;case"diamond":let p=Math.hypot(l,s),u=m*p/s,h=m*p/l;U8(e,l+u*2,s+h*2,o+l/2,n+s/2,t.angle);break;case"ellipse":G8(e,l+m*2,s+m*2,o+l/2,n+s/2,t.angle);break}},V8=(e,t,r)=>{let[o,n,i]=t,a=Gs(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(s=>{let[c,d]=X.getPointAtIndexGlobalCoordinates(o,s,r);dc(e,c,d,a)})},mI=(e,t,r,o=Jn*2)=>{let{angle:n,elementX1:i,elementY1:a,elementX2:l,elementY2:s,selectionColors:c,cx:d,cy:m,dashed:p,activeEmbeddable:u}=r,h=l-i,E=s-a,x=o/t.zoom.value,w=8/t.zoom.value,y=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(u?4:1)/t.zoom.value;let v=c.length;for(let I=0;I<v;++I)e.strokeStyle=c[I],p&&e.setLineDash([w,y+(w+y)*(v-1)]),e.lineDashOffset=(w+y)*I,jc(e,i-x,a-x,h+x*2,E+x*2,d,m,n);e.restore()},Y8=(e,t,r,o)=>{let n=Array.isArray(r)?V8:W8;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},K8=(e,t,r,o)=>{let[n,i,a,l]=re(r,o),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=je.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),jc(e,n,i,s,c,n+s/2,i+c/2,r.angle,!1,je.radius/t.zoom.value),e.restore()},$8=(e,t,r)=>{let o=r.filter(l=>l.groupIds.length===0),n=r.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,d,m]=Se(l);return{angle:0,elementX1:s,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(d-s)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=l=>{let s=tt(r,l);return i(s)};Object.entries(om(n,t)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(o.map(l=>i([l]))).forEach(l=>mI(e,t,l))},bb=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=X.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=X,a=t.editingLinearElement?i:i/2;n.forEach((s,c)=>{let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);Gu(e,t,s,a,d)}),X.getEditorMidPoints(r,o,t).filter(s=>s!==null).forEach(s=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&X.arePointsEqual(s,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(Gu(e,t,s,a,!1),Eb(s,e,t)):(Eb(s,e,t),Gu(e,t,s,a,!1)):(t.editingLinearElement||n.length===2)&&Gu(e,t,s,i/2,!1,!0)}),e.restore()},dI=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[l,s,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?dc(e,l+c/2,s+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,d,2/r.zoom.value),e.fill(),e.stroke()):jc(e,l,s,c,d,l+c/2,s+d/2,n,!0),e.restore()}})},pI=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,scale:n,appState:i,renderConfig:a,device:l})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[s,c]=Pm(e,n),d=Dm({canvas:e,scale:n,normalizedWidth:s,normalizedHeight:c});d.save(),d.scale(i.zoom.value,i.zoom.value);let m;if(r.forEach(h=>{i.editingLinearElement?.elementId===h.id&&h&&(m=h)}),m&&bb(d,i,m,t),i.selectionElement)try{Ky(i.selectionElement,d,i)}catch(h){console.error(h)}i.isBindingEnabled&&i.suggestedBindings.filter(h=>h!=null).forEach(h=>{Y8(d,i,h,t)}),i.frameToHighlight&&K8(d,i,i.frameToHighlight,t),i.elementsToHighlight&&$8(d,i,i.elementsToHighlight);let p=o.some(h=>ee(h));if(o.length===1&&i.editingLinearElement?.elementId===o[0].id&&bb(d,i,o[0],t),i.selectedLinearElement&&i.selectedLinearElement.hoverPointIndex>=0&&H8(d,i,t),!i.multiElement&&!i.editingLinearElement){let h=Qm(o,i);o.length===1&&ne(o[0])&&i.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&bb(d,i,o[0],t);let x=a.selectionColor||Uu.black;if(h){let w=$(o),y=[];for(let I of t.values()){let L=[];w.has(I.id)&&!rm(i,I)&&L.push(x);let C=a.remoteSelectedElementIds.get(I.id);if(C&&L.push(...C.map(M=>Oa(M,i.collaborators.get(M)))),L.length){let[M,_,H,k,N,A]=re(I,t,!0);y.push({angle:I.angle,elementX1:M,elementY1:_,elementX2:H,elementY2:k,selectionColors:L,dashed:!!C,cx:N,cy:A,activeEmbeddable:i.activeEmbeddable?.element===I&&i.activeEmbeddable.state==="active"})}}let v=I=>{let L=tt(t,I),[C,M,_,H]=Se(L);y.push({angle:0,elementX1:C,elementX2:_,elementY1:M,elementY2:H,selectionColors:[Uu.black],dashed:!0,cx:C+(_-C)/2,cy:M+(H-M)/2,activeEmbeddable:!1})};for(let I of Cn(i))v(I);i.editingGroupId&&v(i.editingGroupId),y.forEach(I=>mI(d,i,I))}if(d.save(),d.translate(i.scrollX,i.scrollY),o.length===1){d.fillStyle=Uu.white;let w=gc(o[0],i.zoom,t,"mouse",Ta(l));!i.viewModeEnabled&&h&&dI(d,a,i,w,o[0].angle)}else if(o.length>1&&!i.isRotating){let w=Jn*2/i.zoom.value;d.fillStyle=Uu.white;let[y,v,I,L]=Se(o),C=d.getLineDash();d.setLineDash([2/i.zoom.value]);let M=d.lineWidth;d.lineWidth=1/i.zoom.value,d.strokeStyle=x,jc(d,y-w,v-w,I-y+w*2,L-v+w*2,(y+I)/2,(v+L)/2,0),d.lineWidth=M,d.setLineDash(C);let _=_l([y,v,I,L,(y+I)/2,(v+L)/2],0,i.zoom,"mouse",p?{...Ta(l),rotation:!0}:Ta(l));o.some(H=>!H.locked)&&dI(d,a,i,_,0)}d.restore()}sI(d,i),d.restore(),Gv({context:d,renderConfig:a,appState:i,normalizedWidth:s,normalizedHeight:c});let u;return a.renderScrollbars&&(u=vT(r,s,c,i),d.save(),d.fillStyle=wT,d.strokeStyle="rgba(255,255,255,0.8)",[u.horizontal,u.vertical].forEach(h=>{h&&Pp(d,h.x,h.y,h.width,h.height,mn/2)}),d.restore()),{scrollBars:u,atLeastOneVisibleElement:r.length>0,elementsMap:t}},xb=el(e=>{let t=pI(e);e.callback?.(t)},{trailing:!0}),uI=(e,t)=>{if(t){xb(e);return}let r=pI(e);return e.callback(r),r};import{jsx as Q8}from"react/jsx-runtime";var q8=e=>{let t=j8(!1);return Z8(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),o.set(c,Ot({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),r.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";uI({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},Hu())}),Q8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Le.GRAB:Le.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:b("labels.drawingCanvas")})},hI=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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}),J8=(e,t)=>e.selectionNonce!==t.selectionNonce||e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:Je(hI(e.appState),hI(t.appState)),yb=X8.memo(q8,J8);f();Nm();U();import eD,{useEffect as tD,useRef as gI}from"react";import{jsx as nD}from"react/jsx-runtime";var rD=e=>{let t=gI(null),r=gI(!1);return tD(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.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),Rm({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Hu())}),nD("div",{className:"excalidraw__canvas-wrapper",ref:t})},fI=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId}),oD=(e,t)=>e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Je(fI(e.appState),fI(t.appState))&&Je(e.renderConfig,t.renderConfig),wb=eD.memo(rD,oD);f();va();se();Nm();U();var qc=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:d})=>{let m=[];for(let p of o.values())wa(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=Br(new Map);for(let l of o)to(l)&&i===l.id||(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return WE(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingElement:d,pendingImageElementId:m,versionNonce:p})=>{let u=this.scene.getNonDeletedElements(),h=r({elements:u,editingElement:d,pendingImageElementId:m}),E=t({elementsMap:h,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:h,visibleElements:E}})})();destroy(){xb.cancel(),Tg.cancel(),this.getRenderableElements.clear()}};Xo();f();import{useEffect as iD,useRef as aD}from"react";import{jsx as bI}from"react/jsx-runtime";var EI=({trails:e})=>{let t=aD(null);return iD(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),bI("div",{className:"SVGLayer",children:bI("svg",{ref:t})})};hl();Js();f();U();be();import{jsx as cD}from"react/jsx-runtime";var lD=5,sD=(e,t,r)=>{let[o,n]=re(e,r),{x:i,y:a}=Ot({sceneX:o+e.width,sceneY:n},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},vb=({children:e,element:t,elementsMap:r})=>{let o=Jl();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=sD(t,o,r);return cD("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:lD},children:e})};f();Y();var dD=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
60
+ C -->|Three| F[Car]`,h5=ii(em,300),pR=({mermaidToExcalidrawLib:e})=>{let[t,r]=p5(()=>ro.get(To.MERMAID_TO_EXCALIDRAW)||mR),o=dR(t.trim()),[n,i]=p5(null),a=u5(null),s=u5({elements:[],files:null}),l=tr();g5(()=>{th({canvasRef:a,data:s,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:o}).catch(d=>{_0()&&console.error("Failed to parse mermaid definition",d)}),h5(o)},[o,e]),g5(()=>()=>{h5.flush()},[]);let c=()=>{rh({app:l,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return f5(uR,{children:[Jn("div",{className:"ttd-dialog-desc",children:Jn(Br,{i18nKey:"mermaid.description",flowchartLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>Jn("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),f5(oh,{children:[Jn(sc,{label:E("mermaid.syntax"),children:Jn(nh,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{c()}})}),Jn(sc,{label:E("mermaid.preview"),panelAction:{action:()=>{c()},label:E("mermaid.button"),icon:Ks},renderSubmitShortcut:()=>Jn(sh,{}),children:Jn(ah,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},b5=pR;import{useEffect as hR,useRef as $1,useState as ch}from"react";f();import*as E5 from"@radix-ui/react-tabs";import{jsx as gR}from"react/jsx-runtime";var K1=({children:e,...t})=>gR(E5.List,{className:"ttd-dialog-triggers",...t,children:e});K1.displayName="TTDDialogTabTriggers";f();import*as y5 from"@radix-ui/react-tabs";import{jsx as x5}from"react/jsx-runtime";var lh=({children:e,tab:t,onSelect:r,...o})=>x5(y5.Trigger,{value:t,asChild:!0,onSelect:r,children:x5("button",{type:"button",className:"ttd-dialog-tab-trigger",...o,children:e})});lh.displayName="TTDDialogTabTrigger";ee();V();import{atom as v5,useAtom as w5}from"jotai";import{jsx as Ur,jsxs as wa}from"react/jsx-runtime";var Z1=3,lc=1e3,fR=v5(null),bR=v5(null),j1=e=>{let t=Ue();return t.openDialog?.name!=="ttd"?null:Ur(ER,{...e,tab:t.openDialog.tab})},ER=Di("TTDDialogBase",({tab:e,...t})=>{let r=tr(),o=Oe(),n=$1(null),[i,a]=w5(bR),[s,l]=ch(i?.prompt??""),c=s.trim(),d=I=>{l(I.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:I.target.value}))},[m,p]=ch(!1),[u,g]=w5(fR),h=async()=>{if(c.length>lc||c.length<Z1||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<Z1&&M(new Error(`Prompt is too short (min ${Z1} characters)`)),c.length>lc&&M(new Error(`Prompt is too long (max ${lc} characters)`));return}try{p(!0),Ce("ai","generate","ttd");let{generatedResponse:I,error:P,rateLimit:A,rateLimitRemaining:N}=await t.onTextSubmit(c);if(typeof I=="string"&&a(k=>({generatedResponse:I,prompt:k?.prompt??null})),Hh(A)&&Hh(N)&&g({rateLimit:A,rateLimitRemaining:N}),P){M(P);return}if(!I){M(new Error("Generation failed"));return}try{await th({canvasRef:n,data:w,mermaidToExcalidrawLib:v,setError:M,mermaidDefinition:I}),Ce("ai","mermaid parse success","ttd")}catch(k){console.info(`%cTTD mermaid render errror: ${k.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
61
+ TTD mermaid definition render errror: ${k.message}`,"color: yellow"),Ce("ai","mermaid parse failed","ttd"),M(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(I){let P=I.message;(!P||P==="Failed to fetch")&&(P="Request failed"),M(new Error(P))}finally{p(!1)}},x=$1(h);x.current=h;let[v,y]=ch({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});hR(()=>{(async()=>{await v.api,y(P=>({...P,loaded:!0}))})()},[v.api]);let w=$1({elements:[],files:null}),[C,M]=ch(null);return Ur(xt,{className:"ttd-dialog",onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:wa(eh,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?Ur("p",{className:"dialog-mermaid-title",children:E("mermaid.title")}):wa(K1,{children:[Ur(lh,{tab:"text-to-diagram",children:wa("div",{style:{display:"flex",alignItems:"center"},children:[E("labels.textToDiagram"),Ur("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"})]})}),Ur(lh,{tab:"mermaid",children:"Mermaid"})]}),Ur(ic,{className:"ttd-dialog-content",tab:"mermaid",children:Ur(b5,{mermaidToExcalidrawLib:v})}),!("__fallback"in t)&&wa(ic,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Ur("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."}),wa(oh,{children:[Ur(sc,{label:E("labels.prompt"),panelAction:{action:h,label:"Generate",icon:Ks},onTextSubmitInProgess:m,panelActionDisabled:c.length>lc||u?.rateLimitRemaining===0,renderTopRight:()=>u?wa("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:()=>Ur(sh,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return wa("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(em(i.generatedResponse),o({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Ur(Fo,{icon:Ks})]});let I=c.length/lc;return I>.8?wa("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:I>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",lc]}):null},children:Ur(nh,{onChange:d,input:s,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Ur(sc,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),rh({app:r,data:w})},label:"Insert",icon:Ks},children:Ur(ah,{canvasRef:n,error:C,loaded:v.loaded})})]})]})]})})});f();dt();import{useEffect as F5,useMemo as B5,useState as lN,memo as cN}from"react";ee();import{throttle as dN}from"lodash";f();f();Y();ye();Nn();import{useEffect as S5,useRef as dh,useState as yR}from"react";import wR from"clsx";f();yr();De();kd();He();me();Gt();mt();V();var T5=.01,ao=(e,t)=>!(t==="height"&&H(e)||t==="width"&&H(e)||t==="angle"&&Q(e)),St=(e,t)=>{let r=e+t/2;return r-r%t},cc=(e,t,r)=>Object.keys(e).map(o=>({original:(r??t).get(o),latest:t.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0),xR=(e,t,r,o,n,i,a)=>({x:e+(r-n)/2+(n-r)/2*Math.cos(a)+(o-i)/2*Math.sin(a),y:t+(o-i)/2+(n-r)/2*Math.sin(a)+(i-o)/2*Math.cos(a)}),dc=(e,t,r,o,n,i,a,s=!0)=>{let l=n.get(o.id);if(!l)return;let c={},d=J(l,n);if(d){let u=_l(Me(d),d.lineHeight),g=Dl(d.fontSize,d.lineHeight);e=Math.max(e,u),t=Math.max(t,g)}let{width:m,height:p}=l;if(F(l,{...xR(l.x,l.y,l.width,l.height,e,t,l.angle),width:e,height:t,...Ad(o,e,t,!0)},s),rm(l,n,i,a,{newSize:{width:e,height:t}}),d&&(c={fontSize:d.fontSize},r)){let u={...l,width:e,height:t};c={fontSize:Md(d,n,br(u,d))?.size??d.fontSize}}qt(l,n,a,{oldSize:{width:m,height:p}}),d&&c&&F(d,{fontSize:c.fontSize}),mn(l,n,"e",r)},Cs=(e,t,r,o,n,i,a,s=!0)=>{let l=o.get(r.id);if(!l)return;let[c,d]=[r.x+r.width/2,r.y+r.height/2],[m,p]=xe(r.x,r.y,c,d,r.angle),u=e-m,g=t-p,[h,x]=xe(e,t,c+u,d+g,-r.angle);F(l,{x:h,y:x},s),rm(l,o,n,i);let v=J(r,a);if(v){let y=o.get(v.id);y&&F(y,{x:v.x+u,y:v.y+g},s)}},mc=(e,t)=>{let o=Jo(t).map(n=>ot(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!Ln(n)).forEach(n=>{o.push({[n.id]:!0})}),o},rm=(e,t,r,o,n)=>{ie(e)?es([e],t,r,o,!0,[]):qt(e,t,o,n)};Re();V();import{jsx as q1,jsxs as TR}from"react/jsx-runtime";var vR=({label:e,icon:t,dragInputCallback:r,value:o,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c})=>{let d=tr(),m=dh(null),p=dh(null),[u,g]=yR(o.toString()),h=dh(null);h.current||(h.current={originalAppState:Xr(c),originalElements:n,lastUpdatedValue:u,updatePending:!1}),S5(()=>{let y=o.toString();g(y),h.current.lastUpdatedValue=y},[o]);let x=(y,w,C)=>{if(!h.current.updatePending)return!1;h.current.updatePending=!1;let M=Number(y);if(isNaN(M)){g(o.toString());return}let I=Number(M.toFixed(2)),P=Number(o);(isNaN(P)||Math.abs(I-P)>=T5)&&(h.current.lastUpdatedValue=y,r({accumulatedChange:0,instantChange:0,originalElements:w,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:I,property:s,originalAppState:C}),d.syncActionResult({storeAction:_.CAPTURE}))},v=dh(x);return v.current=x,S5(()=>{let y=m.current;return()=>{let w=y?.value;w&&v.current(w,h.current.originalElements,h.current.originalAppState)}},[i]),i?TR("div",{className:wR("drag-input-container",!i&&"disabled"),"data-testid":e,children:[q1("div",{className:"drag-input-label",ref:p,onPointerDown:y=>{if(m.current&&i){let w=Number(m.current.value);isNaN(w)&&(w=0);let C=null,M=d.scene.getNonDeletedElements().reduce((k,D)=>(k.set(D.id,an(D)),k),new Map),I=n.map(k=>M.get(k.id)),P=Xr(c),A=null;document.body.classList.add("excalidraw-cursor-resize");let N=k=>{if(A||(A=0),C&&M!==null&&I!==null&&A!==null){let D=k.clientX-C.x;A+=D,r({accumulatedChange:A,instantChange:D,originalElements:I,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:k.shiftKey,property:s,scene:l,originalAppState:P})}C={x:k.clientX,y:k.clientY}};window.addEventListener("pointermove",N,!1),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",N,!1),d.syncActionResult({storeAction:_.CAPTURE}),C=null,A=null,I=null,M=null,document.body.classList.remove("excalidraw-cursor-resize")},!1)}},onPointerEnter:()=>{p.current&&(p.current.style.cursor="ew-resize")},children:t?q1(Fo,{icon:t}):e}),q1("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let w=y.target;w instanceof HTMLInputElement&&y.key===S.ENTER&&(x(w.value,n,c),d.focusContainer())}},ref:m,value:u,onChange:y=>{h.current.updatePending=!0,g(y.target.value)},onFocus:y=>{y.target.select(),h.current.originalElements=n,h.current.originalAppState=Xr(c)},onBlur:y=>{u?i&&x(y.target.value,h.current.originalElements,h.current.originalAppState):g(o.toString())},disabled:!i})]}):null},Ir=vR;Y();import{jsx as AR}from"react/jsx-runtime";var I5=10,SR=e=>e.type==="image",IR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:n,nextValue:i,property:a,scene:s})=>{let l=s.getNonDeletedElementsMap(),c=s.getNonDeletedElements(),d=t[0];if(d){let m=o||SR(d),p=d.width/d.height;if(i!==void 0){let v=Math.max(a==="width"?i:m?i*p:d.width,Vr),y=Math.max(a==="height"?i:m?i/p:d.height,Vr);dc(v,y,m,d,l,c,s);return}let u=a==="width"?e:0,g=a==="height"?e:0,h=Math.max(0,d.width+u);a==="width"&&(n?h=St(h,I5):h=Math.round(h));let x=Math.max(0,d.height+g);a==="height"&&(n?x=St(x,I5):x=Math.round(x)),m&&(a==="width"?x=Math.round(h/p*100)/100:h=Math.round(x*p*100)/100),x=Math.max(Vr,x),h=Math.max(Vr,h),dc(h,x,m,d,l,c,s)}},CR=({property:e,element:t,scene:r,appState:o})=>{let n=Math.round((e==="width"?t.width:t.height)*100)/100;return AR(Ir,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:IR,value:n,editable:ao(t,e),scene:r,appState:o,property:e})},J1=CR;f();De();He();me();mt();ee();import{jsx as LR}from"react/jsx-runtime";var MR=15,kR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),s=t[0];if(s&&!de(s)){let l=i.get(s.id);if(!l)return;if(o!==void 0){let g=Ml(o);F(l,{angle:g}),rm(l,i,a,n);let h=J(l,i);h&&!ne(l)&&F(h,{angle:g});return}let c=Math.round(Al(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;r&&(m=St(m,MR)),m=m<0?m+360:m;let p=Ml(m);F(l,{angle:p}),rm(l,i,a,n);let u=J(l,i);u&&!ne(l)&&F(u,{angle:p})}},PR=({element:e,scene:t,appState:r,property:o})=>LR(Ir,{label:"A",icon:np,value:Math.round(Al(e.angle)%360*100)/100,elements:[e],dragInputCallback:kR,editable:ao(e,"angle"),scene:t,appState:r,property:o}),C5=PR;f();De();ee();we();me();He();import{jsx as NR}from"react/jsx-runtime";var A5=4,DR=4,_R=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t[0];if(a){let s=i.get(a.id);if(!s||!H(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),A5);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,A5),r&&(l=St(l,DR))}l&&(F(s,{fontSize:l}),ft(s,n.getContainerElement(s),n.getNonDeletedElementsMap()))}},RR=({element:e,scene:t,appState:r,property:o})=>{let n=H(e)?e:Ct(e)?J(e,t.getNonDeletedElementsMap()):null;return n?NR(Ir,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:_R,icon:za,appState:r,scene:t,property:o}):null},M5=RR;f();we();yr();De();kd();He();import{useMemo as OR}from"react";Y();import{jsx as UR}from"react/jsx-runtime";var pc=10,FR=(e,t,r,o)=>{let n=o.x-e,i=o.y-t,a=o.width*r,s=o.height*r,l=e+n*r,c=t+i*r;return{width:a,height:s,x:l,y:c,...Ad(o,a,s,!1),...H(o)?{fontSize:o.fontSize*r}:{}}},BR=(e,t,r,o,n,i,a,s,l)=>{let c=FR(e,t,o,i),{width:d,height:m}=n;F(n,c,!1);let p=J(i,s);if(p){let u=p.fontSize*o;qt(n,a,l,{oldSize:{width:d,height:m}});let g=a.get(p.id);g&&H(g)&&(F(g,{fontSize:u},!1),mn(n,a,r==="width"?"e":"s",!0))}},k5=(e,t,r,o,n,i,a,s,l,c,d)=>{i==="width"?t=Math.round(e/o*100)/100:e=Math.round(t*o*100)/100;let m=t/r;for(let p=0;p<s.length;p++){let u=s[p],g=a[p];BR(n[0],n[1],i,m,g,u,l,c,d)}},zR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,originalAppState:o,shouldChangeByStepSize:n,nextValue:i,scene:a,property:s})=>{let l=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements(),d=mc(t,o);if(i!==void 0){for(let u of d){let g=cc(u,l,r);if(g.length>1){let h=g.map(k=>k.latest),x=g.map(k=>k.original),[v,y,w,C]=Te(x),M=w-v,I=C-y,P=M/I,A=Math.max(Vr,s==="width"?Math.max(0,i):M),N=Math.max(Vr,s==="height"?Math.max(0,i):I);k5(A,N,I,P,[v,y],s,h,x,l,r,a)}else{let[h]=g,x=h?.latest,v=h?.original;if(x&&v&&ao(x,s)){let y=s==="width"?Math.max(0,i):x.width;s==="width"&&(n?y=St(y,pc):y=Math.round(y));let w=s==="height"?Math.max(0,i):x.height;s==="height"&&(n?w=St(w,pc):w=Math.round(w)),y=Math.max(Vr,y),w=Math.max(Vr,w),dc(y,w,!1,v,l,c,a,!1)}}}a.triggerUpdate();return}let m=s==="width"?e:0,p=s==="height"?e:0;for(let u of d){let g=cc(u,l,r);if(g.length>1){let h=g.map(k=>k.latest),x=g.map(k=>k.original),[v,y,w,C]=Te(x),M=w-v,I=C-y,P=M/I,A=Math.max(0,M+m);s==="width"&&(n?A=St(A,pc):A=Math.round(A));let N=Math.max(0,I+p);s==="height"&&(n?N=St(N,pc):N=Math.round(N)),A=Math.max(Vr,A),N=Math.max(Vr,N),k5(A,N,I,P,[v,y],s,h,x,l,r,a)}else{let[h]=g,x=h?.latest,v=h?.original;if(x&&v&&ao(x,s)){let y=Math.max(0,v.width+m);s==="width"&&(n?y=St(y,pc):y=Math.round(y));let w=Math.max(0,v.height+p);s==="height"&&(n?w=St(w,pc):w=Math.round(w)),y=Math.max(Vr,y),w=Math.max(Vr,w),dc(y,w,!1,v,l,c,a)}}}a.triggerUpdate()},HR=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n,appState:i})=>{let a=OR(()=>o.map(c=>{let d=cc(c,r);if(d.length>1){let[p,u,g,h]=Te(d.map(x=>x.latest));return Math.round((e==="width"?g-p:h-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[r,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return UR(Ir,{label:e==="width"?"W":"H",elements:t,dragInputCallback:zR,value:s,editable:l,appState:i,property:e,scene:n})},Q1=HR;Gt();f();De();He();me();Gt();mt();ee();import{jsx as YR}from"react/jsx-runtime";var GR=15,WR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=t.map(c=>a.get(c.id)).filter(c=>c&&!Ln(c)&&ao(c,n)),l=t.filter(c=>!Ln(c)&&ao(c,n));if(o!==void 0){let c=Ml(o);for(let d of s){if(!d)continue;F(d,{angle:c},!1);let m=J(d,a);m&&!ne(d)&&F(m,{angle:c},!1)}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(Al(m.angle)*100)/100,u=Math.round(e),g=(p+u)%360;r&&(g=St(g,GR)),g=g<0?g+360:g;let h=Ml(g);F(d,{angle:h},!1);let x=J(d,a);x&&!ne(d)&&F(x,{angle:h},!1)}i.triggerUpdate()},VR=({elements:e,scene:t,appState:r,property:o})=>{let n=e.filter(l=>!Ln(l)&&ao(l,"angle")),i=n.map(l=>Math.round(Al(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=n.some(l=>ao(l,"angle"));return YR(Ir,{label:"A",icon:np,value:a,elements:e,dragInputCallback:WR,editable:s,appState:r,scene:t,property:o})},P5=VR;f();we();De();me();Gt();ee();He();import{jsx as jR}from"react/jsx-runtime";var L5=4,XR=4,KR=(e,t)=>e.reduce((r,o)=>{if(!o||Ln(o))return r;if(H(o))return r.push(o),r;if(Ct(o)){let n=J(o,t);if(n)return r.push(n),r}return r},[]),$R=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:r,nextValue:o,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=t.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),L5);for(let l of a)F(l,{fontSize:s},!1),ft(l,n.getContainerElement(l),i,!1);n.triggerUpdate()}else{let l=t;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),g=Math.max(p+u,L5);r&&(g=St(g,XR)),F(d,{fontSize:g},!1),ft(d,n.getContainerElement(d),i,!1)}n.triggerUpdate()}},ZR=({elements:e,scene:t,appState:r,property:o,elementsMap:n})=>{let i=KR(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return jR(Ir,{label:"F",icon:za,elements:i,dragInputCallback:$R,value:s,editable:l,scene:t,property:o,appState:r})},D5=ZR;f();mt();import{jsx as QR}from"react/jsx-runtime";var _5=10,qR=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:o,nextValue:n,property:i,scene:a})=>{let s=a.getNonDeletedElementsMap(),l=a.getNonDeletedElements(),c=t[0],[d,m]=[c.x+c.width/2,c.y+c.height/2],[p,u]=xe(c.x,c.y,d,m,c.angle);if(n!==void 0){Cs(i==="x"?n:p,i==="y"?n:u,c,s,l,a,r);return}let g=i==="x"?e:0,h=i==="y"?e:0,x=i==="x"?Math.round(o?St(c.x+g,_5):p+g):p,v=i==="y"?Math.round(o?St(c.y+h,_5):u+h):u;Cs(x,v,c,s,l,a,r)},JR=({property:e,element:t,elementsMap:r,scene:o,appState:n})=>{let[i,a]=xe(t.x,t.y,t.x+t.width/2,t.y+t.height/2,t.angle),s=Math.round((e==="x"?i:a)*100)/100;return QR(Ir,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:qR,scene:o,value:s,property:e,appState:n})},ex=JR;f();mt();we();import{useMemo as eN}from"react";import{jsx as aN}from"react/jsx-runtime";var tN=10,rN=(e,t,r,o,n,i,a,s)=>{for(let l=0;l<o.length;l++){let c=n[l],[d,m]=[c.x+c.width/2,c.y+c.height/2],[p,u]=xe(c.x,c.y,d,m,c.angle),g=e==="x"?Math.round(p+t):p,h=e==="y"?Math.round(u+r):u;Cs(g,h,c,i,o,s,a,!1)}},oN=(e,t,r,o,n,i,a)=>{let[s,l,,]=Te(r),c=e-s,d=t-l;for(let m=0;m<r.length;m++){let p=r[m],u=o.get(p.id);if(u&&(!H(u)||!u.containerId)){let[g,h]=[u.x+u.width/2,u.y+u.height/2],[x,v]=xe(u.x,u.y,g,h,u.angle);Cs(x+c,v+d,p,o,n,a,i,!1)}}},nN=({accumulatedChange:e,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:o,nextValue:n,property:i,scene:a,originalAppState:s})=>{let l=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of mc(t,s)){let g=cc(u,l,r);if(g.length>1){let[h,x,,]=Te(g.map(w=>w.latest));oN(i==="x"?n:h,i==="y"?n:x,g.map(w=>w.original),l,c,r,a)}else{let h=g[0]?.original,x=g[0]?.latest;if(h&&x&&ao(x,i)){let[v,y]=[h.x+h.width/2,h.y+h.height/2],[w,C]=xe(h.x,h.y,v,y,h.angle);Cs(i==="x"?n:w,i==="y"?n:C,h,l,c,a,r,!1)}}}a.triggerUpdate();return}let d=o?St(e,tN):e;rN(i,i==="x"?d:0,i==="y"?d:0,t,t,l,r,a),a.triggerUpdate()},iN=({property:e,elements:t,elementsMap:r,atomicUnits:o,scene:n,appState:i})=>{let a=eN(()=>o.map(l=>{let c=Object.keys(l).map(h=>r.get(h)).filter(h=>h!==void 0);if(c.length>1){let[h,x]=Te(c);return Math.round((e==="x"?h:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,g]=xe(d.x,d.y,m,p,d.angle);return Math.round((e==="x"?u:g)*100)/100}),[o,r,e]),s=new Set(a).size===1?a[0]:"Mixed";return aN(Ir,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:nN,value:s,property:e,scene:n,appState:i})},tx=iN;f();ee();import{Fragment as O5,jsx as R5,jsxs as N5}from"react/jsx-runtime";var sN=({label:e,open:t,openTrigger:r,children:o})=>N5(O5,{children:[N5("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},onClick:r,children:[e,R5(Fo,{icon:t?Gw:Uw})]}),t&&R5(O5,{children:o})]}),rx=sN;Y();me();import{jsx as We,jsxs as Bo}from"react/jsx-runtime";var mN=50,z5=e=>{let t=Gn(),r=e.scene.getSceneNonce()||1,o=e.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return We(pN,{...e,appState:t,sceneNonce:r,selectedElements:o})},pN=cN(({scene:e,onClose:t,renderCustomStats:r,selectedElements:o,appState:n,sceneNonce:i})=>{let a=e.getNonDeletedElements(),s=e.getNonDeletedElementsMap(),l=Oe(),c=o.length===1?o[0]:null,d=o.length>1?o:null,[m,p]=lN({width:0,height:0}),u=B5(()=>dN(h=>{let x=Te(h);p({width:Math.round(x[2])-Math.round(x[0]),height:Math.round(x[3])-Math.round(x[1])})},mN),[]);F5(()=>{u(a)},[i,a,u]),F5(()=>()=>u.cancel(),[u]);let g=B5(()=>mc(o,n),[o,n]);return We("div",{className:"Stats",children:Bo(Yt,{padding:3,children:[Bo("div",{className:"title",children:[We("h2",{children:E("stats.title")}),We("div",{className:"close",onClick:t,children:Ao})]}),We(rx,{label:We("h3",{children:E("stats.generalStats")}),open:!!(n.stats.panels&Fi.generalStats),openTrigger:()=>l(h=>({...h,stats:{open:!0,panels:h.stats.panels^Fi.generalStats}})),children:We("table",{children:Bo("tbody",{children:[We("tr",{children:We("th",{colSpan:2,children:E("stats.scene")})}),Bo("tr",{children:[We("td",{children:E("stats.elements")}),We("td",{children:a.length})]}),Bo("tr",{children:[We("td",{children:E("stats.width")}),We("td",{children:m.width})]}),Bo("tr",{children:[We("td",{children:E("stats.height")}),We("td",{children:m.height})]}),r?.(a,n)]})})}),o.length>0&&We("div",{id:"elementStats",style:{marginTop:12},children:Bo(rx,{label:We("h3",{children:E("stats.elementProperties")}),open:!!(n.stats.panels&Fi.elementProperties),openTrigger:()=>l(h=>({...h,stats:{open:!0,panels:h.stats.panels^Fi.elementProperties}})),children:[c&&Bo("div",{className:"sectionContent",children:[We("div",{className:"elementType",children:E(`element.${c.type}`)}),Bo("div",{className:"statsItem",children:[We(ex,{element:c,property:"x",elementsMap:s,scene:e,appState:n}),We(ex,{element:c,property:"y",elementsMap:s,scene:e,appState:n}),We(J1,{property:"width",element:c,scene:e,appState:n}),We(J1,{property:"height",element:c,scene:e,appState:n}),!de(c)&&We(C5,{property:"angle",element:c,scene:e,appState:n}),We(M5,{property:"fontSize",element:c,scene:e,appState:n})]})]}),d&&Bo("div",{className:"sectionContent",children:[q0(d)&&We("div",{className:"elementType",children:E("element.group")}),Bo("div",{className:"elementsCount",children:[We("div",{children:E("stats.elements")}),We("div",{children:o.length})]}),Bo("div",{className:"statsItem",children:[We(tx,{property:"x",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(tx,{property:"y",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(Q1,{property:"width",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(Q1,{property:"height",elements:d,elementsMap:s,atomicUnits:g,scene:e,appState:n}),We(P5,{property:"angle",elements:d,scene:e,appState:n}),We(D5,{property:"fontSize",elements:d,scene:e,appState:n,elementsMap:s})]})]})]})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels);import{Fragment as U5,jsx as be,jsxs as wo}from"react/jsx-runtime";var bN=({UIOptions:e})=>wo(Hr,{__fallback:!0,children:[be(Hr.DefaultItems.LoadScene,{}),be(Hr.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&be(Hr.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&be(Hr.DefaultItems.SaveAsImage,{}),be(Hr.DefaultItems.Help,{}),be(Hr.DefaultItems.ClearCanvas,{}),be(Hr.Separator,{}),be(Hr.Group,{title:"Excalidraw links",children:be(Hr.DefaultItems.Socials,{})}),be(Hr.Separator,{}),be(Hr.DefaultItems.ToggleTheme,{}),be(Hr.DefaultItems.ChangeCanvasBackground,{})]}),EN=()=>wo(Jg,{__fallback:!0,children:[be(Jg.Actions.SaveToDisk,{}),be(Jg.Actions.ExportToImage,{})]}),xN=({actionManager:e,appState:t,files:r,setAppState:o,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:g,children:h,app:x,isCollaborating:v,openAIKey:y,isOpenAIKeyPersisted:w,onOpenAIAPIKeyChange:C,onMagicSettingsConfirm:M})=>{let I=Ne(),P=zI(),[A,N]=hN(ca,Xe),k=()=>p.canvasActions.export?be(bC,{elements:n,appState:t,files:r,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,D=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:be(oC,{elements:n,appState:t,files:r,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:x.getName()}),z=()=>wo("div",{style:{position:"relative"},children:[be(P.MainMenuTunnel.Out,{}),g&&be(P.WelcomeScreenMenuHintTunnel.Out,{})]}),R=()=>be(fa,{heading:"selectedShapeActions",className:om("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:be(Yt,{className:vm.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:be(Dg,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),W=()=>{let le=us(t,n),U=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled;return be(zg,{side:"top",children:wo("div",{className:"App-menu App-menu_top",children:[wo(rr.Col,{gap:6,className:om("App-menu_top__left"),children:[z(),le&&R()]}),!t.viewModeEnabled&&be(fa,{heading:"shapes",className:"shapes-section",children:oe=>wo("div",{style:{position:"relative"},children:[g&&be(P.WelcomeScreenToolbarHintTunnel.Out,{}),be(rr.Col,{gap:4,align:"start",children:wo(rr.Row,{gap:1,className:om("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[wo(Yt,{padding:1,className:om("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[be(Hg,{appState:t,isMobile:I.editor.isMobile,device:I,app:x}),oe,wo(rr.Row,{gap:1,children:[be(Gg,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>l(null),title:E("toolBar.penMode"),penDetected:t.penDetected}),be(Ug,{checked:t.activeTool.locked,onChange:a,title:E("toolBar.lock")}),be("div",{className:"App-toolbar__divider"}),be(Wg,{checked:qo(t),onChange:()=>s(),title:E("toolBar.hand"),isMobile:!0}),be(_g,{appState:t,activeTool:t.activeTool,UIOptions:p,app:x})]})]}),v&&be(Yt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:be(t5,{title:E("toolBar.laser"),checked:t.activeTool.type===It.laser,onChange:()=>x.setActiveTool({type:It.laser}),isMobile:!0})})]})})]})}),wo("div",{className:om("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&be(Xg,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(I.editor.isMobile,t),!t.viewModeEnabled&&(!re||t.openSidebar?.name!==co.name)&&be(P.DefaultSidebarTriggerTunnel.Out,{}),U&&be(z5,{scene:x.scene,onClose:()=>{e.executeAction(Zl)},renderCustomStats:m})]})]})})},q=()=>be(Qg,{__fallback:!0,onDock:le=>{Ce("sidebar",`toggleDock (${le?"dock":"undock"})`,`(${I.editor.isMobile?"mobile":"desktop"})`)}}),re=fN(Jd,Xe),ge=wo(U5,{children:[h,be(bN,{UIOptions:p}),be(Qg.Trigger,{__fallback:!0,icon:qm,title:Bi(E("toolBar.library")),onToggle:le=>{le&&Ce("sidebar",`${co.name} (open)`,`button (${I.editor.isMobile?"mobile":"desktop"})`)},tab:co.defaultTab,children:E("toolBar.library")}),be(EN,{}),t.openDialog?.name==="ttd"&&be(j1,{__fallback:!0}),t.isLoading&&be(Dm,{delay:250}),t.errorMessage&&be(eC,{onClose:()=>o({errorMessage:null}),children:t.errorMessage}),A&&!I.editor.isMobile&&be($3,{colorPickerType:A.colorPickerType,onCancel:()=>{N(null)},onChange:(le,U,oe,{altKey:Ie})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(oe.length){for(let Fe of oe)F(Fe,{[Ie&&A.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:U},!1),_e.delete(Fe);er.getScene(oe[0])?.triggerUpdate()}else o(le==="elementBackground"?{currentItemBackgroundColor:U}:{currentItemStrokeColor:U})},onSelect:(le,U)=>{N(oe=>oe?.keepOpenOnAlt&&U.altKey?oe:null),A?.onSelect?.(le,U)}}),t.openDialog?.name==="help"&&be(gC,{onClose:()=>{o({openDialog:null})}}),t.openDialog?.name==="settings"&&be(s5,{openAIKey:y,isPersisted:w,onChange:C,onConfirm:(le,U)=>{let oe=t.openDialog?.name==="settings"?t.openDialog?.source:"settings";o({openDialog:null},()=>{M(le,U,oe)})},onClose:()=>{o({openDialog:null})}}),be(VI,{}),be(P.OverwriteConfirmDialogTunnel.Out,{}),D(),k(),t.pasteDialog.shown&&be(uC,{setAppState:o,appState:t,onClose:()=>o({pasteDialog:{shown:!1,data:null}})}),I.editor.isMobile&&be(mC,{app:x,appState:t,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:D,setAppState:o,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,renderTopRightUI:d,renderCustomStats:m,renderSidebars:q,device:I,renderWelcomeScreen:g,UIOptions:p}),!I.editor.isMobile&&wo(U5,{children:[wo("div",{className:"layer-ui__wrapper",style:t.openSidebar&&re&&I.editor.canFitSidebar?{width:`calc(100% - ${u0}px)`}:{},children:[g&&be(P.WelcomeScreenCenterTunnel.Out,{}),W(),be(yC,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),t.scrolledOutside&&be("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(le=>({..._n(n,le)}))},children:E("buttons.scrollBackToContent")})]}),q()]})]});return be(uE.Provider,{value:t,children:be(gN,{scope:P.jotaiScope,children:be(p1.Provider,{value:P,children:ge})})})},H5=e=>{let{suggestedBindings:t,startBoundElement:r,cursorButton:o,scrollX:n,scrollY:i,...a}=e;return a},yN=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:r,appState:o,...n}=e,{canvas:i,appState:a,...s}=t;return it(H5(o),H5(a),{selectedElementIds:it,selectedGroupIds:it})&&it(n,s)},G5=uN.memo(xN,yN);f();ee();import{useCallback as wN,useEffect as vN,useRef as TN}from"react";import{jsx as W5,jsxs as IN}from"react/jsx-runtime";var SN=5e3,V5=({message:e,onClose:t,closable:r=!1,duration:o=SN,style:n})=>{let i=TN(0),a=o!==1/0,s=wN(()=>{a&&(i.current=window.setTimeout(()=>t(),o))},[t,o,a]);return vN(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),IN("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:n,children:[W5("p",{className:"Toast__message",children:e}),r&&W5(fe,{icon:Ao,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};f();ee();ye();Re();$e();var ox=G({name:"viewMode",label:"labels.viewMode",paletteName:"Toggle view mode",icon:Zs,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},storeAction:_.NONE}},checked:e=>e.viewModeEnabled,predicate:(e,t,r)=>typeof r.viewModeEnabled>"u",keyTest:e=>!e[S.CTRL_OR_CMD]&&e.altKey&&e.code===Se.R});qr();rb();di();He();import E9 from"lodash.throttle";Oa();Cd();on();vr();Ui();f();we();vr();vr();ye();V();Gs();$e();me();ee();Re();var Y5=(e,t)=>{let r=t.scene.getSelectedElements(e);return r.length===1&&Q(r[0])},X5=G({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;if(Q(n)){let i=bo(Ae(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},storeAction:_.CAPTURE}}return{elements:e,appState:t,storeAction:_.NONE}},predicate:(e,t,r,o)=>Y5(t,o)}),K5=G({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,r,o)=>{let n=o.scene.getSelectedElements(t).at(0)||null;return Q(n)?{elements:bb(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},storeAction:_.CAPTURE}:{elements:e,appState:t,storeAction:_.NONE}},predicate:(e,t,r,o)=>Y5(t,o)}),oSe=G({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},storeAction:_.NONE}),checked:e=>e.frameRendering.enabled}),nSe=G({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:sp,viewMode:!1,perform:(e,t,r,o)=>{let n=nt(t,{type:"frame"});return po(o.interactiveCanvas,{...t,activeTool:n}),{elements:e,appState:{...t,activeTool:nt(t,{type:"frame"})},storeAction:_.NONE}},keyTest:e=>!e[S.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===S.F});Hi();f();Y();dt();me();Gt();ye();mt();Ui();var CN=8,$5=99999,mh=e=>CN/e,zo=class e{static referenceSnapPoints=null;static visibleGaps=null;static setReferenceSnapPoints=t=>{e.referenceSnapPoints=t};static getReferenceSnapPoints=()=>e.referenceSnapPoints;static setVisibleGaps=t=>{e.visibleGaps=t};static getVisibleGaps=()=>e.visibleGaps;static destroy=()=>{e.referenceSnapPoints=null,e.visibleGaps=null}},_i=({event:e,appState:t,selectedElements:r})=>e?t.objectsSnapModeEnabled&&!e[S.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[S.CTRL_OR_CMD]&&t.gridSize===null:r.length===1&&r[0].type==="arrow"?!1:t.objectsSnapModeEnabled,AN=(e,t,r=.01)=>Math.abs(e-t)<=r,nm=(e,t,{omitCenter:r,boundingBoxCorners:o,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=ae(a,t);n&&(s+=n.x,c+=n.x,m+=n.x,l+=n.y,d+=n.y,p+=n.y);let u=(c-s)/2,g=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let h=ce([s,l+g],[m,p],a.angle),x=ce([s+u,l],[m,p],a.angle),v=ce([c,l+g],[m,p],a.angle),y=ce([s+u,d],[m,p],a.angle);i=r?[h,x,v,y]:[h,x,v,y,[m,p]]}else{let h=ce([s,l],[m,p],a.angle),x=ce([c,l],[m,p],a.angle),v=ce([s,d],[m,p],a.angle),y=ce([c,d],[m,p],a.angle);i=r?[h,x,v,y]:[h,x,v,y,[m,p]]}}else if(e.length>1){let[a,s,l,c]=Tu(e,n??{x:0,y:0}),d=l-a,m=c-s,p=[a,s],u=[l,s],g=[a,c],h=[l,c],x=[a+d/2,s+m/2];i=r?[p,u,g,h]:[p,u,g,h,x]}return i.map(a=>[yt(a[0]),yt(a[1])])},q5=(e,t,r,o)=>{let n=t.filter(i=>Q(i)).map(i=>i.id);return Zb(e,t,r,o).filter(i=>!(i.frameId&&n.includes(i.frameId)))},J5=(e,t,r,o)=>{let n=q5(e,t,r,o),i=Na(n,o).filter(m=>!(m.length===1&&ze(m[0]))).map(m=>Te(m).map(p=>yt(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>$5)break e;let g=a[u],[,h,x,v]=p,[y,w,,C]=g;x<y&&xd([h,v],[w,C])&&s.push({startBounds:p,endBounds:g,startSide:[[x,h],[x,v]],endSide:[[y,w],[y,C]],length:y-x,overlap:yd([h,v],[w,C])})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>$5)break e;let g=c[u],[h,,x,v]=p,[y,w,C]=g;v<w&&xd([h,x],[y,C])&&d.push({startBounds:p,endBounds:g,startSide:[[h,v],[x,v]],endSide:[[y,w],[C,w]],length:w-v,overlap:yd([h,x],[y,C])})}}return{horizontalGaps:s,verticalGaps:d}},Z5=(e,t,r,o,n,i,a)=>{if(!_i({appState:r,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=zo.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Tu(e,t).map(x=>yt(x)),g=(d+p)/2,h=(m+u)/2;for(let x of l){if(!xd([m,u],x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=yt(v-g);if(x.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(n.length=0),a.x=Math.abs(y);let k={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(k);continue}let[,,C]=x.endBounds,M=d-C,I=yt(x.length-M);if(Math.abs(I)<=a.x){Math.abs(I)<a.x&&(n.length=0),a.x=Math.abs(I);let k={type:"gap",direction:"side_right",gap:x,offset:I};n.push(k);continue}let[P,,,]=x.startBounds,A=P-p,N=yt(A-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let k={type:"gap",direction:"side_left",gap:x,offset:N};n.push(k);continue}}for(let x of c){if(!xd([d,p],x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=yt(v-h);if(x.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let k={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(k);continue}let[,C,,]=x.startBounds,M=C-u,I=yt(M-x.length);if(Math.abs(I)<=a.y){Math.abs(I)<a.y&&(i.length=0),a.y=Math.abs(I);let k={type:"gap",direction:"side_top",gap:x,offset:I};i.push(k);continue}let[,,,P]=x.endBounds,A=yt(m-P),N=x.length-A;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let k={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(k);continue}}}},Q5=(e,t,r,o)=>{let n=q5(e,t,r,o);return Na(n,o).filter(i=>!(i.length===1&&ze(i[0]))).flatMap(i=>nm(i,o))},uc=(e,t,r,o,n,i,a)=>{if(!_i({appState:r,event:o,selectedElements:e})||e.length===0&&t.length===0)return[];let s=zo.getReferenceSnapPoints();if(s)for(let l of t)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(n.length=0),n.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},eA=(e,t,r,o,n)=>{let i=he(e,r);if(!_i({appState:r,event:o,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=yt(t.x),t.y=yt(t.y);let a=[],s=[],l=mh(r.zoom.value),c={x:l,y:l},d=nm(i,n,{dragOffset:t});uc(i,d,r,o,a,s,c),Z5(i,t,r,o,a,s,c);let m={x:a[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,a.length=0,s.length=0;let p={x:yt(t.x+m.x),y:yt(t.y+m.y)};uc(i,nm(i,n,{dragOffset:p}),r,o,a,s,c),Z5(i,p,r,o,a,s,c);let u=nx(a,s),g=kN(i,p,[...a,...s].filter(h=>h.type==="gap"));return{snapOffset:m,snapLines:[...u,...g]}},yt=e=>Math.round(e*10**6)/10**6,j5=e=>{let t=new Map;for(let r of e){let o=r.join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},nx=(e,t)=>{let r={},o={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=yt(n.points[0][0]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>[yt(a[0]),yt(a[1])]))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=yt(n.points[0][1]);o[i]||(o[i]=[]),o[i].push(...n.points.map(a=>[yt(a[0]),yt(a[1])]))}}return Object.entries(r).map(([n,i])=>({type:"points",points:j5(i.map(a=>[Number(n),a[1]]).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([n,i])=>({type:"points",points:j5(i.map(a=>[a[0],Number(n)]).sort((a,s)=>a[0]-s[0]))})))},MN=e=>{let t=new Map;for(let r of e){let o=r.points.flat().map(n=>[yt(n)]).join(",");t.has(o)||t.set(o,r)}return Array.from(t.values())},kN=(e,t,r)=>{let[o,n,i,a]=Tu(e,t),s=[];for(let l of r){let[c,d,m,p]=l.gap.startBounds,[u,g,h,x]=l.gap.endBounds,v=yd([n,a],l.gap.overlap),y=yd([o,i],l.gap.overlap);switch(l.direction){case"center_horizontal":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[l.gap.startSide[0][0],w],[o,w]]},{type:"gap",direction:"horizontal",points:[[i,w],[l.gap.endSide[0][0],w]]})}break}case"center_vertical":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,l.gap.startSide[0][1]],[w,n]]},{type:"gap",direction:"vertical",points:[[w,a],[w,l.gap.endSide[0][1]]]})}break}case"side_right":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[m,w],[u,w]]},{type:"gap",direction:"horizontal",points:[[h,w],[o,w]]})}break}case"side_left":{if(v){let w=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[[i,w],[c,w]]},{type:"gap",direction:"horizontal",points:[[m,w],[u,w]]})}break}case"side_top":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,a],[w,d]]},{type:"gap",direction:"vertical",points:[[w,p],[w,g]]})}break}case"side_bottom":{if(y){let w=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[[w,p],[w,g]]},{type:"gap",direction:"vertical",points:[[w,x],[w,n]]})}break}}}return MN(s.map(l=>({...l,points:l.points.map(c=>[yt(c[0]),yt(c[1])])})))},tA=(e,t,r,o,n,i)=>{if(!_i({event:o,selectedElements:e,appState:r})||e.length===0||e.length===1&&!AN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Te(t);i&&(i.includes("e")?l+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?s+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push([l,s],[l,c]);break}case"w":{d.push([a,s],[a,c]);break}case"n":{d.push([a,s],[l,s]);break}case"s":{d.push([a,c],[l,c]);break}case"ne":{d.push([l,s]);break}case"nw":{d.push([a,s]);break}case"se":{d.push([l,c]);break}case"sw":{d.push([a,c]);break}}let m=mh(r.zoom.value),p={x:m,y:m},u=[],g=[];uc(t,d,r,o,u,g,p);let h={x:u[0]?.offset??0,y:g[0]?.offset??0};p.x=0,p.y=0,u.length=0,g.length=0;let[x,v,y,w]=Te(e).map(I=>yt(I));uc(e,[[x,v],[x,w],[y,v],[y,w]],r,o,u,g,p);let M=nx(u,g);return{snapOffset:h,snapLines:M}},rA=(e,t,r,o,n,i)=>{if(!_i({event:r,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[[o.x+n.x,o.y+n.y]],s=mh(t.zoom.value),l={x:s,y:s},c=[],d=[];uc([e],a,t,r,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=nm([e],i,{boundingBoxCorners:!0,omitCenter:!0});uc([e],p,t,r,c,d,l);let u=nx(c,d);return{snapOffset:m,snapLines:u}},oA=(e,t,r,o,n)=>{if(!_i({event:o,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Zb(e,[],t,n),a=mh(t.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=nm([d],n);for(let p of m){let u=p[0]-r.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,[p[0],r.y]],direction:"vertical"}),s.x=u);let g=p[1]-r.y;Math.abs(g)<=Math.abs(s.y)&&(Math.abs(g)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,[r.x,p[1]]],direction:"horizontal"}),s.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-r.x:0,y:l.length>0?l[0].points[0][1]-r.y:0},snapLines:[...c,...l]}},nA=e=>e===It.rectangle||e===It.ellipse||e===It.diamond||e===It.frame||e===It.magicframe||e===It.image||e===It.text;f();import{jsx as Ho,jsxs as iA}from"react/jsx-runtime";var PN=()=>iA("div",{"data-testid":"brave-measure-text-error",children:[Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Ho("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Ho("p",{children:Ho(Br,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Ho("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>iA("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),aA=PN;f();Y();we();yr();Nn();He();V();Ha();Zo();ko();on();me();var ph={width:100,height:0},va=100,LN=(e,t,r)=>{let o=jt({x:0,y:0,textAlign:Oi.CENTER,verticalAlign:kt.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:o.id})}),ft(o,e,r),[e,o]},sA=(e,t,r,o,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??va,m=t?.height??va,p;t.id&&(p=o.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,g=t.y||e.y-m/2,h=p?p.type:t.type;if(h){if(h==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=jt({x:u,y:g,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{i=go({x:u,y:g,width:d,height:m,...p,...t,type:h});break}default:$o(e,`Unhandled element start type "${t.type}"`,!0)}On(e,i,"start",n)}}if(r){let d=r?.height??va,m=r?.width??va,p;r.id&&(p=o.getElement(r.id),p||console.error(`No element for end binding with id ${r.id} found`));let u=r.x||e.x+e.width,g=r.y||e.y-d/2,h=p?p.type:r.type;if(h){if(h==="text"){let x="";p&&p.type==="text"?x=p.text:r.type==="text"&&(x=r.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=jt({x:u,y:g,type:"text",...p,...r,text:x}),Object.assign(a,{y:r.y||e.y-a.height/2})}else switch(h){case"rectangle":case"ellipse":case"diamond":{a=go({x:u,y:g,width:m,height:d,...p,...r,type:h});break}default:$o(e,`Unhandled element end type "${h}"`,!0)}On(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let s=e.points.length-1,l=.5,c=Xr(e.points);return e.points[s][0]>e.points[s-1][0]&&(c[0][0]=l,c[s][0]-=l),e.points[s][0]<e.points[s-1][0]&&(c[0][0]=-l,c[s][0]+=l),e.points[s][1]>e.points[s-1][1]&&(c[0][1]=l,c[s][1]-=l),e.points[s][1]<e.points[s-1][1]&&(c[0][1]=-l,c[s][1]+=l),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:i,endBoundElement:a}},ix=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>fr(Array.from(this.excalidrawElements.values()));getElementsMap=()=>Mr(Z(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},ac=(e,t)=>{if(!e)return[];let r=Xr(e),o=new ix,n=new Map,i=new Map;for(let s of r){let l,c=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:Ut()}),s.type){case"rectangle":case"ellipse":case"diamond":{let m=s?.label?.text&&s.width===void 0?0:s?.width||va,p=s?.label?.text&&s.height===void 0?0:s?.height||va;l=go({...s,width:m,height:p});break}case"line":{let m=s.width||ph.width,p=s.height||ph.height;l=nn({width:m,height:p,points:[[0,0],[m,p]],...s});break}case"arrow":{let m=s.width||ph.width,p=s.height||ph.height;l=Gc({width:m,height:p,endArrowhead:"arrow",points:[[0,0],[m,p]],...s,type:"arrow"}),Object.assign(l,pi(l.points));break}case"text":{let m=s?.fontFamily||gr,p=s?.fontSize||ur,u=s?.lineHeight||uo(m),g=s.text??"",h=Zi(g),x=Vt(h,Me({fontFamily:m,fontSize:p}),u);l=jt({width:x.width,height:x.height,fontFamily:m,fontSize:p,...s});break}case"image":{l=Wc({width:s?.width||va,height:s?.height||va,...s});break}case"frame":{l=Cp({x:0,y:0,...s});break}case"magicframe":{l=Uc({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{l=s;break}default:l=s,$o(s,`Unhandled element type "${s.type}"`,!0)}o.getElement(l.id)?console.error(`Duplicate id found for ${l.id}`):(o.add(l),n.set(l.id,s),c&&i.set(c,l.id))}let a=o.getElementsMap();for(let[s,l]of n){let c=o.getElement(s);switch(l.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(l.label?.text){let[d,m]=LN(c,l?.label,a);if(o.add(d),o.add(m),ne(d)){let p=l.type==="arrow"?l?.start:void 0,u=l.type==="arrow"?l?.end:void 0;if(p&&p.id){let v=i.get(p.id);v&&Object.assign(p,{id:v})}if(u&&u.id){let v=i.get(u.id);v&&Object.assign(u,{id:v})}let{linearElement:g,startBoundElement:h,endBoundElement:x}=sA(d,p,u,o,a);d=g,o.add(g),o.add(h),o.add(x)}}else switch(l.type){case"arrow":{let{start:d,end:m}=l;if(d&&d.id){let h=i.get(d.id);Object.assign(d,{id:h})}if(m&&m.id){let h=i.get(m.id);Object.assign(m,{id:h})}let{linearElement:p,startBoundElement:u,endBoundElement:g}=sA(c,d,m,o,a);o.add(p),o.add(u),o.add(g);break}}break}}}for(let[s,l]of n){if(l.type!=="frame"&&l.type!=="magicframe")continue;let c=o.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];l.children.forEach(y=>{let w=i.get(y);if(!w)throw new Error(`Element with ${y} wasn't mapped correctly`);let C=o.getElement(w);if(!C)throw new Error(`Frame element with id ${w} doesn't exist`);Object.assign(C,{frameId:c.id}),C?.boundElements?.forEach(M=>{let I=o.getElement(M.id);if(!I)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(I,{frameId:c.id}),d.push(I)}),d.push(C)});let[m,p,u,g]=Te(d),h=10;m=m-h,p=p-h,u=u+h,g=g+h;let x=Math.max(c?.width,u-m),v=Math.max(c?.height,g-p);Object.assign(c,{x:m,y:p,width:x,height:v})}return o.getElements()};f();f();V();Y();import KN,{useEffect as $N,useRef as ZN}from"react";f();V();import{unstable_batchedUpdates as lA}from"react-dom";import{version as DN}from"react";var bt=e=>t=>{lA(e,t)},uh=e=>Hs(t=>{lA(e,t)}),gh=(()=>{let e;try{let r=DN.split(".");e=Number(r[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();f();we();li();Gt();Cd();V();Y();f();Y();var _N="#ff6b6b",RN="#ff0000",cA=1,dA=2,mA=(e,t)=>{if(!t.snapLines.length)return;let r=t.theme===ue.LIGHT||t.zenModeEnabled?_N:RN,o=(t.zenModeEnabled?cA*1.5:cA)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=o,e.strokeStyle=r,ON(n,e,t)):n.type==="gap"?(e.lineWidth=o,e.strokeStyle=r,FN(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=o,e.strokeStyle=r,NN(n,e,t));e.restore()},NN=(e,t,r)=>{if(!r.zenModeEnabled){let o=e.points[0],n=e.points[e.points.length-1];Uo(o,n,t)}for(let o of e.points)pA(o,r,t)},ON=(e,t,r)=>{pA(e.points[0],r,t),r.zenModeEnabled||Uo(e.points[0],e.points[1],t)},pA=([e,t],r,o)=>{o.save();let n=(r.zenModeEnabled?dA*1.5:dA)/r.zoom.value;o.beginPath(),o.moveTo(e-n,t-n),o.lineTo(e+n,t+n),o.moveTo(e+n,t-n),o.lineTo(e-n,t+n),o.stroke(),o.restore()},Uo=(e,t,r)=>{r.beginPath(),r.lineTo(...e),r.lineTo(...t),r.stroke()},FN=(e,t,r,o,n)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(r==="horizontal"){let l=[(e[0]+t[0])/2,e[1]];o.zenModeEnabled||Uo([e[0],e[1]-i],[e[0],e[1]+i],n),Uo([l[0]-s,l[1]-a],[l[0]-s,l[1]+a],n),Uo([l[0]+s,l[1]-a],[l[0]+s,l[1]+a],n),o.zenModeEnabled||(Uo([t[0],t[1]-i],[t[0],t[1]+i],n),Uo(e,t,n))}else{let l=[e[0],(e[1]+t[1])/2];o.zenModeEnabled||Uo([e[0]-i,e[1]],[e[0]+i,e[1]],n),Uo([l[0]-a,l[1]-s],[l[0]+a,l[1]-s],n),Uo([l[0]-a,l[1]+s],[l[0]+a,l[1]+s],n),o.zenModeEnabled||(Uo([t[0]-i,t[1]],[t[0]+i,t[1]],n),Uo(e,t,n))}};yr();Wt();ib();me();mt();import hh from"open-color";var BN=(e,t,r)=>{let{elementId:o,hoverPointIndex:n}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=K.getElement(o,r);if(!i)return;let a=K.getPointAtIndexGlobalCoordinates(i,n,r);e.save(),e.translate(t.scrollX,t.scrollY),sx(a,e,t),e.restore()},sx=(e,t,r)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",dd(t,e[0],e[1],K.POINT_HANDLE_SIZE/r.zoom.value,!1)},im=(e,t,r,o,n,i,a,s,l=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(s),l&&e.fillRect(t-i,r-a,o,n),c&&e.roundRect?(e.beginPath(),e.roundRect(t-i,r-a,o,n,c),e.stroke(),e.closePath()):e.strokeRect(t-i,r-a,o,n),e.restore()},zN=(e,t,r,o,n,i)=>{e.save(),e.translate(o,n),e.rotate(i),e.beginPath(),e.moveTo(0,r/2),e.lineTo(t/2,0),e.lineTo(0,-r/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},fh=(e,t,r,o,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)"),dd(e,r[0],r[1],o/t.zoom.value,!i)},HN=(e,t,r,o,n,i)=>{e.beginPath(),e.ellipse(o,n,t/2,r/2,i,0,Math.PI*2),e.stroke()},UN=(e,t,r)=>{let[o,n,i,a]=ae(t,r),s=i-o,l=a-n,c=10,d=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-d;let m=d/2+c/2,p=fo(Math.min(t.width,t.height),t);switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":im(e,o-m,n-m,s+m*2,l+m*2,o+s/2,n+l/2,t.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,l),g=m*u/l,h=m*u/s;zN(e,s+g*2,l+h*2,o+s/2,n+l/2,t.angle);break;case"ellipse":HN(e,s+m*2,l+m*2,o+s/2,n+l/2,t.angle);break}},GN=(e,t,r)=>{let[o,n,i]=t,a=ed(i,i.width,i.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(n==="both"?[0,-1]:n==="start"?[0]:[-1]).forEach(l=>{let[c,d]=K.getPointAtIndexGlobalCoordinates(o,l,r);dd(e,c,d,a)})},gA=(e,t,r)=>{let{angle:o,elementX1:n,elementY1:i,elementX2:a,elementY2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=r,u=a-n,g=s-i,x=oi*2/t.zoom.value,v=8/t.zoom.value,y=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let w=l.length;for(let C=0;C<w;++C)e.strokeStyle=l[C],m&&e.setLineDash([v,y+(v+y)*(w-1)]),e.lineDashOffset=(v+y)*C,im(e,n-x,i-x,u+x*2,g+x*2,c,d,o);e.restore()},WN=(e,t,r,o)=>{let n=Array.isArray(r)?GN:UN;e.save(),e.translate(t.scrollX,t.scrollY),n(e,r,o),e.restore()},VN=(e,t,r,o)=>{let[n,i,a,s]=ae(r,o),l=a-n,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=rt.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),im(e,n,i,l,c,n+l/2,i+c/2,r.angle,!1,rt.radius/t.zoom.value),e.restore()},YN=(e,t,r)=>{let o=r.filter(s=>s.groupIds.length===0),n=r.filter(s=>s.groupIds.length>0),i=s=>{let[l,c,d,m]=Te(s);return{angle:0,elementX1:l,elementX2:d,elementY1:c,elementY2:m,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:l+(d-l)/2,cy:c+(m-c)/2,activeEmbeddable:!1}},a=s=>{let l=ot(r,s);return i(l)};Object.entries(Vm(n,t)).filter(([s,l])=>l).map(([s,l])=>s).map(s=>a(s)).concat(o.map(s=>i([s]))).forEach(s=>gA(e,t,s))},ax=(e,t,r,o)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=K.getPointsGlobalCoordinates(r,o),{POINT_HANDLE_SIZE:i}=K,a=t.editingLinearElement?i:i/2;n.forEach((l,c)=>{if(de(r)&&c!==0&&c!==n.length-1)return;let d=!!t.editingLinearElement?.selectedPointsIndices?.includes(c);fh(e,t,l,a,d)}),K.getEditorMidPoints(r,o,t).filter(l=>l!==null).forEach(l=>{t?.selectedLinearElement?.segmentMidPointHoveredCoords&&K.arePointsEqual(l,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(fh(e,t,l,a,!1),sx(l,e,t)):(sx(l,e,t),fh(e,t,l,a,!1)):(t.editingLinearElement||n.length===2)&&fh(e,t,l,i/2,!1,!0)}),e.restore()},uA=(e,t,r,o,n)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/r.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?dd(e,s+c/2,l+d/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/r.zoom.value),e.fill(),e.stroke()):im(e,s,l,c,d,s+c/2,l+d/2,n,!0),e.restore()}})},XN=(e,t,r,o)=>{t.save();let n=oi*2/r.zoom.value,i=e.width+n*2,a=e.height+n*2,s=e.x+i/2,l=e.y+a/2,c=-(i/2+n),d=-(a/2+n);t.translate(s+r.scrollX,l+r.scrollY),t.rotate(e.angle),t.lineWidth=1/r.zoom.value,t.strokeStyle=o,t.strokeRect(c,d,i,a),t.restore()},hA=({canvas:e,elementsMap:t,visibleElements:r,selectedElements:o,allElementsMap:n,scale:i,appState:a,renderConfig:s,device:l})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[c,d]=ru(e,i),m=ou({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:d});m.save(),m.scale(a.zoom.value,a.zoom.value);let p;if(r.forEach(h=>{a.editingLinearElement?.elementId===h.id&&h&&(p=h)}),p&&ax(m,a,p,t),a.selectionElement)try{DT(a.selectionElement,m,a,s.selectionColor)}catch(h){console.error(h)}if(a.editingElement&&H(a.editingElement)){let h=n.get(a.editingElement.id);h&&!h.autoResize&&XN(h,m,a,s.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(h=>h!=null).forEach(h=>{WN(m,a,h,t)}),a.frameToHighlight&&VN(m,a,a.frameToHighlight,t),a.elementsToHighlight&&YN(m,a,a.elementsToHighlight);let u=o.some(h=>Q(h));if(o.length===1&&a.editingLinearElement?.elementId===o[0].id&&ax(m,a,o[0],t),a.selectedLinearElement&&a.selectedLinearElement.hoverPointIndex>=0&&!(de(o[0])&&a.selectedLinearElement.hoverPointIndex>0&&a.selectedLinearElement.hoverPointIndex<o[0].points.length-1)&&BN(m,a,t),!a.multiElement&&!a.editingLinearElement){let h=_u(o,a),x=o.length===1&&ie(o[0]);x&&a.selectedLinearElement?.elementId===o[0].id&&!o[0].locked&&ax(m,a,o[0],t);let v=s.selectionColor||hh.black;if(h){let y=Z(o),w=[];for(let M of t.values()){let I=[],P=s.remoteSelectedElementIds.get(M.id);if(x&&ne(M)&&de(M)&&(M.startBinding||M.endBinding)||(y.has(M.id)&&!Wm(a,M)&&I.push(v),P&&I.push(...P.map(A=>vs(A,a.collaborators.get(A))))),I.length){let[A,N,k,D,z,R]=ae(M,t,!0);w.push({angle:M.angle,elementX1:A,elementY1:N,elementX2:k,elementY2:D,selectionColors:I,dashed:!!P,cx:z,cy:R,activeEmbeddable:a.activeEmbeddable?.element===M&&a.activeEmbeddable.state==="active"})}}let C=M=>{let I=ot(t,M),[P,A,N,k]=Te(I);w.push({angle:0,elementX1:P,elementX2:N,elementY1:A,elementY2:k,selectionColors:[hh.black],dashed:!0,cx:P+(N-P)/2,cy:A+(k-A)/2,activeEmbeddable:!1})};for(let M of Jo(a))C(M);a.editingGroupId&&C(a.editingGroupId),w.forEach(M=>gA(m,a,M))}if(m.save(),m.translate(a.scrollX,a.scrollY),o.length===1){m.fillStyle=hh.white;let y=Id(o[0],a.zoom,t,"mouse",ps(l));!a.viewModeEnabled&&h&&!H(a.editingElement)&&uA(m,s,a,y,o[0].angle)}else if(o.length>1&&!a.isRotating){let y=oi*2/a.zoom.value;m.fillStyle=hh.white;let[w,C,M,I]=Te(o),P=m.getLineDash();m.setLineDash([2/a.zoom.value]);let A=m.lineWidth;m.lineWidth=1/a.zoom.value,m.strokeStyle=v,im(m,w-y,C-y,M-w+y*2,I-C+y*2,(w+M)/2,(C+I)/2,0),m.lineWidth=A,m.setLineDash(P);let N=Nl([w,C,M,I,(w+M)/2,(C+I)/2],0,a.zoom,"mouse",u?{...ps(l),rotation:!0}:ps(l));o.some(k=>!k.locked)&&uA(m,s,a,N,0)}m.restore()}mA(m,a),m.restore(),_S({context:m,renderConfig:s,appState:a,normalizedWidth:c,normalizedHeight:d});let g;return s.renderScrollbars&&(g=cC(r,c,d,a),m.save(),m.fillStyle=lC,m.strokeStyle="rgba(255,255,255,0.8)",[g.horizontal,g.vertical].forEach(h=>{h&&sg(m,h.x,h.y,h.width,h.height,Zn/2)}),m.restore()),{scrollBars:g,atLeastOneVisibleElement:r.length>0,elementsMap:t}},lx=Hs(e=>{let t=hA(e);e.callback?.(t)},{trailing:!0}),fA=(e,t)=>{if(t){lx(e);return}let r=hA(e);return e.callback(r),r};import{jsx as JN}from"react/jsx-runtime";var jN=e=>{let t=ZN(!1);return $N(()=>{if(!t.current){t.current=!0;return}let r=new Map,o=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((l,c)=>{if(l.selectedElementIds)for(let d of Object.keys(l.selectedElementIds))n.has(d)||n.set(d,[]),n.get(d).push(c);!l.pointer||l.pointer.renderCursor===!1||(l.username&&i.set(c,l.username),l.userState&&a.set(c,l.userState),o.set(c,$t({sceneX:l.pointer.x,sceneY:l.pointer.y},e.appState)),r.set(c,l.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";fA({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:o,remotePointerButton:r,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:s,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},gh())}),JN("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Be.GRAB:Be.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:E("labels.drawingCanvas")})},bA=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,editingElement:e.editingElement}),qN=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:it(bA(e.appState),bA(t.appState)),cx=KN.memo(jN,qN);f();au();V();import QN,{useEffect as e9,useRef as EA}from"react";import{jsx as o9}from"react/jsx-runtime";var t9=e=>{let t=EA(null),r=EA(!1);return e9(()=>{let o=t.current;if(!o)return;let n=e.canvas;r.current||(r.current=!0,o.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 s=e.appState.width*e.scale,l=e.appState.height*e.scale;n.width!==s&&(n.width=s),n.height!==l&&(n.height=l),iu({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},gh())}),o9("div",{className:"excalidraw__canvas-wrapper",ref:t})},xA=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily}),r9=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:it(xA(e.appState),xA(t.appState))&&it(e.renderConfig,t.renderConfig),dx=QN.memo(t9,r9);f();ms();me();au();V();var am=class{scene;constructor(t){this.scene=t}getRenderableElements=(()=>{let t=({elementsMap:o,zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l,height:c,width:d})=>{let m=[];for(let p of o.values())ds(p,d,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:s,scrollY:l},o)&&m.push(p);return m},r=({elements:o,editingElement:n,pendingImageElementId:i})=>{let a=Mr(new Map);for(let s of o)So(s)&&i===s.id||(!n||n.type!=="text"||s.id!==n.id)&&a.set(s.id,s);return a};return N0(({zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c,editingElement:d,pendingImageElementId:m,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),g=r({elements:u,editingElement:d,pendingImageElementId:m}),h=t({elementsMap:g,zoom:o,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:s,height:l,width:c});return{elementsMap:g,visibleElements:h}})})();destroy(){lx.cancel(),ab.cancel(),this.getRenderableElements.clear()}};Qo();f();import{useEffect as n9,useRef as i9}from"react";import{jsx as yA}from"react/jsx-runtime";var wA=({trails:e})=>{let t=i9(null);return n9(()=>{if(t.current)for(let r of e)r.start(t.current);return()=>{for(let r of e)r.stop()}},e),yA("div",{className:"SVGLayer",children:yA("svg",{ref:t})})};Gs();nd();f();V();we();import{jsx as l9}from"react/jsx-runtime";var a9=5,s9=(e,t,r)=>{let[o,n]=ae(e,r),{x:i,y:a}=$t({sceneX:o+e.width,sceneY:n},t),s=i-t.offsetLeft+10,l=a-t.offsetTop;return{x:s,y:l}},mx=({children:e,element:t,elementsMap:r})=>{let o=Gn();if(o.contextMenu||o.draggingElement||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled)return null;let{x:n,y:i}=s9(t,o,r);return l9("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:a9},children:e})};f();Y();var c9=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
66
62
  Your role is to transform low-fidelity wireframes into working front-end HTML code.
67
63
 
68
64
  YOU MUST FOLLOW FOLLOWING RULES:
@@ -82,13 +78,13 @@ If the wireframes, diagrams, or text is unclear or unreadable, refer to provided
82
78
 
83
79
  Your goal is a production-ready prototype that brings the wireframes to life.
84
80
 
85
- Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function xI({image:e,apiKey:t,text:r,theme:o=ae.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:dD},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}ya();Qt();f();import mD from"clsx";import{jsx as yI,jsxs as uD}from"react/jsx-runtime";var pD="small",Wu=e=>uD("label",{className:mD("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${pD}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[yI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),yI("div",{className:"ToolIcon__icon",children:e.icon})]});f();import{jsx as Tb,jsxs as wI}from"react/jsx-runtime";var hD=({height:e,width:t,userToFollow:r,onDisconnect:o})=>Tb("div",{className:"follow-mode",style:{width:t,height:e},children:wI("div",{className:"follow-mode__badge",children:[wI("div",{className:"follow-mode__badge__label",children:["Following"," ",Tb("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),Tb("button",{onClick:o,className:"follow-mode__disconnect-btn",children:co})]})}),vI=hD;Ne();f();var Vu=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();U();Y();import{LaserPointer as gD}from"@excalidraw/laser-pointer";var Ha=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(He,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),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(t,r){this.currentTrail=new gD(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,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 t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=Ot({sceneX:n,sceneY:i},r);return[a.x,a.y]});return VE(o,!0)}};f();U();Y();var Yu=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Ha(t,r,{...this.getTrailOptions(),fill:()=>rh})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(yn(i),yn(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new Ha(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||Oa(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};Tn();km();f();ge();U();ni();se();Y();Ue();st();Xt();wi();Xd();var fD=(e,t,r,o,n,i)=>{let{zoom:a}=o,l=180*r/Math.PI,s=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},TI=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:l})=>{let s=(A,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let q=B.style.fontFamily.replace(/"/g,"");return Qa({fontFamily:A.fontFamily})!==q||`${A.fontSize}px`!==B.style.fontSize},c=()=>{let A=l.state,B=Ct.getScene(n)?.getElement(e);if(!B)return;let{textAlign:q,verticalAlign:Z}=B,oe=l.scene.getNonDeletedElementsMap();if(B&&G(B)){let Te=B.x,V=B.y,W=pt(B,l.scene.getNonDeletedElementsMap()),he=B.width,Ie=B.height,it=B.width,ke=B.height;if(W&&B.containerId){if(we(W)){let Er=X.getBoundTextElementPosition(W,B,oe);Te=Er.x,V=Er.y}let yo=s(B,d),Rr;if(yo?Rr=ma(W.id,W.height):(Rr=da[W.id],Rr||(Rr=ma(W.id,W.height))),he=vr(W,B),Ie=pa(W,B),!we(W)&&ke>Ie){let Er=In(ke,W.type);F(W,{height:Er});return}else if(!we(W)&&W.height>Rr.height&&ke<Ie){let Er=In(ke,W.type);F(W,{height:Er})}else{let{y:Er}=pl(W,B,oe);V=Er}}let[Jr,$n]=o(Te,V),zo=d.selectionStart,gn=d.selectionEnd,Xn=d.value.length;if(zo===gn&&gn!==Xn){let yo=Xn-gn;d.selectionStart=d.value.length-yo,d.selectionEnd=d.value.length-yo}W||(he=(A.width-8-Jr)/A.zoom.value,it=Math.min(it,he));let Ga=(A.height-$n)/A.zoom.value;Object.assign(d.style,{font:Ye(B),lineHeight:B.lineHeight,width:`${it}px`,height:`${ke}px`,left:`${Jr}px`,top:`${$n}px`,transform:fD(it,ke,Xx(B,W),A,he,Ga),textAlign:q,verticalAlign:Z,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Ga}px`}),d.scrollTop=0,Or()&&(d.style.fontFamily=Qa(B)),F(B,{x:Te,y:V})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let m="pre",p="normal";Ae(n)&&(m="pre-wrap",p="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:p,whiteSpace:m,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),t&&(d.onpaste=async A=>{let B=await Um(A,!0);if(!B.text)return;let q=pi(B.text);if(!q)return;let Z=pt(n,l.scene.getNonDeletedElementsMap()),oe=Ye({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let Te=me(Z,l.scene.getNonDeletedElementsMap()),V=hi(`${d.value}${q}`,oe,vr(Z,Te)),W=Ys(V,oe);d.style.width=`${W}px`}},d.oninput=()=>{t(pi(d.value))}),d.onkeydown=A=>{if(!A.shiftKey&&Cp.keyTest(A))A.preventDefault(),l.actionManager.executeAction(Cp),c();else if(!A.shiftKey&&Ap.keyTest(A))A.preventDefault(),l.actionManager.executeAction(Ap),c();else if(Hf.keyTest(A))l.actionManager.executeAction(Hf);else if(Uf.keyTest(A))l.actionManager.executeAction(Uf);else if(A.key===S.ESCAPE)A.preventDefault(),I=!0,L();else if(A.key===S.ENTER&&A[S.CTRL_OR_CMD]){if(A.preventDefault(),A.isComposing||A.keyCode===229)return;I=!0,L()}else if(A.key===S.TAB||A[S.CTRL_OR_CMD]&&(A.code===fe.BRACKET_LEFT||A.code===fe.BRACKET_RIGHT)){if(A.preventDefault(),A.isComposing)return;A.shiftKey||A.code===fe.BRACKET_LEFT?w():x(),d.dispatchEvent(new Event("input"))}};let u=4,h=" ".repeat(u),E=new RegExp(`^ {1,${u}}`),x=()=>{let{selectionStart:A,selectionEnd:B}=d,q=y(),Z=d.value;q.forEach(oe=>{let Te=Z.slice(0,oe),V=Z.slice(oe);Z=`${Te}${h}${V}`}),d.value=Z,d.selectionStart=A+u,d.selectionEnd=B+u*q.length},w=()=>{let{selectionStart:A,selectionEnd:B}=d,q=y(),Z=[],oe=d.value;q.forEach(Te=>{let V=oe.slice(Te,Te+u).match(E);if(V){let W=oe.slice(0,Te),he=oe.slice(Te+V[0].length);oe=`${W}${he}`,Z.push(Te)}}),d.value=oe,Z.length&&(A>Z[Z.length-1]?d.selectionStart=Math.max(A-u,Z[Z.length-1]):d.selectionStart=A,d.selectionEnd=Math.max(d.selectionStart,B-u*Z.length))},y=()=>{let{selectionStart:A,selectionEnd:B,value:q}=d,Z=q.slice(0,A).match(/[^\n]*$/)[0].length;return A=A-Z,q.slice(A,B).split(`
86
- `).reduce((Te,V,W,he)=>Te.concat(W?Te[W-1]+he[W-1].length+1:A),[]).reverse()},v=A=>{A.preventDefault(),A.stopPropagation()},I=!1,L=()=>{C();let A=Ct.getScene(n)?.getElement(n.id);if(!A)return;let B=d.value,q=pt(A,l.scene.getNonDeletedElementsMap());if(q){if(B=A.text,d.value.trim()){let Z=Po(q);!Z||Z!==n.id?F(q,{boundElements:(q.boundElements||[]).concat({type:"text",id:n.id})}):we(q)&&gi(q)}else F(q,{boundElements:q.boundElements?.filter(Z=>!G(Z))});Rt(A,q,l.scene.getNonDeletedElementsMap())}r({text:B,viaKeyboard:I,originalText:d.value})},C=()=>{k||(k=!0,d.onblur=null,d.oninput=null,d.onkeydown=null,N&&N.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",_),window.removeEventListener("pointerup",M),window.removeEventListener("blur",L),window.removeEventListener("beforeunload",L),H(),d.remove())},M=A=>{window.removeEventListener("pointerup",M);let B=A?.target,q=B instanceof HTMLElement&&B.classList.contains("active-color");setTimeout(()=>{if(d.onblur=L,q){let Z=(Te,V)=>{Te.find(he=>he.removedNodes.length>0&&he.removedNodes[0].dataset?.radixPopperContentWrapper!==void 0)&&(setTimeout(()=>{d.focus()}),V.disconnect())};new MutationObserver(Z).observe(document.querySelector(".excalidraw-container"),{childList:!0})}q||d.focus()})},_=A=>{let B=A.target instanceof HTMLElement&&A.target.classList.contains("active-color");((A.target instanceof HTMLElement||A.target instanceof SVGElement)&&A.target.closest(`.${pd.SHAPE_ACTIONS_MENU}`)&&!eo(A.target)||B)&&(d.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",L))},H=Ct.getScene(n).addCallback(()=>{c(),!!document.activeElement?.closest(".color-picker-content")||d.focus()}),k=!1;d.select(),M();let N=null;i&&"ResizeObserver"in window?(N=new window.ResizeObserver(()=>{c()}),N.observe(i)):window.addEventListener("resize",c),window.addEventListener("pointerdown",_),window.addEventListener("wheel",v,{passive:!1,capture:!0}),window.addEventListener("beforeunload",L),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};no();Lm();import{Fragment as wD,jsx as Ze,jsxs as $u}from"react/jsx-runtime";var AI=hn.createContext(null),kI=hn.createContext(null),MI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Lb=hn.createContext(MI);Lb.displayName="DeviceContext";var Pb=hn.createContext({container:null,id:null});Pb.displayName="ExcalidrawContainerContext";var Db=hn.createContext([]);Db.displayName="ExcalidrawElementsContext";var _b=hn.createContext({...Zt(),width:0,height:0,offsetLeft:0,offsetTop:0});_b.displayName="ExcalidrawAppStateContext";var Rb=hn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Rb.displayName="ExcalidrawSetAppStateContext";var Nb=hn.createContext(null);Nb.displayName="ExcalidrawActionManagerContext";var kr=()=>Ui(AI),ki=()=>Ui(kI),Me=()=>Ui(Lb),Ut=()=>Ui(Pb),Ii=()=>Ui(Db),Jl=()=>Ui(_b),Oe=()=>Ui(Rb),Nt=()=>Ui(Nb),Jc=!1,Ib=0,Ua=!1,Qc=!1,Cb=!1,Ab={horizontal:null,vertical:null},Hi=0,ed=!1,kb=new Map,Ku=!1,II=0,CI=!1,td=null,Be={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Mb=class e extends hn.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=MI;excalidrawContainerRef=hn.createRef();scene;renderer;fonts;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;store;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new Vu;laserTrails=new Yu(this.animationFrameHandler,this);eraserTrail=new Ha(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(yn(i),yn(n))},fill:()=>this.state.theme===ae.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new or;onPointerDownEmitter=new or;onPointerUpEmitter=new or;onUserFollowEmitter=new or;onScrollChangeEmitter=new or;missingPointerEventCleanupEmitter=new or;onRemoveEventListenersEmitter=new or;constructor(t){super(t);let r=Zt(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=r.theme,name:c=`${b("labels.untitled")}-${ch()}`}=t;if(this.state={...r,theme:s,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:l,gridSize:a?xn:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=ED(),this.library=new f3(this),this.actionManager=new du(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ct,this.canvas=document.createElement("canvas"),this.rc=bD.canvas(this.canvas),this.renderer=new qc(this.scene),this.store=new um,this.history=new Fc,o){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:m=>{this.actionManager.registerAction(m)},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:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Ou({scene:this.scene,onSceneUpdated:this.onSceneUpdated}),this.history=new Fc,this.actionManager.registerAll(lm),this.actionManager.registerAction(sT(this.history,this.store)),this.actionManager.registerAction(cT(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 o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.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 o=r.id,n=r.info.playerState;Object.values(bs).includes(n)&&kb.set(o,n)}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},draggingElement:null,selectionElement:null})},100),ro(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=kb.get(t.id);switch(o||(kb.set(t.id,bs.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case bs.PLAYING:case bs.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,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),Pe.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(It(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=fl(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else ro(o)&&t.add(o.id);return!1}),r&&this.scene.informMutation(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>It(i)&&this.embedsValidationStatus.get(i.id)===!0||ro(i));return Ze(wD,{children:n.map(i=>{let{x:a,y:l}=Ot({sceneX:i.x,sceneY:i.y},this.state),s=wa(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(s&&!c&&this.initializedEmbeds.add(i.id),!(s||c))return null;let m;if(ro(i)){m=null;let h=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let E=h.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>E}}else if(h.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>Qs(`
81
+ Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function vA({image:e,apiKey:t,text:r,theme:o=ue.LIGHT}){let n={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:c9},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${o} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:r}]}]},i,a=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return a.ok?i={...await a.json(),ok:!0}:i={...await a.json(),ok:!1},i}os();pr();f();import d9 from"clsx";import{jsx as TA,jsxs as p9}from"react/jsx-runtime";var m9="small",bh=e=>p9("label",{className:d9("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${m9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[TA("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),TA("div",{className:"ToolIcon__icon",children:e.icon})]});ee();f();ee();import{jsx as px,jsxs as SA}from"react/jsx-runtime";var u9=({height:e,width:t,userToFollow:r,onDisconnect:o})=>px("div",{className:"follow-mode",style:{width:t,height:e},children:SA("div",{className:"follow-mode__badge",children:[SA("div",{className:"follow-mode__badge__label",children:["Following"," ",px("span",{className:"follow-mode__badge__username",title:r.username,children:r.username})]}),px("button",{type:"button",onClick:o,className:"follow-mode__disconnect-btn",children:Ao})]})}),IA=u9;Re();f();var Eh=class{targets=new WeakMap;rafIds=new WeakMap;register(t,r){this.targets.set(t,{callback:r,stopped:!0})}start(t){let r=this.targets.get(t);r&&(this.rafIds.has(t)||(this.targets.set(t,{...r,stopped:!1}),this.scheduleFrame(t)))}stop(t){let r=this.targets.get(t);r&&!r.stopped&&this.targets.set(t,{...r,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return r=>{let o=this.targets.get(t);if(!o)return;let n=this.onFrame(o,r);!o.stopped&&!n?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let r=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,r)}cancelFrame(t){if(this.rafIds.has(t)){let r=this.rafIds.get(t);cancelAnimationFrame(r)}this.rafIds.delete(t)}onFrame(t,r){return t.callback(r)??!1}};f();V();Y();import{LaserPointer as g9}from"@excalidraw/laser-pointer";var As=class{constructor(t,r,o){this.animationFrameHandler=t;this.app=r;this.options=o;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Ke,"path")}currentTrail;pastTrails=[];container;trailElement;get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,r){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===t&&this.currentTrail.originalPoints[o-1][1]===r}return!1}start(t){t&&(this.container=t),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(t,r){this.currentTrail=new g9(this.options),this.currentTrail.addPoint([t,r,performance.now()]),this.update()}addPointToPath(t,r){this.currentTrail&&(this.currentTrail.addPoint([t,r,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 t=[];for(let o of this.pastTrails)t.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);t.push(o)}this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline().length!==0),t.length===0&&this.stop();let r=t.join(" ").trim();this.trailElement.setAttribute("d",r),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,r){let o=t.getStrokeOutline(t.options.size/r.zoom.value).map(([n,i])=>{let a=$t({sceneX:n,sceneY:i},r);return[a.x,a.y]});return O0(o,!0)}};f();V();Y();var xh=class{constructor(t,r){this.animationFrameHandler=t;this.app=r;this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new As(t,r,{...this.getTrailOptions(),fill:()=>kh})}localTrail;collabTrails=new Map;container;getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(ai(i),ai(n))}}}startPath(t,r){this.localTrail.startPath(t,r)}addPointToPath(t,r){this.localTrail.addPointToPath(t,r)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,r]of this.app.state.collaborators.entries()){let o;this.collabTrails.has(t)?o=this.collabTrails.get(t):(o=new As(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||vs(t,r)}),o.start(this.container),this.collabTrails.set(t,o)),r.pointer&&r.pointer.tool==="laser"&&(r.button==="down"&&!o.hasCurrentTrail&&o.startPath(r.pointer.x,r.pointer.y),r.button==="down"&&o.hasCurrentTrail&&!o.hasLastPoint(r.pointer.x,r.pointer.y)&&o.addPointToPath(r.pointer.x,r.pointer.y),r.button==="up"&&o.hasCurrentTrail&&(o.addPointToPath(r.pointer.x,r.pointer.y),o.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};li();Zc();f();ye();V();cs();me();Y();De();He();Wt();na();Au();var h9=(e,t,r,o,n,i)=>{let{zoom:a}=o,s=180*r/Math.PI,l=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>n&&a.value!==1&&(l=n*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value}) rotate(${s}deg)`},CA=({id:e,onChange:t,onSubmit:r,getViewportCoords:o,element:n,canvas:i,excalidrawContainer:a,app:s,autoSelect:l=!0})=>{let c=(R,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let q=W.style.fontFamily.replace(/"/g,"");return Sn({fontFamily:R.fontFamily})!==q||`${R.fontSize}px`!==W.style.fontSize},d=()=>{let R=s.state,W=er.getScene(n)?.getElement(e);if(!W)return;let{textAlign:q,verticalAlign:re}=W,ge=s.scene.getNonDeletedElementsMap();if(W&&H(W)){let le=W.x,U=W.y,oe=Et(W,s.scene.getNonDeletedElementsMap()),Ie=W.width,Fe=W.height,lt=W.width,Je=W.height;if(oe&&W.containerId){if(ne(oe)){let xn=K.getBoundTextElementPosition(oe,W,ge);le=xn.x,U=xn.y}let En=c(W,m),lo;if(En?lo=ss(oe.id,oe.height):(lo=as[oe.id],lo||(lo=ss(oe.id,oe.height))),lt=br(oe,W),Je=ns(oe,W),!ne(oe)&&Fe>Je){let xn=Si(Fe,oe.type);F(oe,{height:xn});return}else if(!ne(oe)&&oe.height>lo.height&&Fe<Je){let xn=Si(Fe,oe.type);F(oe,{height:xn})}else{let{y:xn}=Ll(oe,W,ge);U=xn}}let[Gr,Wo]=o(le,U),nr=m.selectionStart,so=m.selectionEnd,Ri=m.value.length;if(nr===so&&so!==Ri){let En=Ri-so;m.selectionStart=m.value.length-En,m.selectionEnd=m.value.length-En}oe?Ie+=.5:(lt=(R.width-8-Gr)/R.zoom.value,Ie=Math.min(Ie,lt)),Fe*=1.05;let Ca=Me(W),Vo=Zx?0:Math.ceil(W.fontSize/2),vo=(R.height-Wo)/R.zoom.value;Object.assign(m.style,{font:Ca,lineHeight:W.lineHeight,width:`${Ie}px`,height:`${Fe}px`,left:`${Gr-Vo}px`,top:`${Wo}px`,transform:h9(Ie,Fe,e3(W,oe),R,lt,vo),padding:`0 ${Vo}px`,textAlign:q,verticalAlign:re,color:W.strokeColor,opacity:W.opacity/100,filter:"var(--theme-filter)",maxHeight:`${vo}px`}),m.scrollTop=0,Yr()&&(m.style.fontFamily=Sn(W)),F(W,{x:le,y:U})}},m=document.createElement("textarea");m.dir="auto",m.tabIndex=0,m.dataset.type="wysiwyg",m.wrap="off",m.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(ze(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(m.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin: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"}),m.value=n.originalText,d(),t&&(m.onpaste=async R=>{let W=await pu(R,!0);if(!W.text)return;let q=Zi(W.text);if(!q)return;let re=Et(n,s.scene.getNonDeletedElementsMap()),ge=Me({fontSize:s.state.currentItemFontSize,fontFamily:s.state.currentItemFontFamily});if(re){let le=J(re,s.scene.getNonDeletedElementsMap()),U=Lo(`${m.value}${q}`,ge,br(re,le)),oe=ku(U,ge,!0);m.style.width=`${oe}px`}},m.oninput=()=>{t(Zi(m.value))}),m.onkeydown=R=>{if(!R.shiftKey&&rg.keyTest(R))R.preventDefault(),s.actionManager.executeAction(rg),d();else if(!R.shiftKey&&og.keyTest(R))R.preventDefault(),s.actionManager.executeAction(og),d();else if(AE.keyTest(R))s.actionManager.executeAction(AE);else if(ME.keyTest(R))s.actionManager.executeAction(ME);else if(R.key===S.ESCAPE)R.preventDefault(),M=!0,I();else if(R.key===S.ENTER&&R[S.CTRL_OR_CMD]){if(R.preventDefault(),R.isComposing||R.keyCode===229)return;M=!0,I()}else if(R.key===S.TAB||R[S.CTRL_OR_CMD]&&(R.code===Se.BRACKET_LEFT||R.code===Se.BRACKET_RIGHT)){if(R.preventDefault(),R.isComposing)return;R.shiftKey||R.code===Se.BRACKET_LEFT?y():v(),m.dispatchEvent(new Event("input"))}};let g=4,h=" ".repeat(g),x=new RegExp(`^ {1,${g}}`),v=()=>{let{selectionStart:R,selectionEnd:W}=m,q=w(),re=m.value;q.forEach(ge=>{let le=re.slice(0,ge),U=re.slice(ge);re=`${le}${h}${U}`}),m.value=re,m.selectionStart=R+g,m.selectionEnd=W+g*q.length},y=()=>{let{selectionStart:R,selectionEnd:W}=m,q=w(),re=[],ge=m.value;q.forEach(le=>{let U=ge.slice(le,le+g).match(x);if(U){let oe=ge.slice(0,le),Ie=ge.slice(le+U[0].length);ge=`${oe}${Ie}`,re.push(le)}}),m.value=ge,re.length&&(R>re[re.length-1]?m.selectionStart=Math.max(R-g,re[re.length-1]):m.selectionStart=R,m.selectionEnd=Math.max(m.selectionStart,W-g*re.length))},w=()=>{let{selectionStart:R,selectionEnd:W,value:q}=m,re=q.slice(0,R).match(/[^\n]*$/)[0].length;return R=R-re,q.slice(R,W).split(`
82
+ `).reduce((le,U,oe,Ie)=>le.concat(oe?le[oe-1]+Ie[oe-1].length+1:R),[]).reverse()},C=R=>{R.target instanceof HTMLCanvasElement&&(R.preventDefault(),R.stopPropagation())},M=!1,I=()=>{if(D)return;D=!0,P();let R=er.getScene(n)?.getElement(n.id);if(!R)return;let W=Et(R,s.scene.getNonDeletedElementsMap());if(W){if(m.value.trim()){let q=pn(W);!q||q!==n.id?F(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:n.id})}):ne(W)&&Ki(W)}else F(W,{boundElements:W.boundElements?.filter(q=>!H(q))});ft(R,W,s.scene.getNonDeletedElementsMap())}r({viaKeyboard:M,nextOriginalText:m.value})},P=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,z&&z.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",C,!0),window.removeEventListener("pointerdown",N),window.removeEventListener("pointerup",A),window.removeEventListener("blur",I),window.removeEventListener("beforeunload",I),k(),m.remove()},A=R=>{window.removeEventListener("pointerup",A);let W=R?.target,q=W instanceof HTMLElement&&W.classList.contains("properties-trigger");setTimeout(()=>{m.onblur=I,q||m.focus()})},N=R=>{let W=R?.target,q=W instanceof HTMLElement&&W.classList.contains("properties-trigger");(R.target instanceof HTMLElement||R.target instanceof SVGElement)&&R.target.closest(`.${vm.SHAPE_ACTIONS_MENU}`)&&!Tn(R.target)||q?(m.onblur=null,window.addEventListener("pointerup",A),window.addEventListener("blur",I)):R.target instanceof HTMLElement&&R.target instanceof HTMLCanvasElement&&!Yr()&&requestAnimationFrame(()=>{I()})},k=er.getScene(n).onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||m.focus()}),D=!1;l&&m.select(),A();let z=null;i&&"ResizeObserver"in window?(z=new window.ResizeObserver(()=>{d()}),z.observe(i)):window.addEventListener("resize",d),m.onpointerdown=R=>R.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",N,{capture:!0})}),window.addEventListener("wheel",C,{passive:!1,capture:!0}),window.addEventListener("beforeunload",I),a?.querySelector(".excalidraw-textEditorContainer").appendChild(m)};ko();tu();f();we();De();He();et();Re();V();$e();var AA=G({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,r,o)=>{let n=he(e,t);return n.length===1&&H(n[0])&&!n[0].autoResize},perform:(e,t,r,o)=>{let n=he(e,t);return{appState:t,elements:e.map(i=>{if(i.id===n[0].id&&H(i)){let a=Vt(i.originalText,Me(i),i.lineHeight);return pe(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),storeAction:_.CAPTURE}}});dt();f();var MA=e=>{let t=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${t.map(o=>`\\s*${o}(-beta)?`).join("|")})\\b`).test(e.trim())};kl();import{Fragment as y9,jsx as tt,jsxs as wh}from"react/jsx-runtime";var DA=Qn.createContext(null),_A=Qn.createContext(null),RA={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},xx=Qn.createContext(RA);xx.displayName="DeviceContext";var yx=Qn.createContext({container:null,id:null});yx.displayName="ExcalidrawContainerContext";var wx=Qn.createContext([]);wx.displayName="ExcalidrawElementsContext";var vx=Qn.createContext({...lr(),width:0,height:0,offsetLeft:0,offsetTop:0});vx.displayName="ExcalidrawAppStateContext";var Tx=Qn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Tx.displayName="ExcalidrawSetAppStateContext";var Sx=Qn.createContext(null);Sx.displayName="ExcalidrawActionManagerContext";var tr=()=>Sa(DA),Wn=()=>Sa(_A),Ne=()=>Sa(xx),Ft=()=>Sa(yx),da=()=>Sa(wx),Gn=()=>Sa(vx),Oe=()=>Sa(Tx),Xt=()=>Sa(Sx),sm=!1,gx=0,Ms=!1,lm=!1,hx=!1,fx={horizontal:null,vertical:null},Ta=0,cm=!1,bx=new Map,yh=!1,PA=0,LA=!1,dm=null,Ve={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ex=class e extends Qn.Component{canvas;interactiveCanvas=null;rc;unmounted=!1;actionManager;device=RA;excalidrawContainerRef=Qn.createRef();scene;fonts;renderer;resizeObserver;nearestScrollableContainer;library;libraryItemsFromStorage;id;store;history;excalidrawContainerValue;files={};imageCache=new Map;iFrameRefs=new Map;embedsValidationStatus=new Map;initializedEmbeds=new Set;elementsPendingErasure=new Set;hitLinkElement;lastPointerDownEvent=null;lastPointerUpEvent=null;lastPointerMoveEvent=null;lastViewportPosition={x:0,y:0};animationFrameHandler=new Eh;laserTrails=new xh(this.animationFrameHandler,this);eraserTrail=new As(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/200),i=(10-Math.min(10,t.totalLength-t.currentIndex))/10;return Math.min(ai(i),ai(n))},fill:()=>this.state.theme===ue.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});onChangeEmitter=new wr;onPointerDownEmitter=new wr;onPointerUpEmitter=new wr;onUserFollowEmitter=new wr;onScrollChangeEmitter=new wr;missingPointerEventCleanupEmitter=new wr;onRemoveEventListenersEmitter=new wr;constructor(t){super(t);let r=lr(),{excalidrawAPI:o,viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=r.theme,name:c=`${E("labels.untitled")}-${Oh()}`}=t;if(this.state={...r,theme:l,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:n,zenModeEnabled:i,objectsSnapModeEnabled:s,gridSize:a?ni:null,name:c,width:window.innerWidth,height:window.innerHeight},this.id=b9(),this.library=new sI(this),this.actionManager=new Fg(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new er,this.canvas=document.createElement("canvas"),this.rc=f9.canvas(this.canvas),this.renderer=new am(this.scene),this.store=new Kp,this.history=new $d,o){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:m=>{this.actionManager.registerAction(m)},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:m=>this.onChangeEmitter.on(m),onPointerDown:m=>this.onPointerDownEmitter.on(m),onPointerUp:m=>this.onPointerUpEmitter.on(m),onScrollChange:m=>this.onScrollChangeEmitter.on(m),onUserFollow:m=>this.onUserFollowEmitter.on(m)};typeof o=="function"?o(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Lr({scene:this.scene}),this.history=new $d,this.actionManager.registerAll($m),this.actionManager.registerAction(ZI(this.history,this.store)),this.actionManager.registerAction(jI(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 o=null,n=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!n)break;for(let i of n)i.contentWindow===t.source&&(o=i.contentWindow);o?.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 o=r.id,n=r.info.playerState;Object.values(bc).includes(n)&&bx.set(o,n)}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},draggingElement:null,selectionElement:null})},100),Io(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let o=bx.get(t.id);switch(o||(bx.set(t.id,bc.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),o){case bc.PLAYING:case bc.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,o,n){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&o>=t.x+t.width/3&&o<=t.x+2*t.width/3&&n>=t.y+t.height/3&&n<=t.y+2*t.height/3}updateEmbedValidationStatus=(t,r)=>{this.embedsValidationStatus.set(t.id,r),_e.delete(t)};updateEmbeddables=()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(o=>{if(Rt(o)){if(t.add(o.id),!this.embedsValidationStatus.has(o.id)){r=!0;let n=hl(o.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(o,n)}}else Io(o)&&t.add(o.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((o,n)=>{t.has(n)||this.iFrameRefs.delete(n)})};renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,o=this.state.height,n=this.scene.getNonDeletedElements().filter(i=>Rt(i)&&this.embedsValidationStatus.get(i.id)===!0||Io(i));return tt(y9,{children:n.map(i=>{let{x:a,y:s}=$t({sceneX:i.x,sceneY:i.y},this.state),l=ds(i,r,o,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(i.id);if(l&&!c&&this.initializedEmbeds.add(i.id),!(l||c))return null;let m;if(Io(i)){m=null;let g=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(g.status==="done"){let h=g.html;m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>h}}else if(g.status==="pending")m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>id(`
87
83
  <style>
88
84
  html, body {
89
85
  width: 100%;
90
86
  height: 100%;
91
- color: ${this.state.theme===ae.DARK?"white":"black"};
87
+ color: ${this.state.theme===ue.DARK?"white":"black"};
92
88
  }
93
89
  body {
94
90
  display: flex;
@@ -155,7 +151,7 @@ Please output JUST THE HTML file containing your best attempt at implementing th
155
151
  </svg>
156
152
  </div>
157
153
  <div>Generating...</div>
158
- `)};else{let E;h.code==="ERR_GENERATION_INTERRUPTED"?E="Generation was interrupted...":E=h.message||"Generation failed",m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>Qs(`
154
+ `)};else{let h;g.code==="ERR_GENERATION_INTERRUPTED"?h="Generation was interrupted...":h=g.message||"Generation failed",m={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>id(`
159
155
  <style>
160
156
  html, body {
161
157
  height: 100%;
@@ -165,7 +161,7 @@ Please output JUST THE HTML file containing your best attempt at implementing th
165
161
  flex-direction: column;
166
162
  align-items: center;
167
163
  justify-content: center;
168
- color: ${de.red[3]};
164
+ color: ${Ee.red[3]};
169
165
  }
170
166
  h1, h3 {
171
167
  margin-top: 0;
@@ -173,10 +169,10 @@ Please output JUST THE HTML file containing your best attempt at implementing th
173
169
  }
174
170
  </style>
175
171
  <h1>Error!</h1>
176
- <h3>${E}</h3>
177
- `)}}}else m=Pn(am(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return Ze("div",{className:SI("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:s?`translate(${a-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:s?"block":"none",opacity:Rg(i,Ht(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${ko(Math.min(i.width,i.height),i)}px`},children:$u("div",{className:"excalidraw__embeddable-container__inner",style:{width:s?`${i.width}px`:0,height:s?`${i.height}px`:0,transform:s?`rotate(${i.angle}rad)`:"none",pointerEvents:p?Ki.enabled:Ki.disabled},children:[u&&Ze("div",{className:"excalidraw__embeddable-hint",children:b("buttons.embeddableInteractionButton")}),Ze("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(It(i)?this.props.renderEmbeddable?.(i,this.state):null)??Ze("iframe",{ref:h=>this.cacheEmbeddableRef(i,h),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.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:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=Ke({clientX:n.x,clientY:n.y},this.state),a=Ke({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===ae.DARK,r=0,o=0;return this.scene.getNonDeletedFramesLikes().map(n=>{if(ri(n)?r++:o++,!wa(n,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 null;let{x:i,y:a}=Ot({sceneX:n.x,sceneY:n.y},this.state),l=6,s=()=>{F(n,{name:n.name?.trim()||null}),this.setState({editingFrame:null})},c,d=Bm(n,ri(n)?r:o);if(n.id===this.state.editingFrame){let m=d;c=Ze("input",{autoFocus:!0,value:m,onChange:p=>{F(n,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>s(),onKeyDown:p=>{(p.key===S.ESCAPE||p.key===S.ENTER)&&s()},style:{background:this.state.viewBackgroundColor,filter:t?ja:"none",zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${l}px, ${l}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-i-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Ze("div",{id:this.getFrameNameDOMId(n),style:{position:"absolute",bottom:`${this.state.height+je.nameOffsetY-a+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:je.nameFontSize,color:t?je.nameColorDarkTheme:je.nameColorLightTheme,lineHeight:je.nameLineHeight,width:"max-content",maxWidth:`${n.width}px`,overflow:n.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Le.MOVE,pointerEvents:this.state.viewModeEnabled?Ki.disabled:Ki.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:n.id})},children:c},n.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getVersionNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({versionNonce:n,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,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),l=this.scene.getNonDeletedElementsMap(),s=!(this.state.editingElement&&ne(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!G(this.state.editingElement)),c=t[0];return Ze("div",{className:SI("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?Ki.disabled:Ki.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Ze(AI.Provider,{value:this,children:Ze(kI.Provider,{value:this.props,children:Ze(Pb.Provider,{value:this.excalidrawContainerValue,children:Ze(Lb.Provider,{value:this.device,children:Ze(Rb.Provider,{value:this.setAppState,children:Ze(_b.Provider,{value:this.state,children:$u(Db.Provider,{value:this.scene.getNonDeletedElements(),children:[$u(Nb.Provider,{value:this.actionManager,children:[Ze(zS,{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:fn().code,renderTopRightUI:r,renderCustomStats:o,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,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),Ze("div",{className:"excalidraw-textEditorContainer"}),Ze("div",{className:"excalidraw-contextMenuContainer"}),Ze("div",{className:"excalidraw-eye-dropper-container"}),Ze(EI,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&Ze(e3,{element:c,elementsMap:l,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&qi(c)&&Ze(vb,{element:c,elementsMap:i,children:Ze(Wu,{title:b("labels.convertToCode"),icon:zl,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&ro(c)&&c.customData?.generationData?.status==="done"&&$u(vb,{element:c,elementsMap:i,children:[Ze(Wu,{title:b("labels.copySource"),icon:up,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),Ze(Wu,{title:"Enter fullscreen",icon:S2,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Ze(US,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Ze(pT,{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?.()})}}),Ze(wb,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:l,visibleElements:a,versionNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),Ze(yb,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,selectedElements:t,versionNonce:n,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&&Ze(vI,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{Ee("export",t,"ui");let n=await _a(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(Id).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&vl(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?F(t,{customData:{generationData:void 0}},!1):F(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.onSceneUpdated()};getTextFromElements(t){return t.reduce((o,n)=>(G(n)&&o.push(n.text),o),[]).join(`
172
+ <h3>${h}</h3>
173
+ `)}}}else m=xi(Km(i.link||""));let p=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",u=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return tt("div",{className:kA("excalidraw__embeddable-container",{"is-hovered":u}),style:{transform:l?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:l?"block":"none",opacity:Eb(i,Qt(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${fo(Math.min(i.width,i.height),i)}px`},children:wh("div",{className:"excalidraw__embeddable-container__inner",style:{width:l?`${i.width}px`:0,height:l?`${i.height}px`:0,transform:l?`rotate(${i.angle}rad)`:"none",pointerEvents:p?ka.enabled:ka.disabled},children:[u&&tt("div",{className:"excalidraw__embeddable-hint",children:E("buttons.embeddableInteractionButton")}),tt("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(Rt(i)?this.props.renderEmbeddable?.(i,this.state):null)??tt("iframe",{ref:g=>this.cacheEmbeddableRef(i,g),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.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:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}getFrameNameDOMId=t=>`${this.id}-frame-name-${t.id}`;frameNameBoundsCache={get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let o=document.getElementById(this.getFrameNameDOMId(t));if(o){let n=o.getBoundingClientRect(),i=Qe({clientX:n.x,clientY:n.y},this.state),a=Qe({clientX:n.right,clientY:n.bottom},this.state);return r={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map};renderFrameNames=()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;let t=this.state.theme===ue.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!ds(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 null;let{x:o,y:n}=$t({sceneX:r.x,sceneY:r.y},this.state),i=6,a=()=>{F(r,{name:r.name?.trim()||null}),this.setState({editingFrame:null})},s,l=lu(r);if(r.id===this.state.editingFrame){let c=l;s=tt("input",{autoFocus:!0,value:c,onChange:d=>{F(r,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>a(),onKeyDown:d=>{(d.key===S.ESCAPE||d.key===S.ENTER)&&a()},style:{background:this.state.viewBackgroundColor,filter:t?Fs:"none",zIndex:2,border:"none",display:"block",padding:`${i}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${i}px, ${i}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-o-i}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else s=l;return tt("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+rt.nameOffsetY-n+this.state.offsetTop}px`,left:`${o-this.state.offsetLeft}px`,zIndex:2,fontSize:rt.nameFontSize,color:t?rt.nameColorDarkTheme:rt.nameColorLightTheme,lineHeight:rt.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Be.MOVE,pointerEvents:this.state.viewModeEnabled?ka.disabled:ka.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:s},r.id)})};toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:o}=this.props,n=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:n,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,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),s=this.scene.getNonDeletedElementsMap(),l=!(this.state.editingElement&&ie(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!H(this.state.editingElement)),c=t[0];return tt("div",{className:kA("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":l?ka.disabled:ka.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:tt(DA.Provider,{value:this,children:tt(_A.Provider,{value:this.props,children:tt(yx.Provider,{value:this.excalidrawContainerValue,children:tt(xx.Provider,{value:this.device,children:tt(Tx.Provider,{value:this.setAppState,children:tt(vx.Provider,{value:this.state,children:wh(wx.Provider,{value:this.scene.getNonDeletedElements(),children:[wh(Sx.Provider,{value:this.actionManager,children:[tt(G5,{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:ei().code,renderTopRightUI:r,renderCustomStats:o,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,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),tt("div",{className:"excalidraw-textEditorContainer"}),tt("div",{className:"excalidraw-contextMenuContainer"}),tt("div",{className:"excalidraw-eye-dropper-container"}),tt(wA,{trails:[this.laserTrails,this.eraserTrail]}),t.length===1&&this.state.showHyperlinkPopup&&tt(YS,{element:c,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&_a(c)&&tt(mx,{element:c,elementsMap:i,children:tt(bh,{title:E("labels.convertToCode"),icon:$s,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&Io(c)&&c.customData?.generationData?.status==="done"&&wh(mx,{element:c,elementsMap:i,children:[tt(bh,{title:E("labels.copySource"),icon:ap,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),tt(bh,{title:"Enter fullscreen",icon:xw,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(c);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},draggingElement:null,selectionElement:null})}catch(m){console.warn(m),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&tt(V5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&tt(QI,{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?.()})}}),tt(dx,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:s,visibleElements:a,sceneNonce:n,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),tt(cx,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:s,selectedElements:t,sceneNonce:n,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&&tt(IA,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}focusContainer=()=>{this.excalidrawContainerRef.current?.focus()};getSceneElementsIncludingDeleted=()=>this.scene.getElementsIncludingDeleted();getSceneElements=()=>this.scene.getNonDeletedElements();onInsertElements=t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})};onExportImage=async(t,r,o)=>{Ce("export",t,"ui");let n=await xs(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:o.exportingFrame}).catch(Nm).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&n&&Js(n)&&this.setState({fileHandle:n})};magicGenerations=new Map;updateMagicGeneration=({frameElement:t,data:r})=>{r.status==="pending"?F(t,{customData:{generationData:void 0}},!1):F(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()};getTextFromElements(t){return t.reduce((o,n)=>(H(n)&&o.push(n.text),o),[]).join(`
178
174
 
179
- `)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),Ee("ai","generate (missing key)","d2c");return}let o=Cl(this.scene.getNonDeletedElements(),t).filter(m=>!qi(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),Ee("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await Wm({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await ym(i),l=this.getTextFromElements(o);Ee("ai","generate (start)","d2c");let s=await xI({image:a,apiKey:this.OPENAI_KEY,text:l,theme:this.state.theme});if(!s.ok){Ee("ai","generate (failed)","d2c"),console.error(s.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:s.error?.message||"Unknown error during generation"}});return}if(Ee("ai","generate (success)","d2c"),s.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=s.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(Bn(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=Lr.get(Qr.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=Lr.has(Qr.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=Lr.set(Qr.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):qi(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),Ee("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:wt.magicframe}),Ee("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&qi(t[0])&&t[0];if(!r&&t.some(n=>ee(n)||n.frameId)){this.setActiveTool({type:wt.magicframe});return}Ee("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,l]=Se(t),s=50;o=Ks({...je,x:n-s,y:i-s,width:a-n+s*2,height:l-i+s*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)F(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{Jt.set(Si,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},storeAction:D.CAPTURE}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},storeAction:D.CAPTURE}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?ie(a,{[n?"strokeColor":"backgroundColor"]:r}):a),storeAction:D.CAPTURE})},keepOpenOnAlt:!1})};syncActionResult=dt(t=>{if(this.unmounted||t===!1)return;let r=null;if(t.elements&&(t.elements.forEach(o=>{this.state.editingElement?.id===o.id&&this.state.editingElement!==o&&Ms(o)&&(r=o)}),t.storeAction===D.UPDATE?this.store.shouldUpdateSnapshot():t.storeAction===D.CAPTURE&&this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(t.elements)),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){t.storeAction===D.UPDATE?this.store.shouldUpdateSnapshot():t.storeAction===D.CAPTURE&&this.store.shouldCaptureIncrement();let o=t?.appState?.viewModeEnabled||!1,n=t?.appState?.zenModeEnabled||!1,i=t?.appState?.gridSize||null,a=t?.appState?.theme||this.props.theme||ae.LIGHT,l=t?.appState?.name??this.state.name,s=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(o=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(n=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(i=this.props.gridModeEnabled?xn:null),r=r||t.appState?.editingElement||null,r?.isDeleted&&(r=null),this.setState(c=>Object.assign(t.appState||{},{contextMenu:null,editingElement:r,viewModeEnabled:o,zenModeEnabled:n,gridSize:i,theme:a,name:l,errorMessage:s}))}});onBlur=dt(()=>{Ua=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetStore=()=>{this.store.clear()};resetScene=dt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...Zt(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=bi(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,...Qo(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.fonts.loadFontsForElements(r.elements),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,storeAction:D.UPDATE})};isMobileBreakpoint=(t,r)=>t<EE||r<yE&&t<xE;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=tl(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:wE,i=this.device.editor,a=tl(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===yr.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.addCallback(this.onSceneUpdated),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Or()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),gs&&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),aE()&&!Jx()&&this.setState({errorMessage:Ze(oI,{})})}componentWillUnmount(){this.renderer.destroy(),this.scene=new Ct,this.renderer=new qc(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.scene.destroy(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),Pe.destroy(),fo.destroy(),clearTimeout(Hi),Ve.clearCache(),jt.clearCache(),Hi=0,document.documentElement.style.overscrollBehaviorX=""}onResize=dt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Pe.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),gs||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(gt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(gt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),gt(window,"message",this.onWindowMessage,!1),gt(document,"pointerup",this.removePointer),gt(document,"copy",this.onCopy),gt(document,"keyup",this.onKeyUp,{passive:!0}),gt(document,"mousemove",this.updateCurrentCursorPosition),gt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onFontsLoaded(r)}),gt(document,"gesturestart",this.onGestureStart,!1),gt(document,"gesturechange",this.onGestureChange,!1),gt(document,"gestureend",this.onGestureEnd,!1),gt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(gt(document,"fullscreenchange",this.onFullscreenChange),gt(document,"paste",this.pasteFromClipboard),gt(document,"cut",this.onCut),gt(window,"resize",this.onResize,!1),gt(window,"unload",this.onUnload,!1),gt(window,"blur",this.onBlur,!1),gt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),gt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(gt(OE(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.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&&Sr(this.state)&&this.setState({activeTool:qe(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&eg(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(),Sr(r)&&!Sr(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()),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}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?xn:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ae.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(uo)}),this.state.editingElement?.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:l}=r;r.activeTool!==this.state.activeTool&&l!=null&&jo(this.state)&&wr(l,!1)&&Us(l,this.state,So(X.getPointAtIndexGlobalCoordinates(l,-1,i)),this),this.store.commit(n,this.state),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(Ab=r);let n=G(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=ji(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},fE);onCut=dt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||eo(t.target)||(this.actionManager.executeAction(_p,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=dt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||eo(t.target)||(this.actionManager.executeAction(jl,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){Jc=!1}onTouchStart=t=>{if(md&&t.preventDefault(),!Jc){Jc=!0,clearTimeout(Ib),Ib=window.setTimeout(e.resetTapTwice,hE);return}if(Jc&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Jc=!1,clearTimeout(Ib)}t.touches.length===2&&this.setState({selectedElementIds:Re({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Re(this.state.previousSelectedElementIds,this.state)}):Be.pointers.clear()};pasteFromClipboard=dt(async t=>{let r=!!Ku,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||eo(o)))return;let{x:a,y:l}=Ke({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),s=t?.clipboardData?.files[0],c=await Um(t,r);if(!s&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:l});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(s=hg(d))}}if(Ei(s)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:l});this.insertImageElement(d,s),this.initializeImageDimensions(d),this.setState({selectedElementIds:Re({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?Kc(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){let d=Md(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>v0(p)).filter(p=>fl(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||Pn(p)?.type==="video"));if(!Ku&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let h=p[p.length-1],E=this.insertEmbeddableElement({sceneX:h?h.x+h.width+20:a,sceneY:l,link:pr(u)});E&&p.push(E)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=oc(t.elements,null,void 0),[o,n,i,a]=Se(r),l=Pt(o,i)/2,s=Pt(n,a)/2,c=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:m,y:p}=Ke({clientX:c,clientY:d},this.state),u=m-l,h=p-s,[E,x]=At(u,h,this.state.gridSize),w=pm(r.map(C=>ie(C,{x:C.x+E-o,y:C.y+x-n})),{randomizeSeed:!t.retainSeed}),v=[...this.scene.getElementsIncludingDeleted(),...w];Bt(v,$(w));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(I){let C=By(w,I);hc(v,C,I)}this.scene.replaceAllElements(v),w.forEach(C=>{if(G(C)&&Ae(C)){let M=pt(C,this.scene.getElementsMapIncludingDeleted());Rt(C,M,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.store.shouldCaptureIncrement();let L=Ia(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Jt.get(Wc)?this.state.openSidebar:null,...jt({editingGroupId:null,selectedElementIds:L.reduce((C,M)=>(Ae(M)||(C[M.id]=!0),C),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await V0(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=b("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=b("errors.unsupportedFileType")),{errorMessage:u}}})),l=n,s=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:l}),u=await this.insertImageElement(p,m.file);u&&(s||(s=!0,l-=u.height/2),F(u,{y:l},!1),l=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Re(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
175
+ `)}async onMagicFrameGenerate(t,r){if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),Ce("ai","generate (missing key)","d2c");return}let o=El(this.scene.getNonDeletedElements(),t).filter(m=>!_a(m));if(!o.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),Ce("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let n=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(!n)return;this.updateMagicGeneration({frameElement:n,data:{status:"pending"}}),this.setState({selectedElementIds:{[n.id]:!0}});let i=await gu({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:t,files:this.files}),a=await wp(i),s=this.getTextFromElements(o);Ce("ai","generate (start)","d2c");let l=await vA({image:a,apiKey:this.OPENAI_KEY,text:s,theme:this.state.theme});if(!l.ok){Ce("ai","generate (failed)","d2c"),console.error(l.error),this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:l.error?.message||"Unknown error during generation"}});return}if(Ce("ai","generate (success)","d2c"),l.choices[0].message.content==null){this.updateMagicGeneration({frameElement:n,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let c=l.choices[0].message.content,d=c.slice(c.indexOf("<!DOCTYPE html>"),c.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:n,data:{status:"done",html:d}})}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(wi(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}OPENAI_KEY=ro.get(To.OAI_API_KEY);OPENAI_KEY_IS_PERSISTED=ro.has(To.OAI_API_KEY)||!1;onOpenAIKeyChange=(t,r)=>{if(this.OPENAI_KEY=t||null,r){let o=ro.set(To.OAI_API_KEY,t);this.OPENAI_KEY_IS_PERSISTED=o}else this.OPENAI_KEY_IS_PERSISTED=!1};onMagicSettingsConfirm=(t,r,o)=>{if(this.OPENAI_KEY=t||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),o==="settings")return;let n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});t?n.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):_a(n[0])||this.setActiveTool({type:"magicframe"})};onMagicframeToolSelect=()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),Ce("ai","tool-select (missing key)","d2c");return}let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:It.magicframe}),Ce("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&_a(t[0])&&t[0];if(!r&&t.some(n=>Q(n)||n.frameId)){this.setActiveTool({type:It.magicframe});return}Ce("ai","tool-select (existing selection)","d2c");let o;if(r)o=r;else{let[n,i,a,s]=Te(t),l=50;o=Uc({...rt,x:n-l,y:i-l,width:a-n+l*2,height:s-i+l*2,opacity:100,locked:!1}),this.scene.insertElement(o);for(let c of t)F(c,{frameId:o.id});this.setState({selectedElementIds:{[o.id]:!0}})}this.onMagicFrameGenerate(o,"upstream")}};openEyeDropper=({type:t})=>{mr.set(ca,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,o)=>{let n=t==="background"&&o.altKey||t==="stroke"&&!o.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?n?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},storeAction:_.CAPTURE}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},storeAction:_.CAPTURE}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?pe(a,{[n?"strokeColor":"backgroundColor"]:r}):a),storeAction:_.CAPTURE})},keepOpenOnAlt:!1})};dismissLinearEditor=()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})};syncActionResult=bt(t=>{if(this.unmounted||t===!1)return;t.storeAction===_.UPDATE?this.store.shouldUpdateSnapshot():t.storeAction===_.CAPTURE&&this.store.shouldCaptureIncrement();let r=!1,o=null;if(t.elements&&(t.elements.forEach(n=>{this.state.editingElement?.id===n.id&&this.state.editingElement!==n&&Sd(n)&&(o=n)}),this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.files=t.replaceFiles?t.files:{...this.files,...t.files},this.addNewImagesToImageCache()),t.appState||o||this.state.contextMenu){let n=t?.appState?.viewModeEnabled||!1,i=t?.appState?.zenModeEnabled||!1,a=t?.appState?.gridSize||null,s=t?.appState?.theme||this.props.theme||ue.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(n=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(i=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(a=this.props.gridModeEnabled?ni:null),o=o||t.appState?.editingElement||null,o?.isDeleted&&(o=null),this.setState(d=>Object.assign(t.appState||{},{contextMenu:null,editingElement:o,viewModeEnabled:n,zenModeEnabled:i,gridSize:a,theme:s,name:l,errorMessage:c})),r=!0}!r&&t.storeAction!==_.NONE&&this.scene.triggerUpdate()});onBlur=bt(()=>{Ms=!1,this.setState({isBindingEnabled:!0})});onUnload=()=>{this.onBlur()};disableEvent=t=>{t.preventDefault()};resetHistory=()=>{this.history.clear()};resetStore=()=>{this.store.clear()};resetScene=bt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...lr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()});initializeScene=async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;let n=o.files[0],i=await n.getFile();this.loadFileToCanvas(new File([i],i.name||"",{type:i.type}),n)}),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(o=>{console.error(o)})}catch(o){console.error(o),t={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}let r=Xi(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,..._n(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,storeAction:_.UPDATE}),this.fonts.loadSceneFonts()};isMobileBreakpoint=(t,r)=>t<c0||r<m0&&t<d0;refreshViewportBreakpoints=()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:o}=document.body,n=this.device.viewport,i=Us(n,{isLandscape:r>o,isMobile:this.isMobileBreakpoint(r,o)});return n!==i?(this.device={...this.device,viewport:i},!0):!1};refreshEditorBreakpoints=()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:o}=t.getBoundingClientRect(),n=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:p0,i=this.device.editor,a=Us(i,{isMobile:this.isMobileBreakpoint(r,o),canFitSidebar:r>n});return i!==a?(this.device={...this.device,editor:a},!0):!1};async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,T.MODE===Kt.TEST||T.DEV){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...o)=>this.setState(...o)},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(),Yr()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),hc&&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),jx()&&!n3()&&this.setState({errorMessage:tt(aA,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new er,this.fonts=new Lr({scene:this.scene}),this.renderer=new am(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(),_e.destroy(),zo.destroy(),clearTimeout(Ta),qe.clearCache(),cr.clearCache(),Ta=0,document.documentElement.style.overscrollBehaviorX=""}onResize=bt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>_e.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),hc||this.refreshEditorBreakpoints(),this.setState({})});onFullscreenChange=()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})};removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(vt(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(vt(this.excalidrawContainerRef.current,"wheel",this.onWheel,{passive:!1}),vt(window,"message",this.onWindowMessage,!1),vt(document,"pointerup",this.removePointer),vt(document,"copy",this.onCopy),vt(document,"keyup",this.onKeyUp,{passive:!0}),vt(document,"pointermove",this.updateCurrentCursorPosition),vt(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)}),vt(document,"gesturestart",this.onGestureStart,!1),vt(document,"gesturechange",this.onGestureChange,!1),vt(document,"gestureend",this.onGestureEnd,!1),vt(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(vt(document,"fullscreenchange",this.onFullscreenChange),vt(document,"paste",this.pasteFromClipboard),vt(document,"cut",this.onCut),vt(window,"resize",this.onResize,!1),vt(window,"unload",this.onUnload,!1),vt(window,"blur",this.onBlur,!1),vt(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),vt(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(vt(A0(this.excalidrawContainerRef.current),"scroll",this.onScroll)))}componentDidUpdate(t,r){this.updateEmbeddables();let o=this.scene.getElementsIncludingDeleted(),n=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!o.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&&$r(this.state)&&this.setState({activeTool:nt(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Yh(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(),$r(r)&&!$r(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()),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}),t.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?ni:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ue.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(xo)}),this.state.editingElement?.isDeleted&&this.setState({editingElement: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&&Fn(this.state)&&Kr(s,!1)&&Jc(s,this.state,ar(K.getPointAtIndexGlobalCoordinates(s,-1,i)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(n,this.state),this.state.isLoading||(this.props.onChange?.(o,this.state,this.files),this.onChangeEmitter.trigger(o,this.state,this.files))}renderInteractiveSceneCallback=({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:o})=>{r&&(fx=r);let n=H(this.state.editingElement)?!1:!t&&o.size>0;this.state.scrolledOutside!==n&&this.setState({scrolledOutside:n}),this.scheduleImageRefresh()};onScroll=ii(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(o=>o.offsetLeft===r&&o.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},s0);onCut=bt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Tn(t.target)||(this.actionManager.executeAction(cg,"keyboard",t),t.preventDefault(),t.stopPropagation())});onCopy=bt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Tn(t.target)||(this.actionManager.executeAction(Kl,"keyboard",t),t.preventDefault(),t.stopPropagation())});static resetTapTwice(){sm=!1}onTouchStart=t=>{if(ym&&t.preventDefault(),!sm){sm=!0,clearTimeout(gx),gx=window.setTimeout(e.resetTapTwice,i0);return}if(sm&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),sm=!1,clearTimeout(gx)}t.touches.length===2&&this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null})};onTouchEnd=t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ge(this.state.previousSelectedElementIds,this.state)}):Ve.pointers.clear()};pasteFromClipboard=bt(async t=>{let r=!!yh,o=document.activeElement,n=this.excalidrawContainerRef.current?.contains(o);if(t&&!n)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||Tn(o)))return;let{x:a,y:s}=Qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),l=t?.clipboardData?.files[0],c=await pu(t,r);if(!l&&!r){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:s});if(c.text){let d=c.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(l=If(d))}}if($i(l)&&!c.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:a,sceneY:s});this.insertImageElement(d,l),this.initializeImageDimensions(d),this.setState({selectedElementIds:Ge({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!r)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let d=c.programmaticAPI?ac(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:d,files:c.files||null,position:"cursor",retainSeed:r})}else if(c.text){if(c.text&&MA(c.text)){let p=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:u,files:g}=await p.parseMermaidToExcalidraw(c.text),h=ac(u,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:h,files:g,position:"cursor"});return}catch(u){console.warn(`parsing pasted text as mermaid definition failed: ${u.message}`)}}let d=zm(c.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),m=d.map(p=>Hv(p)).filter(p=>hl(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||xi(p)?.type==="video"));if(!yh&&m.length>0&&m.length===d.length){let p=[];for(let u of m){let g=p[p.length-1],h=this.insertEmbeddableElement({sceneX:g?g.x+g.width+20:a,sceneY:s,link:Pr(u)});h&&p.push(h)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(u=>[u.id,!0]))});return}this.addTextFromPaste(c.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()});addElementsFromPasteOrLibrary=t=>{let r=Nc(t.elements,null,void 0),[o,n,i,a]=Te(r),s=Ht(o,i)/2,l=Ht(n,a)/2,c=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:m,y:p}=Qe({clientX:c,clientY:d},this.state),u=m-s,g=p-l,[h,x]=Ot(u,g,this.state.gridSize),v=Ap(r.map(I=>pe(I,{x:I.x+h-o,y:I.y+x-n})),{randomizeSeed:!t.retainSeed}),w=[...this.scene.getElementsIncludingDeleted(),...v];Jt(w,Z(v));let C=this.getTopLayerFrameAtSceneCoords({x:m,y:p});if(C){let I=TT(v,C);hd(w,I,C)}this.scene.replaceAllElements(w),v.forEach(I=>{if(H(I)&&ze(I)){let P=Et(I,this.scene.getElementsMapIncludingDeleted());ft(I,P,this.scene.getElementsMapIncludingDeleted())}}),t.files&&(this.files={...this.files,...t.files}),this.store.shouldCaptureIncrement();let M=gs(v);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&mr.get(Jd)?this.state.openSidebar:null,...cr({editingGroupId:null,selectedElementIds:M.reduce((I,P)=>(ze(P)||(I[P.id]=!0),I),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(v,{fitToContent:!0})};async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:o,sceneY:n}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(i.map(async m=>{try{return{file:await a2(m)}}catch(p){let u=p.message;return p.cause==="FETCH_ERROR"?u=E("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(u=E("errors.unsupportedFileType")),{errorMessage:u}}})),s=n,l=!1,c={};for(let m of a)if(m.file){let p=this.createImageElement({sceneX:o,sceneY:s}),u=await this.insertImageElement(p,m.file);u&&(l||(l=!0,s-=u.height/2),F(u,{y:s},!1),s=p.y+p.height+25,c[p.id]=!0)}this.setState({selectedElementIds:Ge(c,this.state)});let d=a.find(m=>!!m.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let i=t.filter(a=>a.type==="text");i.length&&this.addTextFromPaste(i.map(a=>a.value).join(`
180
176
 
181
- `),r)}}addTextFromPaste(t,r=!1){let{x:o,y:n}=Ke({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:o,y:n,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:this.state.currentItemTextAlign,verticalAlign:$i,locked:!1},a=10,l=n,s=r?[t]:t.split(`
182
- `),c=s.reduce((d,m,p)=>{let u=m.trim(),h=Hr(i.fontFamily);if(u.length){let E=this.getTopLayerFrameAtSceneCoords({x:o,y:l}),x=zt({...i,x:o,y:l,text:u,lineHeight:h,frameId:E?E.id:null});d.push(x),l+=x.height+a}else s[p-1]?.trim()&&(l+=ui(i.fontSize,h)+a);return d},[]);c.length!==0&&(this.scene.insertElements(c),this.setState({selectedElementIds:Re(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)}),!r&&c.length>1&&CI===!1&&!this.device.editor.isMobile&&(this.setToast({message:b("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),CI=!0),this.store.shouldCaptureIncrement())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{Hi&&this.resetContextMenuTimer(),Be.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||Ee("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...qe(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(Mv)};zoomCanvas=t=>{this.setState({...zn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:rn(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:l}=kc({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=l.zoom,i=l.scrollX,a=l.scrollY}else{let l=Qo(o,this.state);i=l.scrollX,a=l.scrollY}if(r?.animate){let l=this.state.scrollX,s=this.state.scrollY,c=this.state.zoom.value,d=RE({fromValues:{scrollX:l,scrollY:s,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,h)=>{if(h==="zoom")return m*Math.pow(p/m,yn(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},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:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,fs,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=dt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{sr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),Pe.delete(o))}),this.scene.informMutation(),this.addNewImagesToImageCache()});updateScene=dt(t=>{let r=cr(t.elements??[]);if(t.storeAction&&t.storeAction!==D.NONE){let o=this.store.snapshot.appState,n=this.store.snapshot.elements,i=t.appState?Object.assign({},o,t.appState):o,a=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),$(r)):n;t.storeAction===D.CAPTURE?this.store.captureIncrement(a,i):t.storeAction===D.UPDATE&&this.store.updateSnapshot(a,i)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})});onSceneUpdated=()=>{this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=dt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=dt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let l=i[a];return typeof l=="function"?l.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():l}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:b("commandPalette.shortcutHint",{shortcut:kt("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(Ku=t.shiftKey,clearTimeout(II),II=window.setTimeout(()=>{Ku=!1},100)),t[S.CTRL_OR_CMD]&&eo(t.target)&&(t.code===fe.MINUS||t.code===fe.EQUAL)){t.preventDefault();return}if(eo(t.target)&&t.key!==S.ESCAPE||sl(t.key)&&dh(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),sl(t.key)){let i=this.state.gridSize&&(t.shiftKey?th:this.state.gridSize)||(t.shiftKey?lE:th),a=0,l=0;t.key===S.ARROW_LEFT?a=-i:t.key===S.ARROW_RIGHT?a=i:t.key===S.ARROW_UP?l=-i:t.key===S.ARROW_DOWN&&(l=i);let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});s.forEach(c=>{F(c,{x:c.x+a,y:c.y+l}),zr(c,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:s})}),this.setState({suggestedBindings:Vd(s,this)}),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])ne(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new X(a)}));else if(G(a)||qx(a)){let l;G(a)||(l=a);let s=Qd(a,this.state,this.scene.getNonDeletedElementsMap()),c=s.x,d=s.y;this.startTextEditing({sceneX:c,sceneY:d,container:l}),t.preventDefault();return}else ee(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=q3(t.key);i?(this.state.activeTool.type!==i&&Ee("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&Be.pointers.size===0&&(Ua=!0,We(this.interactiveCanvas,Le.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(vn(this.state.activeTool.type)||i.some(a=>vn(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&Jt.set(Fa,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=dt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=dt(t=>{t.key===S.SPACE&&(this.state.viewModeEnabled?We(this.interactiveCanvas,Le.GRAB):this.state.activeTool.type==="selection"?Gr(this.interactiveCanvas):(Wr(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Re({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ua=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),sl(t.key)&&(Hs(this.scene.getSelectedElements(this.state).filter(ne),this,jo(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[]),this.setState({suggestedBindings:[]}))});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=qe(this.state,t);r.type==="hand"?We(this.interactiveCanvas,Le.GRAB):Ua||Wr(this.interactiveCanvas,this.state),DE(document.activeElement)&&this.focusContainer(),Cs(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.shouldCaptureIncrement(),r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Re({},o),selectedGroupIds:Re({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{We(this.interactiveCanvas,t)};resetCursor=()=>{Gr(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>Be.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${b("labels.untitled")}-${ch()}`;onGestureStart=dt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Re({},this.state),activeEmbeddable:null}),Be.initialScale=this.state.zoom.value});onGestureChange=dt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Be.initialScale;r&&this.setState(o=>({...zn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:rn(r*t.scale)},o)}))});onGestureEnd=dt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Re(this.state.previousSelectedElementIds,this.state)}),Be.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&G(s)?rg(s,pt(s,o),o,{text:i,isDeleted:l,originalText:a}):s)])};TI({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:l,y:s}=Ot({sceneX:i,sceneY:a},this.state);return[l-this.state.offsetLeft,s-this.state.offsetTop]},onChange:dt(i=>{n(i,i,!1),Ms(t)&&zr(t,o)}),onSubmit:dt(({text:i,viaKeyboard:a,originalText:l})=>{let s=!i.trim();if(n(i,l,s),!s&&a){let c=t.containerId?t.containerId:t.id;this.setState(d=>({selectedElementIds:Re({...d.selectedElementIds,[c]:!0},d)}))}s&&Kd(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&Wr(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this}),this.deselectElements(),n(t.text,t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Re({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&G(o)&&!o.isDeleted?o:null}getElementShape(t){switch(t.type){case"rectangle":case"diamond":case"frame":case"magicframe":case"embeddable":case"image":case"iframe":case"text":case"selection":return Cm(t);case"arrow":case"line":{let r=Pe.get(t)?.[0]??Pe.generateElementShape(t,null)[0],[,,,,o,n]=re(t,this.scene.getNonDeletedElementsMap());return Am(t)?ty(t,r,[t.x,t.y],t.angle,[o,n]):Q0(r,[t.x,t.y],t.angle,[o,n])}case"ellipse":return q0(t);case"freedraw":{let[,,,,r,o]=re(t,this.scene.getNonDeletedElementsMap());return ey(t,[r,o],Am(t))}}}getBoundTextShape(t){let r=me(t,this.scene.getNonDeletedElementsMap());return r?t.type==="arrow"?this.getElementShape({...r,...X.getBoundTextElementPosition(t,r,this.scene.getNonDeletedElementsMap())}):this.getElementShape(r):null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return ba({x:t,y:r,element:i,shape:this.getElementShape(i),threshold:this.getElementHitThreshold()/2,frameNameBound:ee(i)?this.frameNameBoundsCache.get(i):null})?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n||!s.locked)&&(o||!(G(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=Ht(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Dg({x:t,y:r},c,a):!0}).filter(s=>ro(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(){return cE/this.state.zoom.value}hitElement(t,r,o,n=!0){if(n&&this.state.selectedElementIds[o.id]&&Qm([o],this.state)){let a=j0(o,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold());return ll([t,r],a)}return oy(t,r,this.getBoundTextShape(o))?!0:ba({x:t,y:r,element:o,shape:this.getElementShape(o),threshold:this.getElementHitThreshold(),frameNameBound:ee(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return Yo(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[l,s,c,d]=re(o[a],this.scene.getNonDeletedElementsMap());if(we(o[a])&&ba({x:t,y:r,element:o[a],shape:this.getElementShape(o[a]),threshold:this.getElementHitThreshold()})){i=o[a];break}else if(l<t&&t<c&&s<r&&r<d){i=o[a];break}}return Yo(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n})=>{let i=!1,a=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&a&&(me(n,this.scene.getNonDeletedElementsMap())||(i=!0));let l=null,s=this.scene.getSelectedElements(this.state);s.length===1?G(s[0])?l=s[0]:n?l=me(s[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let c=l?.fontFamily||this.state.currentItemFontFamily,d=l?.lineHeight||Hr(c),m=this.state.currentItemFontSize;if(!l&&i&&n&&!we(n)){let E=Jd(Ye({fontSize:m,fontFamily:c}),d),x=qd(m,d),w=Math.max(n.height,x),y=Math.max(n.width,E);F(n,{height:w,width:y}),t=n.x+y/2,r=n.y+w/2,a&&(a=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let p=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),u=l||zt({x:a?a.elementCenterX:t,y:a?a.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:m,fontFamily:c,textAlign:a?"center":this.state.currentItemTextAlign,verticalAlign:a?yt.MIDDLE:$i,containerId:i?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:d,angle:n?.angle??0,frameId:p?p.id:null});if(!l&&i&&n&&F(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:u.id})}),this.setState({editingElement:u}),!l)if(n&&i){let h=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(u,h+1)}else this.scene.insertElement(u);this.setState({editingElement:u}),this.handleTextWysiwyg(u,{isExistingElement:!!l})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&ne(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new X(r[0])});return}Gr(this.interactiveCanvas);let{x:o,y:n}=Ke(t,this.state);if(Cn(this.state).length>0){let a=this.getElementAtPosition(o,n),l=a&&n0(a,this.state.selectedGroupIds);if(l){this.store.shouldCaptureIncrement(),this.setState(s=>({...s,...jt({editingGroupId:l,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),s,this)}));return}}if(Gr(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if($t(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let l=this.getTextBindableContainerAtPosition(o,n);if(l&&(tr(l)||!lr(l.backgroundColor)||ba({x:o,y:n,element:l,shape:this.getElementShape(l),threshold:this.getElementHitThreshold()}))){let s=Qd(l,this.state,this.scene.getNonDeletedElementsMap());o=s.x,n=s.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:l})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&Mm(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=vt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>En||!r&&o!==0)return;let n=Ke(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Mm(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),l=Ke(this.lastPointerUpEvent,this.state),s=Mm(this.hitLinkElement,i,this.state,[l.x,l.y],this.device.editor.isMobile);if(a&&s){let c=this.hitLinkElement.link;if(c){c=pr(c);let d;if(this.props.onLinkOpen&&(d=Ad("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=im(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>Dg(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Be.pointers.has(t.pointerId)&&Be.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Be.initialScale;if(Be.pointers.size===2&&Be.lastCenter&&r&&Be.initialDistance){let p=z1(Be.pointers),u=p.x-Be.lastCenter.x,h=p.y-Be.lastCenter.y;Be.lastCenter=p;let E=H1(Array.from(Be.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:E/Be.initialDistance,w=x?rn(r*x):this.state.zoom.value;this.setState(y=>{let v=zn({viewportX:p.x,viewportY:p.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+u/w,scrollY:v.scrollY+h/w,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Be.lastCenter=Be.initialDistance=Be.initialScale=null;if(Ua||Qc||Cb||Do(this.state))return;let n=W1(Ab,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?Gr(this.interactiveCanvas):Wr(this.interactiveCanvas,this.state));let i=Ke(t,this.state),{x:a,y:l}=i;if(!this.state.draggingElement&&tI(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=eI(this.scene.getNonDeletedElements(),this.state,{x:a,y:l},t,this.scene.getNonDeletedElementsMap());this.setState(h=>{let E=kd(h.snapLines,u),x=h.originSnapOffset?kd(h.originSnapOffset,p):p;return h.snapLines===E&&h.originSnapOffset===x?null:{snapLines:E,originSnapOffset:x}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=X.handlePointerMove(t,a,l,this.state,this.scene.getNonDeletedElementsMap());p&&p!==this.state.editingLinearElement&&Sb(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):Sb(()=>{this.setState({suggestedBindings:[]})})}if(hh(this.state.activeTool.type)){let{draggingElement:p}=this.state;wr(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:h}=p,{points:E,lastCommittedPoint:x}=p,w=E[E.length-1];if(Wr(this.interactiveCanvas,this.state),w===x)vt(a-u,l-h,w[0],w[1])>=Xa?F(p,{points:[...E,[a-u,l-h]]}):We(this.interactiveCanvas,Le.POINTER);else if(E.length>2&&x&&vt(a-u,l-h,x[0],x[1])<Xa)We(this.interactiveCanvas,Le.POINTER),F(p,{points:E.slice(0,-1)});else{let[y,v]=At(a,l,t[S.CTRL_OR_CMD]?null:this.state.gridSize),[I,L]=p?.lastCommittedPoint??[0,0],C=y-u-I,M=v-h-L;aa(t)&&({width:C,height:M}=ml(I+u,L+h,y,v)),dr(E,this.state.zoom.value)&&We(this.interactiveCanvas,Le.POINTER),F(p,{points:[...E.slice(0,-1),[I+C,L+M]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,l),!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1){let p=ep(c,this.state,a,l,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(p&&p.transformHandleType){We(this.interactiveCanvas,rp(p));return}}}else if(d.length>1&&!n){let p=tp(Se(d),a,l,this.state.zoom,t.pointerType,this.device);if(p){We(this.interactiveCanvas,rp({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!Sr(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(We(this.interactiveCanvas,Le.POINTER),r3(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(o3(),m&&(m.link||It(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?We(this.interactiveCanvas,G(m)?Le.TEXT:Le.CROSSHAIR):this.state.viewModeEnabled?We(this.interactiveCanvas,Le.GRAB):n?We(this.interactiveCanvas,Le.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,l):t[S.CTRL_OR_CMD]?We(this.interactiveCanvas,Le.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&$t(m)&&this.isIframeLikeElementCenter(m,t,a,l)?(We(this.interactiveCanvas,Le.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(We(this.interactiveCanvas,Le.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),l=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let h=u.groupIds.at(-1);if(!i.has(h)){i.add(h);let E=tt(a,h);for(let x of E)t.altKey?this.elementsPendingErasure.delete(x.id):this.elementsPendingErasure.add(x.id)}}}},s=vt(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getElementHitThreshold(),d={...r.lastCoords},m=0;for(;m<=s;){let p=this.getElementsAtPosition(d.x,d.y);if(l(p),m===s)break;m=Math.min(m+c,s);let u=m/s,h=(1-u)*d.x+u*o.x,E=(1-u)*d.y+u*o.y;d.x=h,d.y=E}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())Ae(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.onSceneUpdated()}};handleTouchMove=t=>{ed=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=X.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,l=null;ba({x:r,y:o,element:i,shape:this.getElementShape(i)})?(a=X.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),l=X.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||l?We(this.interactiveCanvas,Le.POINTER):this.hitElement(r,o,i)&&We(this.interactiveCanvas,Le.MOVE)):this.hitElement(r,o,i)&&We(this.interactiveCanvas,Le.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),X.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}})}else We(this.interactiveCanvas,Le.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Re(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)},storeAction:D.UPDATE});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=tl(this.device,{isTouchScreen:!0})),Qc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===jn.ERASER&&this.state.activeTool.type!==wt.eraser){this.setState({activeTool:qe(this.state,{type:wt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),Sr(this.state)&&this.setState({activeTool:qe(this.state,{...this.state.activeTool.lastActiveTool||{type:wt.selection},lastActiveToolBeforeEraser:null})})},d=gt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==jn.MAIN&&t.button!==jn.TOUCH&&t.button!==jn.ERASER||Be.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!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,o);return}else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){We(this.interactiveCanvas,Le.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=Ke(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});F(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?Wr(this.interactiveCanvas,this.state):this.state.activeTool.type===wt.frame||this.state.activeTool.type===wt.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),l=this.onKeyDownFromPointerDownHandler(o),s=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",l),window.addEventListener("keyup",s),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=s,o.eventListeners.onKeyDown=l)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Ke({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if($t(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&$t(this.hitLinkElement)&&!wg(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(ed=!1,Hi?ed=!0:Hi=window.setTimeout(()=>{Hi=0,ed||this.handleCanvasContextMenu(t)},gE))};resetContextMenuTimer=()=>{clearTimeout(Hi),Hi=0,ed=!1};maybeCleanupAfterMissingPointerUp=t=>{td?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(Be.pointers.size<=1&&(t.button===jn.WHEEL||t.button===jn.MAIN&&Ua||Do(this.state)||this.state.viewModeEnabled))||G(this.state.editingElement))return!1;Qc=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);We(this.interactiveCanvas,Le.GRABBING);let{clientX:n,clientY:i}=t,a=zu(s=>{let c=n-s.clientX,d=i-s.clientY;if(n=s.clientX,i=s.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),l=dt(td=()=>{td=null,Qc=!1,Ua||(this.state.viewModeEnabled?We(this.interactiveCanvas,Le.GRAB):Wr(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),window.removeEventListener("blur",l),a.flush()});return window.addEventListener("blur",l),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",l),!0};updateGestureOnPointerDown(t){Be.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Be.pointers.size===2&&(Be.lastCenter=z1(Be.pointers),Be.initialScale=this.state.zoom.value,Be.initialDistance=H1(Array.from(Be.pointers.values())))}initialPointerDownState(t){let r=Ke(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,l]=Se(o);return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:So(At(r.x,r.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize)),scrollbars:W1(Ab,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((s,c)=>(s.set(c.id,kn(c)),s),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(l+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},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;Cb=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=zu(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=dt(()=>{td=null,Cb=!1,Wr(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return td=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Re({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=ep(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=tp(Se(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=So(Ug(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&ne(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=Gg(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let s=this.state.editingLinearElement||this.state.selectedLinearElement,c=X.handlePointerDown(t,this.state,this.store,r.origin,s,this);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),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 a=r.hit.element,l=r.hit.allHitElements.some(s=>this.isASelectedElement(s));if((a===null||!l)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Re({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(s=>({...o0(s,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!ua(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Re({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!l&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(s=>{let c={...s.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(s.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),ee(a))Yr(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>tt(this.scene.getNonDeletedElements(),u)).filter(u=>ee(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(h=>tt(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete c[h.id]}))})}return{...jt({editingGroupId:s.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),s,this),showHyperlinkPopup:a.link||It(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getElementHitThreshold(),[n,i,a,l]=Se(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<l+o}handleTextOnPointerDown=(t,r)=>{if(G(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);tr(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a}),Gr(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:qe(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=At(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l=g0({type:r,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:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[l.id],{selectedElementIds:Re(m,d)}});let s=l.simulatePressure?l.pressures:[...l.pressures,t.pressure];F(l,{points:[[0,0]],pressures:s});let c=qo(o.origin,this);this.scene.insertElement(l),this.setState({draggingElement:l,editingElement:l,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=At(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),l=u0({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(l),l};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=At(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=Pn(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:b("toast.unrecognizedLinkFormat"),closable:!0});let l=tg({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(l),l};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=At(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return $s({type:"image",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,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&dr(n.points,this.state.zoom.value)){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(uo);return}let{x:i,y:a,lastCommittedPoint:l}=n;if(n.points.length>1&&l&&vt(o.origin.x-i,o.origin.y-a,l[0],l[1])<Xa){this.actionManager.executeAction(uo);return}this.setState(s=>({selectedElementIds:Re({...s.selectedElementIds,[n.id]:!0},s)})),F(n,{lastCommittedPoint:n.points[n.points.length-1]}),We(this.interactiveCanvas,Le.POINTER)}else{let[n,i]=At(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:l,currentItemEndArrowhead:s}=this.state,[c,d]=r==="arrow"?[l,s]:[null,null],m=ao({type:r,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.state.currentItemRoundness==="round"?{type:at.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null});this.setState(u=>{let h={...u.selectedElementIds};return delete h[m.id],{selectedElementIds:Re(h,u)}}),F(m,{points:[...m.points,[0,0]]});let p=qo(o.origin,this);this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:Ko(t)?at.ADAPTIVE_RADIUS:at.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=At(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},l;t==="embeddable"?l=tg({type:"embeddable",...a}):l=Vr({type:t,...a}),l.type==="selection"?this.setState({selectionElement:l,draggingElement:l}):(this.scene.insertElement(l),this.setState({multiElement:null,draggingElement:l,editingElement:l}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=At(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...je},a=r===wt.magicframe?Ks(i):mm(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){Kn({event:t,appState:this.state,selectedElements:r})&&(o||!fo.getReferenceSnapPoints())&&fo.setReferenceSnapPoints(jS(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){Kn({event:t,appState:this.state,selectedElements:r})&&(o||!fo.getVisibleGaps())&&fo.setVisibleGaps(ZS(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return dt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return dt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return zu(r=>{if(t.drag.offset===null&&(t.drag.offset=So(Yg(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=Ke(r,this.state);if(Sr(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=At(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&vt(n.x,n.y,t.origin.x,t.origin.y)<En)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let l=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(X.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,l)){let u=X.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],l);if(!u)return;Sb(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(X.handlePointDragging(r,this.state,n.x,n.y,(u,h)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,h)},m,this.scene.getNonDeletedElementsMap())){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let s=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((s||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(h=>h.locked))return;let p=m.find(h=>ee(h)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let h={x:n.x-t.origin.x,y:n.y-t.origin.y},E=[...t.originalElements.values()],x=r.shiftKey;if(x){let v=Math.abs(h.x),I=Math.abs(h.y),L=x&&v<I,C=x&&v>I;L&&(h.x=0),C&&(h.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:w,snapLines:y}=qS(E,h,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:y}),!this.state.editingFrame&&Vg(t,m,h,this.state,this.scene,w,r[S.CTRL_OR_CMD]?null:this.state.gridSize),this.setState({suggestedBindings:Vd(m,this)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let v=[],I=[],L=new Map,C=new Map,M=t.hit.element,_=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(N=>N.id)),H=this.scene.getElementsIncludingDeleted();for(let N of H)if(_.has(N.id)||N.id===M?.id&&t.hit.wasAddedToSelection){let A=Xs(this.state.editingGroupId,L,N),B=t.originalElements.get(N.id);F(A,{x:B.x,y:B.y}),t.originalElements.set(A.id,A),v.push(A),I.push(N),C.set(N.id,A.id)}else v.push(N);let k=[...v,...I];Bt(k,$(I)),Zd(v,I,C),Yd(k,I,C,"duplicatesServeAsOld"),Ym(k,I,C),this.scene.replaceAllElements(k),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,h=m.length>0&&m[m.length-1];if(!(h&&h[0]===p&&h[1]===u)){let x=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];F(d,{points:[...m,[p,u]],pressures:x})}}else if(ne(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;aa(r)&&m.length===2&&({width:p,height:u}=ml(d.x,d.y,n.x,n.y)),m.length===1?F(d,{points:[...m,[p,u]]}):m.length===2&&F(d,{points:[...m.slice(0,-1),[p,u]]}),wr(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)X.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&Ve(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(h=>jt({...h,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),h,this)):p=!1);let u=Dl(m,d,this.scene.getNonDeletedElementsMap());this.setState(h=>{let E={...p&&h.selectedElementIds,...u.reduce((x,w)=>(x[w.id]=!0,x),{})};return t.hit.element&&(u.length?delete E[t.hit.element.id]:E[t.hit.element.id]=!0),h=p?h:{...h,selectedGroupIds:{},editingGroupId:null},{...jt({editingGroupId:h.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),h,this),selectedLinearElement:u.length===1&&ne(u[0])?new X(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||It(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return dt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:l,isRotating:s}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||G(this.state.editingElement)?this.state.editingElement:null,snapLines:kd(u.snapLines,[]),originSnapOffset:null})),fo.setReferenceSnapPoints(null),fo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(uo);else{let u=X.handlePointerUp(r,this.state.editingLinearElement,this.state,this);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=X.handlePointerUp(r,this.state.selectedLinearElement,this.state,this),{startBindingElement:h,endBindingElement:E}=u,x=this.scene.getElement(u.elementId);wr(x)&&sa(x,h,E,c),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,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?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=Ke(r,this.state),h=o.points,E=u.x-o.x,x=u.y-o.y;E===h[0][0]&&x===h[0][1]&&(x+=1e-4,E+=1e-4);let w=o.simulatePressure?[]:[...o.pressures,r.pressure];F(o,{points:[...h,[E,x]],pressures:w,lastCommittedPoint:[E,x]}),this.actionManager.executeAction(uo);return}if(to(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Re({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(uo)})}catch(h){console.error(h),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(E=>E.id!==u.id)),this.actionManager.executeAction(uo)}return}if(ne(o)){o.points.length>1&&this.store.shouldCaptureIncrement();let u=Ke(r,this.state);!t.drag.hasOccurred&&o&&!i?(F(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(jo(this.state)&&wr(o,!1)&&Us(o,this.state,u,this),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(h=>({draggingElement:null})):(Gr(this.interactiveCanvas),this.setState(h=>({draggingElement:null,activeTool:qe(this.state,{type:"selection"}),selectedElementIds:Re({...h.selectedElementIds,[o.id]:!0},h),selectedLinearElement:new X(o)}))));return}if(a.type!=="selection"&&o&&lo(o)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id),appState:{draggingElement:null},storeAction:D.UPDATE});return}if(o){if(t.drag.hasOccurred){let u=Ke(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let h=this.scene.getElement(this.state.selectedLinearElement.elementId);if(h?.frameId){let E=Ht(h,c);E&&h&&(en(h,E,this.scene.getNonDeletedElementsMap())||(F(h,{groupIds:[]}),Pl([h],this.scene.getNonDeletedElementsMap()),this.scene.informMutation()))}}else{let h=this.getTopLayerFrameAtSceneCoords(u),E=this.scene.getSelectedElements(this.state),x=this.scene.getElementsMapIncludingDeleted(),w=y=>{if(y.length>0){for(let v of y){let I=v.groupIds.indexOf(this.state.editingGroupId);F(v,{groupIds:v.groupIds.slice(0,I)},!1)}x.forEach(v=>{v.groupIds.length&&tt(x,v.groupIds[v.groupIds.length-1]).length<2&&F(v,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(h&&!this.state.selectedElementIds[h.id]){let y=E.filter(v=>v.frameId!==h.id&&Ea(v,x,this.state));this.state.editingGroupId&&w(y),x=hc(x,y,h)}else if(!h&&this.state.editingGroupId){let y=E.filter(v=>v.frameId&&!Ea(v,x,this.state));w(y)}x=tn(x,this.state,this),this.scene.replaceAllElements(x)}}if(ee(o)){let u=Oy(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(hc(this.scene.getElementsMapIncludingDeleted(),u,o))}F(o,nc(o))}if(n&&this.store.shouldCaptureIncrement(),n&&lo(n)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id),storeAction:D.UPDATE}),t.resize.isResizing){let u=tn(this.scene.getElementsIncludingDeleted(),this.state,this),h=this.scene.getSelectedElements(this.state).filter(E=>ee(E));for(let E of h)u=Km(u,Ll(this.scene.getElementsIncludingDeleted(),E,this.state,c),E,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&ne(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new X(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Sr(this.state)&&m&&p){if(this.eraserTrail.endPath(),vt(m.clientX,m.clientY,p.clientX,p.clientY)===0){let h=Ke({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(h.x,h.y).forEach(x=>this.elementsPendingErasure.add(x.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?rm(this.state,d)?this.setState(u=>{let h={...u.selectedElementIds};for(let E of d.groupIds.flatMap(x=>tt(this.scene.getNonDeletedElements(),x)))delete h[E.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(E=>({[E]:!1})).reduce((E,x)=>({...E,...x}),{})},selectedElementIds:Re(h,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let h={...u.selectedElementIds};delete h[d.id];let E=ue(this.scene.getNonDeletedElements(),{selectedElementIds:h});return{...jt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:E.length===1&&ne(E[0])?new X(E[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let h={...u.selectedElementIds,[d.id]:!0};return delete h[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(E=>tt(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete h[E.id]}),{...jt({editingGroupId:u.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||It(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Re({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...jt({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:ne(d)&&u.selectedLinearElement?.elementId!==d.id?new X(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&ry({x:t.origin.x,y:t.origin.y,element:d,shape:this.getElementShape(d),threshold:this.getElementHitThreshold(),frameNameBound:ee(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Re({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),We(this.interactiveCanvas,Le.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Re({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:It(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||Ve(this.scene.getNonDeletedElements(),this.state)||!Je(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||l||s){let u=this.scene.getSelectedElements(this.state).filter(ne);Hs(u,this,jo(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[])}if(a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(Gr(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:qe(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Be.pointers.size<=1&&$t(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.onSceneUpdated()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||Ae(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,ie(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!Ei(t))throw new Error(b("errors.unsupportedFileType"));let n=t.type;if(We(this.interactiveCanvas,"wait"),n===te.svg)try{t=hg(await Z0(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(b("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||G0(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(b("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await ac(t,{maxWidthOrHeight:TE})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>ah)throw new Error(b("errors.fileTooBig",{maxSize:`${Math.trunc(ah/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&W0(c);this.setImagePreviewCursor(d||t)}let l=this.files[i]?.dataURL||await ym(t),s=F(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([s])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==s.id&&this.state.draggingElement?.id!==s.id&&this.initializeImageDimensions(s,!0),c(s)}catch(m){console.error(m),d(new Error(b("errors.imageInsertError")))}finally{o||Gr(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return F(t,{isDeleted:!0}),this.actionManager.executeAction(uo),this.setState({errorMessage:n.message||b("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await ac(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(b("errors.unsupportedFileType")):i}let n=await ym(o);if(t.type===te.svg){let i=await bg(n),a=Math.min(i.height,96),l=a*(i.width/i.height);l>96&&(l=96,a=l*(i.height/i.width));let s=document.createElement("canvas");s.height=a,s.width=l,s.getContext("2d").drawImage(i,0,0,l,a),n=s.toDataURL(te.svg)}this.state.pendingImageElementId&&We(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Ke({clientX:r,clientY:o},this.state),a=await bl({description:"Image",extensions:Object.keys(xs)}),l=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(l,a),this.initializeImageDimensions(l),this.setState({selectedElementIds:Re({[l.id]:!0},this.state)},()=>{this.actionManager.executeAction(uo)})):this.setState({pendingImageElementId:l.id},()=>{this.insertImageElement(l,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:qe(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(uo)})}};initializeImageDimensions=(t,r=!1)=>{let o=sr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<En/this.state.zoom.value&&t.height<En/this.state.zoom.value){let n=100/this.state.zoom.value;F(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<En/this.state.zoom.value&&t.height<En/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),l=a*(o.naturalWidth/o.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;F(t,{x:s,y:c,width:l,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await Sm({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&Pe.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>sr(i)&&n.has(i.fileId)?ie(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=Im(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.informMutation()}};scheduleImageRefresh=xD(()=>{this.addNewImagesToImageCache()},uE);updateBindingEnabledOnPointerMove=t=>{let r=Nx(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=qo(t,this);this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let l=qo(a,this);return l!=null&&!Fh(t,o?.id,l)&&i.push(l),i},[]);this.setState({suggestedBindings:n})};clearSelection(t){this.setState(r=>({selectedElementIds:Re({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&ua(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Re({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await Y0(t),{x:n,y:i}=Ke(t,this.state);try{if(Ei(r)&&this.isToolSupported("image")){if(r?.type===te.png||r?.type===te.svg)try{let s=await Tl(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:D.CAPTURE});return}catch(s){if(s.name!=="EncodingError")throw new Error(b("alerts.couldNotLoadInvalidFile"))}let l=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(l,r),this.initializeImageDimensions(l),this.setState({selectedElementIds:Re({[l.id]:!0},this.state)});return}}catch(l){return this.setState({isLoading:!1,errorMessage:l.message})}let a=t.dataTransfer.getData(te.excalidrawlib);if(a&&typeof a=="string"){try{let l=pg(a);this.addElementsFromPasteOrLibrary({elements:Wp(l),position:t,files:null})}catch(l){this.setState({errorMessage:l.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let l=t.dataTransfer?.getData("text");if(l&&fl(l,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(l)||Pn(l)?.type==="video")){let s=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:pr(l)});s&&this.setState({selectedElementIds:{[s.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await lc(t);try{let o=this.scene.getElementsIncludingDeleted(),n;try{n=await xm(t,this.state,o,r)}catch(i){let a=i instanceof Ao;if(a&&i.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:b("errors.imageToolNotSupported")});return}let l=a?b("alerts.cannotRestoreFromImage"):b("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!n)return;n.type===te.excalidraw?(cr(o.concat(n.data.elements)),this.store.updateSnapshot($(o),this.state),this.setState({isLoading:!0}),this.syncActionResult({...n.data,appState:{...n.data.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:D.CAPTURE})):n.type===te.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(i=>{console.error(i),this.setState({errorMessage:b("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==jn.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=Ke(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),l=n||a?"element":"canvas",s=this.excalidrawContainerRef.current,{top:c,left:d}=s.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;Ee("contextMenu","openContextMenu",l),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...jt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ne(n)?new X(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(l)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")np(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,Pt(t.origin.x,n.x),Pt(t.origin.y,n.y),cl(r),Ud(r));else{let[i,a]=At(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),l=sr(o)&&this.imageCache.get(o.fileId)?.image,s=l&&!(l instanceof Promise)?l.width/l.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=QS(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),np(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,Pt(t.originInGrid.x,i),Pt(t.originInGrid.y,a),to(o)?!cl(r):cl(r),Ud(r),s,this.state.originSnapOffset),(this.state.activeTool.type===wt.frame||this.state.activeTool.type===wt.magicframe)&&this.setState({elementsToHighlight:Ll(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>ee(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[l,s]=At(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{Yr(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=At(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:h,snapLines:E}=JS(o,ue(u,this.state),this.state,r,p,i);l+=h.x,s+=h.y,this.setState({snapLines:E})}if(Fg(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),aa(r),Ud(r),o.some(d=>to(d))?!cl(r):cl(r),l,s,t.resize.center.x,t.resize.center.y)){let d=Vd(o,this),m=new Set;return n.forEach(p=>{Ll(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>m.add(u))}),this.setState({elementsToHighlight:[...m],suggestedBindings:d}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(Np,Rp),t==="canvas"?this.state.viewModeEnabled?[...r,Bp,ql,hb,Ai]:[Qf,gr,Np,Rp,Op,gr,Af,n3,gr,Bp,e1,ql,hb,Ai]:(r.push(Op),this.state.viewModeEnabled?[jl,...r]:[_p,jl,Qf,WS,VS,gr,...r,gr,Yf,Kf,gr,$f,t1,r1,jv,Xf,gr,jf,gr,Tf,Sf,If,Cf,gr,qf,Jf,gr,N1,_c,kf,s1,gr,Sc])};handleWheel=dt(t=>{if(t.preventDefault(),Qc)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=Xi*100,a=Math.abs(o),l=o;a>i&&(l=i*n);let s=this.state.zoom.value-l/100;s+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...zn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:rn(s)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,l=Qd(n,o,this.scene.getNonDeletedElementsMap());if(l&&(i=l.x,a=l.y),Math.hypot(t-i,r-a)<sE){let{x:d,y:m}=Ot({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=Ke({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:Be.pointers})};resetShouldCacheIgnoreZoomDebounced=ji(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:l,height:s,offsetTop:c,offsetLeft:d}=this.state;if(o===l&&n===s&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Ya.find(r=>r.code===this.props.langCode)||Ho;await ad(t),this.setAppState({})}},yD=()=>{(T.MODE===yr.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(cr(e))}}}))};yD();var LI=Mb;U();f();var vD=()=>{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)})},PI=vD;Y();import{Provider as FD}from"jotai";f();import TD from"clsx";import{jsx as DI}from"react/jsx-runtime";var _I=({children:e})=>{let{FooterCenterTunnel:t}=ot(),r=_e();return DI(t.In,{children:DI("div",{className:TD("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},SD=_I;_I.displayName="FooterCenter";f();f();f();import{jsx as Gi,jsxs as NI}from"react/jsx-runtime";var ID=()=>Gi("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Gi("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"})}),CD=()=>NI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Gi("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)"}),Gi("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)"}),Gi("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)"}),Gi("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)"})]}),RI=({style:e,size:t="small",withText:r})=>NI("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Gi(ID,{}),r&&Gi(CD,{})]});import{Fragment as FI,jsx as Mt,jsxs as Ob}from"react/jsx-runtime";var Bb=({icon:e,shortcut:t,children:r})=>{let o=Me();return Ob(FI,{children:[Mt("div",{className:"welcome-screen-menu-item__icon",children:e}),Mt("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&Mt("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};Bb.displayName="WelcomeScreenMenuItemContent";var rd=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>Mt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Mt(Bb,{icon:r,shortcut:o,children:t})});rd.displayName="WelcomeScreenMenuItem";var OI=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>Mt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:Mt(Bb,{icon:r,shortcut:o,children:e})});OI.displayName="WelcomeScreenMenuItemLink";var xo=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=ot();return Mt(t.In,{children:Mt("div",{className:"welcome-screen-center",children:e||Ob(FI,{children:[Mt(Fb,{}),Mt(zb,{children:b("welcomeScreen.defaults.center_heading")}),Ob(Hb,{children:[Mt(Gb,{}),Mt(Ub,{})]})]})})})};xo.displayName="Center";var Fb=({children:e})=>Mt("div",{className:"welcome-screen-center__logo virgil welcome-screen-decor",children:e||Mt(RI,{withText:!0})});Fb.displayName="Logo";var zb=({children:e})=>Mt("div",{className:"welcome-screen-center__heading welcome-screen-decor virgil",children:e});zb.displayName="Heading";var Hb=({children:e})=>Mt("div",{className:"welcome-screen-menu",children:e});Hb.displayName="Menu";var Ub=()=>{let e=Nt();return Mt(rd,{onSelect:()=>e.executeAction(Na),shortcut:"?",icon:Ol,children:b("helpDialog.title")})};Ub.displayName="MenuItemHelp";var Gb=()=>{let e=_e(),t=Nt();return e.viewModeEnabled?null:Mt(rd,{onSelect:()=>t.executeAction(Kl),shortcut:kt("loadScene"),icon:Bl,children:b("buttons.load")})};Gb.displayName="MenuItemLoadScene";var BI=({onSelect:e})=>{let{t}=St();return Mt(rd,{shortcut:null,onSelect:e,icon:mp,children:t("labels.liveCollaboration")})};BI.displayName="MenuItemLiveCollaborationTrigger";xo.Logo=Fb;xo.Heading=zb;xo.Menu=Hb;xo.MenuItem=rd;xo.MenuItemLink=OI;xo.MenuItemHelp=Ub;xo.MenuItemLoadScene=Gb;xo.MenuItemLiveCollaborationTrigger=BI;f();import{jsx as hs,jsxs as Wb}from"react/jsx-runtime";var Xu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=ot();return hs(t.In,{children:Wb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[mw,hs("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.menuHint")})]})})};Xu.displayName="MenuHint";var Zu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=ot();return hs(t.In,{children:Wb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[hs("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.toolbarHint")}),uw]})})};Zu.displayName="ToolbarHint";var ju=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=ot();return hs(t.In,{children:Wb("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[hs("div",{children:e||b("welcomeScreen.defaults.helpHint")}),pw]})})};ju.displayName="HelpHint";import{Fragment as zI,jsx as od,jsxs as kD}from"react/jsx-runtime";var qu=e=>od(zI,{children:e.children||kD(zI,{children:[od(xo,{}),od(Xu,{}),od(Zu,{}),od(ju,{})]})});qu.displayName="WelcomeScreen";qu.Center=xo;qu.Hints={MenuHint:Xu,ToolbarHint:Zu,HelpHint:ju};var AD=qu;f();import MD from"clsx";import{jsx as PD,jsxs as DD}from"react/jsx-runtime";var HI=({isCollaborating:e,onSelect:t,...r})=>{let o=_e(),n=o.width<830;return DD(ln,{...r,className:MD("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:b("labels.liveCollaboration"),children:[n?Ow:b("labels.share"),o.collaborators.size>0&&PD("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},LD=HI;HI.displayName="LiveCollaborationTrigger";be();yl();f();no();U();var _D=(e,t,r)=>!!(t&&(t.id===e.editingElement?.id||t.id===e.resizingElement?.id||t.id===e.draggingElement?.id||t.version>r.version||t.version===r.version&&t.versionNonce<r.versionNonce)),RD=(e,t,r)=>{let o=$(e),n=[],i=new Set;for(let l of t)if(!i.has(l.id)){let s=o.get(l.id),c=_D(r,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=Dd(n);return cr(a),a};ya();Nn();Cr();Tn();se();Y();Ue();Ne();U();f();import{jsx as UI,jsxs as ND}from"react/jsx-runtime";var GI=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=ot(),o=Oe();return UI(r.In,{children:ND(Fe.Item,{onSelect:()=>{Ee("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??C2,children:[e??b("labels.textToDiagram"),UI(Fe.Item.Badge,{children:"AI"})]})})};GI.displayName="TTDDialogTrigger";ga();lt();Lg();import{jsx as Vb}from"react/jsx-runtime";PI();var zD=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=Ho.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,onPaste:E,detectScroll:x=!0,handleKeyboardGlobally:w=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:I,onLinkOpen:L,onPointerDown:C,onPointerUp:M,onScrollChange:_,children:H,validateEmbeddable:k,renderEmbeddable:N,aiEnabled:A}=e,B=e.UIOptions?.canvasActions,q={...e.UIOptions,canvasActions:{...ih.canvasActions,...B},tools:{image:e.UIOptions?.tools?.image??!0}};return B?.export&&(q.canvasActions.export.saveFileToDisk=B.export?.saveFileToDisk??ih.canvasActions.export.saveFileToDisk),q.canvasActions.toggleTheme===null&&typeof p>"u"&&(q.canvasActions.toggleTheme=!0),BD(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let oe=Te=>{typeof Te.scale=="number"&&Te.scale!==1&&Te.preventDefault()};return document.addEventListener("touchmove",oe,{passive:!1}),()=>{document.removeEventListener("touchmove",oe)}},[]),Vb(FD,{unstable_createStore:()=>Jt,scope:ze,children:Vb(kE,{langCode:l,theme:p,children:Vb(LI,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:h,UIOptions:q,onPaste:E,detectScroll:x,handleKeyboardGlobally:w,onLibraryChange:y,autoFocus:v,generateIdForFile:I,onLinkOpen:L,onPointerDown:C,onPointerUp:M,onScrollChange:_,validateEmbeddable:k,renderEmbeddable:N,aiEnabled:A!==!1,children:H})})})},HD=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...l}=t,s=Object.keys(o),c=Object.keys(a);return s.length!==c.length?!1:s.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&Je(n,l)},UD=OD.memo(zD,HD);UD.displayName="Excalidraw";export{ln as Button,rh as DEFAULT_LASER_COLOR,Iu as DefaultSidebar,UD as Excalidraw,mt as FONT_FAMILY,SD as Footer,LD as LiveCollaborationTrigger,te as MIME_TYPES,fr as MainMenu,at as ROUNDNESS,Vn as Sidebar,D as StoreAction,ae as THEME,ub as TTDDialog,GI as TTDDialogTrigger,AD as WelcomeScreen,gi as bumpVersion,Kc as convertToExcalidrawElements,Ho as defaultLang,Ty as elementPartiallyOverlapsWithOrContainsBBox,Mg as elementsOverlappingBBox,Wm as exportToBlob,vi as exportToCanvas,y6 as exportToClipboard,Ml as exportToSvg,Se as getCommonBounds,bm as getFreeDrawSvgPath,Gp as getLibraryItemsHash,xe as getNonDeletedElements,W6 as getSceneVersion,wC as getVisibleSceneBounds,Kg as hashElementsVersion,$g as hashString,kg as isElementInsideBBox,lo as isInvisiblySmallElement,ne as isLinearElement,Ya as languages,Tl as loadFromBlob,ug as loadLibraryFromBlob,xm as loadSceneOrLibraryFromBlob,h3 as mergeLibraryItems,F as mutateElement,ie as newElementWith,pr as normalizeLink,m1 as parseLibraryTokensFromUrl,RD as reconcileElements,bi as restore,M0 as restoreAppState,oc as restoreElements,fa as restoreLibraryItems,Ot as sceneCoordsToViewportCoords,xi as serializeAsJSON,Tm as serializeLibraryAsJSON,Me as useDevice,gk as useHandleLibrary,St as useI18n,Ke as viewportCoordsToSceneCoords,kv as zoomToFitBounds};
177
+ `),r)}}addTextFromPaste(t,r=!1){let{x:o,y:n}=Qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:o,y:n,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:vn,verticalAlign:Pa,locked:!1},a=Me({fontSize:i.fontSize,fontFamily:i.fontFamily}),s=uo(i.fontFamily),[l,,c]=Mb(this.state),d=Math.max(Math.min((c-l)*.5,800),200),m=10,p=n,u=r?[t]:t.split(`
178
+ `),g=u.reduce((h,x,v)=>{let y=x.trim();if(y.length){let w=this.getTopLayerFrameAtSceneCoords({x:o,y:p}),C=Vt(y,a,s),M=C.width>d,I=M?Lo(y,a,d):y;C=M?Vt(I,a,s):C;let P=o-C.width/2,A=p-C.height/2,N=jt({...i,x:P,y:A,text:I,originalText:y,lineHeight:s,autoResize:!M,frameId:w?w.id:null});h.push(N),p+=N.height+m}else u[v-1]?.trim()&&(p+=ra(i.fontSize,s)+m);return h},[]);g.length!==0&&(this.scene.insertElements(g),this.setState({selectedElementIds:Ge(Object.fromEntries(g.map(h=>[h.id,!0])),this.state)}),!r&&g.length>1&&LA===!1&&!this.device.editor.isMobile&&(this.setToast({message:E("toast.pasteAsSingleElement",{shortcut:O("CtrlOrCmd+Shift+V")}),duration:5e3}),LA=!0),this.store.shouldCaptureIncrement())}setAppState=(t,r)=>{this.setState(t,r)};removePointer=t=>{Ta&&this.resetContextMenuTimer(),Ve.pointers.delete(t.pointerId)};toggleLock=(t="ui")=>{this.state.activeTool.locked||Ce("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...nt(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))};updateFrameRendering=t=>{this.setState(r=>{let o=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:o?.enabled??r.frameRendering.enabled,clip:o?.clip??r.frameRendering.clip,name:o?.name??r.frameRendering.name,outline:o?.outline??r.frameRendering.outline}}})};togglePenMode=t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))};onHandToolToggle=()=>{this.actionManager.executeAction(yS)};zoomCanvas=t=>{this.setState({...Ci({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Un(t)},this.state)})};cancelInProgressAnimation=null;scrollToContent=(t=this.scene.getNonDeletedElements(),r)=>{this.cancelInProgressAnimation?.();let o=Array.isArray(t)?t:[t],n=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=zd({targetElements:o,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor});n=s.zoom,i=s.scrollX,a=s.scrollY}else{let s=_n(o,this.state);i=s.scrollX,a=s.scrollY}if(r?.animate){let s=this.state.scrollX,l=this.state.scrollY,c=this.state.zoom.value,d=I0({fromValues:{scrollX:s,scrollY:l,zoom:c},toValues:{scrollX:i,scrollY:a,zoom:n.value},interpolateValue:(m,p,u,g)=>{if(g==="zoom")return m*Math.pow(p/m,ai(u))},onStep:({scrollX:m,scrollY:p,zoom:u})=>{this.setState({scrollX:m,scrollY:p,zoom:{value:u}})},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:i,scrollY:a,zoom:n})};maybeUnfollowRemoteUser=()=>{this.state.userToFollow&&this.setState({userToFollow:null})};translateCanvas=t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)};setToast=t=>{this.setState({toast:t})};restoreFileFromShare=async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let o=await r.blob(),n=new File([o],o.name||"",{type:o.type});this.loadFileToCanvas(n,null),await t.delete("shared-file"),window.history.replaceState(null,fc,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}};addFiles=bt(t=>{let r=t.reduce((o,n)=>(o.set(n.id,n),o),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(o=>{kr(o)&&r.has(o.fileId)&&(this.imageCache.delete(o.fileId),_e.delete(o))}),this.scene.triggerUpdate(),this.addNewImagesToImageCache()});updateScene=bt(t=>{let r=fr(t.elements??[]);if(t.storeAction&&t.storeAction!==_.NONE){let o=this.store.snapshot.appState,n=this.store.snapshot.elements,i=t.appState?Object.assign({},o,t.appState):o,a=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),Z(r)):n;t.storeAction===_.CAPTURE?this.store.captureIncrement(a,i):t.storeAction===_.UPDATE&&this.store.updateSnapshot(a,i)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})});triggerRender=t=>{t===!0?this.scene.triggerUpdate():this.setState({})};toggleSidebar=({name:t,tab:r,force:o})=>{let n;o===void 0?n=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:n=o?t:null;let i=n?{name:n}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!n};updateCurrentCursorPosition=bt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY});onKeyDown=bt(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,a){let s=i[a];return typeof s=="function"?s.bind(i):a==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():s}})),t[S.CTRL_OR_CMD]&&t.key===S.P&&!t.shiftKey&&!t.altKey){this.setToast({message:E("commandPalette.shortcutHint",{shortcut:Bt("commandPalette")})}),t.preventDefault();return}if(t[S.CTRL_OR_CMD]&&t.key.toLowerCase()===S.V&&(yh=t.shiftKey,clearTimeout(PA),PA=window.setTimeout(()=>{yh=!1},100)),t[S.CTRL_OR_CMD]&&Tn(t.target)&&(t.code===Se.MINUS||t.code===Se.EQUAL)){t.preventDefault();return}if(Tn(t.target)&&t.key!==S.ESCAPE||ll(t.key)&&Fh(t.target))return;if(t.key===S.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===S.E&&t.shiftKey&&t[S.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===S.PAGE_UP||t.key===S.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===S.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+i})):this.translateCanvas(a=>({scrollY:a.scrollY+i}))}if(this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[S.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),ll(t.key)){let i=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),a=i.find(de),s=a?a.startBinding||a.endBinding?0:wm:this.state.gridSize&&(t.shiftKey?wm:this.state.gridSize)||(t.shiftKey?Jx:wm),l=0,c=0;t.key===S.ARROW_LEFT?l=-s:t.key===S.ARROW_RIGHT?l=s:t.key===S.ARROW_UP?c=-s:t.key===S.ARROW_DOWN&&(c=s),i.forEach(d=>{F(d,{x:d.x+l,y:d.y+c}),qt(d,this.scene.getNonDeletedElementsMap(),this.scene,{simultaneouslyUpdated:i})}),this.setState({suggestedBindings:Gp(i.filter(d=>d.id!==a?.id||s!==0),this.scene.getNonDeletedElementsMap())}),t.preventDefault()}else if(t.key===S.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let a=i[0];if(t[S.CTRL_OR_CMD])ie(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==i[0].id)&&(this.store.shouldCaptureIncrement(),de(a)||this.setState({editingLinearElement:new K(a)}));else if(H(a)||o3(a)){let s;H(a)||(s=a);let l=Pu(a,this.state,this.scene.getNonDeletedElementsMap()),c=l.x,d=l.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else Q(a)&&this.setState({editingFrame:a.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&this.state.draggingElement===null){let i=Ev(t.key);i?(this.state.activeTool.type!==i&&Ce("toolbar",i,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),i==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(a=>({currentItemArrowType:a.currentItemArrowType===_t.sharp?_t.round:a.currentItemArrowType===_t.round?_t.elbow:_t.sharp})),this.setActiveTool({type:i}),t.stopPropagation()):t.key===S.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===S.SPACE&&Ve.pointers.size===0&&(Ms=!0,Ze(this.interactiveCanvas,Be.GRAB),t.preventDefault()),(t.key===S.G||t.key===S.S)&&!t.altKey&&!t[S.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===S.G&&(vi(this.state.activeTool.type)||i.some(a=>vi(a.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===S.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[S.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===S.F){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;(this.state.activeTool.type==="text"||i.find(a=>H(a)||J(a,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===S.K&&!t.altKey&&!t[S.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[S.CTRL_OR_CMD]&&(t.key===S.BACKSPACE||t.key===S.DELETE)&&mr.set(Ss,"clearCanvas");let r=t.key.toLocaleLowerCase(),o=r===S.S&&t.shiftKey,n=t.key===S.I||r===S.G&&t.shiftKey;(o||n)&&this.openEyeDropper({type:o?"stroke":"background"})});onWheel=bt(t=>{!(t.target instanceof HTMLCanvasElement)&&t.ctrlKey&&t.preventDefault()});onKeyUp=bt(t=>{t.key===S.SPACE&&(this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):this.state.activeTool.type==="selection"?mo(this.interactiveCanvas):(po(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ms=!1),!t[S.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),ll(t.key)&&(es(this.scene.getSelectedElements(this.state).filter(ie),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Fn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[]),this.setState({suggestedBindings:[]}))});isToolSupported=t=>this.props.UIOptions.tools?.[t]!==!1;setActiveTool=t=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=nt(this.state,t);r.type==="hand"?Ze(this.interactiveCanvas,Be.GRAB):Ms||po(this.interactiveCanvas,this.state),T0(document.activeElement)&&this.focusContainer(),Cc(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(o=>{let n={snapLines:o.snapLines.length?[]:o.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.shouldCaptureIncrement(),r.type!=="selection"?{...o,activeTool:r,selectedElementIds:Ge({},o),selectedGroupIds:Ge({},o),editingGroupId:null,multiElement:null,...n}:{...o,activeTool:r,...n}})};setOpenDialog=t=>{this.setState({openDialog:t})};setCursor=t=>{Ze(this.interactiveCanvas,t)};resetCursor=()=>{mo(this.interactiveCanvas)};isTouchScreenMultiTouchGesture=()=>Ve.pointers.size>=2;getName=()=>this.state.name||this.props.name||`${E("labels.untitled")}-${Oh()}`;onGestureStart=bt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null}),Ve.initialScale=this.state.zoom.value});onGestureChange=bt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Ve.initialScale;r&&this.setState(o=>({...Ci({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Un(r*t.scale)},o)}))});onGestureEnd=bt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ge(this.state.previousSelectedElementIds,this.state)}),Ve.initialScale=null});handleTextWysiwyg(t,{isExistingElement:r=!1}){let o=this.scene.getElementsMapIncludingDeleted(),n=(i,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&H(s)?pe(s,{originalText:i,isDeleted:a??s.isDeleted,...Oc(s,Et(s,o),o,i)}):s)])};CA({id:t.id,canvas:this.canvas,getViewportCoords:(i,a)=>{let{x:s,y:l}=$t({sceneX:i,sceneY:a},this.state);return[s-this.state.offsetLeft,l-this.state.offsetTop]},onChange:bt(i=>{n(i,!1),Sd(t)&&qt(t,o,this.scene)}),onSubmit:bt(({viaKeyboard:i,nextOriginalText:a})=>{let s=!a.trim();if(n(a,s),!s&&i){let l=t.containerId?t.containerId:t.id;this.setState(c=>({selectedElementIds:Ge({...c.selectedElementIds,[l]:!0},c)}))}s&&Vp(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&po(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),n(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let o=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return o&&H(o)&&!o.isDeleted?o:null}getElementAtPosition(t,r,o){let n=this.getElementsAtPosition(t,r,o?.includeBoundTextElement,o?.includeLockedElements);if(n.length>1){if(o?.preferSelected){for(let a=n.length-1;a>-1;a--)if(this.state.selectedElementIds[n[a].id])return n[a]}let i=n[n.length-1];return ja({x:t,y:r,element:i,shape:cn(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:Q(i)?this.frameNameBoundsCache.get(i):null})?i:n[n.length-2]}return n.length===1?n[0]:null}getElementsAtPosition(t,r,o=!1,n=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(o&&n?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(n||!l.locked)&&(o||!(H(l)&&l.containerId)))).filter(l=>this.hitElement(t,r,l)).filter(l=>{let c=Qt(l,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?fb({x:t,y:r},c,a):!0}).filter(l=>Io(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(){return e0/this.state.zoom.value}hitElement(t,r,o,n=!0){if(n&&this.state.selectedElementIds[o.id]&&_u([o],this.state)){let a=mv(o,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold());return sl([t,r],a)}return Uf(t,r,Np(o,this.scene.getNonDeletedElementsMap()))?!0:ja({x:t,y:r,element:o,shape:cn(o,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:Q(o)?this.frameNameBoundsCache.get(o):null})}getTextBindableContainerAtPosition(t,r){let o=this.scene.getNonDeletedElements(),n=this.scene.getSelectedElements(this.state);if(n.length===1)return Mn(n[0],!1)?n[0]:null;let i=null;for(let a=o.length-1;a>=0;--a){if(o[a].isDeleted)continue;let[s,l,c,d]=ae(o[a],this.scene.getNonDeletedElementsMap());if(ne(o[a])&&ja({x:t,y:r,element:o[a],shape:cn(o[a],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){i=o[a];break}else if(s<t&&t<c&&l<r&&r<d){i=o[a];break}}return Mn(i,!1)?i:null}startTextEditing=({sceneX:t,sceneY:r,insertAtParentCenter:o=!0,container:n,autoEdit:i=!0})=>{let a=!1,s=o&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n);n&&s&&(J(n,this.scene.getNonDeletedElementsMap())||(a=!0));let l=null,c=this.scene.getSelectedElements(this.state);c.length===1?H(c[0])?l=c[0]:n?l=J(c[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(t,r):l=this.getTextElementAtPosition(t,r);let d=l?.fontFamily||this.state.currentItemFontFamily,m=l?.lineHeight||uo(d),p=this.state.currentItemFontSize;if(!l&&a&&n&&!ne(n)){let x=_l(Me({fontSize:p,fontFamily:d}),m),v=Dl(p,m),y=Math.max(n.height,v),w=Math.max(n.width,x);F(n,{height:y,width:w}),t=n.x+w/2,r=n.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,n))}let u=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),g=l||jt({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:p,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?kt.MIDDLE:Pa,containerId:a?n?.id:void 0,groupIds:n?.groupIds??[],lineHeight:m,angle:n?.angle??0,frameId:u?u.id:null});if(!l&&a&&n&&F(n,{boundElements:(n.boundElements||[]).concat({type:"text",id:g.id})}),this.setState({editingElement:g}),!l)if(n&&a){let h=this.scene.getElementIndex(n.id);this.scene.insertElementAtIndex(g,h+1)}else this.scene.insertElement(g);i||l||n?this.handleTextWysiwyg(g,{isExistingElement:!!l}):this.setState({draggingElement:g,multiElement:null})};handleCanvasDoubleClick=t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state);if(r.length===1&&ie(r[0])&&t[S.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!de(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new K(r[0])});return}mo(this.interactiveCanvas);let{x:o,y:n}=Qe(t,this.state);if(Jo(this.state).length>0){let a=this.getElementAtPosition(o,n),s=a&&X0(a,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(l=>({...l,...cr({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),l,this)}));return}}if(mo(this.interactiveCanvas),!t[S.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(o,n);if(sr(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(o,n);if(s&&(Ct(s)||!Ar(s.backgroundColor)||ja({x:o,y:n,element:s,shape:cn(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let l=Pu(s,this.state,this.scene.getNonDeletedElementsMap());o=l.x,n=l.y}this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:s})}};getElementLinkAtPosition=(t,r)=>{let o=this.scene.getNonDeletedElements().slice().reverse(),n=1/0;return o.find((i,a)=>(r&&i.id===r.id&&(n=a),i.link&&a<=n&&eu(i,this.scene.getNonDeletedElementsMap(),this.state,[t.x,t.y],this.device.editor.isMobile)))};redirectToLink=(t,r)=>{let o=Pt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&o>ri||!r&&o!==0)return;let n=Qe(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=eu(this.hitLinkElement,i,this.state,[n.x,n.y],this.device.editor.isMobile),s=Qe(this.lastPointerUpEvent,this.state),l=eu(this.hitLinkElement,i,this.state,[s.x,s.y],this.device.editor.isMobile);if(a&&l){let c=this.hitLinkElement.link;if(c){c=Pr(c);let d;if(this.props.onLinkOpen&&(d=Fm("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=Xm(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}};getTopLayerFrameAtSceneCoords=t=>{let r=this.scene.getNonDeletedElementsMap(),o=this.scene.getNonDeletedFramesLikes().filter(n=>fb(t,n,r));return o.length?o[o.length-1]:null};handleCanvasPointerMove=t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Ve.pointers.has(t.pointerId)&&Ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Ve.initialScale;if(Ve.pointers.size===2&&Ve.lastCenter&&r&&Ve.initialDistance){let p=v1(Ve.pointers),u=p.x-Ve.lastCenter.x,g=p.y-Ve.lastCenter.y;Ve.lastCenter=p;let h=T1(Array.from(Ve.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:h/Ve.initialDistance,v=x?Un(r*x):this.state.zoom.value;this.setState(y=>{let w=Ci({viewportX:p.x,viewportY:p.y,nextZoom:v},y);this.translateCanvas({zoom:w.zoom,scrollX:w.scrollX+2*(u/v),scrollY:w.scrollY+2*(g/v),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Ve.lastCenter=Ve.initialDistance=Ve.initialScale=null;if(Ms||lm||hx||qo(this.state))return;let n=C1(fx,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(n?mo(this.interactiveCanvas):po(this.interactiveCanvas,this.state));let i=Qe(t,this.state),{x:a,y:s}=i;if(!this.state.draggingElement&&nA(this.state.activeTool.type)){let{originOffset:p,snapLines:u}=oA(this.scene.getNonDeletedElements(),this.state,{x:a,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(g=>{let h=Bm(g.snapLines,u),x=g.originSnapOffset?Bm(g.originSnapOffset,p):p;return g.snapLines===h&&g.originSnapOffset===x?null:{snapLines:h,originSnapOffset:x}})}else this.state.draggingElement||this.setState(p=>p.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let p=K.handlePointerMove(t,a,s,this.state,this.scene);p&&p!==this.state.editingLinearElement&&ux(()=>{this.setState({editingLinearElement:p})}),p?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(i):ux(()=>{this.setState({suggestedBindings:[]})})}if(Uh(this.state.activeTool.type)){let{draggingElement:p}=this.state;Kr(p,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(p,[i],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(i)}if(this.state.multiElement){let{multiElement:p}=this.state,{x:u,y:g}=p,{points:h,lastCommittedPoint:x}=p,v=h[h.length-1];if(po(this.interactiveCanvas,this.state),v===x)Pt(a-u,s-g,v[0],v[1])>=Ns?F(p,{points:[...h,[a-u,s-g]]}):Ze(this.interactiveCanvas,Be.POINTER);else if(h.length>2&&x&&Pt(a-u,s-g,x[0],x[1])<Ns)Ze(this.interactiveCanvas,Be.POINTER),F(p,{points:h.slice(0,-1)});else{let[y,w]=Ot(a,s,t[S.CTRL_OR_CMD]||de(p)?null:this.state.gridSize),[C,M]=p?.lastCommittedPoint??[0,0],I=y-u-C,P=w-g-M;Za(t)&&({width:I,height:P}=Pl(C+u,M+g,y,w)),Dr(h,this.state.zoom.value)&&Ze(this.interactiveCanvas,Be.POINTER),de(p)?_o(p,this.scene,[...h.slice(0,-1),[C+I,M+P]],void 0,void 0,{isDragging:!0}):F(p,{points:[...h.slice(0,-1),[C+I,M+P]]})}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&!(d.length===1&&de(d[0]))){let p=Ru(c,this.state,a,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(p&&p.transformHandleType){Ze(this.interactiveCanvas,Ou(p));return}}}else if(d.length>1&&!n){let p=Nu(Te(d),a,s,this.state.zoom,t.pointerType,this.device);if(p){Ze(this.interactiveCanvas,Ou({transformHandleType:p}));return}}let m=this.getElementAtPosition(i.x,i.y);this.hitLinkElement=this.getElementLinkAtPosition(i,m),!$r(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Ze(this.interactiveCanvas,Be.POINTER),KS(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):($S(),m&&(m.link||Rt(m))&&this.state.selectedElementIds[m.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ze(this.interactiveCanvas,H(m)?Be.TEXT:Be.CROSSHAIR):this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):n?Ze(this.interactiveCanvas,Be.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,s):t[S.CTRL_OR_CMD]?Ze(this.interactiveCanvas,Be.AUTO):(m||this.isHittingCommonBoundingBoxOfSelectedElements(i,d))&&!m?.locked&&(m&&sr(m)&&this.isIframeLikeElementCenter(m,t,a,s)?(Ze(this.interactiveCanvas,Be.POINTER),this.setState({activeEmbeddable:{element:m,state:"hover"}})):(Ze(this.interactiveCanvas,Be.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))))};handleEraser=(t,r,o)=>{this.eraserTrail.addPointToPath(o.x,o.y);let n=!1,i=new Set,a=this.scene.getNonDeletedElements(),s=p=>{for(let u of p){if(u.locked)return;if(t.altKey?this.elementsPendingErasure.delete(u.id)&&(n=!0):this.elementsPendingErasure.has(u.id)||(n=!0,this.elementsPendingErasure.add(u.id)),n&&u.groupIds?.length){let g=u.groupIds.at(-1);if(!i.has(g)){i.add(g);let h=ot(a,g);for(let x of h)t.altKey?this.elementsPendingErasure.delete(x.id):this.elementsPendingErasure.add(x.id)}}}},l=Pt(r.lastCoords.x,r.lastCoords.y,o.x,o.y),c=this.getElementHitThreshold(),d={...r.lastCoords},m=0;for(;m<=l;){let p=this.getElementsAtPosition(d.x,d.y);if(s(p),m===l)break;m=Math.min(m+c,l);let u=m/l,g=(1-u)*d.x+u*o.x,h=(1-u)*d.y+u*o.y;d.x=g,d.y=h}if(r.lastCoords.x=o.x,r.lastCoords.y=o.y,n){for(let p of this.scene.getNonDeletedElements())ze(p)&&(this.elementsPendingErasure.has(p.id)||this.elementsPendingErasure.has(p.containerId))&&(t.altKey?(this.elementsPendingErasure.delete(p.id),this.elementsPendingErasure.delete(p.containerId)):(this.elementsPendingErasure.add(p.id),this.elementsPendingErasure.add(p.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}};handleTouchMove=t=>{cm=!0};handleHoverSelectedLinearElement(t,r,o){let n=this.scene.getNonDeletedElementsMap(),i=K.getElement(t.elementId,n);if(i)if(this.state.selectedLinearElement){let a=-1,s=null;ja({x:r,y:o,element:i,shape:cn(i,this.scene.getNonDeletedElementsMap())})?(a=K.getPointIndexUnderCursor(i,n,this.state.zoom,r,o),s=K.getSegmentMidpointHitCoords(t,{x:r,y:o},this.state,this.scene.getNonDeletedElementsMap()),a>=0||s?Ze(this.interactiveCanvas,Be.POINTER):this.hitElement(r,o,i)&&Ze(this.interactiveCanvas,Be.MOVE)):this.hitElement(r,o,i)&&(!de(i)||!(i.startBinding||i.endBinding))&&Ze(this.interactiveCanvas,Be.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),K.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Ze(this.interactiveCanvas,Be.AUTO)}handleCanvasPointerDown=t=>{if(this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){let c=this.state.draggingElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(d=>d.id!==c.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Ge(Object.keys(this.state.selectedElementIds).filter(d=>d!==c.id).reduce((d,m)=>(d[m]=this.state.selectedElementIds[m],d),{}),this.state)},storeAction:_.UPDATE});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Us(this.device,{isTouchScreen:!0})),lm||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Ni.ERASER&&this.state.activeTool.type!==It.eraser){this.setState({activeTool:nt(this.state,{type:It.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{d(),m?.(),$r(this.state)&&this.setState({activeTool:nt(this.state,{...this.state.activeTool.lastActiveTool||{type:It.selection},lastActiveToolBeforeEraser:null})})},d=vt(window,"pointerup",c,{once:!0}),m;requestAnimationFrame(()=>{m=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==Ni.MAIN&&t.button!==Ni.TOUCH&&t.button!==Ni.ERASER||Ve.pointers.size>1)return;let o=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,o)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,o))||!(!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,o);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,o);else if(this.state.activeTool.type==="image"){Ze(this.interactiveCanvas,Be.CROSSHAIR);let c=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!c)return;this.setState({draggingElement:c,editingElement:c,pendingImageElementId:null,multiElement:null});let{x:d,y:m}=Qe(t,this.state),p=this.getTopLayerFrameAtSceneCoords({x:d,y:m});F(c,{x:d,y:m,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,o):this.state.activeTool.type==="custom"?po(this.interactiveCanvas,this.state):this.state.activeTool.type===It.frame||this.state.activeTool.type===It.magicframe?this.createFrameElementOnPointerDown(o,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(o.lastCoords.x,o.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,o);this.props?.onPointerDown?.(this.state.activeTool,o),this.onPointerDownEmitter.trigger(this.state.activeTool,o,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(o.lastCoords.x,o.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(o),a=this.onPointerUpFromPointerDownHandler(o),s=this.onKeyDownFromPointerDownHandler(o),l=this.onKeyUpFromPointerDownHandler(o);this.missingPointerEventCleanupEmitter.once(c=>a(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",i),window.addEventListener("pointerup",a),window.addEventListener("keydown",s),window.addEventListener("keyup",l),o.eventListeners.onMove=i,o.eventListeners.onUp=a,o.eventListeners.onKeyUp=l,o.eventListeners.onKeyDown=s)};handleCanvasPointerUp=t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Qe({clientX:t.clientX,clientY:t.clientY},this.state),o=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&o<300){let n=this.getElementAtPosition(r.x,r.y);if(sr(n)&&this.isIframeLikeElementCenter(n,t,r.x,r.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,n)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?o<300&&sr(this.hitLinkElement)&&!nb(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})};maybeOpenContextMenuAfterPointerDownOnTouchDevices=t=>{t.pointerType==="touch"&&(cm=!1,Ta?cm=!0:Ta=window.setTimeout(()=>{Ta=0,cm||this.handleCanvasContextMenu(t)},a0))};resetContextMenuTimer=()=>{clearTimeout(Ta),Ta=0,cm=!1};maybeCleanupAfterMissingPointerUp=t=>{dm?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()};handleCanvasPanUsingWheelOrSpaceDrag=t=>{if(!(Ve.pointers.size<=1&&(t.button===Ni.WHEEL||t.button===Ni.MAIN&&Ms||qo(this.state)||this.state.viewModeEnabled))||H(this.state.editingElement))return!1;lm=!0,t.preventDefault();let r=!1,o=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ze(this.interactiveCanvas,Be.GRABBING);let{clientX:n,clientY:i}=t,a=uh(l=>{let c=n-l.clientX,d=i-l.clientY;if(n=l.clientX,i=l.clientY,o&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let m=u=>{document.body.removeEventListener("paste",m),u.stopPropagation()},p=()=>{setTimeout(()=>{document.body.removeEventListener("paste",m),window.removeEventListener("pointerup",p)},100)};document.body.addEventListener("paste",m),window.addEventListener("pointerup",p)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=bt(dm=()=>{dm=null,lm=!1,Ms||(this.state.viewModeEnabled?Ze(this.interactiveCanvas,Be.GRAB):po(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),a.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",s),!0};updateGestureOnPointerDown(t){Ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Ve.pointers.size===2&&(Ve.lastCenter=v1(Ve.pointers),Ve.initialScale=this.state.zoom.value,Ve.initialDistance=T1(Array.from(Ve.pointers.values())))}initialPointerDownState(t){let r=Qe(t,this.state),o=this.scene.getSelectedElements(this.state),[n,i,a,s]=Te(o),l=o.findIndex(de)===0;return{origin:r,withCmdOrCtrl:t[S.CTRL_OR_CMD],originInGrid:ar(Ot(r.x,r.y,t[S.CTRL_OR_CMD]||l?null:this.state.gridSize)),scrollbars:C1(fx,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,an(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+n)/2,y:(s+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,o)},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;hx=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let o=uh(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),n=bt(()=>{dm=null,hx=!1,po(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",n),o.flush()});return dm=n,window.addEventListener("pointermove",o),window.addEventListener("pointerup",n),!0}clearSelectionIfNotUsingSelection=()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})};handleSelectionOnPointerDown=(t,r)=>{if(this.state.activeTool.type==="selection"){let o=this.scene.getNonDeletedElements(),n=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=Ru(o,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else i.length>1&&(r.resize.handleType=Nu(Te(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=ar(Wb(r.resize.handleType,i,n,r.origin.x,r.origin.y)),i.length===1&&ie(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=Vb(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let l=this.state.editingLinearElement||this.state.selectedLinearElement,c=K.handlePointerDown(t,this.state,this.store,r.origin,l,this.scene);if(c.hitElement&&(r.hit.element=c.hitElement),c.linearElementEditor&&(this.setState({selectedLinearElement:c.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:c.linearElementEditor})),c.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),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 a=r.hit.element,s=r.hit.allHitElements.some(l=>this.isASelectedElement(l));if((a===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:Ge({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(t[S.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(l=>({...Y0(l,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!Ra(a,this.state.editingGroupId)&&this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(l=>{let c={...l.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(l.selectedElementIds).forEach(m=>{let p=this.scene.getElement(m);p&&d.push(p)}),Q(a))bo(d,a.id).forEach(m=>{delete c[m.id]});else if(a.frameId)c[a.frameId]&&delete c[a.id];else{let m=a.groupIds,p=new Set(m.flatMap(u=>ot(this.scene.getNonDeletedElements(),u)).filter(u=>Q(u)).map(u=>u.id));p.size>0&&d.forEach(u=>{u.frameId&&p.has(u.frameId)&&(delete c[u.id],u.groupIds.flatMap(g=>ot(this.scene.getNonDeletedElements(),g)).forEach(g=>{delete c[g.id]}))})}return{...cr({editingGroupId:l.editingGroupId,selectedElementIds:c},this.scene.getNonDeletedElements(),l,this),showHyperlinkPopup:a.link||Rt(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1};isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let o=this.getElementHitThreshold(),[n,i,a,s]=Te(r);return t.x>n-o&&t.x<a+o&&t.y>i-o&&t.y<s+o}handleTextOnPointerDown=(t,r)=>{if(H(this.state.editingElement))return;let o=r.origin.x,n=r.origin.y,i=this.getElementAtPosition(o,n,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(o,n);Ct(i)&&(a=i,o=i.x+i.width/2,n=i.y+i.height/2),this.startTextEditing({sceneX:o,sceneY:n,insertAtParentCenter:!t.altKey,container:a,autoEdit:!1}),mo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:nt(this.state,{type:"selection"})})};handleFreeDrawElementOnPointerDown=(t,r,o)=>{let[n,i]=Ot(o.origin.x,o.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),s=B2({type:r,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:null,simulatePressure:t.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{let m={...d.selectedElementIds};return delete m[s.id],{selectedElementIds:Ge(m,d)}});let l=s.simulatePressure?s.pressures:[...s.pressures,t.pressure];F(s,{points:[[0,0]],pressures:l});let c=xr(o.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.scene.insertElement(s),this.setState({draggingElement:s,editingElement:s,startBoundElement:c,suggestedBindings:[]})};insertIframeElement=({sceneX:t,sceneY:r,width:o,height:n})=>{let[i,a]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),s=O2({type:"iframe",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:o,height:n});return this.scene.insertElement(s),s};insertEmbeddableElement=({sceneX:t,sceneY:r,link:o})=>{let[n,i]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=xi(o);if(!a)return;a.error instanceof URIError&&this.setToast({message:E("toast.unrecognizedLinkFormat"),closable:!0});let s=Cf({type:"embeddable",x:n,y:i,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:o});return this.scene.insertElement(s),s};createImageElement=({sceneX:t,sceneY:r,addToFrameUnderCursor:o=!0})=>{let[n,i]=Ot(t,r,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),a=o?this.getTopLayerFrameAtSceneCoords({x:n,y:i}):null;return Wc({type:"image",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,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})};handleLinearElementOnPointerDown=(t,r,o)=>{if(this.state.multiElement){let{multiElement:n}=this.state;if(n.type==="line"&&Dr(n.points,this.state.zoom.value)){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(xo);return}if(de(n)&&n.points.length>1){F(n,{lastCommittedPoint:n.points[n.points.length-1]}),this.actionManager.executeAction(xo);return}let{x:i,y:a,lastCommittedPoint:s}=n;if(n.points.length>1&&s&&Pt(o.origin.x-i,o.origin.y-a,s[0],s[1])<Ns){this.actionManager.executeAction(xo);return}this.setState(l=>({selectedElementIds:Ge({...l.selectedElementIds,[n.id]:!0},l)})),F(n,{lastCommittedPoint:n.points[n.points.length-1]}),Ze(this.interactiveCanvas,Be.POINTER)}else{let[n,i]=Ot(o.origin.x,o.origin.y,t[S.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),{currentItemStartArrowhead:s,currentItemEndArrowhead:l}=this.state,[c,d]=r==="arrow"?[s,l]:[null,null],m=r==="arrow"?Gc({type:r,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.state.currentItemArrowType===_t.round?{type:ct.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===_t.elbow}):nn({type:r,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.state.currentItemRoundness==="round"?{type:ct.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null});this.setState(u=>{let g={...u.selectedElementIds};return delete g[m.id],{selectedElementIds:Ge(g,u)}}),F(m,{points:[...m.points,[0,0]]});let p=xr(o.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),de(m));this.scene.insertElement(m),this.setState({draggingElement:m,editingElement:m,startBoundElement:p,suggestedBindings:[]})}};getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:kn(t)?ct.ADAPTIVE_RADIUS:ct.PROPORTIONAL_RADIUS}:null}createGenericElementOnPointerDown=(t,r)=>{let[o,n]=Ot(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),a={x:o,y:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:i?i.id:null},s;t==="embeddable"?s=Cf({type:"embeddable",...a}):s=go({type:t,...a}),s.type==="selection"?this.setState({selectionElement:s,draggingElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,draggingElement:s,editingElement:s}))};createFrameElementOnPointerDown=(t,r)=>{let[o,n]=Ot(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[S.CTRL_OR_CMD]?null:this.state.gridSize),i={x:o,y:n,opacity:this.state.currentItemOpacity,locked:!1,...rt},a=r===It.magicframe?Uc(i):Cp(i);this.scene.insertElement(a),this.setState({multiElement:null,draggingElement:a,editingElement:a})};maybeCacheReferenceSnapPoints(t,r,o=!1){_i({event:t,appState:this.state,selectedElements:r})&&(o||!zo.getReferenceSnapPoints())&&zo.setReferenceSnapPoints(Q5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,o=!1){_i({event:t,appState:this.state,selectedElements:r})&&(o||!zo.getVisibleGaps())&&zo.setVisibleGaps(J5(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return bt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return bt(r=>{r.key===S.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return uh(r=>{if(t.drag.offset===null&&(t.drag.offset=ar(Xb(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;let n=Qe(r,this.state);if($r(this.state)){this.handleEraser(r,t,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=Ot(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize);if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Pt(n.x,n.y,t.origin.x,t.origin.y)<ri)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleResize(t,r)))return!0;let s=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.editingLinearElement||this.state.selectedLinearElement;if(K.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,s)){let u=K.addMidpoint(this.state.selectedLinearElement,n,this.state,!r[S.CTRL_OR_CMD],s);if(!u)return;ux(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices}})});return}else if(m.pointerDownState.segmentMidpoint.value!==null&&!m.pointerDownState.segmentMidpoint.added)return;if(K.handlePointDragging(r,this.state,n.x,n.y,(u,g)=>{this.maybeSuggestBindingsForLinearElementAtCoords(u,g)},m,this.scene)){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let l=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),c=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((l||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let m=this.scene.getSelectedElements(this.state);if(m.every(g=>g.locked))return;let p=m.find(g=>Q(g)),u=this.getTopLayerFrameAtSceneCoords(n);if(this.setState({frameToHighlight:u&&!p?u:null}),t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:n.x-t.origin.x,y:n.y-t.origin.y},h=[...t.originalElements.values()],x=r.shiftKey;if(x){let w=Math.abs(g.x),C=Math.abs(g.y),M=x&&w<C,I=x&&w>C;M&&(g.x=0),I&&(g.y=0)}this.maybeCacheVisibleGaps(r,m),this.maybeCacheReferenceSnapPoints(r,m);let{snapOffset:v,snapLines:y}=eA(h,g,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:y}),!this.state.editingFrame&&Yb(t,m,g,this.scene,v,r[S.CTRL_OR_CMD]?null:this.state.gridSize),(m.length!==1||!de(m[0]))&&this.setState({suggestedBindings:Gp(m,this.scene.getNonDeletedElementsMap())}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let w=[],C=[],M=new Map,I=new Map,P=t.hit.element,A=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(D=>D.id)),N=this.scene.getElementsIncludingDeleted();for(let D of N)if(A.has(D.id)||D.id===P?.id&&t.hit.wasAddedToSelection){let z=Vc(this.state.editingGroupId,M,D),R=t.originalElements.get(D.id);F(z,{x:R.x,y:R.y}),t.originalElements.set(z.id,z),w.push(z),C.push(D),I.set(D.id,z.id)}else w.push(D);let k=[...w,...C];Jt(k,Z(C)),Mu(w,C,I),Wp(k,C,I,"duplicatesServeAsOld"),fu(k,C,I),this.scene.replaceAllElements(k),this.maybeCacheVisibleGaps(r,m,!0),this.maybeCacheReferenceSnapPoints(r,m,!0)}return}}let d=this.state.draggingElement;if(d){if(d.type==="freedraw"){let m=d.points,p=n.x-d.x,u=n.y-d.y,g=m.length>0&&m[m.length-1];if(!(g&&g[0]===p&&g[1]===u)){let x=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];F(d,{points:[...m,[p,u]],pressures:x})}}else if(ie(d)){t.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});let m=d.points,p=i-d.x,u=a-d.y;Za(r)&&m.length===2&&({width:p,height:u}=Pl(d.x,d.y,n.x,n.y)),m.length===1?F(d,{points:[...m,[p,u]]}):m.length>1&&de(d)?_o(d,this.scene,[...m.slice(0,-1),[p,u]],[0,0],void 0,{isDragging:!0}):m.length===2&&F(d,{points:[...m.slice(0,-1),[p,u]]}),Kr(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r);if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)K.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&qe(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>cr({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):p=!1);let u=Sl(m,d,this.scene.getNonDeletedElementsMap());this.setState(g=>{let h={...p&&g.selectedElementIds,...u.reduce((x,v)=>(x[v.id]=!0,x),{})};return t.hit.element&&(u.length?delete h[t.hit.element.id]:h[t.hit.element.id]=!0),g=p?g:{...g,selectedGroupIds:{},editingGroupId:null},{...cr({editingGroupId:g.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:u.length===1&&ie(u[0])?new K(u[0]):null,showHyperlinkPopup:u.length===1&&(u[0].link||Rt(u[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let o=t.clientX,n=o-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-n/this.state.zoom.value}),r.lastCoords.x=o,!0}if(r.scrollbars.isOverVertical){let o=t.clientY,n=o-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-n/this.state.zoom.value}),r.lastCoords.y=o,!0}return!1}onPointerUpFromPointerDownHandler(t){return bt(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{draggingElement:o,resizingElement:n,multiElement:i,activeTool:a,isResizing:s,isRotating:l}=this.state;this.setState(u=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:i||H(this.state.editingElement)?this.state.editingElement:null,snapLines:Bm(u.snapLines,[]),originSnapOffset:null})),zo.setReferenceSnapPoints(null),zo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let c=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(xo);else{let u=K.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);u!==this.state.editingLinearElement&&this.setState({editingLinearElement:u,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let u=K.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:g,endBindingElement:h}=u,x=this.scene.getElement(u.elementId);Kr(x)&&Qa(x,g,h,c,this.scene),u!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...u,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?.(a,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),o?.type==="freedraw"){let u=Qe(r,this.state),g=o.points,h=u.x-o.x,x=u.y-o.y;h===g[0][0]&&x===g[0][1]&&(x+=1e-4,h+=1e-4);let v=o.simulatePressure?[]:[...o.pressures,r.pressure];F(o,{points:[...g,[h,x]],pressures:v,lastCommittedPoint:[h,x]}),this.actionManager.executeAction(xo);return}if(So(o)){let u=o;try{this.initializeImageDimensions(u),this.setState({selectedElementIds:Ge({[u.id]:!0},this.state)},()=>{this.actionManager.executeAction(xo)})}catch(g){console.error(g),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(h=>h.id!==u.id)),this.actionManager.executeAction(xo)}return}if(ie(o)){o.points.length>1&&this.store.shouldCaptureIncrement();let u=Qe(r,this.state);!t.drag.hasOccurred&&o&&!i?(F(o,{points:[...o.points,[u.x-o.x,u.y-o.y]]}),this.setState({multiElement:o,editingElement:this.state.draggingElement})):t.drag.hasOccurred&&!i&&(Fn(this.state)&&Kr(o,!1)&&Jc(o,this.state,u,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(g=>({draggingElement:null})):(mo(this.interactiveCanvas),this.setState(g=>({draggingElement:null,activeTool:nt(this.state,{type:"selection"}),selectedElementIds:Ge({...g.selectedElementIds,[o.id]:!0},g),selectedLinearElement:new K(o)}))));return}if(H(o)){let u=Rl(Me({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight);o.width<u&&F(o,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(o,{isExistingElement:!0})}if(a.type!=="selection"&&o&&Po(o)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==o.id),appState:{draggingElement:null},storeAction:_.UPDATE});return}if(o){if(t.drag.hasOccurred){let u=Qe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let g=this.scene.getElement(this.state.selectedLinearElement.elementId);if(g?.frameId){let h=Qt(g,c);h&&g&&(Bn(g,h,this.scene.getNonDeletedElementsMap())||(F(g,{groupIds:[]}),Tl([g],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let g=this.getTopLayerFrameAtSceneCoords(u),h=this.scene.getSelectedElements(this.state),x=this.scene.getElementsMapIncludingDeleted(),v=y=>{if(y.length>0){for(let w of y){let C=w.groupIds.indexOf(this.state.editingGroupId);F(w,{groupIds:w.groupIds.slice(0,C)},!1)}x.forEach(w=>{w.groupIds.length&&ot(x,w.groupIds[w.groupIds.length-1]).length<2&&F(w,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(g&&!this.state.selectedElementIds[g.id]){let y=h.filter(w=>w.frameId!==g.id&&ts(w,x,this.state));this.state.editingGroupId&&v(y),x=hd(x,y,g)}else if(!g&&this.state.editingGroupId){let y=h.filter(w=>w.frameId&&!ts(w,x,this.state));v(y)}x=zn(x,this.state,this),this.scene.replaceAllElements(x)}}if(Q(o)){let u=vT(this.scene.getElementsIncludingDeleted(),o,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(hd(this.scene.getElementsMapIncludingDeleted(),u,o))}F(o,Fc(o))}if(n&&this.store.shouldCaptureIncrement(),n&&Po(n)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(u=>u.id!==n.id),storeAction:_.UPDATE}),t.resize.isResizing){let u=zn(this.scene.getElementsIncludingDeleted(),this.state,this),g=this.scene.getSelectedElements(this.state).filter(h=>Q(h));for(let h of g)u=bu(u,vl(this.scene.getElementsIncludingDeleted(),h,this.state,c),h,this);this.scene.replaceAllElements(u)}let d=t.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&ie(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new K(d)});let m=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if($r(this.state)&&m&&p){if(this.eraserTrail.endPath(),Pt(m.clientX,m.clientY,p.clientX,p.clientY)===0){let g=Qe({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(g.x,g.y).forEach(x=>this.elementsPendingErasure.add(x.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?Wm(this.state,d)?this.setState(u=>{let g={...u.selectedElementIds};for(let h of d.groupIds.flatMap(x=>ot(this.scene.getNonDeletedElements(),x)))delete g[h.id];return{selectedGroupIds:{...u.selectedElementIds,...d.groupIds.map(h=>({[h]:!1})).reduce((h,x)=>({...h,...x}),{})},selectedElementIds:Ge(g,u)}}):this.state.selectedLinearElement?.isDragging||this.setState(u=>{let g={...u.selectedElementIds};delete g[d.id];let h=he(this.scene.getNonDeletedElements(),{selectedElementIds:g});return{...cr({editingGroupId:u.editingGroupId,selectedElementIds:g},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:h.length===1&&ie(h[0])?new K(h[0]):u.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(u=>{let g={...u.selectedElementIds,[d.id]:!0};return delete g[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(h=>ot(this.scene.getNonDeletedElements(),h)).forEach(h=>{delete g[h.id]}),{...cr({editingGroupId:u.editingGroupId,selectedElementIds:g},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:d.link||Rt(d)?"info":!1}}):this.setState(u=>({selectedElementIds:Ge({...u.selectedElementIds,[d.id]:!0},u)})):this.setState(u=>({...cr({editingGroupId:u.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),u,this),selectedLinearElement:ie(d)&&u.selectedLinearElement?.elementId!==d.id?new K(d):u.selectedLinearElement}))),!t.drag.hasOccurred&&!this.state.isResizing&&(d&&bv({x:t.origin.x,y:t.origin.y,element:d,shape:cn(d,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:Q(d)?this.frameNameBoundsCache.get(d):null},c)||!d&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Ge({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Ze(this.interactiveCanvas,Be.AUTO);return}if(!a.locked&&a.type!=="freedraw"&&o&&o.type!=="selection"&&this.setState(u=>({selectedElementIds:Ge({...u.selectedElementIds,[o.id]:!0},u),showHyperlinkPopup:Rt(o)&&!o.link?"editor":u.showHyperlinkPopup})),(a.type!=="selection"||qe(this.scene.getNonDeletedElements(),this.state)||!it(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||s||l){let u=this.scene.getSelectedElements(this.state).filter(ie);es(u,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Fn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[])}if(a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(mo(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:nt(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Ve.pointers.size<=1&&sr(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(d)})}restoreReadyToEraseElements=()=>{this.elementsPendingErasure=new Set,this.triggerRender()};eraseElements=()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(o=>this.elementsPendingErasure.has(o.id)||o.frameId&&this.elementsPendingErasure.has(o.frameId)||ze(o)&&this.elementsPendingErasure.has(o.containerId)?(t=!0,pe(o,{isDeleted:!0})):o);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))};initializeImage=async({imageFile:t,imageElement:r,showCursorImagePreview:o=!1})=>{if(!$i(t))throw new Error(E("errors.unsupportedFileType"));let n=t.type;if(Ze(this.interactiveCanvas,"wait"),n===se.svg)try{t=If(await Wv(await t.text()),t.name)}catch(c){throw console.warn(c),new Error(E("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(t)||n2(t));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(E("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{t=await zc(t,{maxWidthOrHeight:g0})}catch(c){console.error("Error trying to resizing image file on insertion",c)}if(t.size>_h)throw new Error(E("errors.fileTooBig",{maxSize:`${Math.trunc(_h/1024/1024)}MB`}))}if(o){let c=this.files[i]?.dataURL,d=c&&i2(c);this.setImagePreviewCursor(d||t)}let s=this.files[i]?.dataURL||await wp(t),l=F(r,{fileId:i},!1);return new Promise(async(c,d)=>{try{this.files={...this.files,[i]:{mimeType:n,id:i,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}};let m=this.imageCache.get(i);m||(this.addNewImagesToImageCache(),await this.updateImageCache([l])),m?.image instanceof Promise&&await m.image,this.state.pendingImageElementId!==l.id&&this.state.draggingElement?.id!==l.id&&this.initializeImageDimensions(l,!0),c(l)}catch(m){console.error(m),d(new Error(E("errors.imageInsertError")))}finally{o||mo(this.interactiveCanvas)}})};insertImageElement=async(t,r,o)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:E("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:o})}catch(n){return F(t,{isDeleted:!0}),this.actionManager.executeAction(xo),this.setState({errorMessage:n.message||E("errors.imageInsertError")}),null}};setImagePreviewCursor=async t=>{let o;try{o=await zc(t,{maxWidthOrHeight:96})}catch(i){throw i.cause==="UNSUPPORTED"?new Error(E("errors.unsupportedFileType")):i}let n=await wp(o);if(t.type===se.svg){let i=await tb(n),a=Math.min(i.height,96),s=a*(i.width/i.height);s>96&&(s=96,a=s*(i.height/i.width));let l=document.createElement("canvas");l.height=a,l.width=s,l.getContext("2d").drawImage(i,0,0,s,a),n=l.toDataURL(se.svg)}this.state.pendingImageElementId&&Ze(this.interactiveCanvas,`url(${n}) 4 4, auto`)};onImageAction=async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Qe({clientX:r,clientY:o},this.state),a=await js({description:"Image",extensions:Object.keys(xc)}),s=this.createImageElement({sceneX:n,sceneY:i,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,a),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ge({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(xo)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:nt(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(xo)})}};initializeImageDimensions=(t,r=!1)=>{let o=kr(t)&&this.imageCache.get(t.fileId)?.image;if(!o||o instanceof Promise){if(t.width<ri/this.state.zoom.value&&t.height<ri/this.state.zoom.value){let n=100/this.state.zoom.value;F(t,{x:t.x-n/2,y:t.y-n/2,width:n,height:n})}return}if(r||t.width<ri/this.state.zoom.value&&t.height<ri/this.state.zoom.value){let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;F(t,{x:l,y:c,width:s,height:a})}};updateImageCache=async(t,r=this.files)=>{let{updatedFiles:o,erroredFiles:n}=await Jp({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});if(o.size||n.size)for(let i of t)o.has(i.fileId)&&_e.delete(i);return n.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>kr(i)&&n.has(i.fileId)?pe(i,{status:"error"}):i)),{updatedFiles:o,erroredFiles:n}};addNewImagesToImageCache=async(t=Qp(this.scene.getNonDeletedElements()),r=this.files)=>{let o=t.filter(n=>!n.isDeleted&&!this.imageCache.has(n.fileId));if(o.length){let{updatedFiles:n}=await this.updateImageCache(o,r);n.size&&this.scene.triggerUpdate()}};scheduleImageRefresh=E9(()=>{this.addNewImagesToImageCache()},n0);updateBindingEnabledOnPointerMove=t=>{let r=vv(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})};maybeSuggestBindingAtCursor=t=>{let r=xr(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({suggestedBindings:r!=null?[r]:[]})};maybeSuggestBindingsForLinearElementAtCoords=(t,r,o)=>{if(!r.length)return;let n=r.reduce((i,a)=>{let s=xr(a,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ne(t)&&de(t));return s!=null&&!Xf(t,o?.id,s)&&i.push(s),i},[]);this.setState({suggestedBindings:n})};clearSelection(t){this.setState(r=>({selectedElementIds:Ge({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ra(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Ge({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}handleInteractiveCanvasRef=t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("wheel",this.handleWheel),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("wheel",this.handleWheel),this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))};handleAppOnDrop=async t=>{let{file:r,fileHandle:o}=await s2(t),{x:n,y:i}=Qe(t,this.state);try{if($i(r)&&this.isToolSupported("image")){if(r?.type===se.png||r?.type===se.svg)try{let l=await Qs(r,this.state,this.scene.getElementsIncludingDeleted(),o);this.syncActionResult({...l,appState:{...l.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:_.CAPTURE});return}catch(l){if(l.name!=="EncodingError")throw new Error(E("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:n,sceneY:i});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ge({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let a=t.dataTransfer.getData(se.excalidrawlib);if(a&&typeof a=="string"){try{let s=Tf(a);this.addElementsFromPasteOrLibrary({elements:xg(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,o),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&hl(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||xi(s)?.type==="video")){let l=this.insertEmbeddableElement({sceneX:n,sceneY:i,link:Pr(s)});l&&this.setState({selectedElementIds:{[l.id]:!0}})}}};loadFileToCanvas=async(t,r)=>{t=await Rc(t);try{let o=this.scene.getElementsIncludingDeleted(),n;try{n=await yp(t,this.state,o,r)}catch(i){let a=i instanceof jo;if(a&&i.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:E("errors.imageToolNotSupported")});return}let s=a?E("alerts.cannotRestoreFromImage"):E("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!n)return;n.type===se.excalidraw?(fr(o.concat(n.data.elements)),this.store.updateSnapshot(Z(o),this.state),this.setState({isLoading:!0}),this.syncActionResult({...n.data,appState:{...n.data.appState||this.state,isLoading:!1},replaceFiles:!0,storeAction:_.CAPTURE})):n.type===se.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(i=>{console.error(i),this.setState({errorMessage:E("errors.importLibraryError")})})}catch(o){this.setState({isLoading:!1,errorMessage:o.message})}};handleCanvasContextMenu=t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Ni.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:o}=Qe(t,this.state),n=this.getElementAtPosition(r,o,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:o},i),s=n||a?"element":"canvas",l=this.excalidrawContainerRef.current,{top:c,left:d}=l.getBoundingClientRect(),m=t.clientX-d,p=t.clientY-c;Ce("contextMenu","openContextMenu",s),this.setState({...n&&!this.state.selectedElementIds[n.id]?{...this.state,...cr({editingGroupId:this.state.editingGroupId,selectedElementIds:{[n.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ie(n)?new K(n):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:p,left:m,items:this.getContextMenuItems(s)}})})};maybeDragNewGenericElement=(t,r)=>{let o=this.state.draggingElement,n=t.lastCoords;if(o)if(o.type==="selection"&&this.state.activeTool.type!=="eraser")Bu(o,this.state.activeTool.type,t.origin.x,t.origin.y,n.x,n.y,Ht(t.origin.x,n.x),Ht(t.origin.y,n.y),cl(r),Lp(r),this.state.zoom.value);else{let[i,a]=Ot(n.x,n.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),s=kr(o)&&this.imageCache.get(o.fileId)?.image,l=s&&!(s instanceof Promise)?s.width/s.height:null;this.maybeCacheReferenceSnapPoints(r,[o]);let{snapOffset:c,snapLines:d}=rA(o,this.state,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:i-t.originInGrid.x,y:a-t.originInGrid.y},this.scene.getNonDeletedElementsMap());i+=c.x,a+=c.y,this.setState({snapLines:d}),Bu(o,this.state.activeTool.type,t.originInGrid.x,t.originInGrid.y,i,a,Ht(t.originInGrid.x,i),Ht(t.originInGrid.y,a),So(o)?!cl(r):cl(r),Lp(r),this.state.zoom.value,l,this.state.originSnapOffset),(this.state.activeTool.type===It.frame||this.state.activeTool.type===It.magicframe)&&this.setState({elementsToHighlight:vl(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap())})}};maybeHandleResize=(t,r)=>{let o=this.scene.getSelectedElements(this.state),n=o.filter(d=>Q(d)),i=t.resize.handleType;if(n.length>0&&i==="rotation")return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let a=t.lastCoords,[s,l]=Ot(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),c=new Map;if(n.forEach(d=>{bo(this.scene.getNonDeletedElements(),d.id).forEach(p=>{c.set(d.id+p.id,{x:p.x-d.x,y:p.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,m]=Ot(a.x,a.y,r[S.CTRL_OR_CMD]?null:this.state.gridSize),p={x:d-t.originInGrid.x,y:m-t.originInGrid.y},u=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,o);let{snapOffset:g,snapLines:h}=tA(o,he(u,this.state),this.state,r,p,i);s+=g.x,l+=g.y,this.setState({snapLines:h})}if(Ub(t.originalElements,i,o,this.scene.getElementsMapIncludingDeleted(),Za(r),Lp(r),o.some(d=>So(d))?!cl(r):cl(r),s,l,t.resize.center.x,t.resize.center.y,this.scene)){let d=Gp(o,this.scene.getNonDeletedElementsMap()),m=new Set;return n.forEach(p=>{vl(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>m.add(u))}),this.setState({elementsToHighlight:[...m],suggestedBindings:d}),!0}return!1};getContextMenuItems=t=>{let r=[];return r.push(mg,dg),t==="canvas"?this.state.viewModeEnabled?[...r,ug,$l,ox,Zl]:[HE,Sr,mg,dg,pg,Sr,iE,ZS,Sr,ug,UE,$l,ox,Zl]:(r.push(pg),this.state.viewModeEnabled?[Kl,...r]:[Sr,cg,Kl,HE,X5,K5,Sr,...r,Sr,DE,_E,Sr,RE,AA,GE,WE,US,NE,Sr,FE,Sr,tE,rE,oE,nE,Sr,BE,zE,Sr,E1,Vd,aE,ZE,Sr,_d])};handleWheel=bt(t=>{if(t.preventDefault(),lm)return;let{deltaX:r,deltaY:o}=t;if(t.metaKey||t.ctrlKey){let n=Math.sign(o),i=La*100,a=Math.abs(o),s=o;a>i&&(s=i*n);let l=this.state.zoom.value-s/100;l+=Math.log10(Math.max(1,this.state.zoom.value))*-n*Math.min(1,a/20),this.translateCanvas(c=>({...Ci({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Un(l)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:n,scrollX:i})=>({scrollX:i-(o||r)/n.value}));return}this.translateCanvas(({zoom:n,scrollX:i,scrollY:a})=>({scrollX:i-r/n.value,scrollY:a-o/n.value}))});getTextWysiwygSnappedToCenterPosition(t,r,o,n){if(n){let i=n.x+n.width/2,a=n.y+n.height/2,s=Pu(n,o,this.scene.getNonDeletedElementsMap());if(s&&(i=s.x,a=s.y),Math.hypot(t-i,r-a)<Qx){let{x:d,y:m}=$t({sceneX:i,sceneY:a},o);return{viewportX:d,viewportY:m,elementCenterX:i,elementCenterY:a}}}}savePointer=(t,r,o)=>{if(!t||!r)return;let{x:n,y:i}=Qe({clientX:t,clientY:r},this.state);isNaN(n)||isNaN(i);let a={x:n,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:o,pointersMap:Ve.pointers})};resetShouldCacheIgnoreZoomDebounced=ii(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300);updateDOMRect=t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:o,height:n,left:i,top:a}=r.getBoundingClientRect(),{width:s,height:l,offsetTop:c,offsetLeft:d}=this.state;if(o===s&&n===l&&i===d&&a===c){t&&t();return}this.setState({width:o,height:n,offsetLeft:i,offsetTop:a},()=>{t&&t()})}};refresh=()=>{this.setState({...this.getCanvasOffsets()})};getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:o}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Ds.find(r=>r.code===this.props.langCode)||yn;await hm(t),this.setAppState({})}},x9=()=>{(T.MODE===Kt.TEST||T.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(fr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};x9();var NA=Ex;V();f();var w9=()=>{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)})},OA=w9;Y();import{Provider as F9}from"jotai";f();import v9 from"clsx";import{jsx as FA}from"react/jsx-runtime";var BA=({children:e})=>{let{FooterCenterTunnel:t}=ut(),r=Ue();return FA(t.In,{children:FA("div",{className:v9("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":r.zenModeEnabled}),children:e})})},T9=BA;BA.displayName="FooterCenter";f();f();ee();f();import{jsx as Ia,jsxs as HA}from"react/jsx-runtime";var S9=()=>Ia("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ia("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"})}),I9=()=>HA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ia("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)"}),Ia("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)"}),Ia("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)"}),Ia("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)"})]}),zA=({style:e,size:t="small",withText:r})=>HA("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Ia(S9,{}),r&&Ia(I9,{})]});import{Fragment as WA,jsx as zt,jsxs as Ix}from"react/jsx-runtime";var Cx=({icon:e,shortcut:t,children:r})=>{let o=Ne();return Ix(WA,{children:[zt("div",{className:"welcome-screen-menu-item__icon",children:e}),zt("div",{className:"welcome-screen-menu-item__text",children:r}),t&&!o.editor.isMobile&&zt("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};Cx.displayName="WelcomeScreenMenuItemContent";var mm=({onSelect:e,children:t,icon:r,shortcut:o,className:n="",...i})=>zt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:zt(Cx,{icon:r,shortcut:o,children:t})});mm.displayName="WelcomeScreenMenuItem";var UA=({children:e,href:t,icon:r,shortcut:o,className:n="",...i})=>zt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noreferrer",children:zt(Cx,{icon:r,shortcut:o,children:e})});UA.displayName="WelcomeScreenMenuItemLink";var Go=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=ut();return zt(t.In,{children:zt("div",{className:"welcome-screen-center",children:e||Ix(WA,{children:[zt(Ax,{}),zt(Mx,{children:E("welcomeScreen.defaults.center_heading")}),Ix(kx,{children:[zt(Lx,{}),zt(Px,{})]})]})})})};Go.displayName="Center";var Ax=({children:e})=>zt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||zt(zA,{withText:!0})});Ax.displayName="Logo";var Mx=({children:e})=>zt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Mx.displayName="Heading";var kx=({children:e})=>zt("div",{className:"welcome-screen-menu",children:e});kx.displayName="Menu";var Px=()=>{let e=Xt();return zt(mm,{onSelect:()=>e.executeAction(ws),shortcut:"?",icon:Vs,children:E("helpDialog.title")})};Px.displayName="MenuItemHelp";var Lx=()=>{let e=Ue(),t=Xt();return e.viewModeEnabled?null:zt(mm,{onSelect:()=>t.executeAction(Wl),shortcut:Bt("loadScene"),icon:Ys,children:E("buttons.load")})};Lx.displayName="MenuItemLoadScene";var GA=({onSelect:e})=>{let{t}=Dt();return zt(mm,{shortcut:null,onSelect:e,icon:op,children:t("labels.liveCollaboration")})};GA.displayName="MenuItemLiveCollaborationTrigger";Go.Logo=Ax;Go.Heading=Mx;Go.Menu=kx;Go.MenuItem=mm;Go.MenuItemLink=UA;Go.MenuItemHelp=Px;Go.MenuItemLoadScene=Lx;Go.MenuItemLiveCollaborationTrigger=GA;f();ee();import{jsx as gc,jsxs as Dx}from"react/jsx-runtime";var vh=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[ay,gc("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.menuHint")})]})})};vh.displayName="MenuHint";var Th=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[gc("div",{className:"welcome-screen-decor-hint__label",children:e||E("welcomeScreen.defaults.toolbarHint")}),ly]})})};Th.displayName="ToolbarHint";var Sh=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=ut();return gc(t.In,{children:Dx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[gc("div",{children:e||E("welcomeScreen.defaults.helpHint")}),sy]})})};Sh.displayName="HelpHint";import{Fragment as VA,jsx as pm,jsxs as A9}from"react/jsx-runtime";var Ih=e=>pm(VA,{children:e.children||A9(VA,{children:[pm(Go,{}),pm(vh,{}),pm(Th,{}),pm(Sh,{})]})});Ih.displayName="WelcomeScreen";Ih.Center=Go;Ih.Hints={MenuHint:vh,ToolbarHint:Th,HelpHint:Sh};var C9=Ih;f();ee();import M9 from"clsx";import{jsx as P9,jsxs as L9}from"react/jsx-runtime";var YA=({isCollaborating:e,onSelect:t,...r})=>{let o=Ue(),n=o.width<830;return L9(Yn,{...r,className:M9("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:n?void 0:"auto"},title:E("labels.liveCollaboration"),children:[n?Py:E("labels.share"),o.collaborators.size>0&&P9("div",{className:"CollabButton-collaborators",children:o.collaborators.size})]})},k9=YA;YA.displayName="LiveCollaborationTrigger";we();el();f();Y();ko();V();var D9=(e,t,r)=>!!(t&&(t.id===e.editingElement?.id||t.id===e.resizingElement?.id||t.id===e.draggingElement?.id||t.version>r.version||t.version===r.version&&t.versionNonce<r.versionNonce)),_9=(e,t,r)=>{let o=Z(e),n=[],i=new Set;for(let s of t)if(!i.has(s.id)){let l=o.get(s.id),c=D9(r,l,s);l&&c?(n.push(l),i.add(l.id)):(n.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(n.push(s),i.add(s.id));let a=Xp(n);if(T.DEV||T.MODE===Kt.TEST||window?.DEBUG_FRACTIONAL_INDICES){let s=fr(a.map(l=>({...l})));Td(s,{shouldThrow:T.DEV||T.MODE===Kt.TEST,includeBoundTextValidation:!0,reconciliationContext:{localElements:e,remoteElements:t}})}return fr(a),a};os();mi();qr();li();me();Y();De();Re();V();f();ee();import{jsx as XA,jsxs as R9}from"react/jsx-runtime";var KA=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:r}=ut(),o=Oe();return XA(r.In,{children:R9(Ye.Item,{onSelect:()=>{Ce("ai","dialog open","ttd"),o({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??ww,children:[e??E("labels.textToDiagram"),XA(Ye.Item.Badge,{children:"AI"})]})})};KA.displayName="TTDDialogTrigger";Oa();dt();ub();import{jsx as _x}from"react/jsx-runtime";OA();var B9=e=>{let{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:s=yn.code,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:g,onPaste:h,detectScroll:x=!0,handleKeyboardGlobally:v=!1,onLibraryChange:y,autoFocus:w=!1,generateIdForFile:C,onLinkOpen:M,onPointerDown:I,onPointerUp:P,onScrollChange:A,children:N,validateEmbeddable:k,renderEmbeddable:D,aiEnabled:z,showDeprecatedFonts:R}=e,W=e.UIOptions?.canvasActions,q={...e.UIOptions,canvasActions:{...Dh.canvasActions,...W},tools:{image:e.UIOptions?.tools?.image??!0}};return W?.export&&(q.canvasActions.export.saveFileToDisk=W.export?.saveFileToDisk??Dh.canvasActions.export.saveFileToDisk),q.canvasActions.toggleTheme===null&&typeof p>"u"&&(q.canvasActions.toggleTheme=!0),O9(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ge=le=>{typeof le.scale=="number"&&le.scale!==1&&le.preventDefault()};return document.addEventListener("touchmove",ge,{passive:!1}),()=>{document.removeEventListener("touchmove",ge)}},[]),_x(F9,{unstable_createStore:()=>mr,scope:Xe,children:_x(x0,{langCode:s,theme:p,children:_x(NA,{onChange:t,initialData:r,excalidrawAPI:o,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:s,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:m,theme:p,name:u,renderCustomStats:g,UIOptions:q,onPaste:h,detectScroll:x,handleKeyboardGlobally:v,onLibraryChange:y,autoFocus:w,generateIdForFile:C,onLinkOpen:M,onPointerDown:I,onPointerUp:P,onScrollChange:A,validateEmbeddable:k,renderEmbeddable:D,aiEnabled:z!==!1,showDeprecatedFonts:R,children:N})})})},z9=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:r,UIOptions:o={},...n}=e,{initialData:i,UIOptions:a={},...s}=t,l=Object.keys(o),c=Object.keys(a);return l.length!==c.length?!1:l.every(m=>m==="canvasActions"?Object.keys(o.canvasActions).every(u=>u==="export"&&o?.canvasActions?.export&&a?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:o?.canvasActions?.[u]===a?.canvasActions?.[u]):o[m]===a[m])&&it(n,s)},H9=N9.memo(B9,z9);H9.displayName="Excalidraw";export{Yn as Button,kh as DEFAULT_LASER_COLOR,Qg as DefaultSidebar,H9 as Excalidraw,Le as FONT_FAMILY,T9 as Footer,k9 as LiveCollaborationTrigger,se as MIME_TYPES,Hr as MainMenu,ct as ROUNDNESS,Li as Sidebar,_ as StoreAction,ue as THEME,j1 as TTDDialog,KA as TTDDialogTrigger,C9 as WelcomeScreen,Ki as bumpVersion,ac as convertToExcalidrawElements,yn as defaultLang,cT as elementPartiallyOverlapsWithOrContainsBBox,pb as elementsOverlappingBBox,gu as exportToBlob,ia as exportToCanvas,vM as exportToClipboard,wl as exportToSvg,Te as getCommonBounds,qp as getFreeDrawSvgPath,Eg as getLibraryItemsHash,Ae as getNonDeletedElements,xk as getSceneVersion,Mb as getVisibleSceneBounds,Kb as hashElementsVersion,$b as hashString,mb as isElementInsideBBox,Po as isInvisiblySmallElement,ie as isLinearElement,Ds as languages,Qs as loadFromBlob,Sf as loadLibraryFromBlob,yp as loadSceneOrLibraryFromBlob,iI as mergeLibraryItems,F as mutateElement,pe as newElementWith,Pr as normalizeLink,JE as parseLibraryTokensFromUrl,_9 as reconcileElements,Xi as restore,Zw as restoreAppState,Nc as restoreElements,Ga as restoreLibraryItems,$t as sceneCoordsToViewportCoords,Vi as serializeAsJSON,hp as serializeLibraryAsJSON,Ne as useDevice,SD as useHandleLibrary,Dt as useI18n,Qe as viewportCoordsToSceneCoords,xS as zoomToFitBounds};