@hellixit/hellixitboard 0.1.0 → 0.1.2

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 (171) hide show
  1. package/README.md +11 -53
  2. package/dist/prod/chunk-IGUB3U7T.js +4 -0
  3. package/dist/prod/data/{image-2IKBHSIF.js → image-WXEFXRM6.js} +1 -1
  4. package/dist/prod/index.css +1 -1
  5. package/dist/prod/index.js +16 -16
  6. package/dist/types/common/src/constants.d.ts +1 -1
  7. package/dist/types/common/src/font-metadata.d.ts +1 -1
  8. package/dist/types/common/src/points.d.ts +1 -1
  9. package/dist/types/common/src/utils.d.ts +2 -2
  10. package/dist/types/element/src/Scene.d.ts +4 -4
  11. package/dist/types/element/src/arrows/focus.d.ts +1 -1
  12. package/dist/types/element/src/binding.d.ts +3 -3
  13. package/dist/types/element/src/bounds.d.ts +2 -2
  14. package/dist/types/element/src/collision.d.ts +1 -1
  15. package/dist/types/element/src/delta.d.ts +2 -2
  16. package/dist/types/element/src/distance.d.ts +1 -1
  17. package/dist/types/element/src/dragElements.d.ts +1 -1
  18. package/dist/types/element/src/duplicate.d.ts +1 -1
  19. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  20. package/dist/types/element/src/embeddable.d.ts +1 -1
  21. package/dist/types/element/src/frame.d.ts +1 -1
  22. package/dist/types/element/src/groups.d.ts +1 -1
  23. package/dist/types/element/src/heading.d.ts +2 -2
  24. package/dist/types/element/src/image.d.ts +1 -1
  25. package/dist/types/element/src/linearElementEditor.d.ts +3 -3
  26. package/dist/types/element/src/mutateElement.d.ts +1 -1
  27. package/dist/types/element/src/newElement.d.ts +1 -1
  28. package/dist/types/element/src/renderElement.d.ts +2 -2
  29. package/dist/types/element/src/resizeElements.d.ts +1 -1
  30. package/dist/types/element/src/resizeTest.d.ts +3 -3
  31. package/dist/types/element/src/shape.d.ts +3 -3
  32. package/dist/types/element/src/store.d.ts +2 -2
  33. package/dist/types/element/src/textElement.d.ts +2 -2
  34. package/dist/types/element/src/transform.d.ts +1 -1
  35. package/dist/types/element/src/transformHandles.d.ts +3 -3
  36. package/dist/types/element/src/typeChecks.d.ts +1 -1
  37. package/dist/types/element/src/types.d.ts +3 -3
  38. package/dist/types/element/src/utils.d.ts +2 -2
  39. package/dist/types/element/src/zindex.d.ts +1 -1
  40. package/dist/types/hellixitboard/actions/actionAddToLibrary.d.ts +82 -82
  41. package/dist/types/hellixitboard/actions/actionAlign.d.ts +7 -7
  42. package/dist/types/hellixitboard/actions/actionBoundText.d.ts +50 -50
  43. package/dist/types/hellixitboard/actions/actionCanvas.d.ts +275 -275
  44. package/dist/types/hellixitboard/actions/actionClipboard.d.ts +63 -63
  45. package/dist/types/hellixitboard/actions/actionCropEditor.d.ts +28 -28
  46. package/dist/types/hellixitboard/actions/actionDeleteSelected.d.ts +69 -69
  47. package/dist/types/hellixitboard/actions/actionDistribute.d.ts +3 -3
  48. package/dist/types/hellixitboard/actions/actionDuplicateSelection.d.ts +2 -2
  49. package/dist/types/hellixitboard/actions/actionElementLink.d.ts +32 -32
  50. package/dist/types/hellixitboard/actions/actionElementLock.d.ts +49 -49
  51. package/dist/types/hellixitboard/actions/actionEmbeddable.d.ts +29 -29
  52. package/dist/types/hellixitboard/actions/actionExport.d.ts +48 -48
  53. package/dist/types/hellixitboard/actions/actionFinalize.d.ts +1 -1
  54. package/dist/types/hellixitboard/actions/actionFlip.d.ts +3 -3
  55. package/dist/types/hellixitboard/actions/actionFrame.d.ts +210 -210
  56. package/dist/types/hellixitboard/actions/actionGroup.d.ts +43 -43
  57. package/dist/types/hellixitboard/actions/actionLinearEditor.d.ts +149 -149
  58. package/dist/types/hellixitboard/actions/actionLink.d.ts +31 -31
  59. package/dist/types/hellixitboard/actions/actionMenu.d.ts +27 -27
  60. package/dist/types/hellixitboard/actions/actionNavigate.d.ts +2 -2
  61. package/dist/types/hellixitboard/actions/actionProperties.d.ts +39 -39
  62. package/dist/types/hellixitboard/actions/actionSelectAll.d.ts +23 -23
  63. package/dist/types/hellixitboard/actions/actionStyles.d.ts +31 -31
  64. package/dist/types/hellixitboard/actions/actionTextAutoResize.d.ts +3 -3
  65. package/dist/types/hellixitboard/actions/actionToggleArrowBinding.d.ts +28 -28
  66. package/dist/types/hellixitboard/actions/actionToggleGridMode.d.ts +29 -29
  67. package/dist/types/hellixitboard/actions/actionToggleMidpointSnapping.d.ts +28 -28
  68. package/dist/types/hellixitboard/actions/actionToggleObjectsSnapMode.d.ts +29 -29
  69. package/dist/types/hellixitboard/actions/actionToggleSearchMenu.d.ts +28 -28
  70. package/dist/types/hellixitboard/actions/actionToggleShapeSwitch.d.ts +2 -2
  71. package/dist/types/hellixitboard/actions/actionToggleStats.d.ts +28 -28
  72. package/dist/types/hellixitboard/actions/actionToggleViewMode.d.ts +29 -29
  73. package/dist/types/hellixitboard/actions/actionToggleZenMode.d.ts +29 -29
  74. package/dist/types/hellixitboard/actions/actionZindex.d.ts +8 -8
  75. package/dist/types/hellixitboard/actions/manager.d.ts +1 -1
  76. package/dist/types/hellixitboard/actions/shortcuts.d.ts +1 -1
  77. package/dist/types/hellixitboard/actions/types.d.ts +2 -2
  78. package/dist/types/hellixitboard/animated-trail.d.ts +2 -2
  79. package/dist/types/hellixitboard/appState.d.ts +9 -9
  80. package/dist/types/hellixitboard/charts/charts.constants.d.ts +1 -1
  81. package/dist/types/hellixitboard/charts/charts.helpers.d.ts +3 -3
  82. package/dist/types/hellixitboard/charts/charts.types.d.ts +1 -1
  83. package/dist/types/hellixitboard/charts/index.d.ts +1 -1
  84. package/dist/types/hellixitboard/clipboard.d.ts +4 -4
  85. package/dist/types/hellixitboard/components/Actions.d.ts +1 -1
  86. package/dist/types/hellixitboard/components/App.d.ts +9 -9
  87. package/dist/types/hellixitboard/components/ColorPicker/ColorPicker.d.ts +2 -2
  88. package/dist/types/hellixitboard/components/ColorPicker/Picker.d.ts +2 -2
  89. package/dist/types/hellixitboard/components/ColorPicker/PickerColorList.d.ts +1 -1
  90. package/dist/types/hellixitboard/components/ColorPicker/ShadeList.d.ts +1 -1
  91. package/dist/types/hellixitboard/components/ColorPicker/colorPickerUtils.d.ts +2 -2
  92. package/dist/types/hellixitboard/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  93. package/dist/types/hellixitboard/components/ConvertElementTypePopup.d.ts +2 -2
  94. package/dist/types/hellixitboard/components/DarkModeToggle.d.ts +1 -1
  95. package/dist/types/hellixitboard/components/DefaultSidebar.d.ts +1 -1
  96. package/dist/types/hellixitboard/components/ElementCanvasButtons.d.ts +1 -1
  97. package/dist/types/hellixitboard/components/ElementLinkDialog.d.ts +2 -2
  98. package/dist/types/hellixitboard/components/EyeDropper.d.ts +1 -1
  99. package/dist/types/hellixitboard/components/FontPicker/FontPicker.d.ts +1 -1
  100. package/dist/types/hellixitboard/components/FontPicker/FontPickerList.d.ts +2 -2
  101. package/dist/types/hellixitboard/components/FontPicker/FontPickerTrigger.d.ts +1 -1
  102. package/dist/types/hellixitboard/components/FontPicker/keyboardNavHandlers.d.ts +1 -1
  103. package/dist/types/hellixitboard/components/HintViewer.d.ts +1 -1
  104. package/dist/types/hellixitboard/components/ImageExportDialog.d.ts +1 -1
  105. package/dist/types/hellixitboard/components/InitializeApp.d.ts +1 -1
  106. package/dist/types/hellixitboard/components/JSONExportDialog.d.ts +1 -1
  107. package/dist/types/hellixitboard/components/LayerUI.d.ts +1 -1
  108. package/dist/types/hellixitboard/components/LibraryMenuSection.d.ts +1 -1
  109. package/dist/types/hellixitboard/components/LoadingMessage.d.ts +1 -1
  110. package/dist/types/hellixitboard/components/MobileMenu.d.ts +1 -1
  111. package/dist/types/hellixitboard/components/Stats/Angle.d.ts +2 -2
  112. package/dist/types/hellixitboard/components/Stats/CanvasGrid.d.ts +1 -1
  113. package/dist/types/hellixitboard/components/Stats/Dimension.d.ts +2 -2
  114. package/dist/types/hellixitboard/components/Stats/DragInput.d.ts +2 -2
  115. package/dist/types/hellixitboard/components/Stats/FontSize.d.ts +2 -2
  116. package/dist/types/hellixitboard/components/Stats/MultiAngle.d.ts +2 -2
  117. package/dist/types/hellixitboard/components/Stats/MultiDimension.d.ts +2 -2
  118. package/dist/types/hellixitboard/components/Stats/MultiFontSize.d.ts +2 -2
  119. package/dist/types/hellixitboard/components/Stats/MultiPosition.d.ts +2 -2
  120. package/dist/types/hellixitboard/components/Stats/Position.d.ts +2 -2
  121. package/dist/types/hellixitboard/components/Stats/index.d.ts +1 -1
  122. package/dist/types/hellixitboard/components/Stats/utils.d.ts +2 -2
  123. package/dist/types/hellixitboard/components/TTDDialog/CodeMirrorEditor.d.ts +1 -1
  124. package/dist/types/hellixitboard/components/TTDDialog/common.d.ts +1 -1
  125. package/dist/types/hellixitboard/components/TTDDialog/hooks/useMermaidRenderer.d.ts +1 -1
  126. package/dist/types/hellixitboard/components/TTDDialog/types.d.ts +3 -3
  127. package/dist/types/hellixitboard/components/ToolButton.d.ts +1 -1
  128. package/dist/types/hellixitboard/components/canvases/InteractiveCanvas.d.ts +2 -2
  129. package/dist/types/hellixitboard/components/canvases/NewElementCanvas.d.ts +1 -1
  130. package/dist/types/hellixitboard/components/canvases/StaticCanvas.d.ts +1 -1
  131. package/dist/types/hellixitboard/components/dropdownMenu/DropdownMenu.d.ts +1 -1
  132. package/dist/types/hellixitboard/components/dropdownMenu/DropdownMenuItem.d.ts +1 -1
  133. package/dist/types/hellixitboard/components/hyperlink/Hyperlink.d.ts +2 -2
  134. package/dist/types/hellixitboard/components/hyperlink/helpers.d.ts +3 -3
  135. package/dist/types/hellixitboard/components/icons.d.ts +1 -1
  136. package/dist/types/hellixitboard/components/live-collaboration/LiveCollaborationTrigger.d.ts +1 -1
  137. package/dist/types/hellixitboard/components/main-menu/DefaultItems.d.ts +1 -1
  138. package/dist/types/hellixitboard/components/main-menu/MainMenu.d.ts +1 -1
  139. package/dist/types/hellixitboard/data/EditorLocalStorage.d.ts +1 -1
  140. package/dist/types/hellixitboard/data/blob.d.ts +49 -49
  141. package/dist/types/hellixitboard/data/filesystem.d.ts +1 -1
  142. package/dist/types/hellixitboard/data/index.d.ts +1 -1
  143. package/dist/types/hellixitboard/data/json.d.ts +24 -24
  144. package/dist/types/hellixitboard/data/library.d.ts +2 -2
  145. package/dist/types/hellixitboard/data/reconcile.d.ts +2 -2
  146. package/dist/types/hellixitboard/data/resave.d.ts +2 -2
  147. package/dist/types/hellixitboard/data/restore.d.ts +2 -2
  148. package/dist/types/hellixitboard/data/types.d.ts +2 -2
  149. package/dist/types/hellixitboard/fonts/Fonts.d.ts +3 -3
  150. package/dist/types/hellixitboard/history.d.ts +4 -4
  151. package/dist/types/hellixitboard/hooks/useEmitter.d.ts +1 -1
  152. package/dist/types/hellixitboard/i18n.d.ts +1 -1
  153. package/dist/types/hellixitboard/index.d.ts +12 -12
  154. package/dist/types/hellixitboard/lasso/utils.d.ts +2 -2
  155. package/dist/types/hellixitboard/renderer/staticScene.d.ts +1 -1
  156. package/dist/types/hellixitboard/renderer/staticSvgScene.d.ts +1 -1
  157. package/dist/types/hellixitboard/scene/Renderer.d.ts +2 -2
  158. package/dist/types/hellixitboard/scene/export.d.ts +1 -1
  159. package/dist/types/hellixitboard/scene/index.d.ts +2 -2
  160. package/dist/types/hellixitboard/scene/scroll.d.ts +1 -1
  161. package/dist/types/hellixitboard/scene/types.d.ts +3 -3
  162. package/dist/types/hellixitboard/snapping.d.ts +5 -5
  163. package/dist/types/hellixitboard/types.d.ts +7 -7
  164. package/dist/types/hellixitboard/wysiwyg/textWysiwyg.d.ts +1 -1
  165. package/dist/types/utils/src/bbox.d.ts +2 -2
  166. package/dist/types/utils/src/export.d.ts +2 -2
  167. package/dist/types/utils/src/index.d.ts +1 -1
  168. package/dist/types/utils/src/shape.d.ts +4 -4
  169. package/dist/types/utils/src/withinBounds.d.ts +2 -2
  170. package/package.json +7 -7
  171. package/dist/prod/chunk-6TQ3TBTF.js +0 -4
@@ -1,34 +1,34 @@
1
- import{$ as _r,A as Sc,B as Eu,C as TL,D as Ny,E as By,F as kc,G as Ml,H as Mc,I as Pc,J as Pl,K as Fy,L as Oy,M as zy,N as Ac,O as Ar,P as Gy,Q as IL,R as Lr,S as Ti,T as Al,V as Uy,X as Wy,Y as Yy,Z as Lc,_ as Vy,a as _y,aa as vu,b as Pr,ba as _c,c as No,ca as Xy,d as Dy,da as Tu,e as Me,ea as Dr,f as Hy,fa as Ky,g as oe,ga as Iu,h as xi,ha as $y,i as Bo,ia as Zy,j as Il,ja as Dc,k as wl,ka as wu,l as yi,la as jy,m as Cl,ma as qy,n as Sl,na as Jy,o as Ei,oa as Ll,p as Ry,q as xu,r as Fo,s as Gn,t as Oo,u as Ht,v as yn,w as vi,x as Cc,y as yu,z as kl}from"./chunk-6TQ3TBTF.js";import{a as w}from"./chunk-SHLNM5GH.js";import{N as bu}from"./chunk-QHHZVMH3.js";import{c as Ly}from"./chunk-3PELD44J.js";import{b as Py,c as Ay,d as S}from"./chunk-SRAX5OIU.js";import o$,{useCallback as n$,useContext as r$,useEffect as i$,useRef as a$,useState as l$}from"react";import{DEFAULT_UI_OPTIONS as vL,isShallowEqual as s$}from"@excalidraw/common";import jP from"clsx";import wV from"lodash.throttle";import go,{useContext as On}from"react";import{flushSync as Yt}from"react-dom";import CV from"roughjs/bin/rough";import{nanoid as SV}from"nanoid";import{clamp as qP,pointFrom as re,pointDistance as Ir,vector as JP,pointRotateRads as Hx,vectorFromPoint as Rx,vectorSubtract as QP,vectorDot as eA,vectorNormalize as tA}from"@excalidraw/math";import{COLOR_PALETTE as kV,CODES as oA,shouldResizeFromCenter as nA,shouldMaintainAspectRatio as sc,shouldRotateWithDiscreteAngle as rA,isArrowKey as Jp,KEYS as j,APP_NAME as MV,CURSOR_TYPE as ze,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as PV,DEFAULT_VERTICAL_ALIGN as iA,DRAGGING_THRESHOLD as aA,ELEMENT_SHIFT_TRANSLATE_AMOUNT as AV,ELEMENT_TRANSLATE_AMOUNT as lA,EVENT as ae,FRAME_STYLE as pn,IMAGE_MIME_TYPES as LV,IMAGE_RENDER_TIMEOUT as _V,LINE_CONFIRM_THRESHOLD as Nx,MAX_ALLOWED_FILE_BYTES as sA,MIME_TYPES as un,MQ_RIGHT_SIDEBAR_MIN_WIDTH as DV,POINTER_BUTTON as wr,ROUNDNESS as Qp,SCROLL_TIMEOUT as HV,TAP_TWICE_TIMEOUT as RV,TEXT_TO_CENTER_SNAP_THRESHOLD as NV,THEME as ul,TOUCH_CTX_MENU_TIMEOUT as BV,VERTICAL_ALIGN as FV,YOUTUBE_STATES as eu,ZOOM_STEP as OV,POINTER_EVENTS as hl,TOOL_TYPE as hn,supportsResizeObserver as zV,DEFAULT_COLLISION_THRESHOLD as cA,DEFAULT_TEXT_ALIGN as GV,ARROW_TYPE as Cr,DEFAULT_REDUCED_GLOBAL_ALPHA as UV,isLocalLink as WV,normalizeLink as Bx,toValidURL as YV,getGridPoint as It,getLineHeight as dA,debounce as mA,distance as gl,getFontString as Fx,getNearestScrollableContainer as VV,isInputLike as pA,isToolIcon as XV,isWritableElement as cc,sceneCoordsToViewportCoords as tu,tupleToCoors as Ox,viewportCoordsToSceneCoords as Be,wrapEvent as KV,updateObject as zx,updateActiveTool as gn,isTransparent as $V,easeToValuesRAF as ZV,muteFSAbortError as jV,isTestEnv as jA,isDevEnv as qA,easeOut as qV,updateStable as dc,addEventListener as $e,normalizeEOL as JV,getDateTime as uA,isShallowEqual as hA,arrayToMap as ou,applyDarkModeFilter as QV,AppEventBus as eX,randomInteger as tX,CLASSES as Gx,Emitter as gi,MINIMUM_ARROW_SIZE as oX,DOUBLE_TAP_POSITION_THRESHOLD as nX,BIND_MODE_TIMEOUT as rX,invariant as fn,getFeatureFlag as Bn,createUserAgentDescriptor as JA,getFormFactor as iX,deriveStylesPanelMode as cu,isIOS as aX,isBrave as lX,isSafari as sX,loadDesktopUIModePreference as cX,setDesktopUIMode as dX,isSelectionLikeTool as nu,oneOf as gA}from"@excalidraw/common";import{getObservedAppState as mX,getCommonBounds as fl,getElementAbsoluteCoords as fA,bindOrUnbindBindingElements as bA,fixBindingsAfterDeletion as pX,getHoveredElementForBinding as Ho,isBindingEnabled as mc,updateBoundElements as ru,LinearElementEditor as xe,newElementWith as Sr,newFrameElement as uX,newFreeDrawElement as hX,newEmbeddableElement as xA,newMagicFrameElement as yA,newIframeElement as gX,newArrowElement as fX,newElement as bX,newImageElement as xX,newLinearElement as yX,newTextElement as EA,refreshTextDimensions as EX,deepCopyElement as vA,duplicateElements as Ux,hasBoundTextElement as TA,isArrowElement as bl,isBindingElement as bn,isBindingElementType as vX,isBoundToContainer as Wx,isFrameLikeElement as Vt,isImageElement as fi,isEmbeddableElement as Fn,isInitializedImageElement as pc,isLinearElement as _t,isLinearElementType as TX,isUsingAdaptiveRadius as IX,isIframeElement as xl,isIframeLikeElement as Yx,isMagicFrameElement as Vx,isTextBindableContainer as IA,isElbowArrow as Xt,isFlowchartNodeElement as wX,isBindableElement as Xx,isTextElement as Ro,getNormalizedDimensions as CX,isElementCompletelyInViewport as Kx,isElementInViewport as wA,isInvisiblySmallElement as CA,getCornerRadius as SX,isPathALoop as SA,createSrcDoc as kA,embeddableURLValidator as $x,maybeParseEmbedSrc as kX,getEmbedLink as iu,getInitializedImageElements as MX,normalizeSVG as MA,updateImageCache as PX,getBoundTextElement as Zx,getContainerCenter as jx,getContainerElement as PA,isValidTextContainer as AX,redrawTextBoundingBox as LX,hasBoundingBox as _X,getFrameChildren as qx,isCursorInFrame as AA,addElementsToFrame as Jx,replaceAllElementsInFrame as DX,removeElementsFromFrame as HX,getElementsInResizingFrame as Qx,getElementsInNewFrame as RX,getContainingFrame as ey,elementOverlapsWithFrame as NX,updateFrameMembershipOfSelectedElements as LA,isElementInFrame as _A,getFrameLikeTitle as BX,getElementsOverlappingFrame as FX,filterElementsEligibleAsFrameChildren as OX,hitElementBoundText as zX,hitElementBoundingBoxOnly as GX,hitElementItself as uc,getVisibleSceneBounds as UX,FlowChartCreator as WX,FlowChartNavigator as YX,getLinkDirectionFromKey as DA,cropElement as VX,wrapText as XX,isElementLink as ty,parseElementLinkFromURL as KX,isMeasureTextSupported as $X,normalizeText as ZX,measureText as HA,getLineHeightInPx as jX,getApproxMinLineWidth as qX,getApproxMinLineHeight as JX,getMinTextElementWidth as QX,ShapeCache as hc,getRenderOpacity as eK,editGroupForSelectedElement as tK,getElementsInGroup as bi,getSelectedGroupIdForElement as oK,getSelectedGroupIds as nK,isElementInGroup as RA,isSelectedViaGroup as rK,selectGroupsForSelectedElements as ho,syncInvalidIndices as QA,syncMovedIndices as NA,excludeElementsInFramesFromSelection as iK,getSelectionStateForElements as aK,makeNextSelectedElementIds as ke,getResizeOffsetXY as lK,getResizeArrowDirection as sK,transformElements as cK,getCursorForResizingElement as BA,getElementWithTransformHandleType as FA,getTransformHandleTypeFromCoords as OA,dragNewElement as zA,dragSelectedElements as dK,getDragOffsetXY as mK,isNonDeletedElement as GA,Scene as UA,Store as pK,CaptureUpdateAction as Dt,hitElementBoundingBox as uK,isLineElement as oy,isSimpleArrow as ny,StoreDelta as WA,positionElementsOnGrid as YA,calculateFixedPointForNonElbowArrowBinding as VA,bindOrUnbindBindingElement as hK,mutateElement as au,getElementBounds as XA,doBoundsIntersect as gK,isPointInElement as fK,maxBindingDistance_simple as ry,convertToHellixitboardElements as KA,getSnapOutlineMidPoint as iy,handleFocusPointDrag as bK,handleFocusPointHover as xK,handleFocusPointPointerDown as yK,handleFocusPointPointerUp as EK,maybeHandleArrowPointlikeDrag as lu,getUncroppedWidthAndHeight as vK}from"@excalidraw/element";import{KEYS as Zu,MOBILE_ACTION_BUTTON_BG as NL,updateActiveTool as BL}from"@excalidraw/common";import{getNonDeletedElements as ju}from"@excalidraw/element";import{fixBindingsAfterDeletion as FL}from"@excalidraw/element";import{LinearElementEditor as e1}from"@excalidraw/element";import{newElementWith as ed}from"@excalidraw/element";import{getContainerElement as t1}from"@excalidraw/element";import{isBoundToContainer as Jc,isElbowArrow as OL,isFrameLikeElement as zL}from"@excalidraw/element";import{getFrameChildren as GL}from"@excalidraw/element";import{getElementsInGroup as qu,selectGroupsForSelectedElements as UL}from"@excalidraw/element";import{CaptureUpdateAction as Qc}from"@excalidraw/element";import{isDevEnv as kL}from"@excalidraw/common";import{atom as ge,createStore as wL}from"jotai";import{createIsolation as CL}from"jotai-scope";var Qy=CL();var{useAtom:Q,useSetAtom:zo,useAtomValue:Ii,useStore:h$}=Qy,e0=Qy.Provider,Qe=wL();var SL=Py({"./locales/ar-SA.json":()=>import("./locales/ar-SA-P5I5R262.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RC6EHA33.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-ZOA2ELPF.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-VDHX36FF.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-EFTDMVGQ.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-T4YNJ7N4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-QQWRSQQN.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-AGDMBNQK.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-QQTSMZVG.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-HP6J4G7Y.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-T47LNPQP.js"),"./locales/en.json":()=>import("./locales/en-MFJ6PZDC.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DD633LFI.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-2OQSNQOH.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-WEJIXYVV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-SB3LWSVU.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-OQPRLJNZ.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-CUZIWTHW.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RVMMEG2R.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-2GSUOACK.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-XUOSG6Q4.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-AJTDEQPL.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-SU7HHZZL.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-YQYP66LN.js"),"./locales/kaa.json":()=>import("./locales/kaa-LETQMP6Q.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-74RKMK6M.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-NTU2ICWV.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-TMFOMOGA.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-UEOM2JLS.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-CAROSSCD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-77PPHO6F.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-3ZV2DMGI.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-O3BV6LV6.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5BOYG2HG.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-VNTJC5HN.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-VXMK7ROD.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-VDGPADYS.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-KXL6M4X5.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-RGWUVB47.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-IZ6OXN22.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-B67CTIJG.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-7TDBEFE2.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-FZIKQ3LJ.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-SEO6CHTN.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-AEY3EXCZ.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-U3CP6CC4.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-CR3WQWNI.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-ADM3SECR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-WJMKK3MZ.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-M765ZUT2.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-OSKPFY3U.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-ILVRWK2W.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-EJPTEYM2.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-JTE2W2SN.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-KRY7YSP6.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-SIQXC37Q.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LEZ3HWVD.js")});var ML=85,Go={code:"en",label:"English"},Ci=[Go,...[{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=>Ly[e.code]>=ML).sort((e,o)=>e.label>o.label?1:-1)],Rc="__test__";kL()&&Ci.unshift({code:Rc,label:"test language"},{code:`${Rc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var wi=Go,Hc={},Nc=async e=>{if(wi=e,document.documentElement.dir=wi.rtl?"rtl":"ltr",document.documentElement.lang=wi.code,e.code.startsWith(Rc))Hc={};else try{Hc=await SL(`./locales/${wi.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Hc=bu}Qe.set(o0,e.code)},En=()=>wi,t0=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},h=(e,o,t)=>{if(wi.code.startsWith(Rc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=t0(Hc,n)||t0(bu,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(w.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},o0=ge(Go.code),Ie=()=>{let e=Ii(o0);return{t:h,langCode:e}};import PL from"clsx";import Je from"react";import{THEME as AL}from"@excalidraw/common";import{Fragment as Se,jsx as f,jsxs as R}from"react/jsx-runtime";var xo=e=>"var(--icon-fill-color)",n0=e=>e===AL.LIGHT?"#fff":"#1e1e1e",L=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...l}=typeof o=="number"?{width:o}:o;return f("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:PL({"rtl-mirror":r}),style:i,...l,children:typeof e=="string"?f("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Ct={width:40,height:20},P$=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:3,y:8,width:18,height:4,rx:1}),f("line",{x1:12,y1:8,x2:12,y2:21}),f("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),f("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"})]}),z),Bc=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),f("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),f("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),r0=L(R("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),i0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"1"}),f("circle",{cx:"12",cy:"19",r:"1"}),f("circle",{cx:"12",cy:"5",r:"1"})]}),z),a0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),f("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),f("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),l0=L(R("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),f("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),f("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Cu=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M6.5 9.5l3.5 -3"}),f("path",{d:"M14 5.5l3 1.5"}),f("path",{d:"M18.5 10l-2.5 7"}),f("path",{d:"M13.5 17.5l-7 -5"})]}),z),Hr=L(R("g",{children:[f("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"}),f("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"}),f("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:f("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"})}),f("g",{mask:"url(#UnlockedIcon)",children:f("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),Si=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),f("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),s0=L(f("g",{fill:"currentColor",children:f("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),c0=L(R(Se,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),f("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"}),d0=L(R(Se,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),f("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"}),m0=L(R(Se,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),f("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"}),A$=L(f("g",{fill:"currentColor",children:f("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"}),Rr=L(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Un=L(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[f("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),f("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ki=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Mi=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),z),Pi=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"})]}),z),Fc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Ai=L(f("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),p0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),f("path",{d:"M16 7h4"}),f("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),Uo=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Wo=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),f("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),f("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),f("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),f("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),u0=L(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 7v-2h13v2"}),f("path",{d:"M10 5v14"}),f("path",{d:"M12 19h-4"}),f("path",{d:"M15 13v-1h6v1"}),f("path",{d:"M18 12v7"}),f("path",{d:"M17 19h2"})]}),z),Li=L(R("g",{strokeWidth:"1.25",children:[f("path",{d:"M12.5 6.667h.01"}),f("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"}),f("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),f("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),Oc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),Su=L(f("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),ku=L(f("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),h0=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M21 21l-6 -6"}),f("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"}),f("path",{d:"M3 4v4h4"})]}),z),pt=L(f("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),_i=L(R("g",{strokeWidth:"1.5",children:[f("polyline",{points:"12 16 18 10 12 4"}),f("polyline",{points:"8 4 2 10 8 16"})]}),me),_l=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),Dl=L(f("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Hl=L(f("g",{stroke:"currentColor",strokeLinejoin:"round",children:f("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),g0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),f("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),Nr=L(f("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),Di=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"}),f("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),f0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"}),f("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),zc=L(f("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),b0=L(f("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),x0=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),y0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),f("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),Gc=L(f("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Rl=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),E0=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}),v0=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}),Hi=L(f("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),L$=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}),_$=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"),Ri=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),f("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"}),f("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"})]}),z),T0=L(f("g",{strokeWidth:1.5,children:f("path",{d:"M6 18l12 -12"})}),z),Uc=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15 8h.01"}),f("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),f("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),f("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),f("path",{d:"M19 16v6"}),f("path",{d:"M22 19l-3 3l-3 -3"})]}),z),I0=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}),D$=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}),H$=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}),w0=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"),R$=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"),Mu=L(f("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Pu=L(f("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),C0=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}),S0=L(f("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),N$=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"),B$=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(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 14v-11"}),f("path",{d:"M9 6l3 -3l3 3"})]}),z),O$=L(R(Se,{children:[f("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"}),f("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}),z$=L(f("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}),k0=R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 10l0 10"}),f("path",{d:"M12 10l4 4"}),f("path",{d:"M12 10l-4 4"}),f("path",{d:"M4 4l16 0"})]}),M0=R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 5l0 14"}),f("path",{d:"M16 9l-4 -4"}),f("path",{d:"M8 9l4 -4"})]}),Au=L(M0,z),Lu=L(M0,{...z,style:{transform:"rotate(180deg)"}}),_u=L(k0,z),Du=L(k0,{...z,style:{transform:"rotate(180deg)"}}),Hu=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ru=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Nu=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Bu=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),P0=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),A0=L(R(Se,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Fu=L(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),f("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Ou=L(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),f("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Wc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"9",cy:"7",r:"4"}),f("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),f("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),f("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),G$=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"),L0=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"),Qt=L(R(Se,{children:[f("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M15 5 5 15M5 5l10 10"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),U$=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}),W$=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}),Y$=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}),Yc=L(R(Se,{children:[f("path",{d:"M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48z"}),f("path",{d:"M216 288h-42.7L192 269.3l18.7 18.7zM192 224l-64 64h40v64h48v-64h40l-64-64z"})]}),{width:384,height:512}),zu=Je.memo(({theme:e})=>L(R(Se,{children:[f("path",{d:"M25 26H111V111H25",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),R("g",{fill:n0(e),stroke:xo(e),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Gu=Je.memo(({theme:e})=>L(R(Se,{children:[f("path",{d:"M25 26H111V111H25",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),R("g",{fill:n0(e),stroke:xo(e),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),f("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),_0=L(f("g",{strokeWidth:1.25,children:f("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),D0=L(R(Se,{children:[f("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"}),f("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:f("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"})}),f("g",{mask:"url(#FillHachureIcon)",children:f("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),H0=L(R(Se,{children:[R("g",{clipPath:"url(#a)",children:[f("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"}),f("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:f("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"})}),f("g",{mask:"url(#FillCrossHatchIcon)",children:f("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"})})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),R0=L(R(Se,{children:[f("g",{clipPath:"url(#a)",children:f("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"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Uu=L(f(Se,{children:f("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),N0=L(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),B0=L(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),V$=Je.memo(({theme:e})=>L(f("path",{d:"M6 10H34",stroke:xo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),F0=L(R("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12h2"}),f("path",{d:"M17 12h2"}),f("path",{d:"M11 12h2"})]}),z),O0=L(R("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v.01"}),f("path",{d:"M8 12v.01"}),f("path",{d:"M12 12v.01"}),f("path",{d:"M16 12v.01"}),f("path",{d:"M20 12v.01"})]}),z),z0=L(f("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),G0=L(f("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),U0=L(f("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),W0=L(R("svg",{strokeWidth:"1.5",children:[f("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"}),f("path",{d:"M13.3333 3.33331V3.34331"}),f("path",{d:"M16.6667 3.33331V3.34331"}),f("path",{d:"M16.6667 6.66669V6.67669"}),f("path",{d:"M16.6667 10V10.01"}),f("path",{d:"M3.33334 13.3333V13.3433"}),f("path",{d:"M16.6667 13.3333V13.3433"}),f("path",{d:"M3.33334 16.6667V16.6767"}),f("path",{d:"M6.66666 16.6667V16.6767"}),f("path",{d:"M10 16.6667V16.6767"}),f("path",{d:"M13.3333 16.6667V16.6767"}),f("path",{d:"M16.6667 16.6667V16.6767"})]}),me),Y0=L(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),f("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),f("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),f("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),f("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),f("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),f("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),f("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),f("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),f("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),f("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),f("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),V0=Je.memo(({flip:e=!1})=>L(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[f("path",{d:"M7,11 H19"}),f("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Ct)),X0=Je.memo(({flip:e=!1})=>L(f("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Ct)),K0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[f("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),f("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Ct)),$0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[f("path",{d:"M7,11 H23"}),f("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Ct)),Z0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[f("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),f("circle",{cx:"29",cy:"11",r:"4"})]}),Ct)),j0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[f("path",{d:"M7,11 H25",strokeLinecap:"round"}),f("circle",{cx:"29",cy:"11",r:"4"})]}),Ct)),q0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[f("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),f("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Ct)),J0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[f("path",{d:"M7,11 H21"}),f("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Ct)),Q0=Je.memo(({flip:e=!1})=>L(f("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:f("path",{d:"M11,11 H31 M31,5 V17"})}),Ct)),eE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,5 V17"})}),Ct)),tE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Ct)),oE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Ct)),nE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Ct)),rE=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),f("circle",{cx:"15",cy:"11",r:"4"})]}),Ct)),iE=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),f("circle",{cx:"23",cy:"11",r:"4"})]}),Ct)),aE=L(R(Se,{children:[f("g",{clipPath:"url(#a)",children:f("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"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),lE=L(R(Se,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),sE=L(R(Se,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),cE=L(f(Se,{children:f("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Br=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 7v-2h13v2"}),f("path",{d:"M10 5v14"}),f("path",{d:"M12 19h-4"}),f("path",{d:"M15 13v-1h6v1"}),f("path",{d:"M18 12v7"}),f("path",{d:"M17 19h2"})]}),z),dE=L(f(Se,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 12h10"}),f("path",{d:"M7 5v14"}),f("path",{d:"M17 5v14"}),f("path",{d:"M15 19h4"}),f("path",{d:"M15 5h4"}),f("path",{d:"M5 19h4"}),f("path",{d:"M5 5h4"})]})}),z),Nl=L(f(Se,{children:f("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),Wu=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 8l-4 4l4 4"}),f("path",{d:"M17 8l4 4l-4 4"}),f("path",{d:"M14 4l-4 16"})]}),z),Vc=Wu,mE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),f("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),pE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),f("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),uE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),hE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),f("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),gE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),f("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),fE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),f("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),f("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Xc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M21 19h-18l9 -15"}),f("path",{d:"M20.615 15.171h.015"}),f("path",{d:"M19.515 11.771h.015"}),f("path",{d:"M17.715 8.671h.015"}),f("path",{d:"M15.415 5.971h.015"})]}),z),bE=L(f("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}),X$=L(f("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"})),Ni=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),f("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),f("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),f("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"})]}),z),Yu=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),f("path",{d:"M7 11l5 5l5 -5"}),f("path",{d:"M12 4l0 12"})]}),z),Bi=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),xE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("path",{d:"M9.15 14.85l8.85 -10.85"}),f("path",{d:"M6 4l8.85 10.85"})]}),z),yE=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),f("path",{d:"M12 17l0 .01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),K$=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 4v16l13 -8z"})]}),z),$$=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),z),EE=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12l5 5l10 -10"})]}),z),Kc=L(R(Se,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 9v4"}),f("path",{d:"M12 17h.01"})]}),z),vE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11 7l6 6"}),f("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"})]}),z),Bl=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3l-4 7h8z"}),f("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("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"})]}),z),yo=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 7l16 0"}),f("path",{d:"M4 17l16 0"}),f("path",{d:"M7 4l0 16"}),f("path",{d:"M17 4l0 16"})]}),z),Fi=L(f("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"})),TE=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),f("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),z),IE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),f("path",{d:"M4 15l8 4l8 -4"}),f("path",{d:"M12 4v7"}),f("path",{d:"M15 8l-3 3l-3 -3"})]}),z),Wn=L(R("g",{strokeWidth:"1.25",children:[f("path",{d:"M4.16602 10H15.8327"}),f("path",{d:"M12.5 13.3333L15.8333 10"}),f("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),Yo=L(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[f("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"}),f("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),Fr=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z"}),f("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),f("path",{d:"M15 6l3 3"}),f("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"}),f("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"})]}),z),Z$=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z"}),f("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),f("path",{d:"M15 6l3 3"}),f("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"}),f("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"})]}),z),j$=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),f("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),f("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"}),f("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),f("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),f("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"})]}),z),wE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),f("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),f("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),f("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),Oi=L(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),f("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"})]}),z),CE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),f("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"}),f("path",{d:"M3 3l18 18"})]}),z),SE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),f("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),f("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),f("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),kE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),f("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),f("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),f("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Kt=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),f("path",{d:"M21 21l-6 -6"})]}),z),ME=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),f("path",{d:"M12 7v5l3 3"}),f("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),PE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 8l0 4l2 2"}),f("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),z),AE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M5 10a7 7 0 0 0 14 0"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),z),LE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 3l18 18"}),f("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"}),f("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),z),Fl=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),_E=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 20v.01"}),f("path",{d:"M16 20v.01"}),f("path",{d:"M8 20v.01"}),f("path",{d:"M4 20v.01"}),f("path",{d:"M4 16v.01"}),f("path",{d:"M4 12v.01"}),f("path",{d:"M4 8v.01"}),f("path",{d:"M4 4v.01"}),f("path",{d:"M8 4v.01"}),f("path",{d:"M12 4v.01"}),f("path",{d:"M16 4v.01"}),f("path",{d:"M20 4v.01"}),f("path",{d:"M20 8v.01"}),f("path",{d:"M20 12v.01"}),f("path",{d:"M20 16v.01"}),f("path",{d:"M20 20v.01"})]}),z),DE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 3v18"}),f("path",{d:"M19 21v-18"}),f("path",{d:"M5 7h14"}),f("path",{d:"M5 15h14"}),f("path",{d:"M8 13v4"}),f("path",{d:"M11 13v4"}),f("path",{d:"M16 13v4"}),f("path",{d:"M14 5v4"}),f("path",{d:"M11 5v4"}),f("path",{d:"M8 5v4"}),f("path",{d:"M3 21h18"})]}),z),HE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 12l18 0"}),f("path",{d:"M7 16l10 0l-10 5l0 -5"}),f("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),RE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3l0 18"}),f("path",{d:"M16 7l0 10l5 0l-5 -10"}),f("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Vu=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),f("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"})]}),z),$c=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),f("path",{d:"M22 22l-3 -3"}),f("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),f("path",{d:"M3 11v-1"}),f("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),f("path",{d:"M10 3h1"}),f("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),NE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),f("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"}),f("path",{d:"M10 15l2 6l2 -6"}),f("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),BE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),f("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),f("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),f("path",{d:"M11 21v-6l3 6v-6"})]}),z),FE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M4 8l5 0"}),f("path",{d:"M15 8l4 0"})]}),z),OE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),f("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),f("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),f("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),zE=L(R("g",{stroke:"currentColor",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),{...z,strokeWidth:1.5}),q$=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M21 12h-13l3 -3"}),f("path",{d:"M11 15l-3 -3"})]}),z),J$=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M10 9l5 3l-5 3z"})]}),z),GE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 6h18"}),f("path",{d:"M3 12h18"}),f("path",{d:"M3 18h18"}),f("path",{d:"M6 3v18"}),f("path",{d:"M12 3v18"}),f("path",{d:"M18 3v18"})]}),z),UE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),zi=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 18l12 -12"}),f("path",{d:"M18 10v-4h-4"})]}),z),Gi=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),f("path",{d:"M18 4l3 3l-3 3"})]}),z),Ui=L(R("g",{children:[f("path",{d:"M16,12L20,9L16,6"}),f("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Zc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 9l6 6l6 -6"})]}),z),WE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 15l6 -6l6 6"})]}),z),YE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 15l6 -6l6 6"})]}),z),Xu=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),f("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),jc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 7l0 10"}),f("path",{d:"M7 5l10 0"}),f("path",{d:"M7 19l10 0"}),f("path",{d:"M19 7l0 10"})]}),z),Q$=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),f("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),VE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 6l8 0"}),f("path",{d:"M16 6l4 0"}),f("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 12l2 0"}),f("path",{d:"M10 12l10 0"}),f("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 18l11 0"}),f("path",{d:"M19 18l1 0"})]}),z),XE=L(R("g",{strokeWidth:1,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),z),KE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),f("path",{d:"M13.5 6.5l4 4"})]}),z),eZ=L(R("g",{strokeWidth:1,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11 7l-5 5l5 5"}),f("path",{d:"M17 7l-5 5l5 5"})]}),z),$E=L(R("g",{strokeWidth:"1.75",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),f("path",{d:"M15 4l0 16"})]}),z),tZ=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),z),oZ=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 4l18 0"}),f("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),f("path",{d:"M12 16l0 4"}),f("path",{d:"M9 20l6 0"}),f("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),z),ZE=f("div",{style:{width:"1rem",height:"1rem"}}),jE=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("polyline",{points:"9 6 15 12 9 18"})]}),z),qE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 6l8 0"}),f("path",{d:"M16 6l4 0"}),f("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 12l2 0"}),f("path",{d:"M10 12l10 0"}),f("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 18l11 0"}),f("path",{d:"M19 18l1 0"})]}),z);import JE from"clsx";import $u,{useEffect as DL,useRef as QE,useState as HL}from"react";import{isPromiseLike as RL}from"@excalidraw/common";import LL from"react";import{jsx as Ku}from"react/jsx-runtime";var _L=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(LL.useRef(Date.now()).current%1600);return Ku("div",{className:`Spinner ${n}`,children:Ku("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Ku("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},it=_L;import{jsx as Ol,jsxs as zl}from"react/jsx-runtime";var J=$u.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=_e(),l=$u.useRef(null);$u.useImperativeHandle(r,()=>l.current);let a=`ToolIcon_size_${e}`,[s,c]=HL(!1),m=QE(!0),p=async u=>{let b="onClick"in n&&n.onClick?.(u);if(RL(b))try{c(!0),await b}catch(g){if(g instanceof Ei)console.warn(g);else throw g}finally{m.current&&c(!1)}};DL(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=QE(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return zl("button",{className:JE("ToolIcon_type_button",a,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:p,ref:l,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&zl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ol("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ol(it,{})]}),n.showAriaLabel&&zl("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Ol(it,{})]}),n.children]})}return zl("label",{className:JE("ToolIcon",t),title:n.title,onPointerDown:u=>{d.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[Ol("input",{className:`ToolIcon_type_radio ${a}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:d.current})},checked:n.checked,ref:l}),zl("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ol("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});J.displayName="ToolButton";var qc=[],O=e=>(qc=qc.concat(e),e);import{jsx as YL}from"react/jsx-runtime";var WL=(e,o,t)=>{let n=new Set(oe(e.filter(m=>zL(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),l=new Set;for(let m of n){let p=GL(e,m);for(let d of p)if(!l.has(d.id)){if(Jc(d)){let u=t1(d,i);u&&(r[u.id]=!0)}else r[d.id]=!0;l.add(d.id)}}let a=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=Jc(m)?t1(m,i):null;return m.frameId&&n.has(m.frameId)?(a=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let u=t.scene.getNonDeletedElementsMap().get(d.id);u&&OL(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),ed(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(a=!1,Jc(m)||(r[m.id]=!0),ed(m,{frameId:null})):Jc(m)&&o.selectedElementIds[m.containerId]?ed(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(a&&o.editingGroupId){let m=qu(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(b=>b===o.editingGroupId),u=p.groupIds[d+1];if(u){let b=qu(s,u).filter(g=>!g.isDeleted);b.length>1&&(c=u,b.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...o,...UL({selectedElementIds:r,editingGroupId:c},s,o,null)}}},o1=(e,o)=>{if(e.editingGroupId){let t=qu(ju(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Gl=O({name:"deleteSelectedElements",label:"labels.delete",icon:pt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:l,selectedPointsIndices:a}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=e1.getElement(l,s);if(!c||a==null)return!1;if(a.length>=c.points.length){let m=e.map(d=>d.id===c.id?ed(d,{isDeleted:!0}):d),p=o1(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:Qc.IMMEDIATELY}}return e1.deletePoints(c,n,a),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:a?.[0]>0?[a[0]-1]:[0]}},captureUpdate:Qc.IMMEDIATELY}}let{elements:r,appState:i}=WL(e,o,n);return FL(r,r.filter(l=>l.isDeleted)),i=o1(i,r),{elements:r,appState:{...i,activeTool:BL(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(ju(e),o)?Qc.IMMEDIATELY:Qc.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Zu.BACKSPACE||e.key===Zu.DELETE)&&!e[Zu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=at()==="mobile";return YL(J,{type:"button",icon:pt,title:h("labels.delete"),"aria-label":h("labels.delete"),onClick:()=>t(null),disabled:!Me(ju(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?NL:{}}})}});import{KEYS as Wi,CODES as Yi,isDarwin as td}from"@excalidraw/common";import{moveOneLeft as VL,moveOneRight as XL,moveAllLeft as KL,moveAllRight as $L}from"@excalidraw/element";import{CaptureUpdateAction as od}from"@excalidraw/element";import{isDarwin as n1}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,n1?h("keys.option"):h("keys.alt")).replace(/\bShift\b/i,h("keys.shift")).replace(/\b(Enter|Return)\b/i,h("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,n1?h("keys.cmd"):h("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,h("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,h("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,h("keys.delete"));import{jsx as nd}from"react/jsx-runtime";var Ju=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Lu,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:VL(e,o,n.scene),appState:o,captureUpdate:od.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Lu})}),Qu=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Au,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:XL(e,o,n.scene),appState:o,captureUpdate:od.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Au})}),eh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Du,trackEvent:{category:"element"},perform:(e,o)=>({elements:KL(e,o),appState:o,captureUpdate:od.IMMEDIATELY}),keyTest:e=>td?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_LEFT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendToBack")} \u2014 ${td?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Du})}),th=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:_u,trackEvent:{category:"element"},perform:(e,o)=>({elements:$L(e,o),appState:o,captureUpdate:od.IMMEDIATELY}),keyTest:e=>td?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_RIGHT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${h("labels.bringToFront")} \u2014 ${td?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:_u})});import{getNonDeletedElements as ZL}from"@excalidraw/element";import{LinearElementEditor as jL}from"@excalidraw/element";import{isLinearElement as qL,isTextElement as JL}from"@excalidraw/element";import{arrayToMap as QL,KEYS as r1}from"@excalidraw/common";import{selectGroupsForSelectedElements as e_}from"@excalidraw/element";import{CaptureUpdateAction as t_}from"@excalidraw/element";var oh=O({name:"selectAll",label:"labels.selectAll",icon:_E,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(JL(i)&&i.containerId)&&!i.locked).reduce((i,l)=>(i[l.id]=!0,i),{});return{appState:{...o,...e_({editingGroupId:null,selectedElementIds:r},ZL(e),o,n),selectedLinearElement:Object.keys(r).length===1&&qL(e[0])?new jL(e[0],QL(e)):null},captureUpdate:t_.IMMEDIATELY}},keyTest:e=>e[r1.CTRL_OR_CMD]&&e.key===r1.A});import{DEFAULT_GRID_SIZE as i1,KEYS as a1,MOBILE_ACTION_BUTTON_BG as o_,arrayToMap as l1}from"@excalidraw/common";import{getNonDeletedElements as s1}from"@excalidraw/element";import{LinearElementEditor as n_}from"@excalidraw/element";import{getSelectedElements as r_,getSelectionStateForElements as i_}from"@excalidraw/element";import{syncMovedIndices as a_}from"@excalidraw/element";import{duplicateElements as l_}from"@excalidraw/element";import{CaptureUpdateAction as c1}from"@excalidraw/element";import{jsx as s_}from"react/jsx-runtime";var nh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:_l,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let l=n_.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:l,captureUpdate:c1.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=l_({type:"in-place",elements:e,idsOfElementsToDuplicate:l1(r_(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:l,origIdToDuplicateId:a})=>{let s=l.frameId&&a.get(l.frameId);return{x:l.x+i1/2,y:l.y+i1/2,frameId:s??l.frameId}}});if(n.props.onDuplicate&&i){let l=n.props.onDuplicate(i,e);l&&(i=l)}return{elements:a_(i,l1(r)),appState:{...o,...i_(r,s1(i),o)},captureUpdate:c1.IMMEDIATELY}},keyTest:e=>e[a1.CTRL_OR_CMD]&&e.key===a1.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=at()==="mobile";return s_(J,{type:"button",icon:_l,title:`${h("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":h("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(s1(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?o_:{}}})}});import{pointFrom as u5}from"@excalidraw/math";import{useEffect as Ch,useMemo as Ph,useRef as Sh,useState as h5}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as g5,DEFAULT_ELEMENT_BACKGROUND_PICKS as f5,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as b5,DEFAULT_ELEMENT_STROKE_PICKS as x5,ARROW_TYPE as oo,DEFAULT_FONT_FAMILY as y5,DEFAULT_FONT_SIZE as E5,FONT_FAMILY as v5,ROUNDNESS as vd,STROKE_WIDTH as kh,VERTICAL_ALIGN as yd,KEYS as Ji,randomInteger as T5,arrayToMap as Ah,getFontFamilyString as I5,getLineHeight as w5,isTransparent as C5,reduceToCommonValue as S5,invariant as Lh,FONT_SIZES as Ed}from"@excalidraw/common";import{canBecomePolygon as k5,getNonDeletedElements as ov}from"@excalidraw/element";import{bindBindingElement as q1,calculateFixedPointForElbowArrowBinding as J1,updateBoundElements as M5}from"@excalidraw/element";import{LinearElementEditor as zr}from"@excalidraw/element";import{newElementWith as et}from"@excalidraw/element";import{getArrowheadForPicker as Q1}from"@excalidraw/element";import{getBoundTextElement as Qn,redrawTextBoundingBox as Ql}from"@excalidraw/element";import{isArrowElement as Td,isBoundToContainer as P5,isElbowArrow as nv,isLinearElement as Mh,isLineElement as ev,isTextElement as Nt,isUsingAdaptiveRadius as A5}from"@excalidraw/element";import{hasStrokeColor as L5}from"@excalidraw/element";import{updateElbowArrowPoints as _5,CaptureUpdateAction as tt,toggleLinePolygonState as D5}from"@excalidraw/element";import{deriveStylesPanelMode as H5}from"@excalidraw/common";import{isDevEnv as c_}from"@excalidraw/common";var d_=new Set(["command_palette","export"]),ce=(e,o,t,n)=>{try{if(typeof window>"u"||w.VITE_WORKER_ID||w.VITE_APP_ENABLE_TRACKING!=="true"||!d_.has(e)||c_())return;w.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import h_ from"clsx";import m_ from"clsx";import{forwardRef as p_}from"react";import{jsx as u_}from"react/jsx-runtime";var Vi=p_((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:l,icon:a,onClick:s}=e;return u_("button",{type:"button",ref:o,title:t,"data-testid":r,className:m_(n,{standalone:l,active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as f_,jsx as rh,jsxs as g_}from"react/jsx-runtime";var Rt=e=>rh(f_,{children:e.options.map(o=>e.type==="button"?rh(Vi,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):g_("label",{className:h_({active:e.value===o.value}),title:o.text,children:[rh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import{Popover as P1}from"radix-ui";import A1 from"clsx";import{useRef as L1,useEffect as xD}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as k1,COLOR_PALETTE as _1,isColorDark as M1,isWritableElement as yD}from"@excalidraw/common";import{jsx as b_}from"react/jsx-runtime";var rd=()=>b_("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as T_,useRef as I_}from"react";import{createPortal as w_}from"react-dom";import{EVENT as Vn,KEYS as C_,rgbToHex as S_}from"@excalidraw/common";import d1 from"react";var ih=d1.createContext(null),se=()=>d1.useContext(ih);import{useState as x_,useLayoutEffect as m1}from"react";import{THEME as y_}from"@excalidraw/common";var id=e=>{let[o,t]=x_(null),n=fe(),{theme:r}=se(),{container:i}=_e();return m1(()=>{o&&(o.className="",o.classList.add("hellixitboard",...e?.className?.split(/\s+/)||[]),o.classList.toggle("hellixitboard--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===y_.DARK))},[o,r,n.formFactor,e?.className]),m1(()=>{let l=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!l)return;let a=document.createElement("div");return l.appendChild(a),t(a),()=>{l.removeChild(a)}},[i,e?.parentSelector]),o};import{useEffect as E_}from"react";import{EVENT as ad}from"@excalidraw/common";function Xi(e,o,t){E_(()=>{function n(r){let i=r;if(!e.current)return;let l=t?.(i,e.current);if(l===!0)return;if(l===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(ad.POINTER_DOWN,n),document.addEventListener(ad.TOUCH_START,n),()=>{document.removeEventListener(ad.POINTER_DOWN,n),document.removeEventListener(ad.TOUCH_START,n)}},[e,o,t])}import{useRef as v_}from"react";var Yn=e=>{let o=v_(e);return Object.assign(o.current,e),o.current};import{jsx as k_}from"react/jsx-runtime";var Xn=ge(null),p1=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=id({className:"hellixitboard-eye-dropper-backdrop",parentSelector:".hellixitboard-eye-dropper-container"}),i=se(),l=Kn(),a=Ae(),s=oe(l,i),c=Yn({app:a,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=_e();T_(()=>{let d=p.current;if(!d||!a.canvas||!r)return;let u=!1,b=a.canvas.getContext("2d"),g=({clientX:C,clientY:M})=>{let k=b.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return S_(k[0],k[1],k[2])},x=({clientX:C,clientY:M,altKey:k})=>{d.style.top=`${M+20}px`,d.style.left=`${C+20}px`;let _=g({clientX:C,clientY:M});u&&c.onChange(n,_,c.selectedElements,{altKey:k}),d.style.background=_},v=()=>{c.onCancel()},y=(C,M)=>{c.onSelect(C,M)},E=C=>{u=!0,C.stopImmediatePropagation()},T=C=>{u=!1,m?.focus(),C.stopImmediatePropagation(),C.preventDefault(),y(g(C),C)},I=C=>{C.key===C_.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),v())};return r.tabIndex=-1,r.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(Vn.KEYDOWN,I),r.addEventListener(Vn.POINTER_DOWN,E),r.addEventListener(Vn.POINTER_UP,T),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(Vn.BLUR,v),()=>{u=!1,r.removeEventListener(Vn.KEYDOWN,I),r.removeEventListener(Vn.POINTER_DOWN,E),r.removeEventListener(Vn.POINTER_UP,T),window.removeEventListener("pointermove",x),window.removeEventListener(Vn.BLUR,v)}},[c,a.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=I_(null);return Xi(p,()=>{e()},d=>!!d.target.closest(".hellixitboard-eye-dropper-trigger, .hellixitboard-eye-dropper-backdrop")),r?w_(k_("div",{ref:p,className:"hellixitboard-eye-dropper-preview"}),r):null};import{Popover as ah}from"radix-ui";import L_ from"clsx";import __ from"react";import{isInteractive as D_}from"@excalidraw/common";import M_ from"react";import P_ from"clsx";import{jsx as A_}from"react/jsx-runtime";var Xe=M_.forwardRef(({children:e,padding:o,className:t,style:n},r)=>A_("div",{className:P_("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as lh,jsxs as H_}from"react/jsx-runtime";var Vo=__.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:l,onPointerLeave:a,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=fe(),d=p.formFactor==="phone"&&!p.isLandscape;return lh(ah.Portal,{container:o,children:H_(ah.Content,{ref:m,className:L_("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:a,onKeyDown:i,onFocusOutside:l,onPointerDownOutside:s,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!D_(document.activeElement)&&o.focus(),r()},children:[lh(Xe,{padding:3,style:n,children:t}),lh(ah.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as R_,useCallback as sh}from"react";var ld=()=>document.querySelector(".hellixitboard-wysiwyg"),sd=()=>{let e=ld();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ul=e=>{setTimeout(()=>{let o=ld();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},Wl=(e,o,t,n)=>{o&&n&&n();let r=o&&t?sd():null;e(),o&&t&&Ul(r)},u1=()=>{let[e,o]=R_(null),t=sh(()=>{let i=sd();o(i)},[]),n=sh(()=>{setTimeout(()=>{let i=ld();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=sh(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},h1=(e=100)=>{let o=ld();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import B_ from"clsx";import{useCallback as F_,useEffect as dh,useRef as f1,useState as O_}from"react";import{KEYS as mh,normalizeInputColor as z_}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as N_}from"@excalidraw/common";var $n=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Yl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ch=({color:e,palette:o})=>!Object.values(o).flat().includes(e),g1=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(l=>{if(l.isDeleted)return!1;let a=l[n[o]];return ch({color:a,palette:t})}),i=new Map;return r.forEach(l=>{let a=l[n[o]];i.has(a)?i.set(a,i.get(a)+1):i.set(a,1)}),[...i.entries()].sort((l,a)=>a[1]-l[1]).map(l=>l[0]).slice(0,N_)},eo=ge(null);import{Fragment as G_,jsx as cd,jsxs as b1}from"react/jsx-runtime";var x1=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=fe(),[l,a]=O_(e),[s,c]=Q(eo);dh(()=>{a(e)},[e]);let m=F_(g=>{let x=g.toLowerCase(),v=z_(x);v&&o(v),a(x)},[o]),p=f1(null),d=f1(null);dh(()=>{p.current&&p.current.focus()},[s]);let[u,b]=Q(Xn);return dh(()=>()=>{b(null)},[b]),b1("div",{className:"color-picker__input-label",children:[cd("div",{className:"color-picker__input-hash",children:"#"}),cd("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{m(g.target.value)},value:(l||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:g=>{g.key!==mh.TAB&&(g.key===mh.ESCAPE&&d.current?.focus(),g.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&b1(G_,{children:[cd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),cd("div",{ref:d,className:B_("hellixitboard-eye-dropper-trigger",{selected:u}),onClick:()=>b(g=>g?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${h("labels.eyeDropper")} \u2014 ${mh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:vE})]})]})};import gh,{useEffect as fh,useImperativeHandle as lD,useState as sD}from"react";import{EVENT as w1}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as cD,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as dD,KEYS as mD}from"@excalidraw/common";import V_ from"clsx";import{useEffect as X_,useRef as K_}from"react";import{isColorDark as U_}from"@excalidraw/common";import{jsxs as Y_}from"react/jsx-runtime";var W_=({color:e,keyLabel:o,isShade:t=!1})=>Y_("div",{className:"color-picker__button__hotkey-label",style:{color:U_(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Ki=W_;import{jsx as ph,jsxs as $_}from"react/jsx-runtime";var y1=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=Q(eo),l=K_(null);return X_(()=>{l.current&&l.current.focus()},[o,r]),ph("div",{className:"color-picker-content--default",children:e.map((a,s)=>$_("button",{ref:o===a?l:void 0,tabIndex:-1,type:"button",className:V_("color-picker__button color-picker__button--large has-outline",{active:o===a,"is-transparent":a==="transparent"||!a}),onClick:()=>{t(a),i("custom")},title:a,"aria-label":n,style:{"--swatch-color":a},children:[ph("div",{className:"color-picker__button-outline"}),ph(Ki,{color:a,keyLabel:s+1})]},s))})};import Z_ from"clsx";import{useEffect as j_,useRef as q_}from"react";import{jsx as uh,jsxs as Q_}from"react/jsx-runtime";var J_=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=$n({color:o,palette:e}),[l,a]=Q(eo),s=q_(null);return j_(()=>{s.current&&l==="baseColors"&&s.current.focus()},[i?.colorName,l]),uh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",u=Yl[p],b=h(`colors.${c.replace(/\d+/,"")}`,null,"");return Q_("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:Z_("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${b}${d.startsWith("#")?` ${d}`:""} \u2014 ${u}`,"aria-label":`${b} \u2014 ${u}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[uh("div",{className:"color-picker__button-outline"}),r&&uh(Ki,{color:d,keyLabel:u})]},c)})})},E1=J_;import{jsx as tD}from"react/jsx-runtime";var eD=({children:e})=>tD("div",{className:"color-picker__heading",children:e}),$i=eD;import oD from"clsx";import{useEffect as nD,useRef as rD}from"react";import{jsx as Vl,jsxs as v1}from"react/jsx-runtime";var T1=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=$n({color:e||"transparent",palette:t}),[i,l]=Q(eo),a=rD(null);if(nD(()=>{a.current&&i==="shades"&&a.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return Vl("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>v1("button",{ref:d===c&&i==="shades"?a:void 0,tabIndex:-1,type:"button",className:oD("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),l("shades")},children:[Vl("div",{className:"color-picker__button-outline"}),n&&Vl(Ki,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return v1("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Vl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Vl("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:h("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Zi,COLOR_PALETTE as iD,KEYS as Xl}from"@excalidraw/common";var hh=(e,o,t)=>{let n=Math.ceil(t/Zi);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Zi;return r>=t?o%Zi:r}case"ArrowUp":{let r=o-Zi,i=r<0?Zi*n+r:r;return i>=t?void 0:i}}},aD=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:l})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let a=Number(e.code.slice(-1))-1;return t(n[o.colorName][a]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Yl.includes(e.key)){let a=Yl.indexOf(e.key),s=Object.keys(n)[a],c=n[s],m=Array.isArray(c)?c[l]:c;return t(m),i("baseColors"),!0}return!1},I1=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:l,updateData:a,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[Xl.CTRL_OR_CMD])return!1;if(e.key===Xl.ESCAPE)return m(e),!0;if(e.key===Xl.ALT)return c(!0),!0;if(e.key===Xl.I)return c(),!0;let p=$n({color:n,palette:t});if(e.key===Xl.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(d).reduce((y,[E,T])=>(T&&y.push(E),y),[]),b=u.indexOf(o),g=e.shiftKey?-1:1,x=b+g>u.length-1?0:b+g<0?u.length-1:b+g,v=u[x];return v&&l(v),v==="custom"?r(i[0]):v==="baseColors"&&(Object.entries(t).find(([E,T])=>Array.isArray(T)?T.includes(n):T===n?E:null)||r(iD.black)),e.preventDefault(),e.stopPropagation(),!0}if(aD({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:l,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,u=hh(e.key,d,Zi);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,u=Object.keys(t),b=u.indexOf(d),g=hh(e.key,b,u.length);if(g!==void 0){let x=u[g],v=t[x];return r(Array.isArray(v)?v[s]:v),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,u=hh(e.key,d,i.length);if(u!==void 0){let b=i[u];return r(b),!0}}return!1};import{jsx as Zn,jsxs as dd}from"react/jsx-runtime";var C1=gh.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:l,showTitle:a,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=a?t==="elementStroke"?h("labels.stroke"):t==="elementBackground"?h("labels.background"):null:null,[u]=gh.useState(()=>t==="canvasBackground"?[]:g1(n,t,r)),[b,g]=Q(eo),x=$n({color:e,palette:r});fh(()=>{if(!b){let T=!!e&&ch({color:e,palette:r}),I=T&&!u.includes(e);g(I?null:T?"custom":x?.shade!=null?"shades":"baseColors")}},[b,e,r,g,x,u]);let[v,y]=sD(x?.shade??(t==="elementBackground"?cD:dD));fh(()=>{x?.shade!=null&&y(x.shade);let T=I=>{I.key===mD.ALT&&s(!1)};return document.addEventListener(w1.KEYUP,T,{capture:!0}),()=>{document.removeEventListener(w1.KEYUP,T,{capture:!0})}},[x,s]);let E=gh.useRef(null);return lD(p,()=>E.current),fh(()=>{E?.current?.focus()},[]),Zn("div",{role:"dialog","aria-modal":"true","aria-label":h("labels.colorPicker"),children:dd("div",{ref:E,onKeyDown:T=>{I1({event:T,activeColorPickerSection:b,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:g,updateData:i,activeShade:v,onEscape:c})&&(T.preventDefault(),T.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&Zn("div",{className:"color-picker__title",children:d}),!!u.length&&dd("div",{children:[Zn($i,{children:h("colorPicker.mostUsedCustomColors")}),Zn(y1,{colors:u,color:e,label:h("colorPicker.mostUsedCustomColors"),onChange:o})]}),dd("div",{children:[Zn($i,{children:h("colorPicker.colors")}),Zn(E1,{color:e,palette:r,onChange:o,activeShade:v,showHotKey:m})]}),dd("div",{children:[Zn($i,{children:h("colorPicker.shades")}),Zn(T1,{color:e,onChange:o,palette:r,showHotKey:m})]}),l]})})});import pD from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as uD,DEFAULT_CANVAS_BACKGROUND_PICKS as hD,DEFAULT_ELEMENT_BACKGROUND_PICKS as gD,DEFAULT_ELEMENT_STROKE_PICKS as fD,isColorDark as bD}from"@excalidraw/common";import{jsx as bh}from"react/jsx-runtime";var S1=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=fD),o==="elementBackground"&&(r=gD),o==="canvasBackground"&&(r=hD),n&&(r=n),r?bh("div",{className:"color-picker__top-picks",children:r.map(i=>bh("button",{className:pD("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!bD(i,uD)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:bh("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as to,jsxs as md}from"react/jsx-runtime";var ED=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=_1,updateData:l,getOpenPopup:a,appState:s})=>{let{container:c}=_e(),m=at(),p=m!=="full",d=m==="mobile",[,u]=Q(eo),[b,g]=Q(Xn),x=md("div",{children:[to($i,{children:h("colorPicker.hexCode")}),to(x1,{color:o||"",label:n,onChange:E=>{t(E)},colorPickerType:e,placeholder:h("colorPicker.color")})]}),v=L1(null),y=()=>{v.current?.focus()};return to(Vo,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:E=>{yD(E.target)||y(),E.preventDefault()},onPointerDownOutside:E=>{b&&E.preventDefault()},onClose:()=>{a()===e&&l({openPopup:null}),u(null),s.editingTextElement&&setTimeout(()=>{let E=document.querySelector(".hellixitboard-wysiwyg");E&&E.focus()},0)},children:i?to(C1,{ref:v,palette:i,color:o,onChange:E=>{let T=s.editingTextElement?sd():null;t(E),s.editingTextElement&&T&&Ul(T)},onEyeDropperToggle:E=>{g(T=>E?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):E===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:E=>{b?g(null):l({openPopup:null})},type:e,elements:r,updateData:l,showTitle:p,showHotKey:!d,children:x}):x})},vD=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let l=at(),a=l!=="full",s=l==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&h1(),r()};return md(P1.Trigger,{type:"button",className:A1("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!M1(o,k1),"compact-sizing":a,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?h("labels.showStroke"):h("labels.showBackground"),"data-openpopup":t,onClick:c,children:[to("div",{className:"color-picker__button-outline",children:!o&&T0}),a&&o&&n==="stroke"&&to("div",{className:"color-picker__button-background",children:to("span",{style:{color:o&&M1(o,k1)?"#fff":"#111"},children:XE})})]})},Kl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=_1,topPicks:l,updateData:a,appState:s})=>{let c=L1(s.openPopup);xD(()=>{c.current=s.openPopup},[s.openPopup]);let p=at()!=="full";return to("div",{children:md("div",{role:"dialog","aria-modal":"true",className:A1("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&to(S1,{activeColor:o,onChange:t,type:e,topPicks:l}),!p&&to(rd,{}),md(P1.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&a({openPopup:e})},children:[to(vD,{color:o,label:n,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?a({openPopup:null}):s.openPopup?a({openPopup:e}):a({openPopup:e})}}),s.openPopup===e&&to(ED,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:a,getOpenPopup:()=>c.current,appState:s})]})]})})};import{Popover as $D}from"radix-ui";import ZD from"clsx";import jD,{useCallback as qD,useMemo as JD}from"react";import{FONT_FAMILY as vh}from"@excalidraw/common";import OD,{useMemo as Jn,useState as zD,useRef as N1,useEffect as B1,useCallback as F1}from"react";import{arrayToList as GD,debounce as UD,FONT_FAMILY as Or,getFontFamilyString as WD}from"@excalidraw/common";import TD from"clsx";import ID from"react";import{jsx as wD,jsxs as CD}from"react/jsx-runtime";var pd=ID.forwardRef(({className:e,placeholder:o,onChange:t},n)=>CD("div",{className:TD("QuickSearch__wrapper",e),children:[Kt,wD("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import SD from"clsx";import{Children as kD}from"react";import{jsx as D1}from"react/jsx-runtime";var ud=({className:e,placeholder:o,children:t})=>{let n=!kD.count(t);return D1("div",{className:SD("ScrollableList__wrapper",e),role:"menu",children:n?D1("div",{className:"empty",children:o}):t})};import{jsx as MD,jsxs as PD}from"react/jsx-runtime";var H1=({children:e,className:o="",style:t,title:n})=>PD("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&MD("p",{className:"dropdown-menu-group-title",children:n}),e]}),$l=H1;H1.displayName="DropdownMenuGroup";import{THEME as BD}from"@excalidraw/common";import{DropdownMenu as FD}from"radix-ui";import AD,{useContext as LD}from"react";import{composeEventHandlers as _D}from"@excalidraw/common";var xh=AD.createContext({}),jn=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),hd=e=>{let o=LD(xh);return _D(e,t=>{o.onSelect?.(t)})};import{jsx as DD}from"react/jsx-runtime";var Zl=({children:e,...o})=>DD("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as RD,jsx as jl,jsxs as ND}from"react/jsx-runtime";var HD=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=fe();return ND(RD,{children:[o&&jl("div",{className:"dropdown-menu-item__icon",children:o}),jl("div",{style:e,className:"dropdown-menu-item__text",children:jl(Zl,{children:n})}),r&&jl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&jl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},qn=HD;import{jsx as gd}from"react/jsx-runtime";var yh=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:l,onSelect:a,...s})=>{let c=hd(a);return gd(FD.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:gd("button",{...s,value:t,className:jn(i,l),title:s.title??s["aria-label"],children:gd(qn,{icon:e,shortcut:r,badge:o,children:n})})})};yh.displayName="DropdownMenuItem";var ji={GREEN:"green",RED:"red",BLUE:"blue"},fd=({type:e=ji.BLUE,children:o})=>{let{theme:t}=Xo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===BD.LIGHT?"1.5px solid white":"none"};switch(e){case ji.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ji.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ji.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return gd("div",{className:"DropDownMenuItemBadge",style:n,children:o})};fd.displayName="DropdownMenuItemBadge";yh.Badge=fd;var St=yh;import{KEYS as qi}from"@excalidraw/common";var R1=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:l})=>{if(!e[qi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===qi.F)return o.current?.focus(),!0;if(e.key===qi.ESCAPE)return r(),!0;if(e.key===qi.ENTER)return t?.value&&i(t.value),!0;if(e.key===qi.ARROW_DOWN)return t?.next?l(t.next.value):n[0]?.value&&l(n[0].value),!0;if(e.key===qi.ARROW_UP)return t?.prev?l(t.prev.value):n[n.length-1]?.value&&l(n[n.length-1].value),!0};import{jsx as vn,jsxs as VD}from"react/jsx-runtime";var YD=e=>{switch(e){case Or.Excalifont:case Or.Virgil:return Uo;case Or.Nunito:case Or.Helvetica:return Nl;case Or["Lilita One"]:return dE;case Or["Comic Shanns"]:case Or.Cascadia:return Vc;default:return Nl}},O1=OD.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:l})=>{let{container:a}=_e(),s=Ae(),{fonts:c}=s,{showDeprecatedFonts:m}=Ko(),p=at(),[d,u]=zD(""),b=N1(null),g=Jn(()=>Array.from(Gn.registered.entries()).filter(([A,{metadata:H}])=>!H.private&&!H.fallback).map(([A,{metadata:H,fontFaces:F}])=>{let Y={value:A,icon:YD(A),text:F[0]?.fontFace?.family??"Unknown"};return H.deprecated&&Object.assign(Y,{deprecated:H.deprecated,badge:{type:ji.RED,placeholder:h("fontList.badge.old")}}),Y}).sort((A,H)=>A.text.toLowerCase()>H.text.toLowerCase()?1:-1),[]),x=Jn(()=>new Set(c.getSceneFamilies()),[e]),v=Jn(()=>g.filter(A=>x.has(A.value)),[g,x]),y=Jn(()=>g.filter(A=>!x.has(A.value)&&(m||!A.deprecated)),[g,x,m]),E=Jn(()=>GD([...v,...y].filter(A=>A.text?.toLowerCase().includes(d))),[v,y,d]),T=Jn(()=>{let A;return o?A=E.find(H=>H.value===o):e&&(A=E.find(H=>H.value===e)),!A&&d&&(E[0]?.value?n(E[0].value):r()),A},[o,e,d,E,n,r]),I=F1(A=>{let H=null;if(s.state.editingTextElement){let F=document.querySelector(".hellixitboard-wysiwyg");F&&(H={start:F.selectionStart,end:F.selectionEnd})}t(A),s.state.editingTextElement&&H&&setTimeout(()=>{let F=document.querySelector(".hellixitboard-wysiwyg");F&&H&&(F.focus(),F.selectionStart=H.start,F.selectionEnd=H.end)},0)},[t,s.state.editingTextElement]),C=F1(A=>{R1({event:A,inputRef:b,hoveredFont:T,filteredFonts:E,onSelect:I,onHover:n,onClose:l})&&(A.preventDefault(),A.stopPropagation())},[T,E,I,n,l]);B1(()=>(i(),()=>{l()}),[]);let M=Jn(()=>E.filter(A=>x.has(A.value)),[E,x]),k=Jn(()=>E.filter(A=>!x.has(A.value)),[E,x]),_=({font:A,order:H})=>{let F=N1(null),Y=A.value===T?.value,V=A.value===e;return B1(()=>{Y&&(H===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,H]),vn("button",{ref:F,type:"button",value:A.value,className:jn("",V,Y),title:A.text,tabIndex:V?0:-1,onClick:U=>{I(Number(U.currentTarget.value))},onMouseMove:()=>{T?.value!==A.value&&n(A.value)},children:vn(qn,{icon:A.icon,badge:A.badge&&vn(fd,{type:A.badge.type,children:A.badge.placeholder}),textStyle:{fontFamily:WD({fontFamily:A.value})},children:A.text})})},P=[];return M.length&&P.push(vn($l,{title:h("fontList.sceneFonts"),children:M.map((A,H)=>vn(_,{font:A,order:H},A.value))},"group_1")),k.length&&P.push(vn($l,{title:h("fontList.availableFonts"),children:k.map((A,H)=>vn(_,{font:A,order:H+M.length},A.value))},"group_2")),VD(Vo,{className:"properties-content",container:a,style:{width:"15rem"},onClose:()=>{l(),s.state.editingTextElement&&setTimeout(()=>{let A=document.querySelector(".hellixitboard-wysiwyg");A&&A.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&vn(pd,{ref:b,placeholder:h("quickSearch.placeholder"),onChange:UD(u,20)}),vn(ud,{className:"dropdown-menu fonts manual-hover",placeholder:h("fontList.empty"),children:P.length?P:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as XD}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as KD}from"@excalidraw/common";import{jsx as Eh}from"react/jsx-runtime";var z1=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...KD,width:"2rem",height:"2rem"}:{};return Eh(XD.Trigger,{asChild:!0,children:Eh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Eh(Vi,{standalone:!0,icon:Wo,title:h("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as ql,jsxs as G1}from"react/jsx-runtime";var U1=[{value:vh.Excalifont,icon:Uo,text:h("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:vh.Nunito,icon:Nl,text:h("labels.normal"),testId:"font-family-normal"},{value:vh["Comic Shanns"],icon:Vc,text:h("labels.code"),testId:"font-family-code"}],pte=new Set(U1.map(e=>e.value));var W1=jD.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:l,compactMode:a=!1})=>{let s=JD(()=>U1,[]),c=qD(m=>{m&&n(m)},[n]);return G1("div",{role:"dialog","aria-modal":"true",className:ZD("FontPicker__container",{"FontPicker__container--compact":a}),children:[!a&&ql("div",{className:"buttonList",children:ql(Rt,{type:"button",options:s,value:o,onClick:c})}),!a&&ql(rd,{}),G1($D.Root,{open:e,onOpenChange:l,children:[ql(z1,{selectedFontFamily:o,isOpened:e,compactMode:a}),e&&ql(O1,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>l(!0),onClose:()=>l(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as Th}from"radix-ui";import o5 from"clsx";import K1,{useEffect as n5,useMemo as r5}from"react";import{isArrowKey as i5,KEYS as Tn}from"@excalidraw/common";import{jsx as QD}from"react/jsx-runtime";var $o=({className:e,icon:o,size:t="1em"})=>QD("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as t5,jsx as Y1,jsxs as V1}from"react/jsx-runtime";var e5=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>V1(t5,{children:[V1("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Y1($o,{icon:o?WE:Zc})]}),o&&Y1("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Jl=e5;import{jsx as Zo,jsxs as xd}from"react/jsx-runtime";var a5=ge(!1),bd=4,l5="default",s5=e=>e.flatMap(o=>o.options),X1=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},c5=(e,o)=>e.some(t=>t.options.some(o)),d5=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/bd)},(t,n)=>o.options.slice(n*bd,n*bd+bd)));function m5({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:l}=_e(),[a,s]=Q(a5),c=[...e,...o],m=s5(c),p=d5([...e,...a?o:[]]),d=g=>{let x=m.find(v=>v.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&x)r(x.value),g.preventDefault();else if(g.key===Tn.TAB){let v=m.findIndex(E=>E.value===t),y=g.shiftKey?(m.length+v-1)%m.length:(v+1)%m.length;r(m[y].value)}else if(i5(g.key)){let v=En().rtl,y=m.findIndex(E=>E.value===t);if(y!==-1){let E=m.length,T=y;switch(g.key){case(v?Tn.ARROW_LEFT:Tn.ARROW_RIGHT):T=(y+1)%E;break;case(v?Tn.ARROW_RIGHT:Tn.ARROW_LEFT):T=(E+y-1)%E;break;case Tn.ARROW_DOWN:{let I=p.findIndex(M=>M.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let M=C.findIndex(P=>P.value===t),k=p[(I+1)%p.length],_=k[Math.min(M,k.length-1)]??m[y];r(_.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Tn.ARROW_UP:{let I=p.findIndex(M=>M.some(k=>k.value===t)),C=p[I];if(I!==-1&&C){let M=C.findIndex(P=>P.value===t),k=p[(p.length+I-1)%p.length],_=k[Math.min(M,k.length-1)]??m[y];r(_.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(m[T].value)}g.preventDefault()}else(g.key===Tn.ESCAPE||g.key===Tn.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};n5(()=>{c5(o,g=>g.value===t)&&s(!0)},[t,o,s]);let u=g=>Zo("div",{className:"picker-content",children:g.map(x=>xd("button",{type:"button",className:o5("picker-option",{active:t===x.value}),onClick:()=>{r(x.value)},title:x.keyBinding?`${x.text} \u2014 ${x.keyBinding.toUpperCase()}`:x.text,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:v=>{t===x.value&&setTimeout(()=>{v?.focus()},0)},children:[x.icon,x.keyBinding&&Zo("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),b=g=>g.map((x,v)=>x.name===l5?Zo(K1.Fragment,{children:u(x.options)},`${x.name}-${v}`):xd("div",{className:"picker-section",children:[Zo("div",{className:"picker-section-label",children:x.name}),u(x.options)]},`${x.name}-${v}`));return Zo(Th.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:d,collisionBoundary:l??void 0,children:xd("div",{className:"picker-sections",children:[b(e),o.length>0&&Zo(Jl,{label:h("labels.more_options"),open:a,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:Zo("div",{className:"picker-sections",children:b(o)})})]})})}function Ih({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,l]=K1.useState(!1),a=r5(()=>X1(t,s=>s.value===e)??X1(n??[],s=>s.value===e),[t,n,e]);return Zo("div",{children:xd(Th.Root,{open:i,onOpenChange:s=>l(s),children:[Zo(Th.Trigger,{type:"button","aria-label":o,onClick:()=>l(!i),className:i?"active":"",children:a?.icon}),i&&Zo(m5,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{l(!1)}})]})})}import $1,{useEffect as p5}from"react";import{jsx as wh,jsxs as Z1}from"react/jsx-runtime";var j1=({updateData:e,app:o,testId:t})=>{let n=$1.useRef(null),r=$1.useRef(null),i=o.scene.getSelectedElements(o.state),l=!0,a=i.at(0),c=i.reduce((m,p)=>(m!=null&&m!==p.opacity&&(l=!1),m==null||m>p.opacity?p.opacity:m),a?.opacity??null)??o.state.currentItemOpacity;return p5(()=>{if(n.current&&r.current){let m=n.current,p=r.current,d=m.offsetWidth,u=15,b=c/100*(d-u)+u/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),Z1("label",{className:"control-label",children:[h("labels.opacity"),Z1("div",{className:"range-wrapper",children:[wh("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),wh("div",{className:"value-bubble",ref:r,children:c!==0?c:null}),wh("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Id,jsx as q,jsxs as Ze}from"react/jsx-runtime";var rv=.1,Qi=e=>{let o=H5(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},bt=(e,o,t,n=!1)=>{let r=Ah(oe(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},xt=function(e,o,t,n,r){let i=o.state.editingTextElement,l=ov(e),a=null;if(i&&(a=t(i)),!a)if(Me(l,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));a=S5(m,t)??(typeof r=="function"?r(!0):r)}else a=typeof r=="function"?r(!1):r;return a},R5=(e,o,t)=>P5(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),_h=(e,o,t,n,r)=>{let i=new Set,l=bt(e,o,a=>{if(Nt(a)){let s=n(a);i.add(s);let c=et(a,{fontSize:s});return Ql(c,t.scene.getContainerElement(a),t.scene),c=R5(a,c,t.scene),c}return a},!0);return oe(e,o,{includeBoundTextElement:!0}).forEach(a=>{Nt(a)&&M5(a,t.scene)}),{elements:l,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:tt.IMMEDIATELY}},N5=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:bt(e,o,n=>L5(n.type)?et(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?tt.IMMEDIATELY:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Qi(n);return Ze(Id,{children:[i==="full"&&q("h3",{"aria-hidden":"true",children:h("labels.stroke")}),q(Kl,{topPicks:x5,palette:b5,type:"elementStroke",label:h("labels.stroke"),color:xt(e,n,l=>l.strokeColor,!0,l=>l?null:o.currentItemStrokeColor),onChange:l=>t({currentItemStrokeColor:l}),elements:e,appState:o,updateData:t})]})}}),B5=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:tt.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!C5(t.currentItemBackgroundColor)&&i.every(a=>ev(a)&&k5(a.points))){let a=Ah(i);r=e.map(s=>a.has(s.id)&&ev(s)?et(s,{backgroundColor:t.currentItemBackgroundColor,...D5(s,!0)}):s)}else r=bt(e,o,a=>et(a,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Qi(n);return Ze(Id,{children:[i==="full"&&q("h3",{"aria-hidden":"true",children:h("labels.background")}),q(Kl,{topPicks:f5,palette:g5,type:"elementBackground",label:h("labels.background"),color:xt(e,n,l=>l.backgroundColor,!0,l=>l?null:o.currentItemBackgroundColor),onChange:l=>t({currentItemBackgroundColor:l}),elements:e,appState:o,updateData:t})]})}}),F5=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ce("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:bt(e,o,r=>et(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=oe(e,o),i=r.length>0&&r.every(l=>l.fillStyle==="zigzag");return Ze("fieldset",{children:[q("legend",{children:h("labels.fill")}),q("div",{className:"buttonList",children:q(Rt,{type:"button",options:[{value:"hachure",text:`${i?h("labels.zigzag"):h("labels.hachure")} (${N("Alt-Click")})`,icon:i?_0:D0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:h("labels.crossHatch"),icon:H0,testId:"fill-cross-hatch"},{value:"solid",text:h("labels.solid"),icon:R0,testId:"fill-solid"}],value:xt(e,n,l=>l.fillStyle,l=>l.hasOwnProperty("fillStyle"),l=>l?null:o.currentItemFillStyle),onClick:(l,a)=>{let s=a.altKey&&l==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":l;t(s)}})})]})}}),O5=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.strokeWidth")}),q("div",{className:"buttonList",children:q(Rt,{group:"stroke-width",options:[{value:kh.thin,text:h("labels.thin"),icon:Uu,testId:"strokeWidth-thin"},{value:kh.bold,text:h("labels.bold"),icon:N0,testId:"strokeWidth-bold"},{value:kh.extraBold,text:h("labels.extraBold"),icon:B0,testId:"strokeWidth-extraBold"}],value:xt(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),z5=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{seed:T5(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.sloppiness")}),q("div",{className:"buttonList",children:q(Rt,{group:"sloppiness",options:[{value:0,text:h("labels.architect"),icon:z0},{value:1,text:h("labels.artist"),icon:G0},{value:2,text:h("labels.cartoonist"),icon:U0}],value:xt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),xoe=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.strokeStyle")}),q("div",{className:"buttonList",children:q(Rt,{group:"strokeStyle",options:[{value:"solid",text:h("labels.strokeStyle_solid"),icon:Uu},{value:"dashed",text:h("labels.strokeStyle_dashed"),icon:F0},{value:"dotted",text:h("labels.strokeStyle_dotted"),icon:O0}],value:xt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),G5=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>q(j1,{updateData:o,app:e,testId:"opacity"})}),U5=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,()=>(Lh(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Qi(n);return Ze("fieldset",{children:[q("legend",{children:h("labels.fontSize")}),q("div",{className:"buttonList",children:q(Rt,{group:"font-size",options:[{value:Ed.sm,text:h("labels.small"),icon:aE,testId:"fontSize-small"},{value:Ed.md,text:h("labels.medium"),icon:lE,testId:"fontSize-medium"},{value:Ed.lg,text:h("labels.large"),icon:sE,testId:"fontSize-large"},{value:Ed.xl,text:h("labels.veryLarge"),icon:cE,testId:"fontSize-veryLarge"}],value:xt(e,n,l=>{if(Nt(l))return l.fontSize;let a=Qn(l,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},l=>Nt(l)||Qn(l,n.scene.getNonDeletedElementsMap())!==null,l=>l?null:o.currentItemFontSize||E5),onChange:l=>{Wl(()=>t(l),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),Dh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Br,trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,r=>Math.round(1/(1+rv)*r.fontSize)),keyTest:e=>e[Ji.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ji.CHEVRON_LEFT||e.key===Ji.COMMA)}),Hh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Br,trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,r=>Math.round(r.fontSize*(1+rv))),keyTest:e=>e[Ji.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ji.CHEVRON_RIGHT||e.key===Ji.PERIOD)}),W5=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:l,...a}=t;if(i)return{elements:bt(e,o,g=>{let x=r?.get(g.id);return x?et(g,{...x}):g},!0),appState:{...o,...a},captureUpdate:tt.NEVER};Lh(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=tt.EVENTUALLY,p,d=!1;if(s)p=s,m=tt.IMMEDIATELY;else if(c){p=c,m=tt.EVENTUALLY;let b=oe(e,o,{includeBoundTextElement:!0}).filter(g=>Nt(g));if(b.length>200)d=!0;else{let g=0,x=0;for(;g<b.length&&x<5e3;){let v=b[g];x+=v?.originalText.length||0,g++}x>5e3&&(d=!0)}}let u={appState:{...o,...a},captureUpdate:m};if(p&&!d){let b=new Map,g=new Set,x=!1,v=Array.from(Gn.loadedFontsCache.values()),y=Object.entries(v5).find(([I,C])=>C===p)?.[0];c&&y&&v.some(I=>I.startsWith(y))&&(x=!0),Object.assign(u,{elements:bt(e,o,I=>{if(Nt(I)&&(I.fontFamily!==p||s)){let C=et(I,{fontFamily:p,lineHeight:w5(p)}),M=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return l&&k&&M&&n.scene.mutateElement(k,{...M}),x||(g=new Set([...g,...Array.from(C.originalText)])),b.set(C,k),C}return I},!0)});let E=`10px ${I5({fontFamily:p})}`,T=Array.from(g.values()).join();if(x||window.document.fonts.check(E,T))for(let[I,C]of b)Ql(I,C,n.scene);else window.document.fonts.load(E,T).then(I=>{for(let[C,M]of b){let k=n.scene.getElement(C.id),_=M?n.scene.getElement(M.id):null;k&&Ql(k,_,n.scene)}n.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=Sh(new Map),i=Sh(null),[l,a]=h5({}),s=Sh(!0),{stylesPanelMode:c,isCompact:m}=Qi(t),p=Ph(()=>{let d=(u,b)=>xt(u,t,g=>{if(Nt(g))return g.fontFamily;let x=Qn(g,b);return x?x.fontFamily:null},g=>Nt(g)||Qn(g,b)!==null,g=>g?null:o.currentItemFontFamily||y5);return l.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!l.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[l.openPopup,o,e,t]);return Ch(()=>{i.current=p},[p]),Ch(()=>{Object.keys(l).length&&(n(l),a({}))},[l]),Ch(()=>(s.current=!1,()=>{s.current=!0}),[]),Ze(Id,{children:[c==="full"&&q("legend",{children:h("labels.fontFamily")}),q(W1,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{Wl(()=>{a({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{a({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{a({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:u}=o;if(u?.type==="text"){let b=t.scene.getElement(u.id);r.current.set(u.id,et(b||u,{},!0))}else{let b=oe(e,o,{includeBoundTextElement:!0});for(let g of b)r.current.set(g.id,et(g,{},!0))}a({...l,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};a({...u}),r.current.clear(),m&&o.editingTextElement&&Ul(null)}}})]})}}),Y5=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:bt(e,o,r=>{if(Nt(r)){let i=et(r,{textAlign:t});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:l}=Qi(n);return Ze("fieldset",{children:[q("legend",{children:h("labels.textAlign")}),q("div",{className:"buttonList",children:q(Rt,{group:"text-align",options:[{value:"left",text:h("labels.left"),icon:mE,testId:"align-left"},{value:"center",text:h("labels.center"),icon:pE,testId:"align-horizontal-center"},{value:"right",text:h("labels.right"),icon:uE,testId:"align-right"}],value:xt(e,n,a=>{if(Nt(a))return a.textAlign;let s=Qn(a,i);return s?s.textAlign:null},a=>Nt(a)||Qn(a,i)!==null,a=>a?null:o.currentItemTextAlign),onChange:a=>{Wl(()=>t(a),l,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),V5=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:bt(e,o,r=>{if(Nt(r)){let i=et(r,{verticalAlign:t});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Qi(n);return q("fieldset",{children:q("div",{className:"buttonList",children:q(Rt,{group:"text-align",options:[{value:yd.TOP,text:h("labels.alignTop"),icon:q(hE,{theme:o.theme}),testId:"align-top"},{value:yd.MIDDLE,text:h("labels.centerVertically"),icon:q(fE,{theme:o.theme}),testId:"align-middle"},{value:yd.BOTTOM,text:h("labels.alignBottom"),icon:q(gE,{theme:o.theme}),testId:"align-bottom"}],value:xt(e,n,l=>{if(Nt(l)&&l.containerId)return l.verticalAlign;let a=Qn(l,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},l=>Nt(l)||Qn(l,n.scene.getNonDeletedElementsMap())!==null,l=>l?null:yd.MIDDLE),onChange:l=>{Wl(()=>t(l),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),yoe=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>nv(n)?n:et(n,{roundness:t==="round"?{type:A5(n.type)?vd.ADAPTIVE_RADIUS:vd.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let l=xi(ov(e),o).some(a=>a.roundness?.type===vd.LEGACY);return Ze("fieldset",{children:[q("legend",{children:h("labels.edges")}),Ze("div",{className:"buttonList",children:[q(Rt,{group:"edges",options:[{value:"sharp",text:h("labels.sharp"),icon:W0},{value:"round",text:h("labels.round"),icon:Y0}],value:xt(e,n,a=>l?null:a.roundness?"round":"sharp",a=>!Td(a)&&a.hasOwnProperty("roundness"),a=>a?null:o.currentItemRoundness),onChange:a=>t(a)}),r("togglePolygon")]})]})}}),tv=e=>({visibleSections:[{name:"default",options:[{value:null,text:h("labels.arrowhead_none"),keyBinding:"q",icon:q(V0,{flip:e})},{value:"arrow",text:h("labels.arrowhead_arrow"),keyBinding:"w",icon:q(X0,{flip:e})},{value:"triangle",text:h("labels.arrowhead_triangle"),icon:q(K0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:h("labels.arrowhead_triangle_outline"),icon:q($0,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:h("labels.arrowhead_circle"),keyBinding:"a",icon:q(Z0,{flip:e})},{value:"circle_outline",text:h("labels.arrowhead_circle_outline"),keyBinding:"s",icon:q(j0,{flip:e})},{value:"diamond",text:h("labels.arrowhead_diamond"),icon:q(q0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:h("labels.arrowhead_diamond_outline"),icon:q(J0,{flip:e}),keyBinding:"f"},{value:"bar",text:h("labels.arrowhead_bar"),keyBinding:"z",icon:q(Q0,{flip:e})}]},{name:h("labels.cardinality"),options:[{value:"cardinality_one",text:h("labels.arrowhead_cardinality_one"),icon:q(eE,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:h("labels.arrowhead_cardinality_many"),icon:q(tE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:h("labels.arrowhead_cardinality_one_or_many"),icon:q(oE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:h("labels.arrowhead_cardinality_exactly_one"),icon:q(nE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:h("labels.arrowhead_cardinality_zero_or_one"),icon:q(rE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:h("labels.arrowhead_cardinality_zero_or_many"),icon:q(iE,{flip:e}),keyBinding:null}]}]}),Eoe=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Lh(t,"actionChangeArrowhead: value must be defined"),{elements:bt(e,o,n=>{if(Mh(n)){let{position:r,type:i}=t;if(r==="start")return et(n,{startArrowhead:i});if(r==="end")return et(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=En().rtl,i=Ph(()=>tv(!r),[r]),l=Ph(()=>tv(!!r),[r]);return Ze("fieldset",{children:[q("legend",{children:h("labels.arrowheads")}),Ze("div",{className:"iconSelectList buttonList",children:[q(Ih,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:xt(e,n,a=>Mh(a)&&yi(a.type)?Q1(a.startArrowhead):o.currentItemStartArrowhead,!0,a=>a?null:o.currentItemStartArrowhead),onChange:a=>t({position:"start",type:a})}),q(Ih,{visibleSections:l.visibleSections,hiddenSections:l.hiddenSections,label:"arrowhead_end",value:xt(e,n,a=>Mh(a)&&yi(a.type)?Q1(a.endArrowhead):o.currentItemEndArrowhead,!0,a=>a?null:o.currentItemEndArrowhead),onChange:a=>t({position:"end",type:a})})]})]})}}),X5=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>Ze("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),voe=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=bt(e,o,a=>{if(!Td(a))return a;let s=n.scene.getNonDeletedElementsMap(),c=zr.getPointAtIndexGlobalCoordinates(a,0,s),m=zr.getPointAtIndexGlobalCoordinates(a,-1,s),p=et(a,{x:t===oo.elbow?c[0]:a.x,y:t===oo.elbow?c[1]:a.y,roundness:t===oo.round?{type:vd.PROPORTIONAL_RADIUS}:null,elbowed:t===oo.elbow,angle:t===oo.elbow?0:a.angle,points:t===oo.elbow||a.elbowed?[zr.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},c,s),zr.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},m,s)]:a.points});if(nv(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=zr.getPointAtIndexGlobalCoordinates(p,0,d),b=zr.getPointAtIndexGlobalCoordinates(p,-1,d),g=p.startBinding&&d.get(p.startBinding.elementId),x=p.endBinding&&d.get(p.endBinding.elementId),v=g&&p.startBinding?{...p.startBinding,...J1(p,g,"start",d,o.isBindingEnabled)}:null,y=x&&p.endBinding?{...p.endBinding,...J1(p,x,"end",d,o.isBindingEnabled)}:null;p={...p,startBinding:v,endBinding:y,..._5(p,d,{points:[u,b].map(E=>u5(E[0]-p.x,E[1]-p.y)),startBinding:v,endBinding:y,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=d.get(p.startBinding.elementId);u&&q1(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=d.get(p.endBinding.elementId);u&&q1(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},l=o.selectedLinearElement?.elementId;if(l){let a=r.find(s=>s.id===l);a&&(i.selectedLinearElement=new zr(a,Ah(e)))}return{elements:r,appState:i,captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ze("fieldset",{children:[q("legend",{children:h("labels.arrowtypes")}),q("div",{className:"buttonList",children:q(Rt,{group:"arrowtypes",options:[{value:oo.sharp,text:h("labels.arrowtype_sharp"),icon:zi,testId:"sharp-arrow"},{value:oo.round,text:h("labels.arrowtype_round"),icon:Ui,testId:"round-arrow"},{value:oo.elbow,text:h("labels.arrowtype_elbowed"),icon:Gi,testId:"elbow-arrow"}],value:xt(e,n,r=>Td(r)?r.elbowed?oo.elbow:r.roundness?oo.round:oo.sharp:null,r=>Td(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})}),K5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[q("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),q("line",{x1:"4",y1:"7",x2:"4",y2:"17",strokeWidth:"1.5"}),q("line",{x1:"20",y1:"7",x2:"20",y2:"17",strokeWidth:"1.5"})]}),$5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[q("line",{x1:"2",y1:"12",x2:"8",y2:"12",strokeDasharray:"3 2"}),q("line",{x1:"10",y1:"12",x2:"16",y2:"12",strokeDasharray:"3 2"}),q("line",{x1:"18",y1:"12",x2:"22",y2:"12",strokeDasharray:"3 2"}),q("polyline",{points:"17,8 22,12 17,16"})]}),Z5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[q("line",{x1:"3",y1:"12",x2:"18",y2:"12"}),q("polyline",{points:"13,7 18,12 13,17"})]}),j5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[q("line",{x1:"21",y1:"12",x2:"6",y2:"12"}),q("polyline",{points:"11,7 6,12 11,17"})]}),q5=O({name:"changeAnimation",label:"Animations",trackEvent:!1,perform:(e,o,t)=>t?{elements:bt(e,o,n=>et(n,{animationType:t.type,animationDirection:t.direction,animationSpeed:t.speed}),!0),appState:o,captureUpdate:tt.IMMEDIATELY}:!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let i=n.scene.getSelectedElements(n.state)[0],l=i?.animationType??"none",a=i?.animationDirection??"forward",s=i?.animationSpeed??10;return Ze("fieldset",{children:[q("legend",{children:"Animations"}),q("div",{className:"buttonList",children:q(Rt,{group:"animation-type",options:[{value:"none",text:"None",icon:K5},{value:"flow",text:"Flow",icon:$5}],value:l,onChange:m=>t({type:m,direction:a,speed:s})})}),l==="flow"&&Ze(Id,{children:[q("div",{className:"buttonList",style:{marginTop:8},children:q(Rt,{group:"animation-direction",options:[{value:"forward",text:"Forward",icon:Z5},{value:"backward",text:"Backward",icon:j5}],value:a,onChange:m=>t({type:l,direction:m,speed:s})})}),Ze("label",{className:"control-label",style:{marginTop:8,display:"block"},children:["Speed",q("div",{className:"range-wrapper",children:q("input",{type:"range",min:"1",max:"100",step:"1",value:s,onChange:m=>t({type:l,direction:a,speed:+m.target.value}),className:"range-input"})})]})]})]})}});import{clamp as Oh,roundToStep as r3}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as i3,CURSOR_TYPE as cv,MAX_ZOOM as dv,MIN_ZOOM as mv,THEME as es,ZOOM_STEP as zh,updateActiveTool as ta,CODES as qo,KEYS as wn}from"@excalidraw/common";import{getNonDeletedElements as a3}from"@excalidraw/element";import{newElementWith as l3}from"@excalidraw/element";import{getCommonBounds as s3}from"@excalidraw/element";import{CaptureUpdateAction as Eo}from"@excalidraw/element";import{useEffect as J5}from"react";import{jsx as e3}from"react/jsx-runtime";var ea=()=>{let e=document.querySelector(".hellixitboard-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("hellixitboard-tooltip"),o},Rh=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,l=5,a=o.left+o.width/2-n.width/2;a<0?a=l:a+n.width>=r&&(a=r-n.width-l);let s;t==="bottom"?(s=o.top+o.height+l,s+n.height>=i&&(s=o.top-n.height-l)):(s=o.top-n.height-l,s<0&&(s=o.top+o.height+l)),Object.assign(e.style,{top:`${s}px`,left:`${a}px`})},Q5=(e,o,t,n)=>{o.classList.add("hellixitboard-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Rh(o,r)},$t=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(J5(()=>()=>ea().classList.remove("hellixitboard-tooltip--visible"),[]),r?null:e3("div",{className:"hellixitboard-tooltip-wrapper",onPointerEnter:i=>Q5(i.currentTarget,ea(),o,t),onPointerLeave:()=>ea().classList.remove("hellixitboard-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Nh,MIME_TYPES as Bh,THEME as av}from"@excalidraw/common";var lv='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',t3='<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"/>',sv='<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"/>',o3=`data:${Bh.svg},${encodeURIComponent(`${lv}${sv}</svg>`)}`,n3=`data:${Bh.svg},${encodeURIComponent(`${lv}${t3}${sv}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},we=(e,o)=>{e&&(e.style.cursor=o)},jo,iv,Fh=(e,o)=>{let n=()=>{let r=o===av.DARK;jo=document.createElement("canvas"),jo.theme=o,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=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),iv=jo.toDataURL(Bh.svg)};(!jo||jo.theme!==o)&&n(),we(e,`url(${iv}) ${20/2} ${20/2}, auto`)},jt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(yn(o))e.style.cursor=Nh.GRAB;else if(Ht(o))Fh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===av.LIGHT?o3:n3;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Nh.AUTO):e.style.cursor=Nh.CROSSHAIR};var In=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,l=n.zoom.value,a=n.scrollX+(r-r/l),s=n.scrollY+(i-i/l),c=-(r-r/t),m=-(i-i/t);return{scrollX:a+c,scrollY:s+m,zoom:{value:t}}};import{jsx as kd,jsxs as p3}from"react/jsx-runtime";var c3=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?Eo.IMMEDIATELY:Eo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>kd(Kl,{palette:null,topPicks:i3,label:h("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Cn=O({name:"clearCanvas",label:"labels.clearCanvas",icon:pt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>l3(r,{isDeleted:!0})),appState:{...Oo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:Eo.IMMEDIATELY})}),wd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Su,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(o.zoom.value+zh)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd(J,{type:"button",className:"zoom-in-button zoom-button",icon:Su,title:`${h("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":h("buttons.zoomIn"),disabled:o.zoom.value>=dv,onClick:()=>{e(null)}}),keyTest:e=>(e.code===qo.EQUAL||e.code===qo.NUM_ADD)&&(e[wn.CTRL_OR_CMD]||e.shiftKey)}),Cd=O({name:"zoomOut",label:"buttons.zoomOut",icon:ku,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(o.zoom.value-zh)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd(J,{type:"button",className:"zoom-out-button zoom-button",icon:ku,title:`${h("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":h("buttons.zoomOut"),disabled:o.zoom.value<=mv,onClick:()=>{e(null)}}),keyTest:e=>(e.code===qo.MINUS||e.code===qo.NUM_SUBTRACT)&&(e[wn.CTRL_OR_CMD]||e.shiftKey)}),Sd=O({name:"resetZoom",label:"buttons.resetZoom",icon:h0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(1)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd($t,{label:h("buttons.resetZoom"),style:{height:"100%"},children:p3(J,{type:"button",className:"reset-zoom-button zoom-button",title:h("buttons.resetZoom"),"aria-label":h("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===qo.ZERO||e.code===qo.NUM_ZERO)&&(e[wn.CTRL_OR_CMD]||e.shiftKey)}),d3=(e,o,t=1)=>{let[n,r,i,l]=e,a=i-n,s=o.width/a,c=l-r,m=o.height/c,d=Math.min(s,m)*Oh(t,.1,1);return Math.min(d,1)},pv=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:l=1/0})=>{r=Oh(r,mv,dv);let[a,s,c,m]=e,p=(a+c)/2,d=(s+m)/2,u=t?.left??0,b=t?.top??0,g=t?.right??0,x=t?.bottom??0,v=o.width-u-g,y=o.height-b-x,E;if(n){let C=c-a,M=m-s;E=Math.min(v/C,y/M)*r}else E=d3(e,{width:v,height:y},r);let T=No(Oh(r3(E,zh,"floor"),i,l)),I=_y({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:T}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:T}},captureUpdate:Eo.EVENTUALLY}},ts=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:l})=>{let a=s3(a3(o));return pv({canvasOffsets:e,bounds:a,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:l})},nne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:$c,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ts({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===qo.TWO&&e.shiftKey&&!e.altKey&&!e[wn.CTRL_OR_CMD]}),rne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:$c,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ts({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===qo.THREE&&e.shiftKey&&!e.altKey&&!e[wn.CTRL_OR_CMD]}),m3=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:$c,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>ts({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===qo.ONE&&e.shiftKey&&!e.altKey&&!e[wn.CTRL_OR_CMD]}),Gr=O({name:"toggleTheme",label:(e,o)=>o.theme===es.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===es.LIGHT?Dl:Hl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===es.LIGHT?es.DARK:es.LIGHT)},captureUpdate:Eo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===qo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),ine=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Ht(o)?r=ta(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=ta(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>e.key===wn.E}),ane=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:Un,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ta(o,{type:"lasso",fromSelection:!1}),we(n.interactiveCanvas,cv.CROSSHAIR)):r=ta(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.NEVER}}}),uv=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ni,viewMode:!1,perform:(e,o,t,n)=>{let r;return yn(o)?r=ta(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ta(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),we(n.interactiveCanvas,cv.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[wn.CTRL_OR_CMD]&&e.key===wn.H});import{updateActiveTool as hv}from"@excalidraw/common";import{CaptureUpdateAction as u3}from"@excalidraw/element";var h3=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=hv(o,{type:"embeddable"});return jt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:hv(o,{type:"embeddable"})},captureUpdate:u3.EVENTUALLY}}});import{pointFrom as gv}from"@excalidraw/math";import{bindOrUnbindBindingElement as g3}from"@excalidraw/element/binding";import{isValidPolygon as fv,LinearElementEditor as Md,newElementWith as Gh}from"@excalidraw/element";import{isBindingElement as bv,isFreeDrawElement as xv,isLinearElement as yv,isLineElement as Pd}from"@excalidraw/element";import{KEYS as Uh,arrayToMap as f3,invariant as Ev,shouldRotateWithDiscreteAngle as b3,updateActiveTool as vv}from"@excalidraw/common";import{isPathALoop as x3}from"@excalidraw/element";import{isInvisiblySmallElement as Wh}from"@excalidraw/element";import{CaptureUpdateAction as Tv}from"@excalidraw/element";import{jsx as y3}from"react/jsx-runtime";var kt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:l,scene:a}=n,s=a.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:u}=t,b=Md.getElement(o.selectedLinearElement.elementId,s);Ev(b,"Arrow element should exist if selectedLinearElement is set"),Ev(u,"sceneCoords should be defined if actionFinalize is called with event");let g=Md.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(bv(b)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let x=!!o.newElement,y=(x||!o.selectedLinearElement.selectedPointsIndices?[b.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((E,T)=>(E.set(T,{point:Md.pointFromAbsoluteCoords(b,gv(u.x-g.pointerOffset.x,u.y-g.pointerOffset.y),s)}),E),new Map)??new Map;g3(b,y,u.x-g.pointerOffset.x,u.y-g.pointerOffset.y,a,o,{newArrow:x,altKey:d.altKey,angleLocked:b3(d)})}else Pd(b)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!fv(b.points)&&a.mutateElement(b,{polygon:!1});if(g!==o.selectedLinearElement){b&&Wh(b)&&(r=r.map(v=>v.id===b.id?Gh(v,{isDeleted:!0}):v));let x=o.activeTool?.locked;return{elements:b.points.length<2||Wh(b)?e.map(v=>v.id===b.id?Gh(v,{isDeleted:!0}):v):r,appState:{...o,cursorButton:"up",selectedLinearElement:x?null:{...g,selectedPointsIndices:null,isEditing:!1,initialState:{...g.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:Tv.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&l();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||bv(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||d[d.length-1]!==u)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&Wh(c)&&(r=r.map(d=>d.id===c?.id?Gh(d,{isDeleted:!0}):d)),yv(c)||xv(c)){if(x3(c.points,o.zoom.value)&&(Pd(c)||xv(c))){let u=c.points,b=u[0],g=u.map((x,v)=>v===u.length-1?gv(b[0],b[1]):x);Pd(c)?a.mutateElement(c,{points:g,polygon:!0}):a.mutateElement(c,{points:g})}Pd(c)&&!fv(c.points)&&a.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Zt(i);let m;o.activeTool.type==="eraser"?m=vv(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=vv(o,{type:n.state.preferredSelectionTool.type});let p=c&&yv(c)?new Md(c,f3(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:Tv.IMMEDIATELY}},keyTest:(e,o)=>e.key===Uh.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Uh.ESCAPE||e.key===Uh.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>y3(J,{type:"button",icon:w0,title:h("buttons.done"),"aria-label":h("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ia,DEFAULT_EXPORT_PADDING as rH,EXPORT_SCALES as iH,THEME as as}from"@excalidraw/common";import{getNonDeletedElements as aH}from"@excalidraw/element";import{CaptureUpdateAction as To}from"@excalidraw/element";import E3 from"clsx";import{jsx as Iv,jsxs as v3}from"react/jsx-runtime";var os=({children:e,checked:o,onChange:t,className:n})=>v3("div",{className:E3("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Iv("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Gc}),Iv("div",{className:"Checkbox-label",children:e})]});import{THEME as ns}from"@excalidraw/common";import{jsx as rs}from"react/jsx-runtime";var Cv=e=>{let o=e.title||(e.value===ns.DARK?h("buttons.lightMode"):h("buttons.darkMode"));return rs(J,{type:"icon",icon:e.value===ns.LIGHT?wv.MOON:wv.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===ns.DARK?ns.LIGHT:ns.DARK),"data-testid":"toggle-dark-mode"})},wv={SUN:rs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:rs("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:rs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:rs("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as T3}from"react";import{focusNearestParent as I3,KEYS as w3}from"@excalidraw/common";import{jsx as Sv,jsxs as C3}from"react/jsx-runtime";var kv=e=>{let{id:o}=_e(),[t,n]=T3(e.value),r=l=>{e.ignoreFocus||I3(l.target);let a=l.target.value;a!==e.value&&e.onChange(a)},i=l=>{if(l.key===w3.ENTER){if(l.preventDefault(),l.nativeEvent.isComposing||l.keyCode===229)return;l.currentTarget.blur()}};return C3("div",{className:"ProjectName",children:[Sv("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Sv("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:l=>n(l.target.value)})]})};import{useCallback as S3,useEffect as k3,useRef as M3}from"react";import{jsx as Ad,jsxs as _3}from"react/jsx-runtime";var P3=5e3,A3=({progress:e})=>Ad("div",{className:"Toast__progress-bar",children:Ad("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),L3=({message:e,onClose:o,closable:t=!1,duration:n=P3,style:r})=>{let i=M3(0),l=n!==1/0,a=S3(()=>{l&&(i.current=window.setTimeout(()=>o(),n))},[o,n,l]);return k3(()=>{if(l)return a(),()=>clearTimeout(i.current)},[a,e,n,l]),_3("div",{className:"Toast",role:"status",onMouseEnter:l?()=>clearTimeout(i?.current):void 0,onMouseLeave:l?a:void 0,style:r,children:[Ad("div",{className:"Toast__message",children:e}),t&&Ad(J,{icon:Qt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Ld=Object.assign(L3,{ProgressBar:A3});import{DEFAULT_EXPORT_PADDING as Z3,DEFAULT_FILENAME as j3,IMAGE_MIME_TYPES as Hv,isFirefox as q3,MIME_TYPES as J3,cloneJSON as Q3,SVG_DOCUMENT_PREAMBLE as eH}from"@excalidraw/common";import{getNonDeletedElements as tH}from"@excalidraw/element";import{isFrameLikeElement as oH}from"@excalidraw/element";import{getElementsOverlappingFrame as nH}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as D3,EXPORT_DATA_TYPES as is,MIME_TYPES as qt,arrayToMap as H3,isMemberOf as R3,isPromiseLike as N3,EVENT as _d}from"@excalidraw/common";import{mutateElement as B3}from"@excalidraw/element";import{deepCopyElement as F3}from"@excalidraw/element";import{isFrameLikeElement as O3,isInitializedImageElement as z3}from"@excalidraw/element";import{getContainingFrame as Mv}from"@excalidraw/element";var Tre="clipboard"in navigator&&"readText"in navigator.clipboard,Dd="clipboard"in navigator&&"writeText"in navigator.clipboard,oa="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,G3=e=>!!([is.hellixitboard,is.hellixitboardClipboard,is.hellixitboardClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Pv=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(_d.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},U3=({elements:e,files:o})=>{let t=H3(e),n=new Set(e.filter(a=>O3(a))),r=!1,i=e.reduce((a,s)=>(z3(s)&&(r=!0,o&&o[s.fileId]&&(a[s.fileId]=o[s.fileId])),a),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let l={type:is.hellixitboardClipboard,elements:e.map(a=>{if(Mv(a,t)&&!n.has(Mv(a,t))){let s=F3(a);return B3(s,t,{frameId:null}),s}return a}),files:o?i:void 0};return JSON.stringify(l)},Hd=async(e,o,t)=>{let n=U3({elements:e,files:o});await vo({[qt.hellixitboardClipboard]:n,[qt.text]:n},t)};function Av(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(Av(t));return o}var W3=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,qt.html),n=Av(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Lv=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[qt.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(R3(D3,n))try{if(n===qt.text||n===qt.html)e[n]=await(await t.getType(n)).text();else if(Vy(n)){let r=await t.getType(n),i=Jy(r,n,void 0);e[n]=i}else throw new xu(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof xu?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},Y3=async(e,o=!1)=>{try{let t=e.findByType(qt.html),n=!o&&t&&W3(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(qt.text)??n.value.map(r=>r.value).join(`
2
- `).trim()}:n:{type:"text",value:(e.getData(qt.text)||"").trim()}}catch{return{type:"text",value:""}}},V3=function(e){return this.find(o=>o.type===e)||null},X3=function(e){return this.find(t=>t.type===e)?.value??null},K3=function(){return this.filter(e=>e.kind==="file")},_v=e=>{let o;Dv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},na=async e=>{let o;Dv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await qy(n);return r=await Ll(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(l=>{n.getAsString(a=>l(a))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:V3,getData:X3,getFiles:K3})},Rd=async(e,o=!1)=>{let t=await Y3(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===is.hellixitboardClipboardWithAPI;if(G3(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Nd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[qt.png]:e})])}catch(o){if(N3(e))await navigator.clipboard.write([new ClipboardItem({[qt.png]:await e})]);else throw o}},vo=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[qt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===qt.text);if(Dd&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!$3(n[1]))throw new Error("Error copying to clipboard.")},$3=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},Dv=e=>e.type===_d.PASTE||e.type===_d.COPY||e.type===_d.CUT;var Ur=(e,{selectedElementIds:o},t)=>{e=tH(e);let n=t&&Me(e,{selectedElementIds:o}),r=null,i=n?oe(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&oH(i[0])?(r=i[0],i=nH(e,r)):i.length>1&&(i=oe(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:Q3(i)}},Wr=async(e,o,t,n,{exportBackground:r,exportPadding:i=Z3,viewBackgroundColor:l,name:a=t.name||j3,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(h("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=Ar(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:l,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return yu(p.then(d=>new Blob([eH+d.outerHTML],{type:J3.svg})),{description:"Export to SVG",name:a,extension:t.exportEmbedScene?"hellixitboard.svg":"svg",mimeTypes:[Hv.svg],fileHandle:s});if(e==="clipboard-svg"){let d=await p.then(u=>u.outerHTML);try{await vo(d)}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return}}let m=Ac(o,t,n,{exportBackground:r,viewBackgroundColor:l,exportPadding:i,exportingFrame:c});if(e==="png"){let p=Dr(m);return t.exportEmbedScene&&(p=p.then(d=>import("./data/image-2IKBHSIF.js").then(({encodePngMetadata:u})=>u({blob:d,metadata:kl(o,t,n,"local")})))),yu(p,{description:"Export to PNG",name:a,extension:t.exportEmbedScene?"hellixitboard.png":"png",mimeTypes:[Hv.png],fileHandle:s})}else if(e==="clipboard")try{let p=Dr(m);await Nd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):q3&&p.name==="TypeError"?new Error(`${h("alerts.couldNotCopyToClipboard")}
1
+ import{$ as _r,A as wc,B as Eu,C as TL,D as Ny,E as By,F as kc,G as Ml,H as Mc,I as Pc,J as Pl,K as Fy,L as Oy,M as zy,N as Ac,O as Ar,P as Gy,Q as IL,R as Lr,S as Ti,T as Al,V as Uy,X as Wy,Y as Yy,Z as Lc,_ as Vy,a as _y,aa as vu,b as Pr,ba as _c,c as No,ca as Xy,d as Dy,da as Tu,e as Me,ea as Dr,f as Hy,fa as Ky,g as oe,ga as Iu,h as xi,ha as $y,i as Bo,ia as Zy,j as Il,ja as Dc,k as Cl,ka as Cu,l as yi,la as jy,m as Sl,ma as qy,n as wl,na as Jy,o as Ei,oa as Ll,p as Ry,q as xu,r as Fo,s as Gn,t as Oo,u as Ht,v as yn,w as vi,x as Sc,y as yu,z as kl}from"./chunk-IGUB3U7T.js";import{a as C}from"./chunk-SHLNM5GH.js";import{N as bu}from"./chunk-QHHZVMH3.js";import{c as Ly}from"./chunk-3PELD44J.js";import{b as Py,c as Ay,d as w}from"./chunk-SRAX5OIU.js";import o$,{useCallback as n$,useContext as r$,useEffect as i$,useRef as a$,useState as l$}from"react";import{DEFAULT_UI_OPTIONS as vL,isShallowEqual as s$}from"@hellixit/common";import jP from"clsx";import CV from"lodash.throttle";import go,{useContext as On}from"react";import{flushSync as Yt}from"react-dom";import SV from"roughjs/bin/rough";import{nanoid as wV}from"nanoid";import{clamp as qP,pointFrom as re,pointDistance as Ir,vector as JP,pointRotateRads as Hx,vectorFromPoint as Rx,vectorSubtract as QP,vectorDot as eA,vectorNormalize as tA}from"@hellixit/math";import{COLOR_PALETTE as kV,CODES as oA,shouldResizeFromCenter as nA,shouldMaintainAspectRatio as sc,shouldRotateWithDiscreteAngle as rA,isArrowKey as Jp,KEYS as j,APP_NAME as MV,CURSOR_TYPE as ze,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as PV,DEFAULT_VERTICAL_ALIGN as iA,DRAGGING_THRESHOLD as aA,ELEMENT_SHIFT_TRANSLATE_AMOUNT as AV,ELEMENT_TRANSLATE_AMOUNT as lA,EVENT as ae,FRAME_STYLE as pn,IMAGE_MIME_TYPES as LV,IMAGE_RENDER_TIMEOUT as _V,LINE_CONFIRM_THRESHOLD as Nx,MAX_ALLOWED_FILE_BYTES as sA,MIME_TYPES as un,MQ_RIGHT_SIDEBAR_MIN_WIDTH as DV,POINTER_BUTTON as Cr,ROUNDNESS as Qp,SCROLL_TIMEOUT as HV,TAP_TWICE_TIMEOUT as RV,TEXT_TO_CENTER_SNAP_THRESHOLD as NV,THEME as ul,TOUCH_CTX_MENU_TIMEOUT as BV,VERTICAL_ALIGN as FV,YOUTUBE_STATES as eu,ZOOM_STEP as OV,POINTER_EVENTS as hl,TOOL_TYPE as hn,supportsResizeObserver as zV,DEFAULT_COLLISION_THRESHOLD as cA,DEFAULT_TEXT_ALIGN as GV,ARROW_TYPE as Sr,DEFAULT_REDUCED_GLOBAL_ALPHA as UV,isLocalLink as WV,normalizeLink as Bx,toValidURL as YV,getGridPoint as It,getLineHeight as dA,debounce as mA,distance as gl,getFontString as Fx,getNearestScrollableContainer as VV,isInputLike as pA,isToolIcon as XV,isWritableElement as cc,sceneCoordsToViewportCoords as tu,tupleToCoors as Ox,viewportCoordsToSceneCoords as Be,wrapEvent as KV,updateObject as zx,updateActiveTool as gn,isTransparent as $V,easeToValuesRAF as ZV,muteFSAbortError as jV,isTestEnv as jA,isDevEnv as qA,easeOut as qV,updateStable as dc,addEventListener as $e,normalizeEOL as JV,getDateTime as uA,isShallowEqual as hA,arrayToMap as ou,applyDarkModeFilter as QV,AppEventBus as eX,randomInteger as tX,CLASSES as Gx,Emitter as gi,MINIMUM_ARROW_SIZE as oX,DOUBLE_TAP_POSITION_THRESHOLD as nX,BIND_MODE_TIMEOUT as rX,invariant as fn,getFeatureFlag as Bn,createUserAgentDescriptor as JA,getFormFactor as iX,deriveStylesPanelMode as cu,isIOS as aX,isBrave as lX,isSafari as sX,loadDesktopUIModePreference as cX,setDesktopUIMode as dX,isSelectionLikeTool as nu,oneOf as gA}from"@hellixit/common";import{getObservedAppState as mX,getCommonBounds as fl,getElementAbsoluteCoords as fA,bindOrUnbindBindingElements as bA,fixBindingsAfterDeletion as pX,getHoveredElementForBinding as Ho,isBindingEnabled as mc,updateBoundElements as ru,LinearElementEditor as xe,newElementWith as wr,newFrameElement as uX,newFreeDrawElement as hX,newEmbeddableElement as xA,newMagicFrameElement as yA,newIframeElement as gX,newArrowElement as fX,newElement as bX,newImageElement as xX,newLinearElement as yX,newTextElement as EA,refreshTextDimensions as EX,deepCopyElement as vA,duplicateElements as Ux,hasBoundTextElement as TA,isArrowElement as bl,isBindingElement as bn,isBindingElementType as vX,isBoundToContainer as Wx,isFrameLikeElement as Vt,isImageElement as fi,isEmbeddableElement as Fn,isInitializedImageElement as pc,isLinearElement as _t,isLinearElementType as TX,isUsingAdaptiveRadius as IX,isIframeElement as xl,isIframeLikeElement as Yx,isMagicFrameElement as Vx,isTextBindableContainer as IA,isElbowArrow as Xt,isFlowchartNodeElement as CX,isBindableElement as Xx,isTextElement as Ro,getNormalizedDimensions as SX,isElementCompletelyInViewport as Kx,isElementInViewport as CA,isInvisiblySmallElement as SA,getCornerRadius as wX,isPathALoop as wA,createSrcDoc as kA,embeddableURLValidator as $x,maybeParseEmbedSrc as kX,getEmbedLink as iu,getInitializedImageElements as MX,normalizeSVG as MA,updateImageCache as PX,getBoundTextElement as Zx,getContainerCenter as jx,getContainerElement as PA,isValidTextContainer as AX,redrawTextBoundingBox as LX,hasBoundingBox as _X,getFrameChildren as qx,isCursorInFrame as AA,addElementsToFrame as Jx,replaceAllElementsInFrame as DX,removeElementsFromFrame as HX,getElementsInResizingFrame as Qx,getElementsInNewFrame as RX,getContainingFrame as ey,elementOverlapsWithFrame as NX,updateFrameMembershipOfSelectedElements as LA,isElementInFrame as _A,getFrameLikeTitle as BX,getElementsOverlappingFrame as FX,filterElementsEligibleAsFrameChildren as OX,hitElementBoundText as zX,hitElementBoundingBoxOnly as GX,hitElementItself as uc,getVisibleSceneBounds as UX,FlowChartCreator as WX,FlowChartNavigator as YX,getLinkDirectionFromKey as DA,cropElement as VX,wrapText as XX,isElementLink as ty,parseElementLinkFromURL as KX,isMeasureTextSupported as $X,normalizeText as ZX,measureText as HA,getLineHeightInPx as jX,getApproxMinLineWidth as qX,getApproxMinLineHeight as JX,getMinTextElementWidth as QX,ShapeCache as hc,getRenderOpacity as eK,editGroupForSelectedElement as tK,getElementsInGroup as bi,getSelectedGroupIdForElement as oK,getSelectedGroupIds as nK,isElementInGroup as RA,isSelectedViaGroup as rK,selectGroupsForSelectedElements as ho,syncInvalidIndices as QA,syncMovedIndices as NA,excludeElementsInFramesFromSelection as iK,getSelectionStateForElements as aK,makeNextSelectedElementIds as ke,getResizeOffsetXY as lK,getResizeArrowDirection as sK,transformElements as cK,getCursorForResizingElement as BA,getElementWithTransformHandleType as FA,getTransformHandleTypeFromCoords as OA,dragNewElement as zA,dragSelectedElements as dK,getDragOffsetXY as mK,isNonDeletedElement as GA,Scene as UA,Store as pK,CaptureUpdateAction as Dt,hitElementBoundingBox as uK,isLineElement as oy,isSimpleArrow as ny,StoreDelta as WA,positionElementsOnGrid as YA,calculateFixedPointForNonElbowArrowBinding as VA,bindOrUnbindBindingElement as hK,mutateElement as au,getElementBounds as XA,doBoundsIntersect as gK,isPointInElement as fK,maxBindingDistance_simple as ry,convertToHellixitboardElements as KA,getSnapOutlineMidPoint as iy,handleFocusPointDrag as bK,handleFocusPointHover as xK,handleFocusPointPointerDown as yK,handleFocusPointPointerUp as EK,maybeHandleArrowPointlikeDrag as lu,getUncroppedWidthAndHeight as vK}from"@hellixit/element";import{KEYS as Zu,MOBILE_ACTION_BUTTON_BG as NL,updateActiveTool as BL}from"@hellixit/common";import{getNonDeletedElements as ju}from"@hellixit/element";import{fixBindingsAfterDeletion as FL}from"@hellixit/element";import{LinearElementEditor as e1}from"@hellixit/element";import{newElementWith as ed}from"@hellixit/element";import{getContainerElement as t1}from"@hellixit/element";import{isBoundToContainer as Jc,isElbowArrow as OL,isFrameLikeElement as zL}from"@hellixit/element";import{getFrameChildren as GL}from"@hellixit/element";import{getElementsInGroup as qu,selectGroupsForSelectedElements as UL}from"@hellixit/element";import{CaptureUpdateAction as Qc}from"@hellixit/element";import{isDevEnv as kL}from"@hellixit/common";import{atom as ge,createStore as CL}from"jotai";import{createIsolation as SL}from"jotai-scope";var Qy=SL();var{useAtom:Q,useSetAtom:zo,useAtomValue:Ii,useStore:h$}=Qy,e0=Qy.Provider,Qe=CL();var wL=Py({"./locales/ar-SA.json":()=>import("./locales/ar-SA-P5I5R262.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RC6EHA33.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-ZOA2ELPF.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-VDHX36FF.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-EFTDMVGQ.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-T4YNJ7N4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-QQWRSQQN.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-AGDMBNQK.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-QQTSMZVG.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-HP6J4G7Y.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-T47LNPQP.js"),"./locales/en.json":()=>import("./locales/en-MFJ6PZDC.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DD633LFI.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-2OQSNQOH.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-WEJIXYVV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-SB3LWSVU.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-OQPRLJNZ.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-CUZIWTHW.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RVMMEG2R.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-2GSUOACK.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-XUOSG6Q4.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-AJTDEQPL.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-SU7HHZZL.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-YQYP66LN.js"),"./locales/kaa.json":()=>import("./locales/kaa-LETQMP6Q.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-74RKMK6M.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-NTU2ICWV.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-TMFOMOGA.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-UEOM2JLS.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-CAROSSCD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-77PPHO6F.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-3ZV2DMGI.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-O3BV6LV6.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5BOYG2HG.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-VNTJC5HN.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-VXMK7ROD.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-VDGPADYS.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-KXL6M4X5.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-RGWUVB47.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-IZ6OXN22.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-B67CTIJG.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-7TDBEFE2.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-FZIKQ3LJ.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-SEO6CHTN.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-AEY3EXCZ.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-U3CP6CC4.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-CR3WQWNI.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-ADM3SECR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-WJMKK3MZ.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-M765ZUT2.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-OSKPFY3U.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-ILVRWK2W.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-EJPTEYM2.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-JTE2W2SN.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-KRY7YSP6.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-SIQXC37Q.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LEZ3HWVD.js")});var ML=85,Go={code:"en",label:"English"},Si=[Go,...[{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=>Ly[e.code]>=ML).sort((e,o)=>e.label>o.label?1:-1)],Rc="__test__";kL()&&Si.unshift({code:Rc,label:"test language"},{code:`${Rc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ci=Go,Hc={},Nc=async e=>{if(Ci=e,document.documentElement.dir=Ci.rtl?"rtl":"ltr",document.documentElement.lang=Ci.code,e.code.startsWith(Rc))Hc={};else try{Hc=await wL(`./locales/${Ci.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Hc=bu}Qe.set(o0,e.code)},En=()=>Ci,t0=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},h=(e,o,t)=>{if(Ci.code.startsWith(Rc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=t0(Hc,n)||t0(bu,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(C.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},o0=ge(Go.code),Ie=()=>{let e=Ii(o0);return{t:h,langCode:e}};import PL from"clsx";import Je from"react";import{THEME as AL}from"@hellixit/common";import{Fragment as we,jsx as f,jsxs as R}from"react/jsx-runtime";var xo=e=>"var(--icon-fill-color)",n0=e=>e===AL.LIGHT?"#fff":"#1e1e1e",L=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...l}=typeof o=="number"?{width:o}:o;return f("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:PL({"rtl-mirror":r}),style:i,...l,children:typeof e=="string"?f("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},St={width:40,height:20},P$=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:3,y:8,width:18,height:4,rx:1}),f("line",{x1:12,y1:8,x2:12,y2:21}),f("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),f("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"})]}),z),Bc=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),f("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),f("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),r0=L(R("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),i0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"1"}),f("circle",{cx:"12",cy:"19",r:"1"}),f("circle",{cx:"12",cy:"5",r:"1"})]}),z),a0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),f("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),f("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),l0=L(R("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),f("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),f("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Su=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M6.5 9.5l3.5 -3"}),f("path",{d:"M14 5.5l3 1.5"}),f("path",{d:"M18.5 10l-2.5 7"}),f("path",{d:"M13.5 17.5l-7 -5"})]}),z),Hr=L(R("g",{children:[f("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"}),f("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"}),f("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:f("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"})}),f("g",{mask:"url(#UnlockedIcon)",children:f("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),wi=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),f("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),s0=L(f("g",{fill:"currentColor",children:f("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),c0=L(R(we,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),f("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"}),d0=L(R(we,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),f("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"}),m0=L(R(we,{children:[f("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"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),f("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"}),A$=L(f("g",{fill:"currentColor",children:f("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"}),Rr=L(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Un=L(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[f("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),f("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ki=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Mi=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),z),Pi=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"})]}),z),Fc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),Ai=L(f("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),p0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),f("path",{d:"M16 7h4"}),f("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),Uo=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Wo=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),f("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),f("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),f("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),f("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),u0=L(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 7v-2h13v2"}),f("path",{d:"M10 5v14"}),f("path",{d:"M12 19h-4"}),f("path",{d:"M15 13v-1h6v1"}),f("path",{d:"M18 12v7"}),f("path",{d:"M17 19h2"})]}),z),Li=L(R("g",{strokeWidth:"1.25",children:[f("path",{d:"M12.5 6.667h.01"}),f("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"}),f("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),f("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),Oc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),wu=L(f("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),ku=L(f("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),h0=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M21 21l-6 -6"}),f("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"}),f("path",{d:"M3 4v4h4"})]}),z),pt=L(f("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),_i=L(R("g",{strokeWidth:"1.5",children:[f("polyline",{points:"12 16 18 10 12 4"}),f("polyline",{points:"8 4 2 10 8 16"})]}),me),_l=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),Dl=L(f("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Hl=L(f("g",{stroke:"currentColor",strokeLinejoin:"round",children:f("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),g0=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),f("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),Nr=L(f("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),Di=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"}),f("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),f0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"}),f("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),zc=L(f("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),b0=L(f("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),x0=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),y0=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),f("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),Gc=L(f("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Rl=L(R("g",{strokeWidth:"1.25",children:[f("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"}),f("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),E0=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}),v0=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}),Hi=L(f("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),L$=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}),_$=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"),Ri=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),f("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"}),f("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"})]}),z),T0=L(f("g",{strokeWidth:1.5,children:f("path",{d:"M6 18l12 -12"})}),z),Uc=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15 8h.01"}),f("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),f("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),f("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),f("path",{d:"M19 16v6"}),f("path",{d:"M22 19l-3 3l-3 -3"})]}),z),I0=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}),D$=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}),H$=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}),C0=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"),R$=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"),Mu=L(f("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Pu=L(f("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),S0=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}),w0=L(f("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),N$=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"),B$=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(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 14v-11"}),f("path",{d:"M9 6l3 -3l3 3"})]}),z),O$=L(R(we,{children:[f("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"}),f("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}),z$=L(f("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}),k0=R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 10l0 10"}),f("path",{d:"M12 10l4 4"}),f("path",{d:"M12 10l-4 4"}),f("path",{d:"M4 4l16 0"})]}),M0=R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 5l0 14"}),f("path",{d:"M16 9l-4 -4"}),f("path",{d:"M8 9l4 -4"})]}),Au=L(M0,z),Lu=L(M0,{...z,style:{transform:"rotate(180deg)"}}),_u=L(k0,z),Du=L(k0,{...z,style:{transform:"rotate(180deg)"}}),Hu=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ru=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Nu=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Bu=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),P0=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),A0=L(R(we,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("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"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Fu=L(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),f("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Ou=L(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),f("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Wc=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"9",cy:"7",r:"4"}),f("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),f("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),f("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),G$=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"),L0=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"),Qt=L(R(we,{children:[f("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M15 5 5 15M5 5l10 10"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),U$=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}),W$=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}),Y$=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}),Yc=L(R(we,{children:[f("path",{d:"M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48z"}),f("path",{d:"M216 288h-42.7L192 269.3l18.7 18.7zM192 224l-64 64h40v64h48v-64h40l-64-64z"})]}),{width:384,height:512}),zu=Je.memo(({theme:e})=>L(R(we,{children:[f("path",{d:"M25 26H111V111H25",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),R("g",{fill:n0(e),stroke:xo(e),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Gu=Je.memo(({theme:e})=>L(R(we,{children:[f("path",{d:"M25 26H111V111H25",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:xo(e)}),f("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:xo(e),strokeWidth:"2"}),R("g",{fill:n0(e),stroke:xo(e),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),f("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),_0=L(f("g",{strokeWidth:1.25,children:f("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),D0=L(R(we,{children:[f("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"}),f("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:f("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"})}),f("g",{mask:"url(#FillHachureIcon)",children:f("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),H0=L(R(we,{children:[R("g",{clipPath:"url(#a)",children:[f("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"}),f("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:f("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"})}),f("g",{mask:"url(#FillCrossHatchIcon)",children:f("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"})})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),R0=L(R(we,{children:[f("g",{clipPath:"url(#a)",children:f("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"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Uu=L(f(we,{children:f("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),N0=L(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),B0=L(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),V$=Je.memo(({theme:e})=>L(f("path",{d:"M6 10H34",stroke:xo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),F0=L(R("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12h2"}),f("path",{d:"M17 12h2"}),f("path",{d:"M11 12h2"})]}),z),O0=L(R("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v.01"}),f("path",{d:"M8 12v.01"}),f("path",{d:"M12 12v.01"}),f("path",{d:"M16 12v.01"}),f("path",{d:"M20 12v.01"})]}),z),z0=L(f("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),G0=L(f("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),U0=L(f("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),W0=L(R("svg",{strokeWidth:"1.5",children:[f("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"}),f("path",{d:"M13.3333 3.33331V3.34331"}),f("path",{d:"M16.6667 3.33331V3.34331"}),f("path",{d:"M16.6667 6.66669V6.67669"}),f("path",{d:"M16.6667 10V10.01"}),f("path",{d:"M3.33334 13.3333V13.3433"}),f("path",{d:"M16.6667 13.3333V13.3433"}),f("path",{d:"M3.33334 16.6667V16.6767"}),f("path",{d:"M6.66666 16.6667V16.6767"}),f("path",{d:"M10 16.6667V16.6767"}),f("path",{d:"M13.3333 16.6667V16.6767"}),f("path",{d:"M16.6667 16.6667V16.6767"})]}),me),Y0=L(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),f("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),f("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),f("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),f("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),f("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),f("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),f("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),f("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),f("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),f("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),f("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),V0=Je.memo(({flip:e=!1})=>L(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[f("path",{d:"M7,11 H19"}),f("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),St)),X0=Je.memo(({flip:e=!1})=>L(f("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),St)),K0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[f("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),f("path",{d:"M23,5 L35,11 L23,17 Z"})]}),St)),$0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[f("path",{d:"M7,11 H23"}),f("path",{d:"M23,5 L35,11 L23,17 Z"})]}),St)),Z0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[f("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),f("circle",{cx:"29",cy:"11",r:"4"})]}),St)),j0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[f("path",{d:"M7,11 H25",strokeLinecap:"round"}),f("circle",{cx:"29",cy:"11",r:"4"})]}),St)),q0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[f("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),f("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),St)),J0=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[f("path",{d:"M7,11 H21"}),f("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),St)),Q0=Je.memo(({flip:e=!1})=>L(f("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:f("path",{d:"M11,11 H31 M31,5 V17"})}),St)),eE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,5 V17"})}),St)),tE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),St)),oE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),St)),nE=Je.memo(({flip:e=!1})=>L(f("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:f("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),St)),rE=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),f("circle",{cx:"15",cy:"11",r:"4"})]}),St)),iE=Je.memo(({flip:e=!1})=>L(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),f("circle",{cx:"23",cy:"11",r:"4"})]}),St)),aE=L(R(we,{children:[f("g",{clipPath:"url(#a)",children:f("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"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),lE=L(R(we,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),sE=L(R(we,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),cE=L(f(we,{children:f("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Br=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 7v-2h13v2"}),f("path",{d:"M10 5v14"}),f("path",{d:"M12 19h-4"}),f("path",{d:"M15 13v-1h6v1"}),f("path",{d:"M18 12v7"}),f("path",{d:"M17 19h2"})]}),z),dE=L(f(we,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 12h10"}),f("path",{d:"M7 5v14"}),f("path",{d:"M17 5v14"}),f("path",{d:"M15 19h4"}),f("path",{d:"M15 5h4"}),f("path",{d:"M5 19h4"}),f("path",{d:"M5 5h4"})]})}),z),Nl=L(f(we,{children:f("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),Wu=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 8l-4 4l4 4"}),f("path",{d:"M17 8l4 4l-4 4"}),f("path",{d:"M14 4l-4 16"})]}),z),Vc=Wu,mE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),f("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),pE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),f("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),uE=L(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),hE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),f("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),gE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),f("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),fE=Je.memo(({theme:e})=>L(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),f("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),f("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Xc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M21 19h-18l9 -15"}),f("path",{d:"M20.615 15.171h.015"}),f("path",{d:"M19.515 11.771h.015"}),f("path",{d:"M17.715 8.671h.015"}),f("path",{d:"M15.415 5.971h.015"})]}),z),bE=L(f("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}),X$=L(f("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"})),Ni=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),f("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),f("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),f("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"})]}),z),Yu=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),f("path",{d:"M7 11l5 5l5 -5"}),f("path",{d:"M12 4l0 12"})]}),z),Bi=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),xE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("path",{d:"M9.15 14.85l8.85 -10.85"}),f("path",{d:"M6 4l8.85 10.85"})]}),z),yE=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),f("path",{d:"M12 17l0 .01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),K$=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 4v16l13 -8z"})]}),z),$$=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),z),EE=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12l5 5l10 -10"})]}),z),Kc=L(R(we,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 9v4"}),f("path",{d:"M12 17h.01"})]}),z),vE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11 7l6 6"}),f("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"})]}),z),Bl=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3l-4 7h8z"}),f("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("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"})]}),z),yo=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 7l16 0"}),f("path",{d:"M4 17l16 0"}),f("path",{d:"M7 4l0 16"}),f("path",{d:"M17 4l0 16"})]}),z),Fi=L(f("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"})),TE=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),f("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),z),IE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),f("path",{d:"M4 15l8 4l8 -4"}),f("path",{d:"M12 4v7"}),f("path",{d:"M15 8l-3 3l-3 -3"})]}),z),Wn=L(R("g",{strokeWidth:"1.25",children:[f("path",{d:"M4.16602 10H15.8327"}),f("path",{d:"M12.5 13.3333L15.8333 10"}),f("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),Yo=L(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[f("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"}),f("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),Fr=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z"}),f("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),f("path",{d:"M15 6l3 3"}),f("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"}),f("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"})]}),z),Z$=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z"}),f("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),f("path",{d:"M15 6l3 3"}),f("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"}),f("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"})]}),z),j$=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),f("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),f("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"}),f("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),f("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),f("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"})]}),z),CE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),f("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),f("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),f("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),Oi=L(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),f("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"})]}),z),SE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),f("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"}),f("path",{d:"M3 3l18 18"})]}),z),wE=L(R("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),f("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),f("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),f("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),kE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),f("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),f("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),f("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),Kt=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),f("path",{d:"M21 21l-6 -6"})]}),z),ME=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),f("path",{d:"M12 7v5l3 3"}),f("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),PE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 8l0 4l2 2"}),f("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),z),AE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M5 10a7 7 0 0 0 14 0"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),z),LE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 3l18 18"}),f("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"}),f("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),z),Fl=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),_E=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M12 20v.01"}),f("path",{d:"M16 20v.01"}),f("path",{d:"M8 20v.01"}),f("path",{d:"M4 20v.01"}),f("path",{d:"M4 16v.01"}),f("path",{d:"M4 12v.01"}),f("path",{d:"M4 8v.01"}),f("path",{d:"M4 4v.01"}),f("path",{d:"M8 4v.01"}),f("path",{d:"M12 4v.01"}),f("path",{d:"M16 4v.01"}),f("path",{d:"M20 4v.01"}),f("path",{d:"M20 8v.01"}),f("path",{d:"M20 12v.01"}),f("path",{d:"M20 16v.01"}),f("path",{d:"M20 20v.01"})]}),z),DE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 3v18"}),f("path",{d:"M19 21v-18"}),f("path",{d:"M5 7h14"}),f("path",{d:"M5 15h14"}),f("path",{d:"M8 13v4"}),f("path",{d:"M11 13v4"}),f("path",{d:"M16 13v4"}),f("path",{d:"M14 5v4"}),f("path",{d:"M11 5v4"}),f("path",{d:"M8 5v4"}),f("path",{d:"M3 21h18"})]}),z),HE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 12l18 0"}),f("path",{d:"M7 16l10 0l-10 5l0 -5"}),f("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),RE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3l0 18"}),f("path",{d:"M16 7l0 10l5 0l-5 -10"}),f("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Vu=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),f("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"})]}),z),$c=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),f("path",{d:"M22 22l-3 -3"}),f("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),f("path",{d:"M3 11v-1"}),f("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),f("path",{d:"M10 3h1"}),f("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),NE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),f("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"}),f("path",{d:"M10 15l2 6l2 -6"}),f("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),BE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),f("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),f("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),f("path",{d:"M11 21v-6l3 6v-6"})]}),z),FE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M4 8l5 0"}),f("path",{d:"M15 8l4 0"})]}),z),OE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),f("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),f("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),f("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),zE=L(R("g",{stroke:"currentColor",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"})]}),{...z,strokeWidth:1.5}),q$=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M21 12h-13l3 -3"}),f("path",{d:"M11 15l-3 -3"})]}),z),J$=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("path",{d:"M10 9l5 3l-5 3z"})]}),z),GE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 6h18"}),f("path",{d:"M3 12h18"}),f("path",{d:"M3 18h18"}),f("path",{d:"M6 3v18"}),f("path",{d:"M12 3v18"}),f("path",{d:"M18 3v18"})]}),z),UE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("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"}),f("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"}),f("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),zi=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 18l12 -12"}),f("path",{d:"M18 10v-4h-4"})]}),z),Gi=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),f("path",{d:"M18 4l3 3l-3 3"})]}),z),Ui=L(R("g",{children:[f("path",{d:"M16,12L20,9L16,6"}),f("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Zc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 9l6 6l6 -6"})]}),z),WE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 15l6 -6l6 6"})]}),z),YE=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 15l6 -6l6 6"})]}),z),Xu=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),f("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),jc=L(R("g",{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M5 7l0 10"}),f("path",{d:"M7 5l10 0"}),f("path",{d:"M7 19l10 0"}),f("path",{d:"M19 7l0 10"})]}),z),Q$=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),f("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),VE=L(R("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 6l8 0"}),f("path",{d:"M16 6l4 0"}),f("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 12l2 0"}),f("path",{d:"M10 12l10 0"}),f("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 18l11 0"}),f("path",{d:"M19 18l1 0"})]}),z),XE=L(R("g",{strokeWidth:1,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),z),KE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),f("path",{d:"M13.5 6.5l4 4"})]}),z),eZ=L(R("g",{strokeWidth:1,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11 7l-5 5l5 5"}),f("path",{d:"M17 7l-5 5l5 5"})]}),z),$E=L(R("g",{strokeWidth:"1.75",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),f("path",{d:"M15 4l0 16"})]}),z),tZ=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),z),oZ=L(R("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 4l18 0"}),f("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),f("path",{d:"M12 16l0 4"}),f("path",{d:"M9 20l6 0"}),f("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),z),ZE=f("div",{style:{width:"1rem",height:"1rem"}}),jE=L(R("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("polyline",{points:"9 6 15 12 9 18"})]}),z),qE=L(R("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 6l8 0"}),f("path",{d:"M16 6l4 0"}),f("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 12l2 0"}),f("path",{d:"M10 12l10 0"}),f("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),f("path",{d:"M4 18l11 0"}),f("path",{d:"M19 18l1 0"})]}),z);import JE from"clsx";import $u,{useEffect as DL,useRef as QE,useState as HL}from"react";import{isPromiseLike as RL}from"@hellixit/common";import LL from"react";import{jsx as Ku}from"react/jsx-runtime";var _L=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(LL.useRef(Date.now()).current%1600);return Ku("div",{className:`Spinner ${n}`,children:Ku("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Ku("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},it=_L;import{jsx as Ol,jsxs as zl}from"react/jsx-runtime";var J=$u.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=_e(),l=$u.useRef(null);$u.useImperativeHandle(r,()=>l.current);let a=`ToolIcon_size_${e}`,[s,c]=HL(!1),m=QE(!0),p=async u=>{let b="onClick"in n&&n.onClick?.(u);if(RL(b))try{c(!0),await b}catch(g){if(g instanceof Ei)console.warn(g);else throw g}finally{m.current&&c(!1)}};DL(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=QE(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return zl("button",{className:JE("ToolIcon_type_button",a,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:p,ref:l,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&zl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ol("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ol(it,{})]}),n.showAriaLabel&&zl("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Ol(it,{})]}),n.children]})}return zl("label",{className:JE("ToolIcon",t),title:n.title,onPointerDown:u=>{d.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[Ol("input",{className:`ToolIcon_type_radio ${a}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:d.current})},checked:n.checked,ref:l}),zl("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ol("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});J.displayName="ToolButton";var qc=[],O=e=>(qc=qc.concat(e),e);import{jsx as YL}from"react/jsx-runtime";var WL=(e,o,t)=>{let n=new Set(oe(e.filter(m=>zL(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),l=new Set;for(let m of n){let p=GL(e,m);for(let d of p)if(!l.has(d.id)){if(Jc(d)){let u=t1(d,i);u&&(r[u.id]=!0)}else r[d.id]=!0;l.add(d.id)}}let a=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=Jc(m)?t1(m,i):null;return m.frameId&&n.has(m.frameId)?(a=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let u=t.scene.getNonDeletedElementsMap().get(d.id);u&&OL(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),ed(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(a=!1,Jc(m)||(r[m.id]=!0),ed(m,{frameId:null})):Jc(m)&&o.selectedElementIds[m.containerId]?ed(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(a&&o.editingGroupId){let m=qu(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(b=>b===o.editingGroupId),u=p.groupIds[d+1];if(u){let b=qu(s,u).filter(g=>!g.isDeleted);b.length>1&&(c=u,b.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...o,...UL({selectedElementIds:r,editingGroupId:c},s,o,null)}}},o1=(e,o)=>{if(e.editingGroupId){let t=qu(ju(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Gl=O({name:"deleteSelectedElements",label:"labels.delete",icon:pt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:l,selectedPointsIndices:a}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=e1.getElement(l,s);if(!c||a==null)return!1;if(a.length>=c.points.length){let m=e.map(d=>d.id===c.id?ed(d,{isDeleted:!0}):d),p=o1(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:Qc.IMMEDIATELY}}return e1.deletePoints(c,n,a),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:a?.[0]>0?[a[0]-1]:[0]}},captureUpdate:Qc.IMMEDIATELY}}let{elements:r,appState:i}=WL(e,o,n);return FL(r,r.filter(l=>l.isDeleted)),i=o1(i,r),{elements:r,appState:{...i,activeTool:BL(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(ju(e),o)?Qc.IMMEDIATELY:Qc.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Zu.BACKSPACE||e.key===Zu.DELETE)&&!e[Zu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=at()==="mobile";return YL(J,{type:"button",icon:pt,title:h("labels.delete"),"aria-label":h("labels.delete"),onClick:()=>t(null),disabled:!Me(ju(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?NL:{}}})}});import{KEYS as Wi,CODES as Yi,isDarwin as td}from"@hellixit/common";import{moveOneLeft as VL,moveOneRight as XL,moveAllLeft as KL,moveAllRight as $L}from"@hellixit/element";import{CaptureUpdateAction as od}from"@hellixit/element";import{isDarwin as n1}from"@hellixit/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,n1?h("keys.option"):h("keys.alt")).replace(/\bShift\b/i,h("keys.shift")).replace(/\b(Enter|Return)\b/i,h("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,n1?h("keys.cmd"):h("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,h("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,h("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,h("keys.delete"));import{jsx as nd}from"react/jsx-runtime";var Ju=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Lu,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:VL(e,o,n.scene),appState:o,captureUpdate:od.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Lu})}),Qu=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Au,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:XL(e,o,n.scene),appState:o,captureUpdate:od.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Au})}),eh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Du,trackEvent:{category:"element"},perform:(e,o)=>({elements:KL(e,o),appState:o,captureUpdate:od.IMMEDIATELY}),keyTest:e=>td?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_LEFT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendToBack")} \u2014 ${td?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Du})}),th=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:_u,trackEvent:{category:"element"},perform:(e,o)=>({elements:$L(e,o),appState:o,captureUpdate:od.IMMEDIATELY}),keyTest:e=>td?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_RIGHT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>nd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${h("labels.bringToFront")} \u2014 ${td?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:_u})});import{getNonDeletedElements as ZL}from"@hellixit/element";import{LinearElementEditor as jL}from"@hellixit/element";import{isLinearElement as qL,isTextElement as JL}from"@hellixit/element";import{arrayToMap as QL,KEYS as r1}from"@hellixit/common";import{selectGroupsForSelectedElements as e_}from"@hellixit/element";import{CaptureUpdateAction as t_}from"@hellixit/element";var oh=O({name:"selectAll",label:"labels.selectAll",icon:_E,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(JL(i)&&i.containerId)&&!i.locked).reduce((i,l)=>(i[l.id]=!0,i),{});return{appState:{...o,...e_({editingGroupId:null,selectedElementIds:r},ZL(e),o,n),selectedLinearElement:Object.keys(r).length===1&&qL(e[0])?new jL(e[0],QL(e)):null},captureUpdate:t_.IMMEDIATELY}},keyTest:e=>e[r1.CTRL_OR_CMD]&&e.key===r1.A});import{DEFAULT_GRID_SIZE as i1,KEYS as a1,MOBILE_ACTION_BUTTON_BG as o_,arrayToMap as l1}from"@hellixit/common";import{getNonDeletedElements as s1}from"@hellixit/element";import{LinearElementEditor as n_}from"@hellixit/element";import{getSelectedElements as r_,getSelectionStateForElements as i_}from"@hellixit/element";import{syncMovedIndices as a_}from"@hellixit/element";import{duplicateElements as l_}from"@hellixit/element";import{CaptureUpdateAction as c1}from"@hellixit/element";import{jsx as s_}from"react/jsx-runtime";var nh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:_l,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let l=n_.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:l,captureUpdate:c1.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=l_({type:"in-place",elements:e,idsOfElementsToDuplicate:l1(r_(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:l,origIdToDuplicateId:a})=>{let s=l.frameId&&a.get(l.frameId);return{x:l.x+i1/2,y:l.y+i1/2,frameId:s??l.frameId}}});if(n.props.onDuplicate&&i){let l=n.props.onDuplicate(i,e);l&&(i=l)}return{elements:a_(i,l1(r)),appState:{...o,...i_(r,s1(i),o)},captureUpdate:c1.IMMEDIATELY}},keyTest:e=>e[a1.CTRL_OR_CMD]&&e.key===a1.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=at()==="mobile";return s_(J,{type:"button",icon:_l,title:`${h("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":h("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(s1(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?o_:{}}})}});import{pointFrom as u5}from"@hellixit/math";import{useEffect as Sh,useMemo as Ph,useRef as wh,useState as h5}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as g5,DEFAULT_ELEMENT_BACKGROUND_PICKS as f5,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as b5,DEFAULT_ELEMENT_STROKE_PICKS as x5,ARROW_TYPE as oo,DEFAULT_FONT_FAMILY as y5,DEFAULT_FONT_SIZE as E5,FONT_FAMILY as v5,ROUNDNESS as vd,STROKE_WIDTH as kh,VERTICAL_ALIGN as yd,KEYS as Ji,randomInteger as T5,arrayToMap as Ah,getFontFamilyString as I5,getLineHeight as C5,isTransparent as S5,reduceToCommonValue as w5,invariant as Lh,FONT_SIZES as Ed}from"@hellixit/common";import{canBecomePolygon as k5,getNonDeletedElements as ov}from"@hellixit/element";import{bindBindingElement as q1,calculateFixedPointForElbowArrowBinding as J1,updateBoundElements as M5}from"@hellixit/element";import{LinearElementEditor as zr}from"@hellixit/element";import{newElementWith as et}from"@hellixit/element";import{getArrowheadForPicker as Q1}from"@hellixit/element";import{getBoundTextElement as Qn,redrawTextBoundingBox as Ql}from"@hellixit/element";import{isArrowElement as Td,isBoundToContainer as P5,isElbowArrow as nv,isLinearElement as Mh,isLineElement as ev,isTextElement as Nt,isUsingAdaptiveRadius as A5}from"@hellixit/element";import{hasStrokeColor as L5}from"@hellixit/element";import{updateElbowArrowPoints as _5,CaptureUpdateAction as tt,toggleLinePolygonState as D5}from"@hellixit/element";import{deriveStylesPanelMode as H5}from"@hellixit/common";import{isDevEnv as c_}from"@hellixit/common";var d_=new Set(["command_palette","export"]),ce=(e,o,t,n)=>{try{if(typeof window>"u"||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!=="true"||!d_.has(e)||c_())return;C.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import h_ from"clsx";import m_ from"clsx";import{forwardRef as p_}from"react";import{jsx as u_}from"react/jsx-runtime";var Vi=p_((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:l,icon:a,onClick:s}=e;return u_("button",{type:"button",ref:o,title:t,"data-testid":r,className:m_(n,{standalone:l,active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as f_,jsx as rh,jsxs as g_}from"react/jsx-runtime";var Rt=e=>rh(f_,{children:e.options.map(o=>e.type==="button"?rh(Vi,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):g_("label",{className:h_({active:e.value===o.value}),title:o.text,children:[rh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import{Popover as P1}from"radix-ui";import A1 from"clsx";import{useRef as L1,useEffect as xD}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as k1,COLOR_PALETTE as _1,isColorDark as M1,isWritableElement as yD}from"@hellixit/common";import{jsx as b_}from"react/jsx-runtime";var rd=()=>b_("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as T_,useRef as I_}from"react";import{createPortal as C_}from"react-dom";import{EVENT as Vn,KEYS as S_,rgbToHex as w_}from"@hellixit/common";import d1 from"react";var ih=d1.createContext(null),se=()=>d1.useContext(ih);import{useState as x_,useLayoutEffect as m1}from"react";import{THEME as y_}from"@hellixit/common";var id=e=>{let[o,t]=x_(null),n=fe(),{theme:r}=se(),{container:i}=_e();return m1(()=>{o&&(o.className="",o.classList.add("hellixitboard",...e?.className?.split(/\s+/)||[]),o.classList.toggle("hellixitboard--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===y_.DARK))},[o,r,n.formFactor,e?.className]),m1(()=>{let l=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!l)return;let a=document.createElement("div");return l.appendChild(a),t(a),()=>{l.removeChild(a)}},[i,e?.parentSelector]),o};import{useEffect as E_}from"react";import{EVENT as ad}from"@hellixit/common";function Xi(e,o,t){E_(()=>{function n(r){let i=r;if(!e.current)return;let l=t?.(i,e.current);if(l===!0)return;if(l===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(ad.POINTER_DOWN,n),document.addEventListener(ad.TOUCH_START,n),()=>{document.removeEventListener(ad.POINTER_DOWN,n),document.removeEventListener(ad.TOUCH_START,n)}},[e,o,t])}import{useRef as v_}from"react";var Yn=e=>{let o=v_(e);return Object.assign(o.current,e),o.current};import{jsx as k_}from"react/jsx-runtime";var Xn=ge(null),p1=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=id({className:"hellixitboard-eye-dropper-backdrop",parentSelector:".hellixitboard-eye-dropper-container"}),i=se(),l=Kn(),a=Ae(),s=oe(l,i),c=Yn({app:a,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=_e();T_(()=>{let d=p.current;if(!d||!a.canvas||!r)return;let u=!1,b=a.canvas.getContext("2d"),g=({clientX:S,clientY:M})=>{let k=b.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return w_(k[0],k[1],k[2])},x=({clientX:S,clientY:M,altKey:k})=>{d.style.top=`${M+20}px`,d.style.left=`${S+20}px`;let _=g({clientX:S,clientY:M});u&&c.onChange(n,_,c.selectedElements,{altKey:k}),d.style.background=_},v=()=>{c.onCancel()},y=(S,M)=>{c.onSelect(S,M)},E=S=>{u=!0,S.stopImmediatePropagation()},T=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),y(g(S),S)},I=S=>{S.key===S_.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),v())};return r.tabIndex=-1,r.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(Vn.KEYDOWN,I),r.addEventListener(Vn.POINTER_DOWN,E),r.addEventListener(Vn.POINTER_UP,T),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(Vn.BLUR,v),()=>{u=!1,r.removeEventListener(Vn.KEYDOWN,I),r.removeEventListener(Vn.POINTER_DOWN,E),r.removeEventListener(Vn.POINTER_UP,T),window.removeEventListener("pointermove",x),window.removeEventListener(Vn.BLUR,v)}},[c,a.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=I_(null);return Xi(p,()=>{e()},d=>!!d.target.closest(".hellixitboard-eye-dropper-trigger, .hellixitboard-eye-dropper-backdrop")),r?C_(k_("div",{ref:p,className:"hellixitboard-eye-dropper-preview"}),r):null};import{Popover as ah}from"radix-ui";import L_ from"clsx";import __ from"react";import{isInteractive as D_}from"@hellixit/common";import M_ from"react";import P_ from"clsx";import{jsx as A_}from"react/jsx-runtime";var Xe=M_.forwardRef(({children:e,padding:o,className:t,style:n},r)=>A_("div",{className:P_("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as lh,jsxs as H_}from"react/jsx-runtime";var Vo=__.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:l,onPointerLeave:a,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=fe(),d=p.formFactor==="phone"&&!p.isLandscape;return lh(ah.Portal,{container:o,children:H_(ah.Content,{ref:m,className:L_("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:a,onKeyDown:i,onFocusOutside:l,onPointerDownOutside:s,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!D_(document.activeElement)&&o.focus(),r()},children:[lh(Xe,{padding:3,style:n,children:t}),lh(ah.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as R_,useCallback as sh}from"react";var ld=()=>document.querySelector(".hellixitboard-wysiwyg"),sd=()=>{let e=ld();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ul=e=>{setTimeout(()=>{let o=ld();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},Wl=(e,o,t,n)=>{o&&n&&n();let r=o&&t?sd():null;e(),o&&t&&Ul(r)},u1=()=>{let[e,o]=R_(null),t=sh(()=>{let i=sd();o(i)},[]),n=sh(()=>{setTimeout(()=>{let i=ld();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=sh(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},h1=(e=100)=>{let o=ld();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import B_ from"clsx";import{useCallback as F_,useEffect as dh,useRef as f1,useState as O_}from"react";import{KEYS as mh,normalizeInputColor as z_}from"@hellixit/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as N_}from"@hellixit/common";var $n=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Yl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ch=({color:e,palette:o})=>!Object.values(o).flat().includes(e),g1=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(l=>{if(l.isDeleted)return!1;let a=l[n[o]];return ch({color:a,palette:t})}),i=new Map;return r.forEach(l=>{let a=l[n[o]];i.has(a)?i.set(a,i.get(a)+1):i.set(a,1)}),[...i.entries()].sort((l,a)=>a[1]-l[1]).map(l=>l[0]).slice(0,N_)},eo=ge(null);import{Fragment as G_,jsx as cd,jsxs as b1}from"react/jsx-runtime";var x1=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=fe(),[l,a]=O_(e),[s,c]=Q(eo);dh(()=>{a(e)},[e]);let m=F_(g=>{let x=g.toLowerCase(),v=z_(x);v&&o(v),a(x)},[o]),p=f1(null),d=f1(null);dh(()=>{p.current&&p.current.focus()},[s]);let[u,b]=Q(Xn);return dh(()=>()=>{b(null)},[b]),b1("div",{className:"color-picker__input-label",children:[cd("div",{className:"color-picker__input-hash",children:"#"}),cd("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{m(g.target.value)},value:(l||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:g=>{g.key!==mh.TAB&&(g.key===mh.ESCAPE&&d.current?.focus(),g.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&b1(G_,{children:[cd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),cd("div",{ref:d,className:B_("hellixitboard-eye-dropper-trigger",{selected:u}),onClick:()=>b(g=>g?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${h("labels.eyeDropper")} \u2014 ${mh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:vE})]})]})};import gh,{useEffect as fh,useImperativeHandle as lD,useState as sD}from"react";import{EVENT as C1}from"@hellixit/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as cD,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as dD,KEYS as mD}from"@hellixit/common";import V_ from"clsx";import{useEffect as X_,useRef as K_}from"react";import{isColorDark as U_}from"@hellixit/common";import{jsxs as Y_}from"react/jsx-runtime";var W_=({color:e,keyLabel:o,isShade:t=!1})=>Y_("div",{className:"color-picker__button__hotkey-label",style:{color:U_(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Ki=W_;import{jsx as ph,jsxs as $_}from"react/jsx-runtime";var y1=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=Q(eo),l=K_(null);return X_(()=>{l.current&&l.current.focus()},[o,r]),ph("div",{className:"color-picker-content--default",children:e.map((a,s)=>$_("button",{ref:o===a?l:void 0,tabIndex:-1,type:"button",className:V_("color-picker__button color-picker__button--large has-outline",{active:o===a,"is-transparent":a==="transparent"||!a}),onClick:()=>{t(a),i("custom")},title:a,"aria-label":n,style:{"--swatch-color":a},children:[ph("div",{className:"color-picker__button-outline"}),ph(Ki,{color:a,keyLabel:s+1})]},s))})};import Z_ from"clsx";import{useEffect as j_,useRef as q_}from"react";import{jsx as uh,jsxs as Q_}from"react/jsx-runtime";var J_=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=$n({color:o,palette:e}),[l,a]=Q(eo),s=q_(null);return j_(()=>{s.current&&l==="baseColors"&&s.current.focus()},[i?.colorName,l]),uh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",u=Yl[p],b=h(`colors.${c.replace(/\d+/,"")}`,null,"");return Q_("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:Z_("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${b}${d.startsWith("#")?` ${d}`:""} \u2014 ${u}`,"aria-label":`${b} \u2014 ${u}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[uh("div",{className:"color-picker__button-outline"}),r&&uh(Ki,{color:d,keyLabel:u})]},c)})})},E1=J_;import{jsx as tD}from"react/jsx-runtime";var eD=({children:e})=>tD("div",{className:"color-picker__heading",children:e}),$i=eD;import oD from"clsx";import{useEffect as nD,useRef as rD}from"react";import{jsx as Vl,jsxs as v1}from"react/jsx-runtime";var T1=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=$n({color:e||"transparent",palette:t}),[i,l]=Q(eo),a=rD(null);if(nD(()=>{a.current&&i==="shades"&&a.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return Vl("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>v1("button",{ref:d===c&&i==="shades"?a:void 0,tabIndex:-1,type:"button",className:oD("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),l("shades")},children:[Vl("div",{className:"color-picker__button-outline"}),n&&Vl(Ki,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return v1("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Vl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Vl("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:h("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Zi,COLOR_PALETTE as iD,KEYS as Xl}from"@hellixit/common";var hh=(e,o,t)=>{let n=Math.ceil(t/Zi);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Zi;return r>=t?o%Zi:r}case"ArrowUp":{let r=o-Zi,i=r<0?Zi*n+r:r;return i>=t?void 0:i}}},aD=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:l})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let a=Number(e.code.slice(-1))-1;return t(n[o.colorName][a]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Yl.includes(e.key)){let a=Yl.indexOf(e.key),s=Object.keys(n)[a],c=n[s],m=Array.isArray(c)?c[l]:c;return t(m),i("baseColors"),!0}return!1},I1=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:l,updateData:a,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[Xl.CTRL_OR_CMD])return!1;if(e.key===Xl.ESCAPE)return m(e),!0;if(e.key===Xl.ALT)return c(!0),!0;if(e.key===Xl.I)return c(),!0;let p=$n({color:n,palette:t});if(e.key===Xl.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(d).reduce((y,[E,T])=>(T&&y.push(E),y),[]),b=u.indexOf(o),g=e.shiftKey?-1:1,x=b+g>u.length-1?0:b+g<0?u.length-1:b+g,v=u[x];return v&&l(v),v==="custom"?r(i[0]):v==="baseColors"&&(Object.entries(t).find(([E,T])=>Array.isArray(T)?T.includes(n):T===n?E:null)||r(iD.black)),e.preventDefault(),e.stopPropagation(),!0}if(aD({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:l,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,u=hh(e.key,d,Zi);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,u=Object.keys(t),b=u.indexOf(d),g=hh(e.key,b,u.length);if(g!==void 0){let x=u[g],v=t[x];return r(Array.isArray(v)?v[s]:v),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,u=hh(e.key,d,i.length);if(u!==void 0){let b=i[u];return r(b),!0}}return!1};import{jsx as Zn,jsxs as dd}from"react/jsx-runtime";var S1=gh.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:l,showTitle:a,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=a?t==="elementStroke"?h("labels.stroke"):t==="elementBackground"?h("labels.background"):null:null,[u]=gh.useState(()=>t==="canvasBackground"?[]:g1(n,t,r)),[b,g]=Q(eo),x=$n({color:e,palette:r});fh(()=>{if(!b){let T=!!e&&ch({color:e,palette:r}),I=T&&!u.includes(e);g(I?null:T?"custom":x?.shade!=null?"shades":"baseColors")}},[b,e,r,g,x,u]);let[v,y]=sD(x?.shade??(t==="elementBackground"?cD:dD));fh(()=>{x?.shade!=null&&y(x.shade);let T=I=>{I.key===mD.ALT&&s(!1)};return document.addEventListener(C1.KEYUP,T,{capture:!0}),()=>{document.removeEventListener(C1.KEYUP,T,{capture:!0})}},[x,s]);let E=gh.useRef(null);return lD(p,()=>E.current),fh(()=>{E?.current?.focus()},[]),Zn("div",{role:"dialog","aria-modal":"true","aria-label":h("labels.colorPicker"),children:dd("div",{ref:E,onKeyDown:T=>{I1({event:T,activeColorPickerSection:b,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:u,setActiveColorPickerSection:g,updateData:i,activeShade:v,onEscape:c})&&(T.preventDefault(),T.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&Zn("div",{className:"color-picker__title",children:d}),!!u.length&&dd("div",{children:[Zn($i,{children:h("colorPicker.mostUsedCustomColors")}),Zn(y1,{colors:u,color:e,label:h("colorPicker.mostUsedCustomColors"),onChange:o})]}),dd("div",{children:[Zn($i,{children:h("colorPicker.colors")}),Zn(E1,{color:e,palette:r,onChange:o,activeShade:v,showHotKey:m})]}),dd("div",{children:[Zn($i,{children:h("colorPicker.shades")}),Zn(T1,{color:e,onChange:o,palette:r,showHotKey:m})]}),l]})})});import pD from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as uD,DEFAULT_CANVAS_BACKGROUND_PICKS as hD,DEFAULT_ELEMENT_BACKGROUND_PICKS as gD,DEFAULT_ELEMENT_STROKE_PICKS as fD,isColorDark as bD}from"@hellixit/common";import{jsx as bh}from"react/jsx-runtime";var w1=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=fD),o==="elementBackground"&&(r=gD),o==="canvasBackground"&&(r=hD),n&&(r=n),r?bh("div",{className:"color-picker__top-picks",children:r.map(i=>bh("button",{className:pD("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!bD(i,uD)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:bh("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as to,jsxs as md}from"react/jsx-runtime";var ED=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=_1,updateData:l,getOpenPopup:a,appState:s})=>{let{container:c}=_e(),m=at(),p=m!=="full",d=m==="mobile",[,u]=Q(eo),[b,g]=Q(Xn),x=md("div",{children:[to($i,{children:h("colorPicker.hexCode")}),to(x1,{color:o||"",label:n,onChange:E=>{t(E)},colorPickerType:e,placeholder:h("colorPicker.color")})]}),v=L1(null),y=()=>{v.current?.focus()};return to(Vo,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:E=>{yD(E.target)||y(),E.preventDefault()},onPointerDownOutside:E=>{b&&E.preventDefault()},onClose:()=>{a()===e&&l({openPopup:null}),u(null),s.editingTextElement&&setTimeout(()=>{let E=document.querySelector(".hellixitboard-wysiwyg");E&&E.focus()},0)},children:i?to(S1,{ref:v,palette:i,color:o,onChange:E=>{let T=s.editingTextElement?sd():null;t(E),s.editingTextElement&&T&&Ul(T)},onEyeDropperToggle:E=>{g(T=>E?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):E===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:E=>{b?g(null):l({openPopup:null})},type:e,elements:r,updateData:l,showTitle:p,showHotKey:!d,children:x}):x})},vD=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let l=at(),a=l!=="full",s=l==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&h1(),r()};return md(P1.Trigger,{type:"button",className:A1("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!M1(o,k1),"compact-sizing":a,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?h("labels.showStroke"):h("labels.showBackground"),"data-openpopup":t,onClick:c,children:[to("div",{className:"color-picker__button-outline",children:!o&&T0}),a&&o&&n==="stroke"&&to("div",{className:"color-picker__button-background",children:to("span",{style:{color:o&&M1(o,k1)?"#fff":"#111"},children:XE})})]})},Kl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=_1,topPicks:l,updateData:a,appState:s})=>{let c=L1(s.openPopup);xD(()=>{c.current=s.openPopup},[s.openPopup]);let p=at()!=="full";return to("div",{children:md("div",{role:"dialog","aria-modal":"true",className:A1("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&to(w1,{activeColor:o,onChange:t,type:e,topPicks:l}),!p&&to(rd,{}),md(P1.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&a({openPopup:e})},children:[to(vD,{color:o,label:n,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?a({openPopup:null}):s.openPopup?a({openPopup:e}):a({openPopup:e})}}),s.openPopup===e&&to(ED,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:a,getOpenPopup:()=>c.current,appState:s})]})]})})};import{Popover as $D}from"radix-ui";import ZD from"clsx";import jD,{useCallback as qD,useMemo as JD}from"react";import{FONT_FAMILY as vh}from"@hellixit/common";import OD,{useMemo as Jn,useState as zD,useRef as N1,useEffect as B1,useCallback as F1}from"react";import{arrayToList as GD,debounce as UD,FONT_FAMILY as Or,getFontFamilyString as WD}from"@hellixit/common";import TD from"clsx";import ID from"react";import{jsx as CD,jsxs as SD}from"react/jsx-runtime";var pd=ID.forwardRef(({className:e,placeholder:o,onChange:t},n)=>SD("div",{className:TD("QuickSearch__wrapper",e),children:[Kt,CD("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import wD from"clsx";import{Children as kD}from"react";import{jsx as D1}from"react/jsx-runtime";var ud=({className:e,placeholder:o,children:t})=>{let n=!kD.count(t);return D1("div",{className:wD("ScrollableList__wrapper",e),role:"menu",children:n?D1("div",{className:"empty",children:o}):t})};import{jsx as MD,jsxs as PD}from"react/jsx-runtime";var H1=({children:e,className:o="",style:t,title:n})=>PD("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&MD("p",{className:"dropdown-menu-group-title",children:n}),e]}),$l=H1;H1.displayName="DropdownMenuGroup";import{THEME as BD}from"@hellixit/common";import{DropdownMenu as FD}from"radix-ui";import AD,{useContext as LD}from"react";import{composeEventHandlers as _D}from"@hellixit/common";var xh=AD.createContext({}),jn=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),hd=e=>{let o=LD(xh);return _D(e,t=>{o.onSelect?.(t)})};import{jsx as DD}from"react/jsx-runtime";var Zl=({children:e,...o})=>DD("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as RD,jsx as jl,jsxs as ND}from"react/jsx-runtime";var HD=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=fe();return ND(RD,{children:[o&&jl("div",{className:"dropdown-menu-item__icon",children:o}),jl("div",{style:e,className:"dropdown-menu-item__text",children:jl(Zl,{children:n})}),r&&jl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&jl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},qn=HD;import{jsx as gd}from"react/jsx-runtime";var yh=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:l,onSelect:a,...s})=>{let c=hd(a);return gd(FD.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:gd("button",{...s,value:t,className:jn(i,l),title:s.title??s["aria-label"],children:gd(qn,{icon:e,shortcut:r,badge:o,children:n})})})};yh.displayName="DropdownMenuItem";var ji={GREEN:"green",RED:"red",BLUE:"blue"},fd=({type:e=ji.BLUE,children:o})=>{let{theme:t}=Xo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===BD.LIGHT?"1.5px solid white":"none"};switch(e){case ji.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ji.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ji.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return gd("div",{className:"DropDownMenuItemBadge",style:n,children:o})};fd.displayName="DropdownMenuItemBadge";yh.Badge=fd;var wt=yh;import{KEYS as qi}from"@hellixit/common";var R1=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:l})=>{if(!e[qi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===qi.F)return o.current?.focus(),!0;if(e.key===qi.ESCAPE)return r(),!0;if(e.key===qi.ENTER)return t?.value&&i(t.value),!0;if(e.key===qi.ARROW_DOWN)return t?.next?l(t.next.value):n[0]?.value&&l(n[0].value),!0;if(e.key===qi.ARROW_UP)return t?.prev?l(t.prev.value):n[n.length-1]?.value&&l(n[n.length-1].value),!0};import{jsx as vn,jsxs as VD}from"react/jsx-runtime";var YD=e=>{switch(e){case Or.Excalifont:case Or.Virgil:return Uo;case Or.Nunito:case Or.Helvetica:return Nl;case Or["Lilita One"]:return dE;case Or["Comic Shanns"]:case Or.Cascadia:return Vc;default:return Nl}},O1=OD.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:l})=>{let{container:a}=_e(),s=Ae(),{fonts:c}=s,{showDeprecatedFonts:m}=Ko(),p=at(),[d,u]=zD(""),b=N1(null),g=Jn(()=>Array.from(Gn.registered.entries()).filter(([A,{metadata:H}])=>!H.private&&!H.fallback).map(([A,{metadata:H,fontFaces:F}])=>{let Y={value:A,icon:YD(A),text:F[0]?.fontFace?.family??"Unknown"};return H.deprecated&&Object.assign(Y,{deprecated:H.deprecated,badge:{type:ji.RED,placeholder:h("fontList.badge.old")}}),Y}).sort((A,H)=>A.text.toLowerCase()>H.text.toLowerCase()?1:-1),[]),x=Jn(()=>new Set(c.getSceneFamilies()),[e]),v=Jn(()=>g.filter(A=>x.has(A.value)),[g,x]),y=Jn(()=>g.filter(A=>!x.has(A.value)&&(m||!A.deprecated)),[g,x,m]),E=Jn(()=>GD([...v,...y].filter(A=>A.text?.toLowerCase().includes(d))),[v,y,d]),T=Jn(()=>{let A;return o?A=E.find(H=>H.value===o):e&&(A=E.find(H=>H.value===e)),!A&&d&&(E[0]?.value?n(E[0].value):r()),A},[o,e,d,E,n,r]),I=F1(A=>{let H=null;if(s.state.editingTextElement){let F=document.querySelector(".hellixitboard-wysiwyg");F&&(H={start:F.selectionStart,end:F.selectionEnd})}t(A),s.state.editingTextElement&&H&&setTimeout(()=>{let F=document.querySelector(".hellixitboard-wysiwyg");F&&H&&(F.focus(),F.selectionStart=H.start,F.selectionEnd=H.end)},0)},[t,s.state.editingTextElement]),S=F1(A=>{R1({event:A,inputRef:b,hoveredFont:T,filteredFonts:E,onSelect:I,onHover:n,onClose:l})&&(A.preventDefault(),A.stopPropagation())},[T,E,I,n,l]);B1(()=>(i(),()=>{l()}),[]);let M=Jn(()=>E.filter(A=>x.has(A.value)),[E,x]),k=Jn(()=>E.filter(A=>!x.has(A.value)),[E,x]),_=({font:A,order:H})=>{let F=N1(null),Y=A.value===T?.value,V=A.value===e;return B1(()=>{Y&&(H===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,H]),vn("button",{ref:F,type:"button",value:A.value,className:jn("",V,Y),title:A.text,tabIndex:V?0:-1,onClick:U=>{I(Number(U.currentTarget.value))},onMouseMove:()=>{T?.value!==A.value&&n(A.value)},children:vn(qn,{icon:A.icon,badge:A.badge&&vn(fd,{type:A.badge.type,children:A.badge.placeholder}),textStyle:{fontFamily:WD({fontFamily:A.value})},children:A.text})})},P=[];return M.length&&P.push(vn($l,{title:h("fontList.sceneFonts"),children:M.map((A,H)=>vn(_,{font:A,order:H},A.value))},"group_1")),k.length&&P.push(vn($l,{title:h("fontList.availableFonts"),children:k.map((A,H)=>vn(_,{font:A,order:H+M.length},A.value))},"group_2")),VD(Vo,{className:"properties-content",container:a,style:{width:"15rem"},onClose:()=>{l(),s.state.editingTextElement&&setTimeout(()=>{let A=document.querySelector(".hellixitboard-wysiwyg");A&&A.focus()},0)},onPointerLeave:r,onKeyDown:S,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&vn(pd,{ref:b,placeholder:h("quickSearch.placeholder"),onChange:UD(u,20)}),vn(ud,{className:"dropdown-menu fonts manual-hover",placeholder:h("fontList.empty"),children:P.length?P:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as XD}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as KD}from"@hellixit/common";import{jsx as Eh}from"react/jsx-runtime";var z1=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...KD,width:"2rem",height:"2rem"}:{};return Eh(XD.Trigger,{asChild:!0,children:Eh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Eh(Vi,{standalone:!0,icon:Wo,title:h("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as ql,jsxs as G1}from"react/jsx-runtime";var U1=[{value:vh.Excalifont,icon:Uo,text:h("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:vh.Nunito,icon:Nl,text:h("labels.normal"),testId:"font-family-normal"},{value:vh["Comic Shanns"],icon:Vc,text:h("labels.code"),testId:"font-family-code"}],pte=new Set(U1.map(e=>e.value));var W1=jD.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:l,compactMode:a=!1})=>{let s=JD(()=>U1,[]),c=qD(m=>{m&&n(m)},[n]);return G1("div",{role:"dialog","aria-modal":"true",className:ZD("FontPicker__container",{"FontPicker__container--compact":a}),children:[!a&&ql("div",{className:"buttonList",children:ql(Rt,{type:"button",options:s,value:o,onClick:c})}),!a&&ql(rd,{}),G1($D.Root,{open:e,onOpenChange:l,children:[ql(z1,{selectedFontFamily:o,isOpened:e,compactMode:a}),e&&ql(O1,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>l(!0),onClose:()=>l(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as Th}from"radix-ui";import o5 from"clsx";import K1,{useEffect as n5,useMemo as r5}from"react";import{isArrowKey as i5,KEYS as Tn}from"@hellixit/common";import{jsx as QD}from"react/jsx-runtime";var $o=({className:e,icon:o,size:t="1em"})=>QD("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as t5,jsx as Y1,jsxs as V1}from"react/jsx-runtime";var e5=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>V1(t5,{children:[V1("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Y1($o,{icon:o?WE:Zc})]}),o&&Y1("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Jl=e5;import{jsx as Zo,jsxs as xd}from"react/jsx-runtime";var a5=ge(!1),bd=4,l5="default",s5=e=>e.flatMap(o=>o.options),X1=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},c5=(e,o)=>e.some(t=>t.options.some(o)),d5=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/bd)},(t,n)=>o.options.slice(n*bd,n*bd+bd)));function m5({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:l}=_e(),[a,s]=Q(a5),c=[...e,...o],m=s5(c),p=d5([...e,...a?o:[]]),d=g=>{let x=m.find(v=>v.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&x)r(x.value),g.preventDefault();else if(g.key===Tn.TAB){let v=m.findIndex(E=>E.value===t),y=g.shiftKey?(m.length+v-1)%m.length:(v+1)%m.length;r(m[y].value)}else if(i5(g.key)){let v=En().rtl,y=m.findIndex(E=>E.value===t);if(y!==-1){let E=m.length,T=y;switch(g.key){case(v?Tn.ARROW_LEFT:Tn.ARROW_RIGHT):T=(y+1)%E;break;case(v?Tn.ARROW_RIGHT:Tn.ARROW_LEFT):T=(E+y-1)%E;break;case Tn.ARROW_DOWN:{let I=p.findIndex(M=>M.some(k=>k.value===t)),S=p[I];if(I!==-1&&S){let M=S.findIndex(P=>P.value===t),k=p[(I+1)%p.length],_=k[Math.min(M,k.length-1)]??m[y];r(_.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Tn.ARROW_UP:{let I=p.findIndex(M=>M.some(k=>k.value===t)),S=p[I];if(I!==-1&&S){let M=S.findIndex(P=>P.value===t),k=p[(p.length+I-1)%p.length],_=k[Math.min(M,k.length-1)]??m[y];r(_.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(m[T].value)}g.preventDefault()}else(g.key===Tn.ESCAPE||g.key===Tn.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};n5(()=>{c5(o,g=>g.value===t)&&s(!0)},[t,o,s]);let u=g=>Zo("div",{className:"picker-content",children:g.map(x=>xd("button",{type:"button",className:o5("picker-option",{active:t===x.value}),onClick:()=>{r(x.value)},title:x.keyBinding?`${x.text} \u2014 ${x.keyBinding.toUpperCase()}`:x.text,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:v=>{t===x.value&&setTimeout(()=>{v?.focus()},0)},children:[x.icon,x.keyBinding&&Zo("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),b=g=>g.map((x,v)=>x.name===l5?Zo(K1.Fragment,{children:u(x.options)},`${x.name}-${v}`):xd("div",{className:"picker-section",children:[Zo("div",{className:"picker-section-label",children:x.name}),u(x.options)]},`${x.name}-${v}`));return Zo(Th.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:d,collisionBoundary:l??void 0,children:xd("div",{className:"picker-sections",children:[b(e),o.length>0&&Zo(Jl,{label:h("labels.more_options"),open:a,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:Zo("div",{className:"picker-sections",children:b(o)})})]})})}function Ih({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,l]=K1.useState(!1),a=r5(()=>X1(t,s=>s.value===e)??X1(n??[],s=>s.value===e),[t,n,e]);return Zo("div",{children:xd(Th.Root,{open:i,onOpenChange:s=>l(s),children:[Zo(Th.Trigger,{type:"button","aria-label":o,onClick:()=>l(!i),className:i?"active":"",children:a?.icon}),i&&Zo(m5,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{l(!1)}})]})})}import $1,{useEffect as p5}from"react";import{jsx as Ch,jsxs as Z1}from"react/jsx-runtime";var j1=({updateData:e,app:o,testId:t})=>{let n=$1.useRef(null),r=$1.useRef(null),i=o.scene.getSelectedElements(o.state),l=!0,a=i.at(0),c=i.reduce((m,p)=>(m!=null&&m!==p.opacity&&(l=!1),m==null||m>p.opacity?p.opacity:m),a?.opacity??null)??o.state.currentItemOpacity;return p5(()=>{if(n.current&&r.current){let m=n.current,p=r.current,d=m.offsetWidth,u=15,b=c/100*(d-u)+u/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),Z1("label",{className:"control-label",children:[h("labels.opacity"),Z1("div",{className:"range-wrapper",children:[Ch("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),Ch("div",{className:"value-bubble",ref:r,children:c!==0?c:null}),Ch("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Id,jsx as q,jsxs as Ze}from"react/jsx-runtime";var rv=.1,Qi=e=>{let o=H5(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},bt=(e,o,t,n=!1)=>{let r=Ah(oe(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},xt=function(e,o,t,n,r){let i=o.state.editingTextElement,l=ov(e),a=null;if(i&&(a=t(i)),!a)if(Me(l,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));a=w5(m,t)??(typeof r=="function"?r(!0):r)}else a=typeof r=="function"?r(!1):r;return a},R5=(e,o,t)=>P5(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),_h=(e,o,t,n,r)=>{let i=new Set,l=bt(e,o,a=>{if(Nt(a)){let s=n(a);i.add(s);let c=et(a,{fontSize:s});return Ql(c,t.scene.getContainerElement(a),t.scene),c=R5(a,c,t.scene),c}return a},!0);return oe(e,o,{includeBoundTextElement:!0}).forEach(a=>{Nt(a)&&M5(a,t.scene)}),{elements:l,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:tt.IMMEDIATELY}},N5=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:bt(e,o,n=>L5(n.type)?et(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?tt.IMMEDIATELY:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Qi(n);return Ze(Id,{children:[i==="full"&&q("h3",{"aria-hidden":"true",children:h("labels.stroke")}),q(Kl,{topPicks:x5,palette:b5,type:"elementStroke",label:h("labels.stroke"),color:xt(e,n,l=>l.strokeColor,!0,l=>l?null:o.currentItemStrokeColor),onChange:l=>t({currentItemStrokeColor:l}),elements:e,appState:o,updateData:t})]})}}),B5=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:tt.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!S5(t.currentItemBackgroundColor)&&i.every(a=>ev(a)&&k5(a.points))){let a=Ah(i);r=e.map(s=>a.has(s.id)&&ev(s)?et(s,{backgroundColor:t.currentItemBackgroundColor,...D5(s,!0)}):s)}else r=bt(e,o,a=>et(a,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=Qi(n);return Ze(Id,{children:[i==="full"&&q("h3",{"aria-hidden":"true",children:h("labels.background")}),q(Kl,{topPicks:f5,palette:g5,type:"elementBackground",label:h("labels.background"),color:xt(e,n,l=>l.backgroundColor,!0,l=>l?null:o.currentItemBackgroundColor),onChange:l=>t({currentItemBackgroundColor:l}),elements:e,appState:o,updateData:t})]})}}),F5=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ce("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:bt(e,o,r=>et(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=oe(e,o),i=r.length>0&&r.every(l=>l.fillStyle==="zigzag");return Ze("fieldset",{children:[q("legend",{children:h("labels.fill")}),q("div",{className:"buttonList",children:q(Rt,{type:"button",options:[{value:"hachure",text:`${i?h("labels.zigzag"):h("labels.hachure")} (${N("Alt-Click")})`,icon:i?_0:D0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:h("labels.crossHatch"),icon:H0,testId:"fill-cross-hatch"},{value:"solid",text:h("labels.solid"),icon:R0,testId:"fill-solid"}],value:xt(e,n,l=>l.fillStyle,l=>l.hasOwnProperty("fillStyle"),l=>l?null:o.currentItemFillStyle),onClick:(l,a)=>{let s=a.altKey&&l==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":l;t(s)}})})]})}}),O5=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.strokeWidth")}),q("div",{className:"buttonList",children:q(Rt,{group:"stroke-width",options:[{value:kh.thin,text:h("labels.thin"),icon:Uu,testId:"strokeWidth-thin"},{value:kh.bold,text:h("labels.bold"),icon:N0,testId:"strokeWidth-bold"},{value:kh.extraBold,text:h("labels.extraBold"),icon:B0,testId:"strokeWidth-extraBold"}],value:xt(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),z5=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{seed:T5(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.sloppiness")}),q("div",{className:"buttonList",children:q(Rt,{group:"sloppiness",options:[{value:0,text:h("labels.architect"),icon:z0},{value:1,text:h("labels.artist"),icon:G0},{value:2,text:h("labels.cartoonist"),icon:U0}],value:xt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),xoe=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Ze("fieldset",{children:[q("legend",{children:h("labels.strokeStyle")}),q("div",{className:"buttonList",children:q(Rt,{group:"strokeStyle",options:[{value:"solid",text:h("labels.strokeStyle_solid"),icon:Uu},{value:"dashed",text:h("labels.strokeStyle_dashed"),icon:F0},{value:"dotted",text:h("labels.strokeStyle_dotted"),icon:O0}],value:xt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),G5=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>et(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>q(j1,{updateData:o,app:e,testId:"opacity"})}),U5=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,()=>(Lh(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Qi(n);return Ze("fieldset",{children:[q("legend",{children:h("labels.fontSize")}),q("div",{className:"buttonList",children:q(Rt,{group:"font-size",options:[{value:Ed.sm,text:h("labels.small"),icon:aE,testId:"fontSize-small"},{value:Ed.md,text:h("labels.medium"),icon:lE,testId:"fontSize-medium"},{value:Ed.lg,text:h("labels.large"),icon:sE,testId:"fontSize-large"},{value:Ed.xl,text:h("labels.veryLarge"),icon:cE,testId:"fontSize-veryLarge"}],value:xt(e,n,l=>{if(Nt(l))return l.fontSize;let a=Qn(l,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},l=>Nt(l)||Qn(l,n.scene.getNonDeletedElementsMap())!==null,l=>l?null:o.currentItemFontSize||E5),onChange:l=>{Wl(()=>t(l),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),Dh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Br,trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,r=>Math.round(1/(1+rv)*r.fontSize)),keyTest:e=>e[Ji.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ji.CHEVRON_LEFT||e.key===Ji.COMMA)}),Hh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Br,trackEvent:!1,perform:(e,o,t,n)=>_h(e,o,n,r=>Math.round(r.fontSize*(1+rv))),keyTest:e=>e[Ji.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ji.CHEVRON_RIGHT||e.key===Ji.PERIOD)}),W5=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:l,...a}=t;if(i)return{elements:bt(e,o,g=>{let x=r?.get(g.id);return x?et(g,{...x}):g},!0),appState:{...o,...a},captureUpdate:tt.NEVER};Lh(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=tt.EVENTUALLY,p,d=!1;if(s)p=s,m=tt.IMMEDIATELY;else if(c){p=c,m=tt.EVENTUALLY;let b=oe(e,o,{includeBoundTextElement:!0}).filter(g=>Nt(g));if(b.length>200)d=!0;else{let g=0,x=0;for(;g<b.length&&x<5e3;){let v=b[g];x+=v?.originalText.length||0,g++}x>5e3&&(d=!0)}}let u={appState:{...o,...a},captureUpdate:m};if(p&&!d){let b=new Map,g=new Set,x=!1,v=Array.from(Gn.loadedFontsCache.values()),y=Object.entries(v5).find(([I,S])=>S===p)?.[0];c&&y&&v.some(I=>I.startsWith(y))&&(x=!0),Object.assign(u,{elements:bt(e,o,I=>{if(Nt(I)&&(I.fontFamily!==p||s)){let S=et(I,{fontFamily:p,lineHeight:C5(p)}),M=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return l&&k&&M&&n.scene.mutateElement(k,{...M}),x||(g=new Set([...g,...Array.from(S.originalText)])),b.set(S,k),S}return I},!0)});let E=`10px ${I5({fontFamily:p})}`,T=Array.from(g.values()).join();if(x||window.document.fonts.check(E,T))for(let[I,S]of b)Ql(I,S,n.scene);else window.document.fonts.load(E,T).then(I=>{for(let[S,M]of b){let k=n.scene.getElement(S.id),_=M?n.scene.getElement(M.id):null;k&&Ql(k,_,n.scene)}n.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=wh(new Map),i=wh(null),[l,a]=h5({}),s=wh(!0),{stylesPanelMode:c,isCompact:m}=Qi(t),p=Ph(()=>{let d=(u,b)=>xt(u,t,g=>{if(Nt(g))return g.fontFamily;let x=Qn(g,b);return x?x.fontFamily:null},g=>Nt(g)||Qn(g,b)!==null,g=>g?null:o.currentItemFontFamily||y5);return l.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!l.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[l.openPopup,o,e,t]);return Sh(()=>{i.current=p},[p]),Sh(()=>{Object.keys(l).length&&(n(l),a({}))},[l]),Sh(()=>(s.current=!1,()=>{s.current=!0}),[]),Ze(Id,{children:[c==="full"&&q("legend",{children:h("labels.fontFamily")}),q(W1,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{Wl(()=>{a({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{a({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{a({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:u}=o;if(u?.type==="text"){let b=t.scene.getElement(u.id);r.current.set(u.id,et(b||u,{},!0))}else{let b=oe(e,o,{includeBoundTextElement:!0});for(let g of b)r.current.set(g.id,et(g,{},!0))}a({...l,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};a({...u}),r.current.clear(),m&&o.editingTextElement&&Ul(null)}}})]})}}),Y5=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:bt(e,o,r=>{if(Nt(r)){let i=et(r,{textAlign:t});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:l}=Qi(n);return Ze("fieldset",{children:[q("legend",{children:h("labels.textAlign")}),q("div",{className:"buttonList",children:q(Rt,{group:"text-align",options:[{value:"left",text:h("labels.left"),icon:mE,testId:"align-left"},{value:"center",text:h("labels.center"),icon:pE,testId:"align-horizontal-center"},{value:"right",text:h("labels.right"),icon:uE,testId:"align-right"}],value:xt(e,n,a=>{if(Nt(a))return a.textAlign;let s=Qn(a,i);return s?s.textAlign:null},a=>Nt(a)||Qn(a,i)!==null,a=>a?null:o.currentItemTextAlign),onChange:a=>{Wl(()=>t(a),l,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),V5=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:bt(e,o,r=>{if(Nt(r)){let i=et(r,{verticalAlign:t});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=Qi(n);return q("fieldset",{children:q("div",{className:"buttonList",children:q(Rt,{group:"text-align",options:[{value:yd.TOP,text:h("labels.alignTop"),icon:q(hE,{theme:o.theme}),testId:"align-top"},{value:yd.MIDDLE,text:h("labels.centerVertically"),icon:q(fE,{theme:o.theme}),testId:"align-middle"},{value:yd.BOTTOM,text:h("labels.alignBottom"),icon:q(gE,{theme:o.theme}),testId:"align-bottom"}],value:xt(e,n,l=>{if(Nt(l)&&l.containerId)return l.verticalAlign;let a=Qn(l,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},l=>Nt(l)||Qn(l,n.scene.getNonDeletedElementsMap())!==null,l=>l?null:yd.MIDDLE),onChange:l=>{Wl(()=>t(l),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),yoe=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:bt(e,o,n=>nv(n)?n:et(n,{roundness:t==="round"?{type:A5(n.type)?vd.ADAPTIVE_RADIUS:vd.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let l=xi(ov(e),o).some(a=>a.roundness?.type===vd.LEGACY);return Ze("fieldset",{children:[q("legend",{children:h("labels.edges")}),Ze("div",{className:"buttonList",children:[q(Rt,{group:"edges",options:[{value:"sharp",text:h("labels.sharp"),icon:W0},{value:"round",text:h("labels.round"),icon:Y0}],value:xt(e,n,a=>l?null:a.roundness?"round":"sharp",a=>!Td(a)&&a.hasOwnProperty("roundness"),a=>a?null:o.currentItemRoundness),onChange:a=>t(a)}),r("togglePolygon")]})]})}}),tv=e=>({visibleSections:[{name:"default",options:[{value:null,text:h("labels.arrowhead_none"),keyBinding:"q",icon:q(V0,{flip:e})},{value:"arrow",text:h("labels.arrowhead_arrow"),keyBinding:"w",icon:q(X0,{flip:e})},{value:"triangle",text:h("labels.arrowhead_triangle"),icon:q(K0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:h("labels.arrowhead_triangle_outline"),icon:q($0,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:h("labels.arrowhead_circle"),keyBinding:"a",icon:q(Z0,{flip:e})},{value:"circle_outline",text:h("labels.arrowhead_circle_outline"),keyBinding:"s",icon:q(j0,{flip:e})},{value:"diamond",text:h("labels.arrowhead_diamond"),icon:q(q0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:h("labels.arrowhead_diamond_outline"),icon:q(J0,{flip:e}),keyBinding:"f"},{value:"bar",text:h("labels.arrowhead_bar"),keyBinding:"z",icon:q(Q0,{flip:e})}]},{name:h("labels.cardinality"),options:[{value:"cardinality_one",text:h("labels.arrowhead_cardinality_one"),icon:q(eE,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:h("labels.arrowhead_cardinality_many"),icon:q(tE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:h("labels.arrowhead_cardinality_one_or_many"),icon:q(oE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:h("labels.arrowhead_cardinality_exactly_one"),icon:q(nE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:h("labels.arrowhead_cardinality_zero_or_one"),icon:q(rE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:h("labels.arrowhead_cardinality_zero_or_many"),icon:q(iE,{flip:e}),keyBinding:null}]}]}),Eoe=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Lh(t,"actionChangeArrowhead: value must be defined"),{elements:bt(e,o,n=>{if(Mh(n)){let{position:r,type:i}=t;if(r==="start")return et(n,{startArrowhead:i});if(r==="end")return et(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=En().rtl,i=Ph(()=>tv(!r),[r]),l=Ph(()=>tv(!!r),[r]);return Ze("fieldset",{children:[q("legend",{children:h("labels.arrowheads")}),Ze("div",{className:"iconSelectList buttonList",children:[q(Ih,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:xt(e,n,a=>Mh(a)&&yi(a.type)?Q1(a.startArrowhead):o.currentItemStartArrowhead,!0,a=>a?null:o.currentItemStartArrowhead),onChange:a=>t({position:"start",type:a})}),q(Ih,{visibleSections:l.visibleSections,hiddenSections:l.hiddenSections,label:"arrowhead_end",value:xt(e,n,a=>Mh(a)&&yi(a.type)?Q1(a.endArrowhead):o.currentItemEndArrowhead,!0,a=>a?null:o.currentItemEndArrowhead),onChange:a=>t({position:"end",type:a})})]})]})}}),X5=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>Ze("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),voe=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=bt(e,o,a=>{if(!Td(a))return a;let s=n.scene.getNonDeletedElementsMap(),c=zr.getPointAtIndexGlobalCoordinates(a,0,s),m=zr.getPointAtIndexGlobalCoordinates(a,-1,s),p=et(a,{x:t===oo.elbow?c[0]:a.x,y:t===oo.elbow?c[1]:a.y,roundness:t===oo.round?{type:vd.PROPORTIONAL_RADIUS}:null,elbowed:t===oo.elbow,angle:t===oo.elbow?0:a.angle,points:t===oo.elbow||a.elbowed?[zr.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},c,s),zr.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},m,s)]:a.points});if(nv(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=zr.getPointAtIndexGlobalCoordinates(p,0,d),b=zr.getPointAtIndexGlobalCoordinates(p,-1,d),g=p.startBinding&&d.get(p.startBinding.elementId),x=p.endBinding&&d.get(p.endBinding.elementId),v=g&&p.startBinding?{...p.startBinding,...J1(p,g,"start",d,o.isBindingEnabled)}:null,y=x&&p.endBinding?{...p.endBinding,...J1(p,x,"end",d,o.isBindingEnabled)}:null;p={...p,startBinding:v,endBinding:y,..._5(p,d,{points:[u,b].map(E=>u5(E[0]-p.x,E[1]-p.y)),startBinding:v,endBinding:y,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=d.get(p.startBinding.elementId);u&&q1(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=d.get(p.endBinding.elementId);u&&q1(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},l=o.selectedLinearElement?.elementId;if(l){let a=r.find(s=>s.id===l);a&&(i.selectedLinearElement=new zr(a,Ah(e)))}return{elements:r,appState:i,captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ze("fieldset",{children:[q("legend",{children:h("labels.arrowtypes")}),q("div",{className:"buttonList",children:q(Rt,{group:"arrowtypes",options:[{value:oo.sharp,text:h("labels.arrowtype_sharp"),icon:zi,testId:"sharp-arrow"},{value:oo.round,text:h("labels.arrowtype_round"),icon:Ui,testId:"round-arrow"},{value:oo.elbow,text:h("labels.arrowtype_elbowed"),icon:Gi,testId:"elbow-arrow"}],value:xt(e,n,r=>Td(r)?r.elbowed?oo.elbow:r.roundness?oo.round:oo.sharp:null,r=>Td(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})}),K5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[q("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),q("line",{x1:"4",y1:"7",x2:"4",y2:"17",strokeWidth:"1.5"}),q("line",{x1:"20",y1:"7",x2:"20",y2:"17",strokeWidth:"1.5"})]}),$5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[q("line",{x1:"2",y1:"12",x2:"8",y2:"12",strokeDasharray:"3 2"}),q("line",{x1:"10",y1:"12",x2:"16",y2:"12",strokeDasharray:"3 2"}),q("line",{x1:"18",y1:"12",x2:"22",y2:"12",strokeDasharray:"3 2"}),q("polyline",{points:"17,8 22,12 17,16"})]}),Z5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[q("line",{x1:"3",y1:"12",x2:"18",y2:"12"}),q("polyline",{points:"13,7 18,12 13,17"})]}),j5=Ze("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[q("line",{x1:"21",y1:"12",x2:"6",y2:"12"}),q("polyline",{points:"11,7 6,12 11,17"})]}),q5=O({name:"changeAnimation",label:"Animations",trackEvent:!1,perform:(e,o,t)=>t?{elements:bt(e,o,n=>et(n,{animationType:t.type,animationDirection:t.direction,animationSpeed:t.speed}),!0),appState:o,captureUpdate:tt.IMMEDIATELY}:!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let i=n.scene.getSelectedElements(n.state)[0],l=i?.animationType??"none",a=i?.animationDirection??"forward",s=i?.animationSpeed??10;return Ze("fieldset",{children:[q("legend",{children:"Animations"}),q("div",{className:"buttonList",children:q(Rt,{group:"animation-type",options:[{value:"none",text:"None",icon:K5},{value:"flow",text:"Flow",icon:$5}],value:l,onChange:m=>t({type:m,direction:a,speed:s})})}),l==="flow"&&Ze(Id,{children:[q("div",{className:"buttonList",style:{marginTop:8},children:q(Rt,{group:"animation-direction",options:[{value:"forward",text:"Forward",icon:Z5},{value:"backward",text:"Backward",icon:j5}],value:a,onChange:m=>t({type:l,direction:m,speed:s})})}),Ze("label",{className:"control-label",style:{marginTop:8,display:"block"},children:["Speed",q("div",{className:"range-wrapper",children:q("input",{type:"range",min:"1",max:"100",step:"1",value:s,onChange:m=>t({type:l,direction:a,speed:+m.target.value}),className:"range-input"})})]})]})]})}});import{clamp as Oh,roundToStep as r3}from"@hellixit/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as i3,CURSOR_TYPE as cv,MAX_ZOOM as dv,MIN_ZOOM as mv,THEME as es,ZOOM_STEP as zh,updateActiveTool as ta,CODES as qo,KEYS as Cn}from"@hellixit/common";import{getNonDeletedElements as a3}from"@hellixit/element";import{newElementWith as l3}from"@hellixit/element";import{getCommonBounds as s3}from"@hellixit/element";import{CaptureUpdateAction as Eo}from"@hellixit/element";import{useEffect as J5}from"react";import{jsx as e3}from"react/jsx-runtime";var ea=()=>{let e=document.querySelector(".hellixitboard-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("hellixitboard-tooltip"),o},Rh=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,l=5,a=o.left+o.width/2-n.width/2;a<0?a=l:a+n.width>=r&&(a=r-n.width-l);let s;t==="bottom"?(s=o.top+o.height+l,s+n.height>=i&&(s=o.top-n.height-l)):(s=o.top-n.height-l,s<0&&(s=o.top+o.height+l)),Object.assign(e.style,{top:`${s}px`,left:`${a}px`})},Q5=(e,o,t,n)=>{o.classList.add("hellixitboard-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Rh(o,r)},$t=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(J5(()=>()=>ea().classList.remove("hellixitboard-tooltip--visible"),[]),r?null:e3("div",{className:"hellixitboard-tooltip-wrapper",onPointerEnter:i=>Q5(i.currentTarget,ea(),o,t),onPointerLeave:()=>ea().classList.remove("hellixitboard-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Nh,MIME_TYPES as Bh,THEME as av}from"@hellixit/common";var lv='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',t3='<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"/>',sv='<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"/>',o3=`data:${Bh.svg},${encodeURIComponent(`${lv}${sv}</svg>`)}`,n3=`data:${Bh.svg},${encodeURIComponent(`${lv}${t3}${sv}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},Ce=(e,o)=>{e&&(e.style.cursor=o)},jo,iv,Fh=(e,o)=>{let n=()=>{let r=o===av.DARK;jo=document.createElement("canvas"),jo.theme=o,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=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),iv=jo.toDataURL(Bh.svg)};(!jo||jo.theme!==o)&&n(),Ce(e,`url(${iv}) ${20/2} ${20/2}, auto`)},jt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(yn(o))e.style.cursor=Nh.GRAB;else if(Ht(o))Fh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===av.LIGHT?o3:n3;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Nh.AUTO):e.style.cursor=Nh.CROSSHAIR};var In=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,l=n.zoom.value,a=n.scrollX+(r-r/l),s=n.scrollY+(i-i/l),c=-(r-r/t),m=-(i-i/t);return{scrollX:a+c,scrollY:s+m,zoom:{value:t}}};import{jsx as kd,jsxs as p3}from"react/jsx-runtime";var c3=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?Eo.IMMEDIATELY:Eo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>kd(Kl,{palette:null,topPicks:i3,label:h("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Sn=O({name:"clearCanvas",label:"labels.clearCanvas",icon:pt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>l3(r,{isDeleted:!0})),appState:{...Oo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:Eo.IMMEDIATELY})}),Cd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:wu,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(o.zoom.value+zh)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd(J,{type:"button",className:"zoom-in-button zoom-button",icon:wu,title:`${h("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":h("buttons.zoomIn"),disabled:o.zoom.value>=dv,onClick:()=>{e(null)}}),keyTest:e=>(e.code===qo.EQUAL||e.code===qo.NUM_ADD)&&(e[Cn.CTRL_OR_CMD]||e.shiftKey)}),Sd=O({name:"zoomOut",label:"buttons.zoomOut",icon:ku,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(o.zoom.value-zh)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd(J,{type:"button",className:"zoom-out-button zoom-button",icon:ku,title:`${h("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":h("buttons.zoomOut"),disabled:o.zoom.value<=mv,onClick:()=>{e(null)}}),keyTest:e=>(e.code===qo.MINUS||e.code===qo.NUM_SUBTRACT)&&(e[Cn.CTRL_OR_CMD]||e.shiftKey)}),wd=O({name:"resetZoom",label:"buttons.resetZoom",icon:h0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...In({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:No(1)},o),userToFollow:null},captureUpdate:Eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>kd($t,{label:h("buttons.resetZoom"),style:{height:"100%"},children:p3(J,{type:"button",className:"reset-zoom-button zoom-button",title:h("buttons.resetZoom"),"aria-label":h("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===qo.ZERO||e.code===qo.NUM_ZERO)&&(e[Cn.CTRL_OR_CMD]||e.shiftKey)}),d3=(e,o,t=1)=>{let[n,r,i,l]=e,a=i-n,s=o.width/a,c=l-r,m=o.height/c,d=Math.min(s,m)*Oh(t,.1,1);return Math.min(d,1)},pv=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:l=1/0})=>{r=Oh(r,mv,dv);let[a,s,c,m]=e,p=(a+c)/2,d=(s+m)/2,u=t?.left??0,b=t?.top??0,g=t?.right??0,x=t?.bottom??0,v=o.width-u-g,y=o.height-b-x,E;if(n){let S=c-a,M=m-s;E=Math.min(v/S,y/M)*r}else E=d3(e,{width:v,height:y},r);let T=No(Oh(r3(E,zh,"floor"),i,l)),I=_y({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:T}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:T}},captureUpdate:Eo.EVENTUALLY}},ts=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:l})=>{let a=s3(a3(o));return pv({canvasOffsets:e,bounds:a,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:l})},nne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:$c,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ts({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===qo.TWO&&e.shiftKey&&!e.altKey&&!e[Cn.CTRL_OR_CMD]}),rne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:$c,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ts({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===qo.THREE&&e.shiftKey&&!e.altKey&&!e[Cn.CTRL_OR_CMD]}),m3=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:$c,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>ts({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===qo.ONE&&e.shiftKey&&!e.altKey&&!e[Cn.CTRL_OR_CMD]}),Gr=O({name:"toggleTheme",label:(e,o)=>o.theme===es.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===es.LIGHT?Dl:Hl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===es.LIGHT?es.DARK:es.LIGHT)},captureUpdate:Eo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===qo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),ine=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Ht(o)?r=ta(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=ta(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>e.key===Cn.E}),ane=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:Un,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ta(o,{type:"lasso",fromSelection:!1}),Ce(n.interactiveCanvas,cv.CROSSHAIR)):r=ta(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.NEVER}}}),uv=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ni,viewMode:!1,perform:(e,o,t,n)=>{let r;return yn(o)?r=ta(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ta(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Ce(n.interactiveCanvas,cv.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Eo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Cn.CTRL_OR_CMD]&&e.key===Cn.H});import{updateActiveTool as hv}from"@hellixit/common";import{CaptureUpdateAction as u3}from"@hellixit/element";var h3=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=hv(o,{type:"embeddable"});return jt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:hv(o,{type:"embeddable"})},captureUpdate:u3.EVENTUALLY}}});import{pointFrom as gv}from"@hellixit/math";import{bindOrUnbindBindingElement as g3}from"@hellixit/element/binding";import{isValidPolygon as fv,LinearElementEditor as Md,newElementWith as Gh}from"@hellixit/element";import{isBindingElement as bv,isFreeDrawElement as xv,isLinearElement as yv,isLineElement as Pd}from"@hellixit/element";import{KEYS as Uh,arrayToMap as f3,invariant as Ev,shouldRotateWithDiscreteAngle as b3,updateActiveTool as vv}from"@hellixit/common";import{isPathALoop as x3}from"@hellixit/element";import{isInvisiblySmallElement as Wh}from"@hellixit/element";import{CaptureUpdateAction as Tv}from"@hellixit/element";import{jsx as y3}from"react/jsx-runtime";var kt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:l,scene:a}=n,s=a.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:u}=t,b=Md.getElement(o.selectedLinearElement.elementId,s);Ev(b,"Arrow element should exist if selectedLinearElement is set"),Ev(u,"sceneCoords should be defined if actionFinalize is called with event");let g=Md.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(bv(b)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let x=!!o.newElement,y=(x||!o.selectedLinearElement.selectedPointsIndices?[b.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((E,T)=>(E.set(T,{point:Md.pointFromAbsoluteCoords(b,gv(u.x-g.pointerOffset.x,u.y-g.pointerOffset.y),s)}),E),new Map)??new Map;g3(b,y,u.x-g.pointerOffset.x,u.y-g.pointerOffset.y,a,o,{newArrow:x,altKey:d.altKey,angleLocked:b3(d)})}else Pd(b)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!fv(b.points)&&a.mutateElement(b,{polygon:!1});if(g!==o.selectedLinearElement){b&&Wh(b)&&(r=r.map(v=>v.id===b.id?Gh(v,{isDeleted:!0}):v));let x=o.activeTool?.locked;return{elements:b.points.length<2||Wh(b)?e.map(v=>v.id===b.id?Gh(v,{isDeleted:!0}):v):r,appState:{...o,cursorButton:"up",selectedLinearElement:x?null:{...g,selectedPointsIndices:null,isEditing:!1,initialState:{...g.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:Tv.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&l();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||bv(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||d[d.length-1]!==u)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&Wh(c)&&(r=r.map(d=>d.id===c?.id?Gh(d,{isDeleted:!0}):d)),yv(c)||xv(c)){if(x3(c.points,o.zoom.value)&&(Pd(c)||xv(c))){let u=c.points,b=u[0],g=u.map((x,v)=>v===u.length-1?gv(b[0],b[1]):x);Pd(c)?a.mutateElement(c,{points:g,polygon:!0}):a.mutateElement(c,{points:g})}Pd(c)&&!fv(c.points)&&a.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Zt(i);let m;o.activeTool.type==="eraser"?m=vv(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=vv(o,{type:n.state.preferredSelectionTool.type});let p=c&&yv(c)?new Md(c,f3(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:Tv.IMMEDIATELY}},keyTest:(e,o)=>e.key===Uh.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Uh.ESCAPE||e.key===Uh.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>y3(J,{type:"button",icon:C0,title:h("buttons.done"),"aria-label":h("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ia,DEFAULT_EXPORT_PADDING as rH,EXPORT_SCALES as iH,THEME as as}from"@hellixit/common";import{getNonDeletedElements as aH}from"@hellixit/element";import{CaptureUpdateAction as To}from"@hellixit/element";import E3 from"clsx";import{jsx as Iv,jsxs as v3}from"react/jsx-runtime";var os=({children:e,checked:o,onChange:t,className:n})=>v3("div",{className:E3("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Iv("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Gc}),Iv("div",{className:"Checkbox-label",children:e})]});import{THEME as ns}from"@hellixit/common";import{jsx as rs}from"react/jsx-runtime";var Sv=e=>{let o=e.title||(e.value===ns.DARK?h("buttons.lightMode"):h("buttons.darkMode"));return rs(J,{type:"icon",icon:e.value===ns.LIGHT?Cv.MOON:Cv.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===ns.DARK?ns.LIGHT:ns.DARK),"data-testid":"toggle-dark-mode"})},Cv={SUN:rs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:rs("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:rs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:rs("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as T3}from"react";import{focusNearestParent as I3,KEYS as C3}from"@hellixit/common";import{jsx as wv,jsxs as S3}from"react/jsx-runtime";var kv=e=>{let{id:o}=_e(),[t,n]=T3(e.value),r=l=>{e.ignoreFocus||I3(l.target);let a=l.target.value;a!==e.value&&e.onChange(a)},i=l=>{if(l.key===C3.ENTER){if(l.preventDefault(),l.nativeEvent.isComposing||l.keyCode===229)return;l.currentTarget.blur()}};return S3("div",{className:"ProjectName",children:[wv("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),wv("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:l=>n(l.target.value)})]})};import{useCallback as w3,useEffect as k3,useRef as M3}from"react";import{jsx as Ad,jsxs as _3}from"react/jsx-runtime";var P3=5e3,A3=({progress:e})=>Ad("div",{className:"Toast__progress-bar",children:Ad("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),L3=({message:e,onClose:o,closable:t=!1,duration:n=P3,style:r})=>{let i=M3(0),l=n!==1/0,a=w3(()=>{l&&(i.current=window.setTimeout(()=>o(),n))},[o,n,l]);return k3(()=>{if(l)return a(),()=>clearTimeout(i.current)},[a,e,n,l]),_3("div",{className:"Toast",role:"status",onMouseEnter:l?()=>clearTimeout(i?.current):void 0,onMouseLeave:l?a:void 0,style:r,children:[Ad("div",{className:"Toast__message",children:e}),t&&Ad(J,{icon:Qt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Ld=Object.assign(L3,{ProgressBar:A3});import{DEFAULT_EXPORT_PADDING as Z3,DEFAULT_FILENAME as j3,IMAGE_MIME_TYPES as Hv,isFirefox as q3,MIME_TYPES as J3,cloneJSON as Q3,SVG_DOCUMENT_PREAMBLE as eH}from"@hellixit/common";import{getNonDeletedElements as tH}from"@hellixit/element";import{isFrameLikeElement as oH}from"@hellixit/element";import{getElementsOverlappingFrame as nH}from"@hellixit/element";import{ALLOWED_PASTE_MIME_TYPES as D3,EXPORT_DATA_TYPES as is,MIME_TYPES as qt,arrayToMap as H3,isMemberOf as R3,isPromiseLike as N3,EVENT as _d}from"@hellixit/common";import{mutateElement as B3}from"@hellixit/element";import{deepCopyElement as F3}from"@hellixit/element";import{isFrameLikeElement as O3,isInitializedImageElement as z3}from"@hellixit/element";import{getContainingFrame as Mv}from"@hellixit/element";var Tre="clipboard"in navigator&&"readText"in navigator.clipboard,Dd="clipboard"in navigator&&"writeText"in navigator.clipboard,oa="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,G3=e=>!!([is.hellixitboard,is.hellixitboardClipboard,is.hellixitboardClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Pv=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(_d.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},U3=({elements:e,files:o})=>{let t=H3(e),n=new Set(e.filter(a=>O3(a))),r=!1,i=e.reduce((a,s)=>(z3(s)&&(r=!0,o&&o[s.fileId]&&(a[s.fileId]=o[s.fileId])),a),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let l={type:is.hellixitboardClipboard,elements:e.map(a=>{if(Mv(a,t)&&!n.has(Mv(a,t))){let s=F3(a);return B3(s,t,{frameId:null}),s}return a}),files:o?i:void 0};return JSON.stringify(l)},Hd=async(e,o,t)=>{let n=U3({elements:e,files:o});await vo({[qt.hellixitboardClipboard]:n,[qt.text]:n},t)};function Av(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(Av(t));return o}var W3=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,qt.html),n=Av(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Lv=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[qt.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(R3(D3,n))try{if(n===qt.text||n===qt.html)e[n]=await(await t.getType(n)).text();else if(Vy(n)){let r=await t.getType(n),i=Jy(r,n,void 0);e[n]=i}else throw new xu(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof xu?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},Y3=async(e,o=!1)=>{try{let t=e.findByType(qt.html),n=!o&&t&&W3(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(qt.text)??n.value.map(r=>r.value).join(`
2
+ `).trim()}:n:{type:"text",value:(e.getData(qt.text)||"").trim()}}catch{return{type:"text",value:""}}},V3=function(e){return this.find(o=>o.type===e)||null},X3=function(e){return this.find(t=>t.type===e)?.value??null},K3=function(){return this.filter(e=>e.kind==="file")},_v=e=>{let o;Dv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},na=async e=>{let o;Dv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await qy(n);return r=await Ll(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(l=>{n.getAsString(a=>l(a))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:V3,getData:X3,getFiles:K3})},Rd=async(e,o=!1)=>{let t=await Y3(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===is.hellixitboardClipboardWithAPI;if(G3(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Nd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[qt.png]:e})])}catch(o){if(N3(e))await navigator.clipboard.write([new ClipboardItem({[qt.png]:await e})]);else throw o}},vo=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[qt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===qt.text);if(Dd&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!$3(n[1]))throw new Error("Error copying to clipboard.")},$3=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},Dv=e=>e.type===_d.PASTE||e.type===_d.COPY||e.type===_d.CUT;var Ur=(e,{selectedElementIds:o},t)=>{e=tH(e);let n=t&&Me(e,{selectedElementIds:o}),r=null,i=n?oe(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&oH(i[0])?(r=i[0],i=nH(e,r)):i.length>1&&(i=oe(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:Q3(i)}},Wr=async(e,o,t,n,{exportBackground:r,exportPadding:i=Z3,viewBackgroundColor:l,name:a=t.name||j3,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(h("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=Ar(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:l,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return yu(p.then(d=>new Blob([eH+d.outerHTML],{type:J3.svg})),{description:"Export to SVG",name:a,extension:t.exportEmbedScene?"hellixitboard.svg":"svg",mimeTypes:[Hv.svg],fileHandle:s});if(e==="clipboard-svg"){let d=await p.then(u=>u.outerHTML);try{await vo(d)}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return}}let m=Ac(o,t,n,{exportBackground:r,viewBackgroundColor:l,exportPadding:i,exportingFrame:c});if(e==="png"){let p=Dr(m);return t.exportEmbedScene&&(p=p.then(d=>import("./data/image-WXEFXRM6.js").then(({encodePngMetadata:u})=>u({blob:d,metadata:kl(o,t,n,"local")})))),yu(p,{description:"Export to PNG",name:a,extension:t.exportEmbedScene?"hellixitboard.png":"png",mimeTypes:[Hv.png],fileHandle:s})}else if(e==="clipboard")try{let p=Dr(m);await Nd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):q3&&p.name==="TypeError"?new Error(`${h("alerts.couldNotCopyToClipboard")}
3
3
 
4
- ${h("hints.firefox_clipboard_write")}`):new Error(h("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Rv=async(e,o,t)=>{let n=Wy(o);if(!Yy(n))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:l}=await e,{exportBackground:a,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:m}=Ur(r,i,!1);return await Wr(n,c,i,l,{exportBackground:a,viewBackgroundColor:s,name:t,fileHandle:o,exportingFrame:m}),{fileHandle:o}};import{Fragment as Ov,jsx as Jo,jsxs as zv}from"react/jsx-runtime";var Vh=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Jo(kv,{label:h("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),Nv=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=aH(e),i=Me(n,o)?oe(n,o):n;return Jo(Ov,{children:iH.map(l=>{let[a,s]=Gy(i,rH,l),c=`${h("imageExportDialog.label.scale")} ${l}x (${a}x${s})`;return Jo(J,{size:"small",type:"radio",icon:`${l}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:l===o.exportScale,onChange:()=>t(l)},l)})})}}),Xh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Jo(os,{checked:e.exportBackground,onChange:t=>o(t),children:h("imageExportDialog.label.withBackground")})}),Bd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zv(os,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[h("imageExportDialog.label.embedScene"),Jo($t,{label:h("imageExportDialog.tooltip.embedScene"),long:!0,children:Jo("div",{className:"hellixitboard-tooltip-icon",children:C0})})]})}),ra=!1,Yh=(e,o)=>{let t=o.message??h("progressDialog.defaultMessage");e.setAppState({toast:{message:o.progress!=null?zv(Ov,{children:[t,Jo(Ld.ProgressBar,{progress:o.progress})]}):t,duration:1/0}})};async function lH(e,o){if(o.app.state.isLoading&&(Yh(o.app,{progress:null}),await o.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(o.signal.aborted){e.return();return}if(t.type==="progress")Yh(o.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Yh(o.app,{progress:null}),await e)}function Bv(e,o,t,n){let r=new AbortController,i=r.signal,l=new Promise(async a=>{try{n.props.onExport&&await lH(n.props.onExport("json",{elements:e,appState:o,files:t},{signal:i}),{app:n,signal:i})}catch(s){s?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",s)}a({elements:e,appState:o,files:n.files})});return{abortController:r,data:l}}var Yr=O({name:"saveToActiveFile",label:"buttons.save",icon:Nr,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{if(ra)return!1;ra=!0;let r=o.fileHandle,i=n.getName(),{abortController:l,data:a}=Bv(e,o,n.files,n);try{let{fileHandle:s}=Lc(r)?await Rv(a,r,i):await Sc({data:a,filename:i,fileHandle:r});return{captureUpdate:To.NEVER,appState:{fileHandle:s,toast:{message:r&&s?.name?h("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):h("toast.fileSaved"),duration:1500}}}}catch(s){return l.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:To.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>e.key===ia.S&&e[ia.CTRL_OR_CMD]&&!e.shiftKey}),ls=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Nr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{if(ra)return!1;ra=!0;let{abortController:r,data:i}=Bv(e,o,n.files,n);try{let{fileHandle:l}=await Sc({data:i,filename:n.getName(),fileHandle:null});return{captureUpdate:To.NEVER,appState:{openDialog:null,fileHandle:l,toast:{message:h("toast.fileSaved"),duration:3e3}}}}catch(l){return r.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:To.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>e.key.toLowerCase()===ia.S&&e.shiftKey&&e[ia.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Jo(J,{type:"button",icon:v0,title:h("buttons.saveAs"),"aria-label":h("buttons.saveAs"),showAriaLabel:fe().formFactor==="phone",hidden:!vi,onClick:()=>e(null),"data-testid":"save-as-button"})}),aa=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:l}=await Eu(o,e);return{elements:r,appState:i,files:l,captureUpdate:To.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:To.EVENTUALLY}}},keyTest:e=>e[ia.CTRL_OR_CMD]&&e.key===ia.O}),Fv=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t,n)=>(n.sessionExportThemeOverride=t?as.DARK:as.LIGHT,{appState:{...o,exportWithDarkMode:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Jo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Jo(Cv,{value:e.exportWithDarkMode?as.DARK:as.LIGHT,onChange:t=>{o(t===as.DARK)},title:h("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as sH,DEFAULT_FONT_FAMILY as cH,DEFAULT_TEXT_ALIGN as dH,CODES as Gv,KEYS as Uv,getLineHeight as mH}from"@excalidraw/common";import{newElementWith as Fd}from"@excalidraw/element";import{hasBoundTextElement as pH,canApplyRoundnessTypeToElement as uH,getDefaultRoundnessTypeForElement as hH,isFrameLikeElement as gH,isArrowElement as fH,isHellixitboardElement as bH,isTextElement as Kh}from"@excalidraw/element";import{getBoundTextElement as xH,redrawTextBoundingBox as yH}from"@excalidraw/element";import{CaptureUpdateAction as $h}from"@excalidraw/element";var Wv="{}",Zh=O({name:"copyStyles",label:"labels.copyStyles",icon:Vu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(l=>o.selectedElementIds[l.id]);if(r.push(i),i&&pH(i)){let l=xH(i,n.scene.getNonDeletedElementsMap());r.push(l)}return i&&(Wv=JSON.stringify(r)),{appState:{...o,toast:{message:h("toast.copyStyles")}},captureUpdate:$h.EVENTUALLY}},keyTest:e=>e[Uv.CTRL_OR_CMD]&&e.altKey&&e.code===Gv.C}),jh=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Vu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(Wv),i=r[0],l=r[1];if(!bH(i))return{elements:e,captureUpdate:$h.EVENTUALLY};let a=oe(e,o,{includeBoundTextElement:!0}),s=a.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Kh(c)&&c.containerId&&(m=l),!m)return c;let p=Fd(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?uH(m.roundness.type,c)?m.roundness:hH(c):null});if(Kh(p)){let d=m.fontSize||sH,u=m.fontFamily||cH;p=Fd(p,{fontSize:d,fontFamily:u,textAlign:m.textAlign||dH,lineHeight:m.lineHeight||mH(u)});let b=null;p.containerId&&(b=a.find(g=>Kh(p)&&g.id===p.containerId)||null),yH(p,b,n.scene)}return p.type==="arrow"&&fH(m)&&(p=Fd(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),gH(c)&&(p=Fd(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:$h.IMMEDIATELY}},keyTest:e=>e[Uv.CTRL_OR_CMD]&&e.altKey&&e.code===Gv.V});import{KEYS as EH}from"@excalidraw/common";import{CaptureUpdateAction as vH}from"@excalidraw/element";var Vr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:f0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:vH.EVENTUALLY}),keyTest:e=>e.key===EH.QUESTION_MARK});import{getNonDeletedElements as zd}from"@excalidraw/element";import{newElementWith as Xv}from"@excalidraw/element";import{isBoundToContainer as TH}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as IH,getElementsInResizingFrame as wH,getFrameLikeElements as CH,getRootElements as SH,groupByFrameLikes as kH,removeElementsFromFrame as MH,replaceAllElementsInFrame as PH}from"@excalidraw/element";import{KEYS as Gd,randomId as AH,arrayToMap as qh}from"@excalidraw/common";import{getSelectedGroupIds as Od,selectGroup as LH,selectGroupsForSelectedElements as _H,getElementsInGroup as Yv,addToGroup as DH,removeFromSelectedGroups as HH,isElementInGroup as Kv}from"@excalidraw/element";import{syncMovedIndices as RH}from"@excalidraw/element";import{CaptureUpdateAction as ss}from"@excalidraw/element";import{jsx as la}from"react/jsx-runtime";var NH=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&Kv(r,t),!0))return!0}return!1},Vv=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!NH(n)&&!IH(n)},Jh=O({name:"group",label:"labels.group",icon:e=>la(zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=SH(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY};let i=Od(o);if(i.length===1){let x=i[0],v=new Set(Yv(e,x).map(T=>T.id)),y=new Set(r.map(T=>T.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY}}let l=[...e];new Set(r.map(x=>x.frameId)).size>1&&kH(r).forEach((v,y)=>{MH(v,n.scene.getNonDeletedElementsMap())});let s=AH(),c=qh(r);l=l.map(x=>c.get(x.id)?Xv(x,{groupIds:DH(x.groupIds,s,o.editingGroupId)}):x);let m=Yv(l,s),p=m[m.length-1],d=l.lastIndexOf(p),u=l.slice(d+1),b=l.slice(0,d).filter(x=>!Kv(x,s)),g=RH([...b,...m,...u],qh(m));return{appState:{...o,...LH(s,{...o,selectedGroupIds:{}},zd(l))},elements:g,captureUpdate:ss.IMMEDIATELY}},predicate:(e,o,t,n)=>Vv(e,o,n),keyTest:e=>!e.shiftKey&&e[Gd.CTRL_OR_CMD]&&e.key===Gd.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>la(J,{hidden:!Vv(e,o,n),type:"button",icon:la(zu,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":h("labels.group"),visible:Me(zd(e),o)})}),Qh=O({name:"ungroup",label:"labels.ungroup",icon:e=>la(Gu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Od(o),i=qh(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY};let l=[...e],a=[];l=l.map(d=>{TH(d)&&a.push(d.id);let u=HH(d.groupIds,o.selectedGroupIds);return u.length===d.groupIds.length?d:Xv(d,{groupIds:u})});let s=_H(o,zd(l),o,null),c=n.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return CH(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(l=PH(l,wH(l,d,o,i),d,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[u,b])=>(b&&!a.includes(u)&&(d[u]=!0),d),{}),{appState:{...o,...s},elements:l,captureUpdate:ss.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Gd.CTRL_OR_CMD]&&e.key===Gd.G.toUpperCase(),predicate:(e,o)=>Od(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>la(J,{type:"button",hidden:Od(o).length===0,icon:la(Gu,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":h("labels.ungroup"),visible:Me(zd(e),o)})});import WH from"clsx";import{CaptureUpdateAction as Jv}from"@excalidraw/element";import{invariant as YH}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as BH,COLOR_VOICE_CALL as FH,COLOR_WHITE as Wd,THEME as OH,UserIdleState as $v}from"@excalidraw/common";var Ud=(e,o,t,n,r,i,l)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),l&&(e.strokeStyle=l),e.stroke()};function zH(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var Xr=(e,o)=>`hsl(${Math.abs(zH(o?.id||e))%37*10}, 100%, 83%)`,Zv=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},jv=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,l]of o.remotePointerViewportCoords){let{x:a,y:s}=l,c=t.collaborators.get(i);a-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=a<0||a>n-m||s<0||s>r-p;a=Math.max(a,0),a=Math.min(a,n-m),s=Math.max(s,0),s=Math.min(s,r-p);let u=Xr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let b=o.remotePointerUserStates.get(i),g=d||b===$v.IDLE||b===$v.AWAY;g&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===OH.DARK?"#2f6330":FH,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Wd,e.strokeStyle=Wd,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(a-1,s-1),e.lineTo(a-1,s+15),e.lineTo(a+5,s+10),e.lineTo(a+12,s+9),e.closePath(),e.fill()):(e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.fill(),e.stroke());let y=o.remotePointerUsernames.get(i)||"";if(!d&&y){e.font="600 12px sans-serif";let E=(v?a+0:a)+m/2,T=(v?s+0:s)+p+2,I=5,C=3,M=e.measureText(y),k=M.actualBoundingBoxDescent+M.actualBoundingBoxAscent,_=Math.max(k,12),P=E-1,A=T-1,H=M.width+2+I*2+2,F=_+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,A,H,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=Wd,e.stroke(),v&&(e.beginPath(),e.roundRect(P-2,A-2,H+4,F+4,8),e.strokeStyle=x,e.stroke())):Ud(e,P,A,H,F,8,Wd),e.fillStyle=BH,e.fillText(y,E+I+1,T+C+M.actualBoundingBoxAscent+Math.floor((_-k)/2)+2),v){e.fillStyle=x;let Y=8,V=8,U=5;e.fillRect(P+H+V,A+(F/2-Y/2),2,Y),e.fillRect(P+H+V+U,A+(F/2-Y*2/2),2,Y*2),e.fillRect(P+H+V+U*2,A+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import GH from"clsx";import{useState as UH}from"react";import{jsx as qv}from"react/jsx-runtime";var eg=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=Zv(t),[l,a]=UH(!1),s=!l&&n,c=s?void 0:{background:e};return qv("div",{className:GH("Avatar",r),style:c,onClick:o,children:s?qv("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>a(!0)}):i})};import{jsx as Qo,jsxs as Yd}from"react/jsx-runtime";var VH=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(YH(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:Jv.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:Jv.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:l}=o,a=Xr(n,r),s=WH({"is-followed":l,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?Yd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:h("userList.hint.isSpeaking"),children:[Qo("div",{}),Qo("div",{}),Qo("div",{})]}):r.isMuted?Qo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:h("userList.hint.micMuted"),children:LE}):Qo("div",{title:h("userList.hint.inCall"),children:AE}):null;return i?Yd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[Qo(eg,{color:a,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),Qo("div",{className:"UserList__collaborator-name",children:r.username}),Yd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[l&&Qo("div",{className:"UserList__collaborator-status-icon-is-followed",title:h("userList.hint.followStatus"),children:Oi}),c]})]}):Yd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Qo(eg,{color:a,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&Qo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as XH,randomId as KH}from"@excalidraw/common";import{deepCopyElement as $H}from"@excalidraw/element";import{CaptureUpdateAction as tg}from"@excalidraw/element";var og=O({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of XH)if(r.some(l=>l.type===i))return{captureUpdate:tg.EVENTUALLY,appState:{...o,errorMessage:h(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:KH(),status:"unpublished",elements:r.map($H),created:Date.now()},...i])).then(()=>({captureUpdate:tg.EVENTUALLY,appState:{...o,toast:{message:h("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:tg.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as sa}from"@excalidraw/element";import{isFrameLikeElement as ZH}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as jH}from"@excalidraw/element";import{KEYS as er,arrayToMap as qH}from"@excalidraw/common";import{alignElements as JH}from"@excalidraw/element";import{CaptureUpdateAction as ca}from"@excalidraw/element";import{getSelectedElementsByGroup as QH}from"@excalidraw/element";import{jsx as ma}from"react/jsx-runtime";var Mt=(e,o)=>{let t=o.scene.getSelectedElements(e);return QH(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>ZH(n))},da=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=JH(r,n,t.scene,o),l=qH(i);return jH(e.map(a=>l.get(a.id)||a),o,t)},eR=O({name:"alignTop",label:"labels.alignTop",icon:Hu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"start",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Hu,onClick:()=>t(null),title:`${h("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":h("labels.alignTop"),visible:Me(sa(e),o)})}),tR=O({name:"alignBottom",label:"labels.alignBottom",icon:Ru,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"end",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Ru,onClick:()=>t(null),title:`${h("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":h("labels.alignBottom"),visible:Me(sa(e),o)})}),oR=O({name:"alignLeft",label:"labels.alignLeft",icon:Nu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"start",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Nu,onClick:()=>t(null),title:`${h("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":h("labels.alignLeft"),visible:Me(sa(e),o)})}),nR=O({name:"alignRight",label:"labels.alignRight",icon:Bu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"end",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Bu,onClick:()=>t(null),title:`${h("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":h("labels.alignRight"),visible:Me(sa(e),o)})}),rR=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Fu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"center",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Fu,onClick:()=>t(null),title:h("labels.centerVertically"),"aria-label":h("labels.centerVertically"),visible:Me(sa(e),o)})}),iR=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ou,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"center",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Ou,onClick:()=>t(null),title:h("labels.centerHorizontally"),"aria-label":h("labels.centerHorizontally"),visible:Me(sa(e),o)})});import{getNonDeletedElements as Qv}from"@excalidraw/element";import{isFrameLikeElement as aR}from"@excalidraw/element";import{CODES as e2,KEYS as t2,arrayToMap as lR}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as sR}from"@excalidraw/element";import{distributeElements as cR}from"@excalidraw/element";import{CaptureUpdateAction as o2}from"@excalidraw/element";import{getSelectedElementsByGroup as dR}from"@excalidraw/element";import{jsx as i2}from"react/jsx-runtime";var n2=(e,o)=>{let t=o.scene.getSelectedElements(e);return dR(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>aR(n))},r2=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=cR(r,t.scene.getNonDeletedElementsMap(),n,o,t.scene),l=lR(i);return sR(e.map(a=>l.get(a.id)||a),o,t)},mR=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:r2(e,o,n,{space:"between",axis:"x"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[t2.CTRL_OR_CMD]&&e.altKey&&e.code===e2.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>i2(J,{hidden:!n2(o,n),type:"button",icon:P0,onClick:()=>t(null),title:`${h("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":h("labels.distributeHorizontally"),visible:Me(Qv(e),o)})}),pR=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:r2(e,o,n,{space:"between",axis:"y"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[t2.CTRL_OR_CMD]&&e.altKey&&e.code===e2.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>i2(J,{hidden:!n2(o,n),type:"button",icon:A0,onClick:()=>t(null),title:`${h("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":h("labels.distributeVertically"),visible:Me(Qv(e),o)})});import{getNonDeletedElements as uR}from"@excalidraw/element";import{bindOrUnbindBindingElements as hR}from"@excalidraw/element";import{getCommonBoundingBox as a2}from"@excalidraw/element";import{newElementWith as gR}from"@excalidraw/element";import{deepCopyElement as fR}from"@excalidraw/element";import{resizeMultipleElements as bR}from"@excalidraw/element";import{isArrowElement as l2,isElbowArrow as xR}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as s2}from"@excalidraw/element";import{CODES as c2,KEYS as yR,arrayToMap as ER}from"@excalidraw/common";import{CaptureUpdateAction as d2}from"@excalidraw/element";var ng=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:RE,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:s2(m2(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:d2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===c2.H}),rg=O({name:"flipVertical",label:"labels.flipVertical",icon:HE,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:s2(m2(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:d2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===c2.V&&!e[yR.CTRL_OR_CMD]}),m2=(e,o,t,n,r)=>{let i=oe(uR(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),l=vR(i,o,n,r),a=ER(l);return e.map(s=>a.get(s.id)||s)},vR=(e,o,t,n)=>{if(e.every(d=>l2(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let u=d;return gR(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=a2(e);bR(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(d=>[d.id,fR(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),hR(e.filter(l2),n.scene,n.state);let{elbowArrows:l,otherElements:a}=e.reduce((d,u)=>xR(u)?{...d,elbowArrows:d.elbowArrows.concat(u)}:{...d,otherElements:d.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=a2(e),[m,p]=[r-s,i-c];return a.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),l.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};import{isTextElement as TR}from"@excalidraw/element";import{getTextFromElements as IR}from"@excalidraw/element";import{CODES as wR,KEYS as p2,isFirefox as CR}from"@excalidraw/common";import{CaptureUpdateAction as Jt}from"@excalidraw/element";var pa=O({name:"copy",label:"labels.copy",icon:_l,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Hd(r,n.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),ig=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await Lv()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),CR?{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(Pv({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),Vd=O({name:"cut",label:"labels.cut",icon:xE,trackEvent:{category:"element"},perform:(e,o,t,n)=>(pa.perform(e,o,t,n),Gl.perform(e,o,null,n)),keyTest:e=>e[p2.CTRL_OR_CMD]&&e.key===p2.X}),Xd=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:NE,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Ur(e,o,!0);try{await Wr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let l=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:h("toast.copyToClipboardAsSvg",{exportSelection:l.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(l){return console.error(l),{appState:{errorMessage:l.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Dd&&e.length>0,keywords:["svg","clipboard","copy"]}),Kd=O({name:"copyAsPng",label:"labels.copyAsPng",icon:BE,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:l}=Ur(e,o,!0);try{return await Wr("clipboard",i,o,n.files,{...o,exportingFrame:l,name:n.getName()}),{appState:{...o,toast:{message:h("toast.copyToClipboardAsPng",{exportSelection:r.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{...o,errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>oa&&e.length>0,keyTest:e=>e.code===wR.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),$d=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{vo(IR(r))}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,o,t,n)=>Dd&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(TR),keywords:["text","clipboard","copy"]});import{CODES as SR,KEYS as kR}from"@excalidraw/common";import{CaptureUpdateAction as MR}from"@excalidraw/element";var ua=O({name:"gridMode",icon:GE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:MR.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[kR.CTRL_OR_CMD]&&e.code===SR.QUOTE});import{CODES as PR,KEYS as AR}from"@excalidraw/common";import{CaptureUpdateAction as LR}from"@excalidraw/element";var tr=O({name:"zenMode",label:"buttons.zenMode",icon:OE,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:LR.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[AR.CTRL_OR_CMD]&&e.altKey&&e.code===PR.Z});import{CODES as _R,KEYS as DR}from"@excalidraw/common";import{CaptureUpdateAction as HR}from"@excalidraw/element";var cs=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:FE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:HR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[DR.CTRL_OR_CMD]&&e.altKey&&e.code===_R.S});import{CaptureUpdateAction as RR}from"@excalidraw/element";var ds=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,o){let t=o.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...o,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:RR.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as NR}from"@excalidraw/element";var ms=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,o){return{appState:{...o,isMidpointSnappingEnabled:!this.checked(o)},captureUpdate:NR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as BR,KEYS as FR}from"@excalidraw/common";import{CaptureUpdateAction as OR}from"@excalidraw/element";var or=O({name:"stats",label:"stats.fullTitle",icon:DE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:OR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[FR.CTRL_OR_CMD]&&e.altKey&&e.code===BR.SLASH});import{BOUND_TEXT_PADDING as u2,ROUNDNESS as h2,TEXT_ALIGN as b2,VERTICAL_ALIGN as x2,arrayToMap as y2,getFontString as zR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as GR,isBoundToContainer as g2,resetOriginalContainerCache as UR,updateOriginalContainerCache as WR}from"@excalidraw/element";import{computeBoundTextPosition as YR,computeContainerDimensionForBoundText as f2,getBoundTextElement as E2,redrawTextBoundingBox as v2}from"@excalidraw/element";import{hasBoundTextElement as VR,isArrowElement as XR,isTextBindableContainer as ag,isTextElement as ps,isUsingAdaptiveRadius as KR}from"@excalidraw/element";import{measureText as $R}from"@excalidraw/element";import{syncMovedIndices as T2}from"@excalidraw/element";import{newElement as ZR}from"@excalidraw/element";import{CaptureUpdateAction as lg}from"@excalidraw/element";var sg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>VR(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(l=>{let a=E2(l,i);if(a){let{width:s,height:c}=$R(a.originalText,zR(a),a.lineHeight),m=GR(l.id);UR(l.id);let{x:p,y:d}=YR(l,a,i);n.scene.mutateElement(a,{containerId:null,width:s,height:c,text:a.originalText,x:p,y:d}),n.scene.mutateElement(l,{boundElements:l.boundElements?.filter(u=>u.id!==a.id),height:m||l.height})}}),{elements:e,appState:o,captureUpdate:lg.IMMEDIATELY}}}),cg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=ps(r[0])||ps(r[1]),l;if(ag(r[0])?l=r[0]:ag(r[1])&&(l=r[1]),i&&l&&E2(l,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,l;ps(r[0])&&ag(r[1])?(i=r[0],l=r[1]):(i=r[1],l=r[0]),n.scene.mutateElement(i,{containerId:l.id,verticalAlign:x2.MIDDLE,textAlign:b2.CENTER,autoResize:!0,angle:XR(l)?0:l?.angle??0}),n.scene.mutateElement(l,{boundElements:(l.boundElements||[]).concat({type:"text",id:i.id})});let a=l.height;return v2(i,l,n.scene),WR(l.id,a),{elements:jR(e,l,i),appState:{...o,selectedElementIds:{[l.id]:!0}},captureUpdate:lg.IMMEDIATELY}}}),jR=(e,o,t)=>{let n=e.slice(),r=n.findIndex(l=>l.id===t.id);n.splice(r,1);let i=n.findIndex(l=>l.id===o.id);return n.splice(i+1,0,t),T2(n,y2([o,t])),n},qR=(e,o,t)=>{let n=e.slice(),r=n.findIndex(l=>l.id===o.id);n.splice(r,1);let i=n.findIndex(l=>l.id===t.id);return n.splice(i,0,o),T2(n,y2([o,t])),n},I2=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(l=>ps(l)&&!g2(l));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),l={};for(let a of r)if(ps(a)&&!g2(a)){let s=ZR({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...a.boundElements||[],{id:a.id,type:"text"}],angle:a.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:KR("rectangle")?h2.ADAPTIVE_RADIUS:h2.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:a.x-u2,y:a.y-u2,width:f2(a.width,"rectangle"),height:f2(a.height,"rectangle"),groupIds:a.groupIds,frameId:a.frameId});if(a.boundElements?.length){let c=a.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,u=p.endBinding;d?.elementId===a.id&&(d={...d,elementId:s.id}),u?.elementId===a.id&&(u={...u,elementId:s.id}),(d||u)&&n.scene.mutateElement(p,{startBinding:d,endBinding:u})})}n.scene.mutateElement(a,{containerId:s.id,verticalAlign:x2.MIDDLE,boundElements:null,textAlign:b2.CENTER,autoResize:!0}),v2(a,s,n.scene),i=qR([...i,s],s,a),l[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:l},captureUpdate:lg.IMMEDIATELY}}});import{isEmbeddableElement as h6}from"@excalidraw/element";import{KEYS as D2}from"@excalidraw/common";import{CaptureUpdateAction as g6}from"@excalidraw/element";import{pointFrom as k2}from"@excalidraw/math";import JR from"clsx";import{useCallback as w2,useEffect as C2,useLayoutEffect as QR,useRef as e6,useState as t6}from"react";import{EVENT as dg,HYPERLINK_TOOLTIP_DELAY as o6,KEYS as Zd}from"@excalidraw/common";import{getElementAbsoluteCoords as gg}from"@excalidraw/element";import{hitElementBoundingBox as n6}from"@excalidraw/element";import{isElementLink as r6}from"@excalidraw/element";import{getEmbedLink as i6,embeddableURLValidator as a6}from"@excalidraw/element";import{sceneCoordsToViewportCoords as M2,viewportCoordsToSceneCoords as l6,wrapEvent as s6,isLocalLink as c6,normalizeLink as mg}from"@excalidraw/common";import{isEmbeddableElement as pg}from"@excalidraw/element";import{jsx as ha,jsxs as S2}from"react/jsx-runtime";var fg=380,d6=42,ug=5,P2=85,m6=500,hg=!1,jd=new Map,A2=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let l=o.getNonDeletedElementsMap(),a=Xo(),s=Ko(),c=fe(),m=e.link||"",[p,d]=t6(m),u=e6(null),b=a.showHyperlinkPopup==="editor",g=w2(()=>{if(!u.current)return;let T=mg(u.current.value)||null;if(!e.link&&T&&ce("hyperlink","create"),pg(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!T){o.mutateElement(e,{link:null}),i(e,!1);return}if(!a6(T,s.validateEmbeddable))T&&r({message:h("toast.unableToEmbed"),closable:!0}),e.link&&jd.set(e.id,e.link),o.mutateElement(e,{link:T}),i(e,!1);else{let{width:I,height:C}=e,M=i6(T);M?.error instanceof URIError&&r({message:h("toast.unrecognizedLinkFormat"),closable:!0});let k=M?M.intrinsicSize.w/M.intrinsicSize.h:1,_=jd.get(e.id)!==e.link;o.mutateElement(e,{..._?{width:M?.type==="video"?I>C?I:C*k:I,height:M?.type==="video"&&I>C?I/k:C}:{},link:T}),i(e,!0),jd.has(e.id)&&jd.delete(e.id)}}else o.mutateElement(e,{link:T})},[e,o,r,s.validateEmbeddable,a.activeEmbeddable,t,i]);QR(()=>()=>{g()},[g]),C2(()=>{b&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[b,c.formFactor,c.isTouchScreen]),C2(()=>{let T=null,I=C=>{if(b)return;T&&clearTimeout(T),u6(e,l,a,k2(C.clientX,C.clientY))&&(T=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},m6))};return window.addEventListener(dg.POINTER_MOVE,I,!1),()=>{window.removeEventListener(dg.POINTER_MOVE,I,!1),T&&clearTimeout(T)}},[a,e,b,t,l]);let x=w2(()=>{ce("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),v=()=>{ce("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:E}=L2(e,a,l);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:S2("div",{className:"hellixitboard-hyperlinkContainer",style:{top:`${E}px`,left:`${y}px`,width:fg,padding:ug},children:[b?ha("input",{className:JR("hellixitboard-hyperlinkContainer-input"),placeholder:h("labels.link.hint"),ref:u,value:p,onChange:T=>d(T.target.value),autoFocus:!0,onKeyDown:T=>{T.stopPropagation(),T[Zd.CTRL_OR_CMD]&&T.key===Zd.K&&T.preventDefault(),(T.key===Zd.ENTER||T.key===Zd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ha("a",{href:mg(e.link||""),className:"hellixitboard-hyperlinkContainer-link",target:c6(e.link)?"_self":"_blank",onClick:T=>{if(e.link&&n){let I=s6(dg.HELLIXITBOARD_LINK,T.nativeEvent);n({...e,link:mg(e.link)},I),I.defaultPrevented&&T.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ha("div",{className:"hellixitboard-hyperlinkContainer-link",children:h("labels.link.empty")}),S2("div",{className:"hellixitboard-hyperlinkContainer__buttons",children:[!b&&ha(J,{type:"button",title:h("buttons.edit"),"aria-label":h("buttons.edit"),label:h("buttons.edit"),onClick:v,className:"hellixitboard-hyperlinkContainer--edit",icon:Uo}),ha(J,{type:"button",title:h("labels.linkToElement"),"aria-label":h("labels.linkToElement"),label:h("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:jc}),m&&!pg(e)&&ha(J,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:x,className:"hellixitboard-hyperlinkContainer--remove",icon:pt})]})]})},L2=(e,o,t)=>{let[n,r]=gg(e,t),{x:i,y:l}=M2({sceneX:n+e.width/2,sceneY:r},o),a=i-o.offsetLeft-fg/2,s=l-o.offsetTop-P2;return{x:a,y:s}},bg=(e,o)=>{let t=oe(e,o);return pg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},us=null,_2=(e,o,t)=>{us&&clearTimeout(us),us=window.setTimeout(()=>p6(e,o,t),o6)},p6=(e,o,t)=>{if(!e.link)return;let n=ea();n.classList.add("hellixitboard-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=r6(e.link)?h("labels.link.goToElement"):e.link;let[r,i,l,a]=gg(e,t),[s,c,m,p]=By([r,i,l,a],e.angle,o),d=M2({sceneX:s,sceneY:c},o);Rh(n,{left:d.x,top:d.y,width:m,height:p},"top"),ce("hyperlink","tooltip","link-icon"),hg=!0},xg=()=>{us&&clearTimeout(us),hg&&(hg=!1,ea().classList.remove("hellixitboard-tooltip--visible"))},u6=(e,o,t,[n,r])=>{let{x:i,y:l}=l6({clientX:n,clientY:r},t),a=15/t.zoom.value;if(n6(k2(i,l),e,o))return!1;let[s,c,m]=gg(e,o);if(i>=s&&i<=m&&l>=c-P2&&l<=c)return!1;let{x:p,y:d}=L2(e,t,o);return!(n>=p-a&&n<=p+fg+ug*2+a&&r>=d-a&&r<=d+a+ug*2+d6)};import{jsx as f6}from"react/jsx-runtime";var hs=O({name:"hyperlink",label:(e,o)=>bg(e,o),icon:Rl,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:g6.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[D2.CTRL_OR_CMD]&&e.key===D2.K,predicate:(e,o)=>oe(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=oe(e,o);return f6(J,{type:"button",icon:Rl,"aria-label":h(bg(e,o)),title:`${h6(e[0])?h("labels.link.labelEmbed"):h("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as H2,arrayToMap as Eg,randomId as b6}from"@excalidraw/common";import{elementsAreInSameGroup as x6,newElementWith as R2,selectGroupsFromGivenElements as N2}from"@excalidraw/element";import{CaptureUpdateAction as B2}from"@excalidraw/element";var yg=e=>e.every(o=>!o.locked),gs=O({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return yg(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=oe(o,e);return yg(t)?Si:Hr},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=yg(r),l=Eg(r),a=r.length>1&&x6(r),c=r.length===1||a?null:b6(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(a){let v=r[0].groupIds.at(-1);delete m[v]}let p=e.map(v=>{if(!l.has(v.id))return v;let y=v.groupIds;return i?c&&(y=[...y,c]):y=y.filter(E=>!o.lockedMultiSelections[E]),R2(v,{locked:i,groupIds:y.length!==v.groupIds.length?y:v.groupIds})}),d=Eg(p),u=i?{}:Object.fromEntries(r.map(v=>[v.id,!0])),b=r.map(v=>d.get(v.id)||v),g=i?{}:N2(b,o),x=i?c||(a?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:B2.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===H2.L&&e[H2.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),F2=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Hr,predicate:(e,o)=>oe(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(l=>l.locked),n=e.map(l=>{if(l.locked){let a=l.groupIds.filter(s=>!o.lockedMultiSelections[s]);return R2(l,{locked:!1,groupIds:l.groupIds.length!==a.length?a:l.groupIds})}return l}),r=Eg(n),i=t.map(l=>r.get(l.id)||l);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(l=>[l.id,!0])),selectedGroupIds:N2(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:B2.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as l8,isLinearElement as s8,isLineElement as Da}from"@excalidraw/element";import{arrayToMap as c8,invariant as Lf}from"@excalidraw/common";import{toggleLinePolygonState as d8,CaptureUpdateAction as cw}from"@excalidraw/element";import BI from"clsx";import ZB from"fuzzy";import{useEffect as Cm,useRef as FI,useMemo as jB,useState as wm}from"react";import{DEFAULT_SIDEBAR as HI,EVENT as km,KEYS as Mo,capitalizeString as qB,isWritableElement as JB}from"@excalidraw/common";import{CaptureUpdateAction as t4}from"@excalidraw/element";import{useEffect as ys,useMemo as O2,useRef as Cg,useState as y6}from"react";import{bumpVersion as fs,getLinearElementSubType as fa,mutateElement as Sg,updateElbowArrowPoints as E6}from"@excalidraw/element";import{pointFrom as Jd,pointRotateRads as v6}from"@excalidraw/math";import{hasBoundTextElement as T6,isArrowBoundToElement as I6,isArrowElement as w6,isElbowArrow as C6,isLinearElement as Ag,isUsingAdaptiveRadius as S6}from"@excalidraw/element";import{getCommonBoundingBox as k6,getElementAbsoluteCoords as M6}from"@excalidraw/element";import{getBoundTextElement as Y2,getBoundTextMaxHeight as P6,getBoundTextMaxWidth as A6,redrawTextBoundingBox as L6}from"@excalidraw/element";import{wrapText as _6}from"@excalidraw/element";import{assertNever as D6,CLASSES as H6,getFontString as vg,isProdEnv as R6,mapFind as N6,reduceToCommonValue as B6,ROUNDNESS as Tg,sceneCoordsToViewportCoords as F6,updateActiveTool as z2}from"@excalidraw/common";import{measureText as G2}from"@excalidraw/element";import{LinearElementEditor as O6}from"@excalidraw/element";import{newArrowElement as Ig,newElement as z6,newLinearElement as G6}from"@excalidraw/element";import{ShapeCache as U6}from"@excalidraw/element";import{updateBindings as W6}from"@excalidraw/element";import{jsx as Pg}from"react/jsx-runtime";var Y6=8,V6=10,bs=["rectangle","diamond","ellipse"],xs=["line","sharpArrow","curvedArrow","elbowArrow"],X6=new Set(bs),K6=new Set(xs),ba=e=>X6.has(e),Qd=e=>e==="arrow"||K6.has(e),Io=ge(null),Es=new Map,vs=new Map,$6=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Cg(null);return ys(()=>{if(o.length===0){e.updateEditorAtom(Io,null);return}let n=xa(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(Io,null),t.current=null)},[o,e]),ys(()=>()=>{Es.clear(),vs.clear()},[]),Pg(Z6,{app:e,elements:o})},Z6=({app:e,elements:o})=>{let t=xa(o),n=O2(()=>t==="generic"?X2(o):[],[t,o]),r=O2(()=>t==="linear"?Mg(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>fa(p)===fa(r[0])):!1,[l,a]=y6({x:0,y:0}),s=Cg(""),c=Cg(null);ys(()=>{let p=[...n,...r].sort((x,v)=>x.id.localeCompare(v.id)),d=`
5
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(x=>x.id).join(",")}`;if(d===s.current)return;s.current=d;let u;if(p.length===1){let[x,,,v,y,E]=M6(p[0],e.scene.getNonDeletedElementsMap());u=v6(Jd(x,v),Jd(y,E),p[0].angle)}else{let{minX:x,maxY:v}=k6(p);u=Jd(x,v)}let{x:b,y:g}=F6({sceneX:u[0],sceneY:u[1]},e.state);a({x:b,y:g})},[n,r,e.scene,e.state]),ys(()=>{for(let p of r){let d=kg(p.id,e4(p));vs.has(d)||vs.set(d,p)}},[r]),ys(()=>{for(let p of n)if(!Es.has(p.id)){let d=Y2(p,e.scene.getNonDeletedElementsMap());d&&Es.set(p.id,{fontSize:d.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",Ai],["sharpArrow",zi],["curvedArrow",Ui],["elbowArrow",Gi]]:t==="generic"?[["rectangle",ki],["diamond",Mi],["ellipse",Pi]]:[];return Pg("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${l.y+(V6+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${l.x-e.state.offsetLeft-Y6}px`,zIndex:2},className:H6.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let u=i&&(t==="generic"&&n[0].type===p||t==="linear"&&fa(r[0])===p);return Pg(J,{className:"Shape",type:"radio",icon:d,checked:u,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&ce("convertElementType",p,"ui"),Lg(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},j6=(e,o,t)=>{let n=A6(e,o),r=P6(e,o),i=_6(o.text,vg(o),n),l=G2(i,vg(o),o.lineHeight),a=o.fontSize;for(;(l.width>n||l.height>r)&&a>0;){a-=1;let s={...o,fontSize:a};l=G2(o.text,vg(s),o.lineHeight)}Sg(o,t.getNonDeletedElementsMap(),{fontSize:a,width:l.width,height:l.height}),L6(o,e,t)},Lg=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((a,s)=>({...a,[s.id]:!0}),{}),l=n==="right"?1:-1;if(o==="generic"){let a=X2(r),c=a.every(m=>m.type===a[0].type)?bs.indexOf(a[0].type):-1;if(t=t??bs[(c+bs.length+l)%bs.length],t&&ba(t)){let m={};for(let d of a){let u=W2(d,t,e);m[u.id]=u}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let u=Y2(d,e.scene.getNonDeletedElementsMap());u&&(Es.get(d.id)&&Sg(u,e.scene.getNonDeletedElementsMap(),{fontSize:Es.get(d.id)?.fontSize??u.fontSize}),j6(d,u,e.scene))}e.setState(d=>({selectedElementIds:i,activeTool:z2(d,{type:"selection"})}))}}if(o==="linear"){let a=Mg(r);if(!t){let c=B6(a,fa),m=c?xs.indexOf(c):-1;t=xs[(m+xs.length+l)%xs.length]}if(Qd(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of a){let d=vs.get(kg(p.id,t));if(d&&fa(d)===t)m.set(d.id,d),c.push(d);else{let u=W2(p,t,e);m.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(m);for(let p of c)if(Ag(p))if(C6(p)){let d=q6(p);if(d.length<2)continue;let u=[];for(let g=1;g<d.length-2;g++)u.push({start:d[g],end:d[g+1],index:g+1});let b=E6(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:u});Sg(p,e.scene.getNonDeletedElementsMap(),{...b,endArrowhead:"arrow"})}else{let d=N6(["line","sharpArrow","curvedArrow"],u=>vs.get(kg(p.id,u)));if(d){let u=d.points;e.scene.mutateElement(p,{points:u})}}}let s=Mg(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new O6(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:z2(c,{type:"selection"})}))}return!0},xa=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ba(t.type))return"generic";V2(t)&&(o=!0)}return o?"linear":null},V2=e=>Ag(e)&&(!w6(e)||!I6(e)&&!T6(e)),kg=(e,o)=>`${e}:${o}`,X2=e=>e.filter(o=>ba(o.type)),Mg=e=>e.filter(o=>V2(o)),qd=20,ga=(e,o)=>e[0]===o[0],wg=(e,o)=>e[1]===o[1],U2=(e,o)=>ga(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),q6=e=>{let o=[e.points[0]],t=J6(e.points);for(let i=1;i<t.length;++i){let l=o[o.length-1],a=[...t[i]];Math.abs(a[0]-l[0])<qd?a[0]=l[0]:Math.abs(a[1]-l[1])<qd&&(a[1]=l[1]),ga(l,a)||wg(l,a)||o.push(Jd(l[0],a[1])),o.push(a)}let n=[o[0]];for(let i=1;i<o.length-1;++i)ga(o[i-1],o[i])&&ga(o[i],o[i+1])||wg(o[i-1],o[i])&&wg(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let l=r[r.length-1],a=n[i],s=n[i+1],c=ga(l,a),m=ga(a,s);if(c!==m){let p=U2(l,a),d=U2(a,s);if(p<qd||d<qd){if(d<p)c?s[0]=l[0]:s[1]=l[1];else if(m)for(let u=r.length-1;u>=0&&r[u][0]===l[0];--u)r[u][0]=a[0];else for(let u=r.length-1;u>=0&&r[u][1]===l[1];--u)r[u][1]=a[1];continue}}r.push(a)}return r.push(n[n.length-1]),r},J6=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,l]=e[t];(n!==i||r!==l)&&o.push(e[t])}return o},W2=(e,o,t)=>{if(!Q6(e.type,o)){if(!R6())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(U6.delete(e),ba(o)){let n=fs(z6({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:S6(o)?Tg.ADAPTIVE_RADIUS:Tg.PROPORTIONAL_RADIUS}:e.roundness}));return W6(n,t.scene,t.state),n}if(Qd(o))switch(o){case"line":return fs(G6({...e,type:"line"}));case"sharpArrow":return fs(Ig({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return fs(Ig({...e,type:"arrow",elbowed:!1,roundness:{type:Tg.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return fs(Ig({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return D6(o,`unhandled conversion type: ${o}`),e},Q6=(e,o)=>!!(ba(e)&&ba(o)||Qd(e)&&Qd(o)),e4=e=>Ag(e)?fa(e):e.type,K2=$6;var $2=O({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return Qe.set(Io,{type:"panel"}),{captureUpdate:t4.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>xa(e)!==null});import{canCreateLinkFromElements as _g,defaultGetElementLinkFromSelection as o4,getLinkIdAndTypeFromSelection as n4}from"@excalidraw/element";import{CaptureUpdateAction as Ts}from"@excalidraw/element";var em=O({name:"copyElementLink",label:"labels.copyElementLink",icon:Bi,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=oe(e,o);try{if(window.location){let i=n4(r,o);return i?(await vo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):o4(i.id,i.type)),{appState:{toast:{message:h("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ts.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Ts.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Ts.EVENTUALLY}},predicate:(e,o)=>_g(oe(e,o))}),Z2=O({name:"linkToElement",label:"labels.linkToElement",icon:jc,perform:(e,o,t,n)=>{let r=oe(e,o);return r.length!==1||!_g(r)?{elements:e,appState:o,app:n,captureUpdate:Ts.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:oe(e,o)[0].id}},captureUpdate:Ts.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=oe(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&_g(r)},trackEvent:!1});import{isDarwin as j2}from"@excalidraw/common";var r4={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],clearCanvas:[N("CtrlOrCmd+Delete")],imageExport:[N("CtrlOrCmd+Shift+E")],commandPalette:[N("CtrlOrCmd+/"),N("CtrlOrCmd+Shift+P")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${h("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[j2?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[j2?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],zenMode:[N("Alt+Z")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],addToLibrary:[],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[N("Shift+3")],zoomToFit:[N("Shift+1")],zoomToFitSelectionInViewport:[N("Shift+2")],toggleEraserTool:[N("E")],toggleHandTool:[N("H")],setFrameAsActiveTool:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],toolLock:[N("Q")]},Le=(e,o=0)=>{let t=r4[e];return t&&t.length>0?t[o]||t[0]:""};var i4="\\u0300-\\u036f",a4="\\ufe20-\\ufe2f",l4="\\u20d0-\\u20ff",s4=i4+a4+l4,c4=`[${s4}]`,d4=RegExp(c4,"g"),m4=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,p4={\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"},Kr=e=>e.replace(m4,o=>p4[o]||o).replace(d4,"");import kB from"clsx";import{useEffect as MB,useState as PB}from"react";import{KEYS as AB,queryFocusableElements as aI}from"@excalidraw/common";import{useCallback as u4,useState as h4}from"react";var q2=()=>{let[e,o]=h4(null),t=u4(n=>o(n),[]);return[e,t]};import{useState as eI,useCallback as tf,useMemo as tI,useEffect as of,memo as oI,useRef as pB}from"react";import{LIBRARY_DISABLED_TYPES as uB,randomId as hB,isShallowEqual as gB,KEYS as fB,isWritableElement as bB,addEventListener as xB,EVENT as yB,CLASSES as qT}from"@excalidraw/common";import{useEffect as tT,useRef as oT}from"react";import{URL_HASH_KEYS as Ng,URL_QUERY_KEYS as Bg,APP_NAME as nT,EVENT as nm,DEFAULT_SIDEBAR as x4,LIBRARY_SIDEBAR_TAB as y4,arrayToMap as Fg,cloneJSON as E4,preventUnload as v4,promiseTry as rT,resolvablePromise as T4,toValidURL as I4,Queue as w4,Emitter as C4}from"@excalidraw/common";import{hashElementsVersion as S4,hashString as k4}from"@excalidraw/element";import{getCommonBoundingBox as Rg}from"@excalidraw/element";import{MIME_TYPES as $r}from"@excalidraw/common";var nr=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:l})=>{let a=Lr(e,null,{deleteInvisibleElements:!0}),s=Ti(o,null),{exportBackground:c,viewBackgroundColor:m}=s;return Ac(a,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:l},(p,d)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(p,d),x=n<g?n/g:o?.exportScale??1;return u.width=p*x,u.height=d*x,{canvas:u,scale:x}}let b=r?.(p,d)||{width:p,height:d};return u.width=b.width,u.height=b.height,{canvas:u,scale:b.scale??1}})},J2=async e=>{let{mimeType:o=$r.png,quality:t}=e;o===$r.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${$r.png}" mimeType`),o==="image/jpg"&&(o=$r.jpg),o===$r.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${$r.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await nr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async l=>{if(!l)return i(new Error("couldn't export to blob"));l&&o===$r.png&&e.appState?.exportEmbedScene&&(l=await Uy({blob:l,metadata:kl(e.elements,e.appState,e.files||{},"local")})),r(l)},o,t)})},ya=async({elements:e,appState:o=Oo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:l,reuseImages:a})=>{let s=Lr(e,null,{deleteInvisibleElements:!0}),m={...Ti(o,null),exportPadding:n};return Ar(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:l,reuseImages:a})},g4=async e=>{if(e.type==="svg"){let o=await ya(e);await vo(o.outerHTML)}else if(e.type==="png")await Nd(J2(e));else if(e.type==="json")await Hd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Q2,useState as f4}from"react";import{COLOR_PALETTE as b4}from"@excalidraw/common";var Dg=ge(new Map),eT=async e=>await ya({elements:e,appState:{exportBackground:!1,viewBackgroundColor:b4.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),tm=(e,o,t,n)=>{let[r,i]=f4();return Q2(()=>{if(o)if(e){let l=t.get(e);l?i(l):(async()=>{let a=await eT(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),i(a))})()}else(async()=>{let l=await eT(o);i(l)})()},[e,o,t,i]),Q2(()=>{let l=n.current;if(l)return r&&(l.innerHTML=r.outerHTML),()=>{l.innerHTML=""}},[r,n]),r},Ea=()=>{let[e]=Q(Dg);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var Hg=ge({active:!1});async function om({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{Qe.set(Hg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}var M4=["board.hellixit.cloud","libraries.hellixit.cloud"],aT=new C4,Sn=ge({status:"loaded",isInitialized:!1,libraryItems:[]}),Is=e=>E4(e),P4=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),lT=(e,o)=>{let t=[];for(let n of o)P4(e,n)&&t.push(n);return[...t,...e]},sT=(e,o)=>{let t=Fg(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Fg(e);for(let i of o){let l=r.get(i.id);l?Gg(l)!==Gg(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},Og=class{constructor(o){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",Is(this.currLibraryItems));S(this,"app");S(this,"updateQueue",[]);S(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);S(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Qe.set(Sn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Qe.set(Sn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Is(this.currLibraryItems);let t=Is(this.currLibraryItems);this.app.props.onLibraryChange?.(t),aT.trigger(sT(o,t),t)}catch(o){console.error(o)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Qe.set(Dg,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Is(t))}catch{return o(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:x4.name,tab:y4}}),this.setLibrary(()=>new Promise(async(l,a)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Tu(s,i):c=Al(s,i),!t||await om({title:h("alerts.confirmAddLibrary_title"),description:h("alerts.confirmAddLibrary",{numShapes:c.length}),actionLabel:h("buttons.confirm"),color:"warning"})?(t&&this.app.focusContainer(),l(n?lT(this.currLibraryItems,c):c)):a(new Ei)}catch(s){a(s)}}))));S(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Is(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},cT=Og,Ta=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((g,x)=>{let{height:v}=Rg(x.elements);return Math.max(g,v)},0),i=u=>{let b=0,g=0,x=0;for(let v of e){if(b%t===0&&(g=0),g===u){let{width:y}=Rg(v.elements);x=Math.max(x,y)}b++,g++}return x},l=0,a=0,s=0,c=0,m=0,p=0,d=0;for(let u of e){m&&m%t===0&&(a+=s+50,l=0,p=0,d++),p===0&&(s=r(d)),c=i(p);let{minX:b,minY:g,width:x,height:v}=Rg(u.elements),y=(c-x)/2,E=(s-v)/2;n.push(...u.elements.map(T=>({...T,x:T.x+l+y-b,y:T.y+a+E-g}))),l+=c+50,m++,p++}return n},A4=(e,o=M4)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},zg=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ng.addLibrary)||new URLSearchParams(window.location.search).get(Bg.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},rr=class rr{constructor(o){S(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,l)=>{try{let a=await o.load({source:t});i(Al(a?.libraryItems||[],"published"))}catch(a){l(a)}});return n?rr.queue.push(r):r()}getLibraryItems(o){return rr.getLibraryItems(this.adapter,o,!1)}};S(rr,"queue",new w4),S(rr,"run",async(o,t)=>{let n=new rr(o);return rr.queue.push(()=>t(n))});var va=rr,ws=0,rm=0,Gg=e=>`${e.id}:${e.name||""}:${S4(e.elements)}`,im=e=>k4(e.map(o=>Gg(o)).sort().join()),iT=async(e,o)=>{try{return rm++,await va.run(e,async t=>{let n=Fg(await t.getLibraryItems("save"));for(let[a]of o.deletedItems)n.delete(a);let r=[];for(let[a,s]of o.addedItems)n.has(a)?n.set(a,s):r.push(s);if(o.updatedItems)for(let[a,s]of o.updatedItems)n.set(a,s);let i=r.concat(Array.from(n.values())),l=im(i);return l!==ws&&await e.save({libraryItems:i}),ws=l,i})}finally{rm--}},L4=e=>{let{hellixitboardAPI:o}=e,t=oT(e);t.current=e;let n=oT(!1);tT(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:a,idToken:s})=>{let c=new Promise(async(p,d)=>{try{a=decodeURIComponent(a),a=I4(a),A4(a,t.current.validateLibraryUrl);let u=a.replace(/^https?:\/\/libraries\.hellixit\.cloud\//,"/library-proxy/"),g=await(await fetch(u)).blob();p(g)}catch(u){d(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Ng.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Ng.addLibrary),window.history.replaceState({},nT,`#${p.toString()}`)}else if(window.location.search.includes(Bg.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(Bg.addLibrary),window.history.replaceState({},nT,`?${p.toString()}`)}}},i=a=>{a.preventDefault();let s=zg();s&&(a.stopImmediatePropagation(),window.history.replaceState({},"",a.oldURL),r(s))},l=zg();if(l&&r(l),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(a=>{o.updateLibrary({libraryItems:a,merge:!0})}).catch(a=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${a?.message}`)})),"adapter"in t.current&&t.current.adapter){let a=t.current.adapter,s=t.current.migrationAdapter,c=T4();s?c.resolve(rT(s.load).then(async m=>{let p=null;try{if(!m)return va.getLibraryItems(a,"load");p=Al(m.libraryItems||[],"published");let d=await iT(a,sT([],p));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),va.getLibraryItems(a,"load")))):c.resolve(rT(va.getLibraryItems,a,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return ws=im(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(nm.HASHCHANGE,i),()=>{window.removeEventListener(nm.HASHCHANGE,i)}},[o]),tT(()=>{let r=aT.on(async(l,a)=>{let s=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&ws!==im(a)&&await iT(c,l)}catch(m){console.error(`couldn't persist library update: ${m.message}`,l),s&&t.current.hellixitboardAPI&&t.current.hellixitboardAPI.updateScene({appState:{errorMessage:h("errors.saveLibraryError")}})}}),i=l=>{rm&&v4(l)};return window.addEventListener(nm.BEFORE_UNLOAD,i),()=>{window.removeEventListener(nm.BEFORE_UNLOAD,i),r(),ws=0,rm=0}},[])};import R4 from"clsx";import{VERSIONS as _4}from"@excalidraw/common";import{jsx as H4}from"react/jsx-runtime";var D4=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return H4("a",{className:"library-menu-browse-button",href:`https://libraries.hellixit.cloud/?target=${window.name||"_hellixitboard"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${_4.hellixitboardLibrary}`,target:"_hellixitboard_libraries",children:h("labels.libraries")})},dT=D4;import{jsx as N4,jsxs as B4}from"react/jsx-runtime";var am=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>B4("div",{className:R4("library-menu-control-buttons",i),style:n,children:[N4(dT,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Ca,useEffect as qg,useMemo as Jg,useRef as $T,useState as ZT}from"react";import{MIME_TYPES as iB,arrayToMap as aB,nextAnimationFrame as lB}from"@excalidraw/common";import{duplicateElements as sB}from"@excalidraw/element";import cB from"clsx";import F4 from"lodash.throttle";import{useEffect as O4}from"react";var z4=ge(0),mT=e=>{let[o,t]=Q(z4);return O4(()=>{let{current:n}=e;if(!n)return;let r=F4(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import RN from"clsx";import{useCallback as NN,useState as $g}from"react";import{muteFSAbortError as BN}from"@excalidraw/common";import{flushSync as pT}from"react-dom";import G4 from"clsx";import{jsx as lm,jsxs as W4}from"react/jsx-runtime";var U4=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:l,...a})=>{let s=r?`Dialog__action-button--${r}`:"";return W4("button",{className:G4("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...a,children:[n&&lm("div",{style:l?{visibility:"hidden"}:{},children:n}),lm("div",{style:l?{visibility:"hidden"}:{},children:e}),l&&lm("div",{style:{position:"absolute",inset:0},children:lm(it,{})})]})},kn=U4;import{jsx as uT,jsxs as hT}from"react/jsx-runtime";var Y4=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=h("buttons.confirm"),cancelText:i=h("buttons.cancel"),className:l="",...a}=e,s=he(),c=zo(Ia),{container:m}=_e();return hT(je,{onCloseRequest:t,size:"small",...a,className:`confirm-dialog ${l}`,children:[n,hT("div",{className:"confirm-dialog-buttons",children:[uT(kn,{label:i,onClick:()=>{s({openMenu:null}),c(!1),pT(()=>{t()}),m?.focus()}}),uT(kn,{label:r,onClick:()=>{s({openMenu:null}),c(!1),pT(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},sm=Y4;import{useCallback as q4,useEffect as Yg,useRef as gT,useState as Ug}from"react";import{EDITOR_LS_KEYS as Wg,EXPORT_DATA_TYPES as J4,MIME_TYPES as fT,VERSIONS as Q4,chunk as eN,getExportSource as tN}from"@excalidraw/common";var no=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};S(no,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),S(no,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import cm from"react";var V4=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,X4=/{{([\w-]+)}}/,K4=/<([\w-]+)>/,$4=/<\/([\w-]+)>/,Z4=(e,o)=>{let t=[{name:"",children:[]}];return e.split(V4).filter(Boolean).forEach(n=>{let r=n.match(K4),i=n.match($4),l=n.match(X4);if(r!==null){let a=r[1];o.hasOwnProperty(a)?t.push({name:a,children:[]}):console.warn(`Trans: missed to pass in prop ${a} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=cm.createElement(cm.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(l!==null){let a=l[1];o.hasOwnProperty(a)?t[t.length-1].children.push(o[a]):console.warn(`Trans: key ${a} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},j4=({i18nKey:e,children:o,...t})=>{let{t:n}=Ie();return cm.createElement(cm.Fragment,{},...Z4(n(e),t))},Pt=j4;import{jsx as be,jsxs as yt}from"react/jsx-runtime";var oN=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=eN(e,6),l=document.createElement("canvas");l.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,l.height=i.length*128+(i.length+1)*(n*2)-n*2;let a=l.getContext("2d");a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height);for(let[s,c]of e.entries()){let m=await nr({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:p,height:d}=m,u=Math.floor(s/6)*(128+n*2),b=s%6*(128+n*2);a.drawImage(m,b+(128-p)/2+n,u+(128-d)/2+n),a.lineWidth=r,a.strokeStyle="#ced4da",a.strokeRect(b+n/2,u+n/2,128+n,128+n)}return await Dc(new File([await Dr(l)],"preview",{type:fT.png}),{outputType:fT.jpg,maxWidthOrHeight:5e3})},nN=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=gT(null),l=gT(null);return Yg(()=>{let a=i.current;a&&(async()=>{let s=await ya({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});a.innerHTML=s.outerHTML})()},[e.elements,o]),yt("div",{className:"single-library-item",children:[e.status==="published"&&be("span",{className:"single-library-item-status",children:h("labels.statusPublished")}),be("div",{ref:i,className:"single-library-item__svg"}),be(J,{"aria-label":h("buttons.remove"),type:"button",icon:Qt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:h("buttons.remove")}),yt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[yt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[yt("div",{style:{padding:"0.5em 0"},children:[be("span",{style:{fontWeight:500,color:"#868e96"},children:h("publishDialog.itemName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",ref:l,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:a=>{n(a.target.value,t)}})]}),be("span",{className:"error",children:e.error})]})]})},rN=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:l})=>{let[a,s]=Ug({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Ug(!1);Yg(()=>{let E=no.get(Wg.PUBLISH_LIBRARY);E&&s(E)},[]);let[p,d]=Ug(o.slice());Yg(()=>{d(o.slice())},[o]);let u=E=>{s({...a,[E.target.name]:E.target.value})},b=async E=>{E.preventDefault(),m(!0);let T=[],I=!1;if(p.forEach(A=>{let H="";A.name||(H=h("publishDialog.errors.required"),I=!0),T.push({...A,error:H})}),I){d(T),m(!1);return}let C=await oN(p),M={type:J4.hellixitboardLibrary,version:Q4.hellixitboardLibrary,source:tN(),libraryItems:p},k=JSON.stringify(M,null,2),_=new Blob([k],{type:"application/json"}),P=new FormData;P.append("hellixitboardLib",_),P.append("previewImage",C),P.append("previewImageType",C.type),P.append("title",a.name),P.append("authorName",a.authorName),P.append("githubHandle",a.githubHandle),P.append("name",a.name),P.append("description",a.description),P.append("twitterHandle",a.twitterHandle),P.append("website",a.website),fetch(`${w.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(A=>A.ok?A.json().then(({url:H})=>{no.delete(Wg.PUBLISH_LIBRARY),n({url:H,authorName:a.authorName,items:p})}):A.json().catch(()=>{throw new Error(A.statusText||"something went wrong")}).then(H=>{throw new Error(H.message||A.statusText||"something went wrong")}),A=>{console.error(A),r(A),m(!1)}).catch(A=>{console.error(A),r(A),m(!1)})},g=()=>{let E=[];return p.forEach((T,I)=>{E.push(be("div",{className:"single-library-item-wrapper",children:be(nN,{libItem:T,appState:t,index:I,onChange:(C,M)=>{let k=p.slice();k[M].name=C,d(k)},onRemove:l})},I))}),be("div",{className:"selected-library-items",children:E})},x=q4(()=>{i(p),no.set(Wg.PUBLISH_LIBRARY,a),e()},[p,e,i,a]),v=!!o.length,y=o.some(E=>E.status==="published");return be(je,{onCloseRequest:x,title:h("publishDialog.title"),className:"publish-library",children:v?yt("form",{onSubmit:b,children:[be("div",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteDescription",link:E=>be("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:E})})}),be("span",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteGuidelines",link:E=>be("a",{href:"https://github.com/hellixitboard/hellixitboard-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:E})})}),be("div",{className:"publish-library-note",children:h("publishDialog.noteItems")}),y&&be("span",{className:"publish-library-note publish-library-warning",children:h("publishDialog.republishWarning")}),g(),yt("div",{className:"publish-library__fields",children:[yt("label",{children:[yt("div",{children:[be("span",{children:h("publishDialog.libraryName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"name",required:!0,value:a.name,onChange:u,placeholder:h("publishDialog.placeholder.libraryName")})]}),yt("label",{style:{alignItems:"flex-start"},children:[yt("div",{children:[be("span",{children:h("publishDialog.libraryDesc")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("textarea",{name:"description",rows:4,required:!0,value:a.description,onChange:u,placeholder:h("publishDialog.placeholder.libraryDesc")})]}),yt("label",{children:[yt("div",{children:[be("span",{children:h("publishDialog.authorName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"authorName",required:!0,value:a.authorName,onChange:u,placeholder:h("publishDialog.placeholder.authorName")})]}),yt("label",{children:[be("span",{children:h("publishDialog.githubUsername")}),be("input",{type:"text",name:"githubHandle",value:a.githubHandle,onChange:u,placeholder:h("publishDialog.placeholder.githubHandle")})]}),yt("label",{children:[be("span",{children:h("publishDialog.twitterUsername")}),be("input",{type:"text",name:"twitterHandle",value:a.twitterHandle,onChange:u,placeholder:h("publishDialog.placeholder.twitterHandle")})]}),yt("label",{children:[be("span",{children:h("publishDialog.website")}),be("input",{type:"text",name:"website",pattern:"https?://.+",title:h("publishDialog.errors.website"),value:a.website,onChange:u,placeholder:h("publishDialog.placeholder.website")})]}),be("span",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteLicense",link:E=>be("a",{href:"https://github.com/hellixitboard/hellixitboard-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:E})})})]}),yt("div",{className:"publish-library__buttons",children:[be(kn,{label:h("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),be(kn,{type:"submit",label:h("buttons.submit"),actionType:"primary",isLoading:c})]})]}):be("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:h("publishDialog.atleastOneLibItem")})})},bT=rN;import GT from"react";import{DropdownMenu as LN}from"radix-ui";import{CLASSES as _N}from"@excalidraw/common";import lN from"clsx";import{useCallback as sN,useEffect as cN,useRef as dN}from"react";import{CLASSES as mN,EVENT as vT,KEYS as pN}from"@excalidraw/common";import{DropdownMenu as uN}from"radix-ui";import{forwardRef as xT}from"react";import yT from"clsx";import{jsx as ET}from"react/jsx-runtime";var iN=xT(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},l)=>ET("div",{className:yT("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:l,children:e})),aN=xT(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},l)=>ET("div",{className:yT("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:l,children:e})),Et={Row:iN,Col:aN};import{jsx as dm}from"react/jsx-runtime";var TT=({children:e,onClickOutside:o,className:t="",onSelect:n,open:r=!0,align:i="end",style:l})=>{let a=fe(),s=dN(null),c=Yn({onClickOutside:o});Xi(s,sN(p=>{s.current?.closest(`.${mN.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),cN(()=>{if(!r)return;let p=u=>{u.key===pN.ESCAPE&&(u.stopImmediatePropagation(),c.onClickOutside?.())},d={capture:!0};return document.addEventListener(vT.KEYDOWN,p,d),()=>{document.removeEventListener(vT.KEYDOWN,p,d)}},[c,r]);let m=lN(`dropdown-menu ${t}`,{"dropdown-menu--mobile":a.formFactor==="phone"}).trim();return dm(xh.Provider,{value:{onSelect:n},children:dm(uN.Content,{ref:s,className:m,style:l,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:a.formFactor==="phone"?dm(Et.Col,{className:"dropdown-menu-container",children:e}):dm(Xe,{className:"dropdown-menu-container",padding:2,children:e})})})};TT.displayName="DropdownMenuContent";var IT=TT;import{jsx as gN}from"react/jsx-runtime";var hN=({children:e,className:o="",selected:t,...n})=>gN("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),wT=hN;import{DropdownMenu as fN}from"radix-ui";import{jsx as Vg}from"react/jsx-runtime";var CT=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:l,rel:a="noopener",...s})=>{let c=hd(r);return Vg(fN.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Vg("a",{...s,href:t,target:"_blank",rel:`noopener ${a}`,className:jn(i,l),title:s.title??s["aria-label"],children:Vg(qn,{icon:e,shortcut:o,children:n})})})},wa=CT;CT.displayName="DropdownMenuItemLink";import{jsx as bN}from"react/jsx-runtime";var ST=()=>bN("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),kT=ST;ST.displayName="DropdownMenuSeparator";import{DropdownMenu as wN}from"radix-ui";import xN from"clsx";import{DropdownMenu as yN}from"radix-ui";import{useCallback as EN,useState as MT}from"react";import{jsx as Kg}from"react/jsx-runtime";var Xg=-4,vN=4,PT=({children:e,className:o})=>{let t=fe(),n=xN(`dropdown-menu dropdown-submenu ${o}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=EN(c=>{if(c){let p=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let d=c.getBoundingClientRect().width,b=window.innerWidth-p.right;b<d+20&&(l(b-d+Xg),s(Xg+8))}}},[]),[i,l]=MT(vN),[a,s]=MT(Xg);return Kg(yN.SubContent,{className:n,sideOffset:i,alignOffset:a,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Kg(Et.Col,{className:"dropdown-menu-container",children:e}):Kg(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},AT=PT;PT.displayName="DropdownMenuSubContent";import{DropdownMenu as TN}from"radix-ui";import{jsx as LT,jsxs as IN}from"react/jsx-runtime";var _T=({children:e,icon:o,shortcut:t,className:n})=>IN(TN.SubTrigger,{className:`${jn(n)} dropdown-menu__submenu-trigger`,children:[LT(qn,{icon:o,shortcut:t,children:e}),LT("div",{className:"dropdown-menu__submenu-trigger-icon",children:jE})]}),DT=_T;_T.displayName="DropdownMenuSubTrigger";import HT from"react";var mm=e=>o=>{let t=HT.Children.toArray(o).find(n=>HT.isValidElement(n)&&typeof n.type!="string"&&n?.type.displayName&&n.type.displayName===e);return t||null},RT=mm("DropdownMenuTrigger"),NT=mm("DropdownMenuContent"),BT=mm("DropdownMenuSubTrigger"),FT=mm("DropdownMenuSubContent");import{jsxs as CN}from"react/jsx-runtime";var pm=({children:e})=>{let o=BT(e),t=FT(e);return CN(wN.Sub,{children:[o,t]})};pm.Trigger=DT;pm.Content=AT;pm.displayName="DropdownMenuSub";var ir=pm;import SN from"clsx";import{DropdownMenu as kN}from"radix-ui";import{jsx as MN}from"react/jsx-runtime";var OT=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=fe(),l=SN(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return MN(kN.Trigger,{className:l,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},zT=OT;OT.displayName="DropdownMenuTrigger";import{jsx as AN}from"react/jsx-runtime";var PN=e=>AN(St,{...e,icon:e.checked?Gc:ZE}),wo=PN;import{jsx as HN,jsxs as DN}from"react/jsx-runtime";var Co=({children:e,open:o})=>{let t=RT(e),n=NT(e),r=n&&GT.isValidElement(n)?GT.cloneElement(n,{open:o}):n;return HN(LN.Root,{open:o,modal:!1,children:DN("div",{className:_N.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Co.Trigger=zT;Co.Content=IT;Co.Item=St;Co.ItemCheckbox=wo;Co.ItemLink=wa;Co.ItemCustom=wT;Co.Group=$l;Co.Separator=kT;Co.Sub=ir;var ie=Co;Co.displayName="DropdownMenu";import{jsx as Bt,jsxs as um}from"react/jsx-runtime";var FN=(e,o)=>e.filter(t=>o.includes(t.id)),ON=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:l,className:a})=>{let[s]=Q(Sn),[c,m]=Q(Ia),p=()=>{let P=o.length?h("alerts.removeItemsFromsLibrary",{count:o.length}):h("alerts.resetLibrary"),A=o.length?h("confirmDialog.removeItemsFromLib"):h("confirmDialog.resetLibrary");return Bt(sm,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:A,children:Bt("p",{children:P})})},[d,u]=$g(!1),b=!!o.length,g=b?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=b?h("buttons.remove"):h("buttons.resetLibrary"),[v,y]=$g(!1),[E,T]=$g(null),I=NN(()=>um(je,{onCloseRequest:()=>T(null),title:h("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Bt("p",{children:Bt(Pt,{i18nKey:"publishSuccessDialog.content",authorName:E.authorName,link:P=>Bt("a",{href:E?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Bt(J,{type:"button",title:h("buttons.close"),"aria-label":h("buttons.close"),label:h("buttons.close"),onClick:()=>T(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[T,E]),C=(P,A)=>{y(!1),T({url:P.url,authorName:P.authorName});let H=A.slice();H.forEach(F=>{o.includes(F.id)&&(F.status="published")}),t.setLibrary(H)},M=async()=>{try{await t.updateLibrary({libraryItems:Cc({description:"Hellix IT library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:h("errors.importLibraryError")})}},k=async()=>{let P=b?g:await t.getLatestLibrary();Ny(P).catch(BN).catch(A=>{e({errorMessage:A.message})})},_=()=>um(ie,{open:c,children:[Bt(ie.Trigger,{onToggle:()=>m(!c),children:i0}),um(ie.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!b&&Bt(ie.Item,{onSelect:M,icon:Hi,"data-testid":"lib-dropdown--load",children:h("buttons.load")}),!!g.length&&Bt(ie.Item,{onSelect:k,icon:Nr,"data-testid":"lib-dropdown--export",children:h("buttons.export")}),b&&Bt(ie.Item,{icon:bE,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:h("buttons.publishLibrary")}),!!g.length&&Bt(ie.Item,{onSelect:()=>u(!0),icon:pt,children:x})]})]});return um("div",{className:RN("library-menu-dropdown-container",a),children:[_(),o.length>0&&Bt("div",{className:"library-actions-counter",children:o.length}),d&&p(),v&&Bt(bT,{onClose:()=>y(!1),libraryItems:FN(s.libraryItems,o),appState:l,onSuccess:P=>C(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(A=>A!==P))}),E&&I()]})},UT=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Ae(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Ea(),l=se(),a=he(),[s]=Q(Sn),c=async p=>{let d=p.filter(u=>!e.includes(u.id));n.setLibrary(d).catch(()=>{a({errorMessage:h("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Bt(ON,{appState:l,setAppState:a,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as KN,useEffect as $N,useState as ZN}from"react";import zN,{useCallback as GN}from"react";function UN(){return[!1,GN(o=>o(),[])]}var WT=zN.useTransition||UN;import YT from"clsx";import{memo as WN,useRef as YN,useState as VN}from"react";import{jsx as hm,jsxs as XN}from"react/jsx-runtime";var VT=WN(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:l,svgCache:a})=>{let s=YN(null),c=tm(e,o,a,s),[m,p]=VN(!1),d=fe().formFactor==="phone",u=t&&hm("div",{className:"library-unit__adder",children:r0});return XN("div",{className:YT("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[hm("div",{className:YT("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?b=>{e&&b.shiftKey?i(e,b):n(e)}:void 0,onDragStart:b=>{if(!e){b.preventDefault();return}p(!1),l(e,b)}}),u,e&&o&&(m||d||r)&&hm(os,{checked:r,onChange:(b,g)=>i(e,g),className:"library-unit__checkbox"})]})}),XT=()=>hm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as jN,jsx as gm}from"react/jsx-runtime";var fm=({children:e})=>gm("div",{className:"library-menu-items-container__grid",children:e}),Cs=KN(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:l})=>{let[,a]=WT(),[s,c]=ZN(0);return $N(()=>{s<e.length&&a(()=>{c(s+l)})},[s,e.length,a,l]),gm(jN,{children:e.map((m,p)=>p<s?gm(VT,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??p):gm(XT,{},p))})});import Zg from"clsx";import{forwardRef as eB,useRef as tB,useImperativeHandle as oB,useLayoutEffect as nB,useState as rB}from"react";import qN from"clsx";import{composeEventHandlers as JN}from"@excalidraw/common";import{jsx as QN}from"react/jsx-runtime";var ut=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>QN("button",{onClick:JN(i.onClick,l=>{o()}),type:e,className:qN("hellixitboard-button",r,{selected:t}),...i,children:n});import{jsx as jg,jsxs as KT}from"react/jsx-runtime";var ar=eB(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:l,isRedacted:a=!1,icon:s,className:c,type:m,...p},d)=>{let u=tB(null);oB(d,()=>u.current),nB(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[b,g]=rB(!1);return KT("div",{className:Zg("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,o&&jg("div",{className:"ExcTextField__label",children:o}),KT("div",{className:Zg("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[jg("input",{className:Zg({"is-redacted":"value"in p&&p.value&&a&&!b}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:l,type:m}),a&&jg(ut,{onSelect:()=>g(!b),style:{border:0,userSelect:"none"},children:b?CE:Oi})]})]})});import{Fragment as jT,jsx as lt,jsxs as en}from"react/jsx-runtime";var dB=17,mB=64;function Qg({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:l,libraryReturnUrl:a,onSelectItems:s,selectedItems:c}){let m=fe(),p=$T(null),d=mT(p);qg(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:u}=Ea(),[b,g]=ZT(null),[x,v]=ZT(""),y=!o.length&&!r.length,E=!y&&!!x.trim(),T=Jg(()=>{let D=Kr(x.trim().toLowerCase());return D?o.filter(B=>{let W=B.name||"";return W.trim()&&Kr(W.toLowerCase()).includes(D)}):[]},[o,x]),I=Jg(()=>o.filter(D=>D.status!=="published"),[o]),C=Jg(()=>o.filter(D=>D.status==="published"),[o]),M=Ca((D,B)=>{let W=!c.includes(D),te=[...I,...C];if(W){if(B.shiftKey&&b){let X=te.findIndex(rt=>rt.id===b),le=te.findIndex(rt=>rt.id===D);if(X===-1||le===-1){s([...c,D]);return}let pe=aB(c),de=Math.min(X,le),Ee=Math.max(X,le),Ve=te.reduce((rt,ft,wt)=>((wt>=de&&wt<=Ee||pe.has(ft.id))&&rt.push(ft.id),rt),[]);s(Ve)}else s([...c,D]);g(D)}else g(null),s(c.filter(X=>X!==D))},[b,s,C,c,I]);qg(()=>{c.length||g(null)},[c]);let k=Ca(D=>{let B;return c.includes(D)?B=o.filter(W=>c.includes(W.id)):B=o.filter(W=>W.id===D),B.map(W=>({...W,elements:sB({type:"everything",elements:W.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),_=Ca((D,B)=>{let W={itemIds:c.includes(D)?c:[D]};B.dataTransfer.setData(iB.hellixitboardlibIds,JSON.stringify(W))},[c]),P=Ca(D=>D?c.includes(D):!1,[c]),A=Ca(()=>{t(r)},[r,t]),H=Ca(D=>{D&&n(k(D))},[k,n]),F=u.size>=(T.length?T:o).length?mB:dB,Y=$T(null);qg(()=>{lB(()=>{Y.current?.focus()})},[]);let V=!E&&en(jT,{children:[!y&&lt("div",{className:"library-menu-items-container__header",children:h("labels.personalLib")}),!r.length&&!I.length?en("div",{className:"library-menu-items__no-items",children:[!C.length&&lt("div",{className:"library-menu-items__no-items__label",children:h("library.noItems")}),lt("div",{className:"library-menu-items__no-items__hint",children:C.length>0?h("library.hint_emptyPrivateLibrary"):h("library.hint_emptyLibrary")})]}):en(fm,{children:[r.length>0&&lt(Cs,{itemsRenderedPerBatch:F,items:[{id:null,elements:r}],onItemSelectToggle:M,onItemDrag:_,onClick:A,isItemSelected:P,svgCache:u}),lt(Cs,{itemsRenderedPerBatch:F,items:I,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})]}),C.length>0&&lt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:h("labels.hellixitboardLib")}),C.length>0&&lt(fm,{children:lt(Cs,{itemsRenderedPerBatch:F,items:C,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})})]}),U=E&&en(jT,{children:[en("div",{className:"library-menu-items-container__header",children:[h("library.search.heading"),!e&&en("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:D=>D.preventDefault(),onClick:D=>{v("")},children:[lt("kbd",{children:"esc"})," to clear"]})]}),T.length>0?lt(fm,{children:lt(Cs,{itemsRenderedPerBatch:F,items:T,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})}):en("div",{className:"library-menu-items__no-items",children:[lt("div",{className:"library-menu-items__no-items__hint",children:h("library.search.noResults")}),lt(ut,{onPointerDown:D=>D.preventDefault(),onSelect:()=>{v("")},style:{width:"auto",marginTop:"1rem"},children:h("library.search.clearSearch")})]})]});return en("div",{className:"library-menu-items-container",style:r.length||I.length||C.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[en("div",{className:"library-menu-items-header",children:[!y&&lt(ar,{ref:Y,type:"search",className:cB("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:h("library.search.inputPlaceholder"),value:x,onChange:D=>v(D)}),lt(UT,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),en(Et.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:C.length>0?1:"0 1 auto",margin:y?"auto":0},ref:p,children:[e&&lt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:lt(it,{})}),V,U,y&&lt(am,{style:{padding:"16px 0",width:"100%"},id:l,libraryReturnUrl:a,theme:i})]})]})}import{jsx as lr,jsxs as QT}from"react/jsx-runtime";var Ia=ge(!1),JT=({children:e})=>lr("div",{className:"layer-ui__library",children:e}),EB=oI(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:l,theme:a,selectedItems:s,onSelectItems:c})=>{let[m]=Q(Sn),p=tf(b=>{(async(x,v)=>{ce("element","addToLibrary","ui");for(let E of uB)if(x.some(T=>T.type===E))return n({errorMessage:h(`errors.libraryElementTypeError.${E}`)});let y=[{status:"unpublished",elements:x,id:hB(),created:Date.now()},...v];t(),i.setLibrary(y).catch(()=>{n({errorMessage:h("alerts.errorAddingToLibrary")})})})(b,m.libraryItems)},[t,i,n,m.libraryItems]),d=tI(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return lr(JT,{children:lr("div",{className:"layer-ui__library-message",children:QT("div",{children:[lr(it,{size:"2em"}),lr("span",{children:h("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return QT(JT,{children:[lr(Qg,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:l,libraryReturnUrl:r,theme:a,onSelectItems:c,selectedItems:s}),u&&lr(am,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:l,libraryReturnUrl:r,theme:a})]})}),ef=(e,o)=>({elements:e,pending:oe(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),vB=(e,o)=>{let t=Kn(),[n,r]=eI(()=>ef(t,e.selectedElementIds)),i=pB(new Map);return of(()=>{for(let l of n.pending)i.current.set(l.id,l.version)},[n.pending]),of(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(l=>{if(!gB(l.selectedElementIds,e.selectedElementIds))return i.current.clear(),ef(t,e.selectedElementIds);let a=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=a.get(s)?.version;if(c&&c!==i.current.get(s))return ef(t,e.selectedElementIds)}return l})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},nI=oI(()=>{let e=Ae(),{onInsertElements:o}=e,t=Ko(),n=se(),r=he(),[i,l]=eI([]),a=tI(()=>e.library,[e.library]),s=vB(n,e);of(()=>xB(document,yB.KEYDOWN,p=>{if(p.key===fB.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${qT.SIDEBAR}`))i.length>0?(p.stopPropagation(),l([])):bB(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:b}=e.lastViewportPosition;document.elementFromPoint(u,b)?.closest(`.${qT.SIDEBAR}`)&&(p.stopPropagation(),l([]))}}},{capture:!0}),[i,r,e]);let c=tf(p=>{o(Ta(p)),e.focusContainer()},[o,e]),m=tf(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return lr(EB,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:a,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:l})});import TB from"clsx";import{useRef as IB}from"react";import{createPortal as wB}from"react-dom";import{KEYS as CB}from"@excalidraw/common";import{jsx as rI,jsxs as SB}from"react/jsx-runtime";var iI=e=>{let{closeOnClickOutside:o=!0}=e,t=id({className:"hellixitboard-modal-container"}),n=IB(document.body.classList.contains("hellixitboard-animations-disabled"));if(!t)return null;let r=i=>{i.key===CB.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return wB(SB("div",{className:TB("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[rI("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),rI("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Ss,jsxs as _B}from"react/jsx-runtime";function LB(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var je=e=>{let[o,t]=q2(),[n]=PB(document.activeElement),{id:r}=_e(),i=fe().formFactor==="phone";MB(()=>{if(!o)return;let c=aI(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===AB.TAB){let d=aI(o),{activeElement:u}=document,b=d.findIndex(g=>g===u);b===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):b===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let l=he(),a=zo(Ia),s=()=>{l({openMenu:null}),a(!1),n.focus(),e.onCloseRequest()};return Ss(iI,{className:kB("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:LB(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:_B(Xe,{ref:t,children:[e.title&&Ss("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:Ss("span",{className:"Dialog__titleContent",children:e.title})}),i&&Ss("button",{className:"Dialog__close",onClick:s,title:h("buttons.close"),"aria-label":h("buttons.close"),type:"button",children:Qt}),Ss("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as Ge}from"@excalidraw/common";var bm=[{icon:Ni,value:"hand",key:Ge.H,numericKey:null,fillable:!1,toolbar:!0},{icon:Rr,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0,toolbar:!0},{icon:ki,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0,toolbar:!0},{icon:Mi,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0,toolbar:!0},{icon:Pi,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0,toolbar:!0},{icon:Fc,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0,toolbar:!0},{icon:Ai,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0,toolbar:!0},{icon:Uo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1,toolbar:!0},{icon:Wo,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1,toolbar:!0},{icon:Li,value:"image",key:null,numericKey:Ge[9],fillable:!1,toolbar:!0},{icon:Oc,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1,toolbar:!0},{icon:Yo,value:"laser",key:Ge.K,numericKey:null,fillable:!1,toolbar:!1}],nf=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Rr,key:Ge.V,numericKey:Ge[1],fillable:!0,toolbar:!0},...bm.slice(1)]:bm,lI=(e,o)=>nf(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import ko from"clsx";import{useRef as gI,useState as GB}from"react";import{Popover as tn}from"radix-ui";import{CLASSES as fI,KEYS as mI,capitalizeString as ka,isTransparent as ym,viewportCoordsToSceneCoords as UB}from"@excalidraw/common";import{shouldAllowVerticalAlign as bI,suppportsHorizontalAlign as xI,hasBoundTextElement as Em,isElbowArrow as sf,isImageElement as yI,isLinearElement as cf,isTextElement as Tm,isArrowElement as pI,hasStrokeColor as uI,toolIsArrow as vm,newElement as WB,newTextElement as hI}from"@excalidraw/element";import{createIsolation as DB}from"jotai-scope";import rf from"react";import So from"tunnel-rat";var af=rf.createContext(null),Pe=()=>rf.useContext(af),HB=DB(),sI=()=>rf.useMemo(()=>({MainMenuTunnel:So(),WelcomeScreenMenuHintTunnel:So(),WelcomeScreenToolbarHintTunnel:So(),WelcomeScreenHelpHintTunnel:So(),WelcomeScreenCenterTunnel:So(),FooterCenterTunnel:So(),FooterRightSlotTunnel:So(),DefaultSidebarTriggerTunnel:So(),DefaultSidebarTabTriggersTunnel:So(),OverwriteConfirmDialogTunnel:So(),TTDDialogTriggerTunnel:So(),tunnelsJotai:HB}),[]);import{CODES as RB,KEYS as NB}from"@excalidraw/common";import{CaptureUpdateAction as BB}from"@excalidraw/element";var Zr=O({name:"viewMode",label:"labels.viewMode",icon:Oi,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:BB.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[NB.CTRL_OR_CMD]&&e.altKey&&e.code===RB.R});import{useEffect as FB,useState as OB}from"react";import cI from"clsx";import{capitalizeString as dI}from"@excalidraw/common";import{Popover as lf}from"radix-ui";import{jsx as xm,jsxs as zB}from"react/jsx-runtime";var Sa=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:l,"data-testid":a,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=OB(!1),u=t.type,b=c.type===u,g=32/2+10,{container:x}=_e();return!o.some(v=>v.type===u)&&p&&d(!1),FB(()=>{let v=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>v?.()},[e]),zB(lf.Root,{open:p,children:[xm(lf.Trigger,{asChild:!0,children:xm(J,{className:cI(r,{fillable:m,active:o.some(v=>v.type===t.type)}),type:"radio",icon:c.icon,checked:b,name:"editor-current-shape",title:l,"aria-label":l,"data-testid":a,onPointerDown:()=>{d(v=>!v),s(n)}})}),xm(lf.Content,{className:"tool-popover-content",sideOffset:g,collisionBoundary:x??void 0,children:o.map(({type:v,icon:y,title:E})=>xm(J,{className:cI(r,{active:u===v}),type:"radio",icon:y,checked:u===v,name:`${i}-option`,title:E||dI(v),keyBindingLabel:"","aria-label":E||dI(v),"data-testid":`toolbar-${v}`,onChange:()=>{e.state.activeTool.type!==v&&ce("toolbar",v,"ui"),e.setActiveTool({type:v}),s?.(v)}},v))})]})};import{Fragment as Ft,jsx as K,jsxs as ue}from"react/jsx-runtime";var Im=ko([fI.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),ks=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return uI(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>uI(n.type))},Ms=(e,o)=>Bo(e.activeTool.type)||o.some(t=>Bo(t.type)),EI=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=xi(o,e),i=!1;r.length===2&&(Em(r[0])||Em(r[1]))&&(i=!0);let l=!!(e.editingTextElement||e.newElement),a=fe(),s=document.documentElement.getAttribute("dir")==="rtl",c=Bo(e.activeTool.type)&&!ym(e.currentItemBackgroundColor)||r.some(b=>Bo(b.type)&&!ym(b.backgroundColor)),m=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&cf(r[0])&&!sf(r[0]),d=!e.croppingElementId&&r.length===1&&yI(r[0]),u=!i&&Mt(e,n);return ue("div",{className:"selected-shape-actions",children:[K("div",{children:ks(e,r)&&t("changeStrokeColor")}),Ms(e,r)&&K("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Il(e.activeTool.type)||r.some(b=>Il(b.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(b=>b.type==="freedraw"))&&t("changeStrokeShape"),(wl(e.activeTool.type)||r.some(b=>wl(b.type)))&&ue(Ft,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Cl(e.activeTool.type)||r.some(b=>Cl(b.type)))&&K(Ft,{children:t("changeRoundness")}),(Sl(e.activeTool.type)||r.some(b=>Sl(b.type)))&&K(Ft,{children:t("changeAnimation")}),(vm(e.activeTool.type)||r.some(b=>vm(b.type)))&&K(Ft,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Tm))&&ue(Ft,{children:[K("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),(e.activeTool.type==="text"||xI(r,o))&&t("changeTextAlign")]}),bI(r,o)&&t("changeVerticalAlign"),(yi(e.activeTool.type)||r.some(b=>yi(b.type)))&&K(Ft,{children:t("changeArrowhead")}),t("changeOpacity"),ue("fieldset",{children:[K("legend",{children:h("labels.layers")}),ue("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ue("fieldset",{children:[K("legend",{children:h("labels.align")}),ue("div",{className:"buttonList",children:[s?ue(Ft,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ue(Ft,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),K("div",{style:{flexBasis:"100%",height:0}}),ue("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!l&&r.length>0&&ue("fieldset",{children:[K("legend",{children:h("labels.actions")}),ue("div",{className:"buttonList",children:[a.formFactor!=="phone"&&t("duplicateSelection"),a.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor")]})]})]})},vI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=Bo(e.activeTool.type)&&!ym(e.currentItemBackgroundColor)||n.some(s=>Bo(s.type)&&!ym(s.backgroundColor)),l=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return l?K("div",{className:"compact-action-item",children:ue(tn.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:a}),title:h("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:VE})}),a&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:ue("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(Il(e.activeTool.type)||n.some(s=>Il(s.type)))&&o("changeStrokeWidth"),(wl(e.activeTool.type)||n.some(s=>wl(s.type)))&&ue(Ft,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Cl(e.activeTool.type)||n.some(s=>Cl(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},TI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let l=vm(e.activeTool.type)||n.some(s=>vm(s.type)),a=e.openPopup==="compactArrowProperties";return l?K("div",{className:"compact-action-item",children:ue(tn.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:a}),title:h("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactArrowProperties"})},children:(()=>{let s=xt(n,i,c=>pI(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>pI(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?Gi:s==="round"?Ui:zi})()})}),a&&K(Vo,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},II=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:l,restoreCaretPosition:a}=u1(),s=e.openPopup==="compactTextProperties";return K("div",{className:"compact-action-item",children:ue(tn.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&l(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:s}),title:h("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&l(),t({openPopup:"compactTextProperties"}))},children:u0})}),e.openPopup==="compactTextProperties"&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:ue("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(Tm))&&o("changeFontSize"),(e.activeTool.type==="text"||xI(n,i))&&o("changeTextAlign"),bI(n,i)&&o("changeVerticalAlign")]})})]})})},wI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=Sl(e.activeTool.type)||n.some(s=>Sl(s.type)),l=e.openPopup==="compactAnimationProperties";if(!i)return null;let a=ue("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[K("line",{x1:"2",y1:"12",x2:"8",y2:"12",strokeDasharray:"3 2"}),K("line",{x1:"10",y1:"12",x2:"16",y2:"12",strokeDasharray:"3 2"}),K("line",{x1:"18",y1:"12",x2:"22",y2:"12",strokeDasharray:"3 2"}),K("polyline",{points:"17,8 22,12 17,16"})]});return K("div",{className:"compact-action-item",children:ue(tn.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactAnimationProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:l}),title:"Animations",onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactAnimationProperties"})},children:a})}),l&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:K("div",{className:"selected-shape-actions",children:o("changeAnimation")})})]})})},CI=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:l,showDelete:a})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&yI(t[0]),m=t.length===1,p=Mt(e,i),d=!1;t.length===2&&(Em(t[0])||Em(t[1]))&&(d=!0);let u=document.documentElement.getAttribute("dir")==="rtl",b=e.openPopup==="compactOtherProperties";return s||t.length===0?null:K("div",{className:"compact-action-item",children:ue(tn.Root,{open:b,onOpenChange:g=>{n(g?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:b}),title:h("labels.actions"),onClick:g=>{g.preventDefault(),g.stopPropagation(),n({openPopup:b?null:"compactOtherProperties"})},children:a0})}),b&&K(Vo,{className:Im,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ue("div",{className:"selected-shape-actions",children:[ue("fieldset",{children:[K("legend",{children:h("labels.layers")}),ue("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&ue("fieldset",{children:[K("legend",{children:h("labels.align")}),ue("div",{className:"buttonList",children:[u?ue(Ft,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):ue(Ft,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),K("div",{style:{flexBasis:"100%",height:0}}),ue("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically")]})]})]}),ue("fieldset",{children:[K("legend",{children:h("labels.actions")}),ue("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),l&&o("duplicateSelection"),a&&o("deleteSelectedElements")]})]})]})})]})})},YB=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&cf(t[0])&&!sf(t[0])?K("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,SI=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=xi(o,e),{container:l}=_e(),a=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&cf(i[0])&&!sf(i[0]);return ue("div",{className:"compact-shape-actions",children:[ks(e,i)&&K("div",{className:ko("compact-action-item"),children:t("changeStrokeColor")}),Ms(e,i)&&K("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),K(vI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(TI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,app:n}),K(wI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),s&&K("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(Tm))&&ue(Ft,{children:[K("div",{className:"compact-action-item",children:t("changeFontFamily")}),K(II,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,elementsMap:o})]}),!a&&i.length>0&&K("div",{className:"compact-action-item",children:t("duplicateSelection")}),!a&&i.length>0&&K("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),K(CI,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:l,app:n})]})},kI=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=xi(o,e),{container:l}=_e(),a=gI(null),s=a.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,u=p+m,b=s>=d+u,g=s>=d+2*u;return ue(Xe,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:a,children:[ue("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[ks(e,i)&&K("div",{className:ko("compact-action-item"),children:t("changeStrokeColor")}),Ms(e,i)&&K("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),K(vI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(TI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,app:n}),K(wI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(YB,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(Tm))&&ue(Ft,{children:[K("div",{className:"compact-action-item",children:t("changeFontFamily")}),K(II,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,elementsMap:o})]}),K(CI,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:l,app:n,showDuplicate:!g,showDelete:!b})]}),ue("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[K("div",{className:"compact-action-item",children:t("undo")}),K("div",{className:"compact-action-item",children:t("redo")}),g&&K("div",{className:"compact-action-item",children:t("duplicateSelection")}),b&&K("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},MI=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=GB(!1),l=gI(null),a=at(),s=a==="full",c=a==="compact",m=[{type:"selection",icon:Rr,title:ka(h("toolBar.selection"))},{type:"lasso",icon:Un,title:ka(h("toolBar.lasso"))}],p=e.type==="frame",d=e.type==="laser",u=s&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",b=e.type==="embeddable",{TTDDialogTriggerTunnel:g}=Pe();return ue(Ft,{children:[K("input",{ref:l,type:"file",style:{display:"none"},onChange:async x=>{let v=x.target.files?.[0];if(!v||(x.target.value="",_r(v)))return;let E=(await t.props.onFileUpload?.(v))?.url;if(!E)return;let T=t.state.width/2+t.state.offsetLeft,I=t.state.height/2+t.state.offsetTop,{x:C,y:M}=UB({clientX:T,clientY:I},t.state),k=v.name.length>28?`${v.name.slice(0,25)}...`:v.name,_=Math.max(220,Math.min(460,k.length*11+132)),P=56,A=C-_/2,H=M-P/2,F=`file-chip-${Date.now()}-${Math.round(Math.random()*1e6)}`,Y=WB({type:"rectangle",x:A,y:H,width:_,height:P,strokeColor:"#d8d8e2",backgroundColor:"#ececf3",fillStyle:"solid",strokeWidth:1,roughness:0,roundness:{type:3,value:16},groupIds:[F],customData:{filePlaceholderUrl:E}}),V=hI({x:A+22,y:H+16,text:"\u{1F4CE}",fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#5a5a66",groupIds:[F],customData:{filePlaceholderUrl:E}}),U=hI({x:A+52,y:H+17,text:k,fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#2d2d36",groupIds:[F],customData:{filePlaceholderUrl:E}});t.scene.insertElements([Y,V,U])}}),nf(t).map(({value:x,icon:v,key:y,numericKey:E,fillable:T,toolbar:I})=>{if(I===!1||n.tools?.[x]===!1)return null;let C=h(`toolBar.${x}`),M=y&&ka(typeof y=="string"?y:y[0]),k=M?`${M} ${h("helpDialog.or")} ${E}`:`${E}`,_=x==="hand"?void 0:E||M;return(x==="selection"||x==="lasso")&&c?K(Sa,{app:t,options:m,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:ka(h("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:P=>{(P==="selection"||P==="lasso")&&(t.setActiveTool({type:P}),o({preferredSelectionTool:{type:P,initialized:!0}}))},displayedOption:m.find(P=>P.type===t.state.preferredSelectionTool.type)||m[0],fillable:e.type==="selection"},"selection-popover"):K(J,{className:ko("Shape",{fillable:T}),type:"radio",icon:v,checked:e.type===x,name:"editor-current-shape",title:`${ka(C)} \u2014 ${k}`,keyBindingLabel:_,"aria-label":ka(C),"aria-keyshortcuts":k,"data-testid":`toolbar-${x}`,onPointerDown:({pointerType:P})=>{!t.state.penDetected&&P==="pen"&&t.togglePenMode(!0),x==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:P})=>{t.state.activeTool.type!==x&&ce("toolbar",x,"ui"),x==="image"?t.setActiveTool({type:x}):t.setActiveTool({type:x})}},x)}),K("div",{className:"App-toolbar__divider"}),ue(ie,{open:r,children:[K(ie.Trigger,{className:ko("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":p||b||u||d&&!t.props.isCollaborating}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),children:p?yo:b?_i:d&&!t.props.isCollaborating?Yo:u?Un:Bl}),ue(ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[K(ie.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:yo,shortcut:mI.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,children:h("toolBar.frame")}),K(ie.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:_i,"data-testid":"toolbar-embeddable",selected:b,children:h("toolBar.embeddable")}),K(ie.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:d,shortcut:mI.K.toLocaleUpperCase(),children:h("toolBar.laser")}),s&&K(ie.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Un,"data-testid":"toolbar-lasso",selected:u,children:h("toolBar.lasso")}),t.props.onFileUpload&&K(ie.Item,{onSelect:()=>l.current?.click(),icon:Yc,"data-testid":"toolbar-upload-file",children:h("toolBar.uploadFile")}),K("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&K(g.Out,{}),K(ie.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Fi,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToHellixitboard")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&K(ie.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Fr,"data-testid":"toolbar-magicframe",badge:K(ie.Item.Badge,{children:"AI"}),children:h("toolBar.magicframe")})]})]})]})},PI=({renderAction:e,zoom:o})=>K(Et.Col,{gap:1,className:fI.ZOOM_ACTIONS,children:ue(Et.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),AI=({renderAction:e,className:o})=>ue("div",{className:`undo-redo-buttons ${o}`,children:[K("div",{className:"undo-button-container",children:K($t,{label:h("buttons.undo"),children:e("undo")})}),K("div",{className:"redo-button-container",children:ue($t,{label:h("buttons.redo"),children:[" ",e("redo")]})})]}),LI=({actionManager:e,showExitZenModeBtn:o})=>K("button",{type:"button",className:ko("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(tr),children:h("buttons.exitZenMode")}),_I=({actionManager:e})=>K("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Zr),children:KE});import{useRef as VB}from"react";var df=e=>{let o=VB({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as KB,jsxs as XB}from"react/jsx-runtime";var jr=ge(null),DI=()=>{let[e,o]=Q(jr),t=De(),n=Ae();return e&&e==="clearCanvas"?KB(sm,{onConfirm:()=>{t.executeAction(Cn),n.props.onClearCanvas?.(),o(null)},onCancel:()=>o(null),title:h("clearCanvasDialog.title"),children:XB("p",{className:"clear-canvas__content",children:[" ",h("alerts.clearReset")]})}):null};var mf={};Ay(mf,{toggleTheme:()=>$B});var $B={...Gr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Gr,"commandPalette")}};import{jsx as st,jsxs as on}from"react/jsx-runtime";var QB=ge(null),Fe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},RI=e=>{switch(e){case Fe.app:return 1;case Fe.export:return 2;case Fe.editor:return 3;case Fe.tools:return 4;case Fe.elements:return 5;case Fe.links:return 6;default:return 10}},Sm=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return on("div",{className:BI("shortcut",o),children:[n.map((r,i)=>st("div",{className:"shortcut-wrapper",children:st("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),st("div",{className:"shortcut-desc",children:t})]})},OI=e=>!e.altKey&&e[Mo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===Mo.P||e.key===Mo.SLASH),eF=Object.assign(e=>{let o=se(),t=he();return Cm(()=>{let n=r=>{OI(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let l=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return l&&ce("command_palette","open","shortcut"),{openDialog:l}}))};return window.addEventListener(km.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(km.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:st(tF,{...e})},{defaultItems:mf});function tF({customCommandPaletteItems:e}){let o=Ae(),t=se(),n=he(),r=Ko(),i=De(),[l,a]=Q(QB),[s,c]=wm(null),m=FI(null),p=Yn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[d]=Q(Sn),u=jB(()=>d.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:st(oF,{id:k.id,elements:k.elements}),category:"Library",order:RI("Library"),haystack:Kr(k.name),perform:()=>{o.onInsertElements(Ta([k]))}}))||[],[o,d.libraryItems]);Cm(()=>{let{uiAppState:k,customCommandPaletteItems:_,appProps:P}=p,A=V=>{let U="";return V.label&&(typeof V.label=="function"?U=h(V.label(o.scene.getNonDeletedElements(),k,o)):U=h(V.label)),U},H=V=>typeof V.icon=="function"?V.icon(k,o.scene.getNonDeletedElements()):V.icon,F=[],Y=(V,U,D)=>{let B={label:A(V),icon:H(V),category:U,shortcut:Le(V.name),keywords:V.keywords,predicate:V.predicate,viewMode:V.viewMode,perform:()=>{i.executeAction(V,"commandPalette")}};return D?D(B,V):B};if(k&&o.scene&&i){let V=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,hs,em,Z2].map(X=>Y(X,Fe.elements,(le,pe)=>({...le,predicate:pe.predicate?pe.predicate:(de,Ee,Ve,rt)=>oe(de,Ee).length>0}))),U=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>Y(X,Fe.tools)),D=[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(X=>Y(X,Fe.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>Y(X,Fe.export));F=[...V,...D,{label:A(Cn),icon:H(Cn),shortcut:Le(Cn.name),category:Fe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Qe.set(jr,"clearCanvas")}},{label:h("buttons.exportImage"),category:Fe.export,icon:Uc,shortcut:Le("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...B];let W=[{label:h("toolBar.library"),category:Fe.app,icon:Bc,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:HI.name,tab:HI.defaultTab}})}},{label:h("search.title"),category:Fe.app,icon:Kt,viewMode:!0,perform:()=>{i.executeAction(Ps)}},{label:h("labels.shapeSwitch"),category:Fe.elements,icon:Fl,perform:()=>{i.executeAction($2)}},{label:h("labels.changeStroke"),keywords:["color","outline"],category:Fe.elements,icon:Ri,viewMode:!1,predicate:(X,le)=>{let pe=oe(X,le);return pe.length>0&&ks(le,pe)},perform:()=>{n(X=>({openPopup:"elementStroke"}))}},{label:h("labels.changeBackground"),keywords:["color","fill"],icon:Ri,category:Fe.elements,viewMode:!1,predicate:(X,le)=>{let pe=oe(X,le);return pe.length>0&&Ms(le,pe)},perform:()=>{n(X=>({openPopup:"elementBackground"}))}},{label:h("labels.canvasBackground"),keywords:["color"],icon:Ri,category:Fe.editor,viewMode:!1,perform:()=>{n(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...bm.reduce((X,le)=>{let{value:pe,icon:de,key:Ee,numericKey:Ve}=le;if(P.UIOptions.tools?.[pe]===!1)return X;let ft=Ee&&qB(typeof Ee=="string"?Ee:Ee[0])||Ve,wt={label:h(`toolBar.${pe}`),category:Fe.tools,shortcut:ft,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:zn})=>{pe==="image"?o.setActiveTool({type:pe}):o.setActiveTool({type:pe})}};return X.push(wt),X},[]),...U,{label:h("toolBar.lock"),category:Fe.tools,icon:k.activeTool.locked?Si:Hr,shortcut:Mo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${h("labels.textToDiagram")}...`,category:Fe.tools,icon:kE,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${h("toolBar.mermaidToHellixitboard")}...`,category:Fe.tools,icon:Fi,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],te=[...F,...W,..._||[]].map(X=>({...X,icon:X.icon||Fl,order:X.order??RI(X.category),haystack:`${Kr(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));c(te),a([...te,...u].find(X=>X.label===l?.label)??null)}},[p,o,i,c,l?.label,a,n,u]);let[b,g]=wm(""),[x,v]=wm(null),[y,E]=wm({}),T=k=>{n({openDialog:null},k),g("")},I=(k,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("hellixitboard-animations-disabled"),T(()=>{k.perform({actionManager:i,event:_}),a(k),requestAnimationFrame(()=>{document.body.classList.remove("hellixitboard-animations-disabled")})}))},C=df(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,r,o):k.predicate===void 0||k.predicate),M=df(k=>{let _=JB(k.target)||OI(k)||k.key===Mo.ESCAPE;if(_&&k.key!==Mo.ARROW_UP&&k.key!==Mo.ARROW_DOWN&&k.key!==Mo.ENTER)return;let P=Object.values(y).flat(),A=l&&!b&&C(l);if(k.key===Mo.ARROW_UP){k.preventDefault();let H=P.findIndex(V=>V.label===x?.label);if(A){if(H===0){v(l);return}if(x===l){let V=P[P.length-1];V&&v(V);return}}let F;H===-1?F=P.length-1:F=H===0?P.length-1:(H-1)%P.length;let Y=P[F];Y&&v(Y);return}if(k.key===Mo.ARROW_DOWN){k.preventDefault();let H=P.findIndex(V=>V.label===x?.label);if(A){if(!x||H===P.length-1){v(l);return}if(x===l){let V=P[0];V&&v(V);return}}let F=(H+1)%P.length,Y=P[F];Y&&v(Y);return}if(k.key===Mo.ENTER&&x&&setTimeout(()=>{I(x,k)}),!_){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return Cm(()=>(window.addEventListener(km.KEYDOWN,M,{capture:!0}),()=>window.removeEventListener(km.KEYDOWN,M,{capture:!0})),[M]),Cm(()=>{if(!s)return;let k=H=>{let F={};for(let Y of H)F[Y.category]?F[Y.category].push(Y):F[Y.category]=[Y];return F},_=b?.length>1?[...s.filter(C).sort((H,F)=>H.order-F.order),...u]:s.filter(C).sort((H,F)=>H.order-F.order),P=!b&&l&&C(l);if(!b){E(k(P?_.filter(H=>H.label!==l?.label):_)),v(P?l:_[0]||null);return}let A=Kr(b.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=ZB.filter(A,_,{extract:H=>H.haystack??""}).sort((H,F)=>F.score-H.score).map(H=>H.original),E(k(_)),v(_[0]??null)},[b,s,C,l,u]),on(je,{onCloseRequest:()=>T(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[st(ar,{value:b,placeholder:h("commandPalette.search.placeholder"),onChange:k=>{g(k)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&on("div",{className:"shortcuts-wrapper",children:[st(Sm,{shortcut:"\u2191\u2193",children:h("commandPalette.shortcuts.select")}),st(Sm,{shortcut:"\u21B5",children:h("commandPalette.shortcuts.confirm")}),st(Sm,{shortcut:N("Esc"),children:h("commandPalette.shortcuts.close")})]}),on("div",{className:"commands",children:[l&&!b&&on("div",{className:"command-category",children:[on("div",{className:"command-category-title",children:[h("commandPalette.recents"),st("div",{className:"icon",style:{marginLeft:"6px"},children:ME})]}),st(NI,{command:l,isSelected:l.label===x?.label,onClick:k=>I(l,k),disabled:!C(l),onMouseMove:()=>v(l),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(y).length>0?Object.keys(y).map((k,_)=>on("div",{className:"command-category",children:[st("div",{className:"command-category-title",children:k}),y[k].map(P=>st(NI,{command:P,isSelected:P.label===x?.label,onClick:A=>I(P,A),onMouseMove:()=>v(P),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:k==="Library"?"large":"small"},P.label))]},k)):s?on("div",{className:"no-match",children:[st("div",{className:"icon",children:Kt})," ",h("commandPalette.search.noMatch")]}):null]})]})}var oF=({id:e,elements:o})=>{let t=FI(null),{svgCache:n}=Ea();return tm(e,o,n,t),st("div",{className:"library-item-icon",ref:t})},NI=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:l,size:a="small"})=>{let s=()=>{};return on("div",{className:BI("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":a==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?h("commandPalette.itemNotAvailable"):"",children:[on("div",{className:"name",children:[e.icon&&st($o,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(l,[]):e.icon}),st(Zl,{children:e.label})]}),i&&e.shortcut&&st(Sm,{shortcut:e.shortcut})]})};import{getSizeFromPoints as mIe,randomInteger as i8,getUpdatedTimestamp as a8}from"@excalidraw/common";import{simplify as YF}from"points-on-curve";import{getStroke as VF}from"perfect-freehand";import{pointsOnBezierCurves as Jbe}from"points-on-curve";import{invariant as exe}from"@excalidraw/common";import{curve as oxe,lineSegment as nxe,pointFrom as rxe,pointDistance as ixe,pointFromArray as axe,pointFromVector as lxe,pointRotateRads as sxe,polygon as cxe,polygonFromPoints as dxe,PRECISION as mxe,segmentsIntersectAt as pxe,vector as uxe,vectorAdd as hxe,vectorFromPoint as gxe,vectorScale as fxe}from"@excalidraw/math";import{getElementAbsoluteCoords as xxe}from"@excalidraw/element";var pf=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as XF,pointDistance as nw,pointRotateRads as jTe}from"@excalidraw/math";import{ROUGHNESS as KF,THEME as Af,isTransparent as Hs,assertNever as $F,COLOR_PALETTE as ZF,LINE_POLYGON_POINT_MERGE_DISTANCE as JTe,applyDarkModeFilter as Rs}from"@excalidraw/common";import{RoughGenerator as jF}from"roughjs/bin/generator";import aTe from"roughjs/bin/rough";import{isRightAngleRads as sTe,lineSegment as cTe,pointFrom as dTe,pointRotateRads as mTe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as uTe,DEFAULT_REDUCED_GLOBAL_ALPHA as hTe,ELEMENT_READY_TO_ERASE_OPACITY as gTe,FRAME_STYLE as fTe,DARK_THEME_FILTER as bTe,MIME_TYPES as tw,THEME as xTe,distance as yTe,getFontString as ETe,isRTL as vTe,getVerticalOffset as TTe,invariant as ITe,applyDarkModeFilter as wTe,isSafari as CTe}from"@excalidraw/common";import xve from"roughjs/bin/rough";import{arrayToMap as Eve,invariant as $I,rescalePoints as vve,sizeOf as Tve}from"@excalidraw/common";import{degreesToRadians as wf,lineSegment as wve,pointDistance as Cve,pointFrom as ht,pointFromArray as wF,pointRotateRads as _a}from"@excalidraw/math";import{pointsOnBezierCurves as Mve}from"points-on-curve";import{pointCenter as D1e,pointFrom as H1e,pointRotateRads as R1e,pointsEqual as N1e,pointDistance as B1e,vectorFromPoint as F1e,curveLength as O1e,curvePointAtLength as z1e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as W1e,KEYS as Y1e,shouldRotateWithDiscreteAngle as V1e,getGridPoint as X1e,invariant as K1e,isShallowEqual as $1e,getFeatureFlag as Z1e}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as q1e,getSnapOutlineMidPoint as J1e,isPathALoop as Q1e,moveArrowAboveBindable as eve,projectFixedPointOntoDiagonal as tve}from"@excalidraw/element";import{arrayToMap as HEe,getFeatureFlag as REe,invariant as NEe,isTransparent as BEe}from"@excalidraw/common";import{PRECISION as OEe,clamp as zEe,lineSegment as GEe,pointDistance as UEe,pointDistanceSq as WEe,pointFrom as YEe,pointFromVector as VEe,pointRotateRads as XEe,pointsEqual as KEe,vectorFromPoint as $Ee,vectorNormalize as ZEe,vectorScale as jEe}from"@excalidraw/math";import{invariant as a0e,isTransparent as l0e}from"@excalidraw/common";import{curveIntersectLineSegment as c0e,isPointWithinBounds as d0e,lineSegment as m0e,lineSegmentIntersectionPoints as p0e,pointFrom as u0e,pointFromVector as h0e,pointRotateRads as g0e,pointsEqual as f0e,vectorFromPoint as b0e,vectorNormalize as x0e,vectorScale as y0e}from"@excalidraw/math";import{ellipse as v0e,ellipseSegmentInterceptPoints as T0e}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as iF,DEFAULT_PROPORTIONAL_RADIUS as hf,invariant as Pxe,LINE_CONFIRM_THRESHOLD as aF,ROUNDNESS as gf}from"@excalidraw/common";import{bezierEquation as Lxe,curve as _xe,curveCatmullRomCubicApproxPoints as Dxe,curveOffsetPoints as Hxe,lineSegment as Rxe,lineSegmentIntersectionPoints as Nxe,pointDistance as lF,pointFrom as Bxe,pointFromArray as Fxe,pointFromVector as Oxe,pointRotateRads as zxe,pointTranslate as Gxe,rectangle as Uxe,vectorFromPoint as Wxe,vectorNormalize as Yxe,vectorScale as Vxe}from"@excalidraw/math";import{ROUNDNESS as Txe,assertNever as Ixe}from"@excalidraw/common";import{pointsEqual as Cxe}from"@excalidraw/math";var zI=e=>!!e&&e.type==="embeddable",GI=e=>!!e&&e.type==="iframe",uf=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),qr=e=>e!=null&&e.type==="text";var Mm=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Jr=e=>e!=null&&nF(e.type);var Qr=e=>e!=null&&e.type==="arrow",As=e=>Qr(e)&&e.elbowed;var nF=e=>e==="arrow"||e==="line";var Ma=e=>e!==null&&"containerId"in e&&e.containerId!==null&&qr(e);var Pm=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return lF(t,n)<=aF/o}return!1},Ls=(e,o)=>{if(o.roundness?.type===gf.PROPORTIONAL_RADIUS||o.roundness?.type===gf.LEGACY)return e*hf;if(o.roundness?.type===gf.ADAPTIVE_RADIUS){let t=o.roundness?.value??iF,n=t/hf;return e<=n?e*hf:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Pye,ARROW_LABEL_WIDTH_FRACTION as Aye,BOUND_TEXT_PADDING as Lye,DEFAULT_FONT_SIZE as _ye,TEXT_ALIGN as Dye,VERTICAL_ALIGN as Hye,getFontString as Rye,isProdEnv as Nye,invariant as Bye}from"@excalidraw/common";import{pointFrom as Oye,pointRotateRads as zye}from"@excalidraw/math";import{BOUND_TEXT_PADDING as aye,DEFAULT_FONT_SIZE as lye,DEFAULT_FONT_FAMILY as sye,getFontString as cye,isTestEnv as dye,normalizeEOL as mye}from"@excalidraw/common";var pye="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as yye,isTestEnv as Eye}from"@excalidraw/common";import{curvePointDistance as Zye,distanceToLineSegment as jye,pointRotateRads as qye}from"@excalidraw/math";import{ellipse as Qye,ellipseDistanceFromPoint as e0e}from"@excalidraw/math/ellipse";import{invariant as N0e,isDevEnv as B0e,isTestEnv as F0e}from"@excalidraw/common";import{pointFrom as z0e,pointFromVector as G0e,pointRotateRads as U0e,pointScaleFromOrigin as W0e,pointsEqual as Y0e,triangleIncludesPoint as V0e,vectorCross as X0e,vectorFromPoint as bF,vectorScale as K0e}from"@excalidraw/math";var Tf=[1,0],YI=[0,1],If=[-1,0],VI=[0,-1],_m=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Tf:o<=-r?If:t>n?YI:VI},XI=(e,o)=>_m(bF(e,o)),Dm=(e,o)=>Hm(XI(e,o)),vf=(e,o)=>e[0]===o[0]&&e[1]===o[1],Hm=e=>vf(e,Tf)||vf(e,If);import{clamp as Q0e,pointDistance as eEe,pointFrom as tEe,pointScaleFromOrigin as oEe,pointsEqual as nEe,pointTranslate as rEe,vector as iEe,vectorCross as aEe,vectorFromPoint as lEe,vectorScale as sEe}from"@excalidraw/math";import{BinaryHeap as dEe,invariant as mEe,isAnyTrue as pEe,getSizeFromPoints as uEe,isDevEnv as hEe,arrayToMap as gEe}from"@excalidraw/common";var s1e=10/1.5;import{SHIFT_LOCKING_ANGLE as u1e,viewportCoordsToSceneCoords as h1e}from"@excalidraw/common";import{normalizeRadians as f1e,radiansBetweenAngles as b1e,radiansDifference as x1e}from"@excalidraw/math";import{pointsEqual as E1e}from"@excalidraw/math";var Am=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,l=e.height;return[o,t,n,r,i,l,0,r]};var CF=20,SF=15,kF=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return SF;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return CF;default:return 15}},MF=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,o,t,n,r=0)=>{if(n===null||o.length<1)return null;let i=pf(o[0]);if(i.length<1)return null;let l=t==="start"?1:i.length-1,a=i[l].data;$I(a.length===6,"Op data length is not 6");let s=ht(a[4],a[5]),c=ht(a[2],a[3]),m=ht(a[0],a[1]),p=i[l-1],d=ht(0,0);if(p.op==="move"){let B=wF(p.data);$I(B!=null,"Op data is not a point"),d=B}else p.op==="bcurveTo"&&(d=ht(p.data[4],p.data[5]));let u=(B,W)=>Math.pow(1-B,3)*s[W]+3*B*Math.pow(1-B,2)*c[W]+3*Math.pow(B,2)*(1-B)*m[W]+d[W]*Math.pow(B,3),[b,g]=t==="start"?d:s,[x,v]=[u(.3,0),u(.3,1)],y=Math.hypot(b-x,g-v),E=(b-x)/y,T=(g-v)/y,I=kF(n),C=0;{let[B,W]=t==="end"?e.points[e.points.length-1]:e.points[0],[te,X]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(B-te,W-X)}let k=Math.min(I,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),_=b-E*k*r,P=g-T*k*r,A=_-E*k,H=P-T*k;if(n==="circle"||n==="circle_outline"){let B=Math.hypot(H-P,A-_)+e.strokeWidth-2;return[_,P,B]}let F=MF(n);if(n==="cardinality_many"||n==="cardinality_one_or_many"){let[B,W]=_a(ht(_,P),ht(A,H),wf(-F)),[te,X]=_a(ht(_,P),ht(A,H),wf(F));return[A,H,B,W,te,X]}let[Y,V]=_a(ht(A,H),ht(_,P),-F*Math.PI/180),[U,D]=_a(ht(A,H),ht(_,P),wf(F));if(n==="diamond"||n==="diamond_outline"){let B,W;if(t==="start"){let[te,X]=e.points.length>1?e.points[1]:[0,0];[B,W]=_a(ht(_+k*2,P),ht(_,P),Math.atan2(X-P,te-_))}else{let[te,X]=e.points.length>1?e.points[e.points.length-2]:[0,0];[B,W]=_a(ht(_-k*2,P),ht(_,P),Math.atan2(P-X,_-te))}return[_,P,Y,V,B,W,U,D]}return[_,P,Y,V,U,D]};import{pointFrom as Uve,pointCenter as Wve,pointRotateRads as Yve,vectorFromPoint as Vve,vectorNormalize as Xve,vectorSubtract as Kve,vectorAdd as $ve,vectorScale as Zve,pointFromVector as jve,clamp as qve,isCloseTo as Jve}from"@excalidraw/math";import{arrayToMap as F2e}from"@excalidraw/common";import{isPointWithinBounds as z2e,pointFrom as G2e}from"@excalidraw/math";import{vectorCross as n2e,vectorFromPoint as r2e}from"@excalidraw/math";import{arrayToMap as PF}from"@excalidraw/common";import{getElementBounds as AF}from"@excalidraw/element";import{isArrowElement as LF,isHellixitboardElement as _F,isFreeDrawElement as DF,isLinearElement as HF,isTextElement as RF}from"@excalidraw/element";import{rangeIncludesValue as Rm,pointFrom as Pn,pointRotateRads as NF,rangeInclusive as Nm}from"@excalidraw/math";var BF=e=>e.type==="diamond"?[Pn(e.width/2,0),Pn(e.width,e.height/2),Pn(e.width/2,e.height),Pn(0,e.height/2)]:[Pn(0,0),Pn(0+e.width,0),Pn(0+e.width,e.height),Pn(0,e.height)],FF=e=>HF(e)||DF(e)?e.points:BF(e),jI=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},qI=e=>{let o=FF(e),{cx:t,cy:n}=jI(o),r=Pn(t,n),i=o.map(m=>NF(m,r,e.angle)),{minX:l,minY:a,maxX:s,maxY:c}=jI(i);return[l+e.x,a+e.y,s+e.x,c+e.y]},Cf=(e,o,t=!1)=>{let n=qI(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},JI=(e,o)=>{let t=qI(e);return(Rm(t[0],Nm(o[0],o[2]))||Rm(o[0],Nm(t[0],t[2])))&&(Rm(t[1],Nm(o[1],o[3]))||Rm(o[1],Nm(t[1],t[3])))},QI=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{_F(o)&&(o=AF(o,PF(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let l of e){if(i.has(l.id))continue;if(t==="overlap"?JI(l,r):t==="inside"?Cf(l,r):Cf(l,r,!0)){if(i.add(l.id),l.boundElements)for(let s of l.boundElements)i.add(s.id);RF(l)&&l.containerId&&i.add(l.containerId),LF(l)&&(l.startBinding&&i.add(l.startBinding.elementId),l.endBinding&&i.add(l.endBinding?.elementId))}}return e.filter(l=>i.has(l.id))};import{arrayToMap as E2e,isShallowEqual as zF}from"@excalidraw/common";var OF=function(){let e=null,o=null,t=null,n=(i,l,a,s)=>{if(t!==void 0&&l===o&&i===e&&a.editingGroupId===t?.editingGroupId)return t;let c={};for(let d of i){let u=d.groupIds;if(a.editingGroupId){let b=u.indexOf(a.editingGroupId);b>-1&&(u=u.slice(0,b))}if(u.length>0){let b=u[u.length-1];c[b]=!0}}let m={},p=l.reduce((d,u)=>{if(u.isDeleted)return d;let b=u.groupIds.find(g=>c[g]);return b&&(d[u.id]=!0,Array.isArray(m[b])?m[b].push(u.id):m[b]=[u.id]),d},{});for(let d of Object.keys(m))m[d].length<2&&c[d]&&(c[d]=!1);return o=l,e=i,t={editingGroupId:a.editingGroupId,selectedGroupIds:c,selectedElementIds:Sf({...a.selectedElementIds,...p},s)},t},r=(i,l,a,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:l}):kf(l,i);return c.length?n(c,l,i,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Sf(i.selectedElementIds,a)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var k2e=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(l=>i.selectedElementIds[l.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),kf=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&Ma(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(l=>{Mm(l)&&ew(e,l.id).forEach(a=>!n.has(a.id)&&i.push(a)),i.push(l)}),i}return r};var Sf=(e,o)=>zF(o.selectedElementIds,e)?o.selectedElementIds:e;var ew=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var UF=typeof document<"u"?document.createElement("img"):{src:""};UF.src=`data:${tw.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>')}`;var WF=typeof document<"u"?document.createElement("img"):{src:""};WF.src=`data:${tw.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>')}`;var Mf=new WeakMap;var ow=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var Ot=class Ot{};S(Ot,"rg",new jF),S(Ot,"cache",new WeakMap),S(Ot,"get",(o,t)=>{let n=Ot.cache.get(o);if(n&&(t===null||n.theme===t))return n.shape}),S(Ot,"delete",o=>{Ot.cache.delete(o),Mf.delete(o)}),S(Ot,"destroy",()=>{Ot.cache=new WeakMap}),S(Ot,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:Ot.get(o,t?t.theme:null);if(n!==void 0)return n;Mf.delete(o);let r=QF(o,Ot.rg,t||{isExporting:!1,canvasBackgroundColor:ZF.white,embedsValidationStatus:null,theme:Af.LIGHT});return t?.isExporting||Ot.cache.set(o,{shape:r,theme:t?.theme||Af.LIGHT}),r});var La=Ot,qF=e=>[8,8+e],lw=e=>[1.5,6+e];function JF(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&ow(e.type)||Jr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Mn=(e,o=!1,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?qF(e.strokeWidth):e.strokeStyle==="dotted"?lw(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:JF(e),stroke:t?Rs(e.strokeColor):e.strokeColor,preserveVertices:o||e.roughness<KF.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=Hs(e.backgroundColor)?void 0:t?Rs(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return Pm(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:t?Rs(e.backgroundColor):e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},rw=(e,o,t)=>uf(e)&&(o||zI(e)&&t?.get(e.id)!==!0)&&Hs(e.backgroundColor)&&Hs(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:GI(e)?{...e,strokeColor:Hs(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Hs(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ds=(e,o,t)=>{if(o===null)return[];let[,,n,r,i,l]=o;return[e.line(n,r,i,l,t)]},Bm=(e,o,t)=>{if(o===null)return[];let[n,r,i,l,a,s]=o;return[e.line(i,l,n,r,t),e.line(a,s,n,r,t)]},ei=(e,o)=>{let t={...o};if(e.strokeStyle==="dotted"){let n=lw(e.strokeWidth-1);t.strokeLineDash=[n[0],n[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Pf=(e,o,t,n,r,i=1)=>{if(n===null)return[];let[l,a,s]=n,c={...o,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,o.roughness||0)};return delete c.strokeLineDash,[e.circle(l,a,s*i,c)]},iw=(e,o,t,n,r,i,l,a)=>{if(n===null)return[];let s=a?Rs(e.strokeColor):e.strokeColor,c=a?Rs(l):l,m=-.25,p=.8;switch(n){case"circle":case"circle_outline":return Pf(r,i,s,At(e,o,t,n),n==="circle_outline"?c:s);case"triangle":case"triangle_outline":{let d=At(e,o,t,n);if(d===null)return[];let[u,b,g,x,v,y]=d,E={...i,fill:n==="triangle_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete E.strokeLineDash,[r.polygon([[u,b],[g,x],[v,y],[u,b]],E)]}case"diamond":case"diamond_outline":{let d=At(e,o,t,n);if(d===null)return[];let[u,b,g,x,v,y,E,T]=d,I={...i,fill:n==="diamond_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete I.strokeLineDash,[r.polygon([[u,b],[g,x],[v,y],[E,T],[u,b]],I)]}case"cardinality_one":return Ds(r,At(e,o,t,n),ei(e,i));case"cardinality_many":return Bm(r,At(e,o,t,n),ei(e,i));case"cardinality_one_or_many":{let d=ei(e,i);return[...Bm(r,At(e,o,t,"cardinality_many"),d),...Ds(r,At(e,o,t,"cardinality_one",m),d)]}case"cardinality_exactly_one":{let d=ei(e,i);return[...Ds(r,At(e,o,t,"cardinality_one",-.5),d),...Ds(r,At(e,o,t,"cardinality_one"),d)]}case"cardinality_zero_or_one":{let d=ei(e,i);return[...Pf(r,i,s,At(e,o,t,"circle_outline",1.5),c,p),...Ds(r,At(e,o,t,"cardinality_one",-.5),d)]}case"cardinality_zero_or_many":{let d=ei(e,i);return[...Bm(r,At(e,o,t,"cardinality_many"),d),...Pf(r,i,s,At(e,o,t,"circle_outline",1.5),c,p)]}case"bar":case"arrow":default:return Bm(r,At(e,o,t,n),ei(e,i))}};var QF=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i})=>{let l=i===Af.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let a;if(e.roundness){let s=e.width,c=e.height,m=Ls(Math.min(s,c),e);a=o.path(`M ${m} 0 L ${s-m} 0 Q ${s} 0, ${s} ${m} L ${s} ${c-m} Q ${s} ${c}, ${s-m} ${c} L ${m} ${c} Q 0 ${c}, 0 ${c-m} L 0 ${m} Q 0 0, ${m} 0`,Mn(rw(e,t,r),!0,l))}else a=o.rectangle(0,0,e.width,e.height,Mn(rw(e,t,r),!1,l));return a}case"diamond":{let a,[s,c,m,p,d,u,b,g]=Am(e);if(e.roundness){let x=Ls(Math.abs(s-b),e),v=Ls(Math.abs(p-c),e);a=o.path(`M ${s+x} ${c+v} L ${m-x} ${p-v}
4
+ ${h("hints.firefox_clipboard_write")}`):new Error(h("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Rv=async(e,o,t)=>{let n=Wy(o);if(!Yy(n))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:l}=await e,{exportBackground:a,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:m}=Ur(r,i,!1);return await Wr(n,c,i,l,{exportBackground:a,viewBackgroundColor:s,name:t,fileHandle:o,exportingFrame:m}),{fileHandle:o}};import{Fragment as Ov,jsx as Jo,jsxs as zv}from"react/jsx-runtime";var Vh=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Jo(kv,{label:h("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),Nv=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=aH(e),i=Me(n,o)?oe(n,o):n;return Jo(Ov,{children:iH.map(l=>{let[a,s]=Gy(i,rH,l),c=`${h("imageExportDialog.label.scale")} ${l}x (${a}x${s})`;return Jo(J,{size:"small",type:"radio",icon:`${l}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:l===o.exportScale,onChange:()=>t(l)},l)})})}}),Xh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Jo(os,{checked:e.exportBackground,onChange:t=>o(t),children:h("imageExportDialog.label.withBackground")})}),Bd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zv(os,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[h("imageExportDialog.label.embedScene"),Jo($t,{label:h("imageExportDialog.tooltip.embedScene"),long:!0,children:Jo("div",{className:"hellixitboard-tooltip-icon",children:S0})})]})}),ra=!1,Yh=(e,o)=>{let t=o.message??h("progressDialog.defaultMessage");e.setAppState({toast:{message:o.progress!=null?zv(Ov,{children:[t,Jo(Ld.ProgressBar,{progress:o.progress})]}):t,duration:1/0}})};async function lH(e,o){if(o.app.state.isLoading&&(Yh(o.app,{progress:null}),await o.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(o.signal.aborted){e.return();return}if(t.type==="progress")Yh(o.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Yh(o.app,{progress:null}),await e)}function Bv(e,o,t,n){let r=new AbortController,i=r.signal,l=new Promise(async a=>{try{n.props.onExport&&await lH(n.props.onExport("json",{elements:e,appState:o,files:t},{signal:i}),{app:n,signal:i})}catch(s){s?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",s)}a({elements:e,appState:o,files:n.files})});return{abortController:r,data:l}}var Yr=O({name:"saveToActiveFile",label:"buttons.save",icon:Nr,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{if(ra)return!1;ra=!0;let r=o.fileHandle,i=n.getName(),{abortController:l,data:a}=Bv(e,o,n.files,n);try{let{fileHandle:s}=Lc(r)?await Rv(a,r,i):await wc({data:a,filename:i,fileHandle:r});return{captureUpdate:To.NEVER,appState:{fileHandle:s,toast:{message:r&&s?.name?h("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):h("toast.fileSaved"),duration:1500}}}}catch(s){return l.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:To.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>e.key===ia.S&&e[ia.CTRL_OR_CMD]&&!e.shiftKey}),ls=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Nr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{if(ra)return!1;ra=!0;let{abortController:r,data:i}=Bv(e,o,n.files,n);try{let{fileHandle:l}=await wc({data:i,filename:n.getName(),fileHandle:null});return{captureUpdate:To.NEVER,appState:{openDialog:null,fileHandle:l,toast:{message:h("toast.fileSaved"),duration:3e3}}}}catch(l){return r.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:To.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>e.key.toLowerCase()===ia.S&&e.shiftKey&&e[ia.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Jo(J,{type:"button",icon:v0,title:h("buttons.saveAs"),"aria-label":h("buttons.saveAs"),showAriaLabel:fe().formFactor==="phone",hidden:!vi,onClick:()=>e(null),"data-testid":"save-as-button"})}),aa=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:l}=await Eu(o,e);return{elements:r,appState:i,files:l,captureUpdate:To.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:To.EVENTUALLY}}},keyTest:e=>e[ia.CTRL_OR_CMD]&&e.key===ia.O}),Fv=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t,n)=>(n.sessionExportThemeOverride=t?as.DARK:as.LIGHT,{appState:{...o,exportWithDarkMode:t},captureUpdate:To.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Jo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Jo(Sv,{value:e.exportWithDarkMode?as.DARK:as.LIGHT,onChange:t=>{o(t===as.DARK)},title:h("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as sH,DEFAULT_FONT_FAMILY as cH,DEFAULT_TEXT_ALIGN as dH,CODES as Gv,KEYS as Uv,getLineHeight as mH}from"@hellixit/common";import{newElementWith as Fd}from"@hellixit/element";import{hasBoundTextElement as pH,canApplyRoundnessTypeToElement as uH,getDefaultRoundnessTypeForElement as hH,isFrameLikeElement as gH,isArrowElement as fH,isHellixitboardElement as bH,isTextElement as Kh}from"@hellixit/element";import{getBoundTextElement as xH,redrawTextBoundingBox as yH}from"@hellixit/element";import{CaptureUpdateAction as $h}from"@hellixit/element";var Wv="{}",Zh=O({name:"copyStyles",label:"labels.copyStyles",icon:Vu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(l=>o.selectedElementIds[l.id]);if(r.push(i),i&&pH(i)){let l=xH(i,n.scene.getNonDeletedElementsMap());r.push(l)}return i&&(Wv=JSON.stringify(r)),{appState:{...o,toast:{message:h("toast.copyStyles")}},captureUpdate:$h.EVENTUALLY}},keyTest:e=>e[Uv.CTRL_OR_CMD]&&e.altKey&&e.code===Gv.C}),jh=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Vu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(Wv),i=r[0],l=r[1];if(!bH(i))return{elements:e,captureUpdate:$h.EVENTUALLY};let a=oe(e,o,{includeBoundTextElement:!0}),s=a.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Kh(c)&&c.containerId&&(m=l),!m)return c;let p=Fd(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?uH(m.roundness.type,c)?m.roundness:hH(c):null});if(Kh(p)){let d=m.fontSize||sH,u=m.fontFamily||cH;p=Fd(p,{fontSize:d,fontFamily:u,textAlign:m.textAlign||dH,lineHeight:m.lineHeight||mH(u)});let b=null;p.containerId&&(b=a.find(g=>Kh(p)&&g.id===p.containerId)||null),yH(p,b,n.scene)}return p.type==="arrow"&&fH(m)&&(p=Fd(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),gH(c)&&(p=Fd(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:$h.IMMEDIATELY}},keyTest:e=>e[Uv.CTRL_OR_CMD]&&e.altKey&&e.code===Gv.V});import{KEYS as EH}from"@hellixit/common";import{CaptureUpdateAction as vH}from"@hellixit/element";var Vr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:f0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:vH.EVENTUALLY}),keyTest:e=>e.key===EH.QUESTION_MARK});import{getNonDeletedElements as zd}from"@hellixit/element";import{newElementWith as Xv}from"@hellixit/element";import{isBoundToContainer as TH}from"@hellixit/element";import{frameAndChildrenSelectedTogether as IH,getElementsInResizingFrame as CH,getFrameLikeElements as SH,getRootElements as wH,groupByFrameLikes as kH,removeElementsFromFrame as MH,replaceAllElementsInFrame as PH}from"@hellixit/element";import{KEYS as Gd,randomId as AH,arrayToMap as qh}from"@hellixit/common";import{getSelectedGroupIds as Od,selectGroup as LH,selectGroupsForSelectedElements as _H,getElementsInGroup as Yv,addToGroup as DH,removeFromSelectedGroups as HH,isElementInGroup as Kv}from"@hellixit/element";import{syncMovedIndices as RH}from"@hellixit/element";import{CaptureUpdateAction as ss}from"@hellixit/element";import{jsx as la}from"react/jsx-runtime";var NH=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&Kv(r,t),!0))return!0}return!1},Vv=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!NH(n)&&!IH(n)},Jh=O({name:"group",label:"labels.group",icon:e=>la(zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=wH(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY};let i=Od(o);if(i.length===1){let x=i[0],v=new Set(Yv(e,x).map(T=>T.id)),y=new Set(r.map(T=>T.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY}}let l=[...e];new Set(r.map(x=>x.frameId)).size>1&&kH(r).forEach((v,y)=>{MH(v,n.scene.getNonDeletedElementsMap())});let s=AH(),c=qh(r);l=l.map(x=>c.get(x.id)?Xv(x,{groupIds:DH(x.groupIds,s,o.editingGroupId)}):x);let m=Yv(l,s),p=m[m.length-1],d=l.lastIndexOf(p),u=l.slice(d+1),b=l.slice(0,d).filter(x=>!Kv(x,s)),g=RH([...b,...m,...u],qh(m));return{appState:{...o,...LH(s,{...o,selectedGroupIds:{}},zd(l))},elements:g,captureUpdate:ss.IMMEDIATELY}},predicate:(e,o,t,n)=>Vv(e,o,n),keyTest:e=>!e.shiftKey&&e[Gd.CTRL_OR_CMD]&&e.key===Gd.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>la(J,{hidden:!Vv(e,o,n),type:"button",icon:la(zu,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":h("labels.group"),visible:Me(zd(e),o)})}),Qh=O({name:"ungroup",label:"labels.ungroup",icon:e=>la(Gu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Od(o),i=qh(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:ss.EVENTUALLY};let l=[...e],a=[];l=l.map(d=>{TH(d)&&a.push(d.id);let u=HH(d.groupIds,o.selectedGroupIds);return u.length===d.groupIds.length?d:Xv(d,{groupIds:u})});let s=_H(o,zd(l),o,null),c=n.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return SH(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(l=PH(l,CH(l,d,o,i),d,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[u,b])=>(b&&!a.includes(u)&&(d[u]=!0),d),{}),{appState:{...o,...s},elements:l,captureUpdate:ss.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Gd.CTRL_OR_CMD]&&e.key===Gd.G.toUpperCase(),predicate:(e,o)=>Od(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>la(J,{type:"button",hidden:Od(o).length===0,icon:la(Gu,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":h("labels.ungroup"),visible:Me(zd(e),o)})});import WH from"clsx";import{CaptureUpdateAction as Jv}from"@hellixit/element";import{invariant as YH}from"@hellixit/common";import{COLOR_CHARCOAL_BLACK as BH,COLOR_VOICE_CALL as FH,COLOR_WHITE as Wd,THEME as OH,UserIdleState as $v}from"@hellixit/common";var Ud=(e,o,t,n,r,i,l)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),l&&(e.strokeStyle=l),e.stroke()};function zH(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var Xr=(e,o)=>`hsl(${Math.abs(zH(o?.id||e))%37*10}, 100%, 83%)`,Zv=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},jv=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,l]of o.remotePointerViewportCoords){let{x:a,y:s}=l,c=t.collaborators.get(i);a-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=a<0||a>n-m||s<0||s>r-p;a=Math.max(a,0),a=Math.min(a,n-m),s=Math.max(s,0),s=Math.min(s,r-p);let u=Xr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let b=o.remotePointerUserStates.get(i),g=d||b===$v.IDLE||b===$v.AWAY;g&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===OH.DARK?"#2f6330":FH,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Wd,e.strokeStyle=Wd,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(a-1,s-1),e.lineTo(a-1,s+15),e.lineTo(a+5,s+10),e.lineTo(a+12,s+9),e.closePath(),e.fill()):(e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.fill(),e.stroke());let y=o.remotePointerUsernames.get(i)||"";if(!d&&y){e.font="600 12px sans-serif";let E=(v?a+0:a)+m/2,T=(v?s+0:s)+p+2,I=5,S=3,M=e.measureText(y),k=M.actualBoundingBoxDescent+M.actualBoundingBoxAscent,_=Math.max(k,12),P=E-1,A=T-1,H=M.width+2+I*2+2,F=_+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,A,H,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=Wd,e.stroke(),v&&(e.beginPath(),e.roundRect(P-2,A-2,H+4,F+4,8),e.strokeStyle=x,e.stroke())):Ud(e,P,A,H,F,8,Wd),e.fillStyle=BH,e.fillText(y,E+I+1,T+S+M.actualBoundingBoxAscent+Math.floor((_-k)/2)+2),v){e.fillStyle=x;let Y=8,V=8,U=5;e.fillRect(P+H+V,A+(F/2-Y/2),2,Y),e.fillRect(P+H+V+U,A+(F/2-Y*2/2),2,Y*2),e.fillRect(P+H+V+U*2,A+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import GH from"clsx";import{useState as UH}from"react";import{jsx as qv}from"react/jsx-runtime";var eg=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=Zv(t),[l,a]=UH(!1),s=!l&&n,c=s?void 0:{background:e};return qv("div",{className:GH("Avatar",r),style:c,onClick:o,children:s?qv("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>a(!0)}):i})};import{jsx as Qo,jsxs as Yd}from"react/jsx-runtime";var VH=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(YH(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:Jv.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:Jv.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:l}=o,a=Xr(n,r),s=WH({"is-followed":l,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?Yd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:h("userList.hint.isSpeaking"),children:[Qo("div",{}),Qo("div",{}),Qo("div",{})]}):r.isMuted?Qo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:h("userList.hint.micMuted"),children:LE}):Qo("div",{title:h("userList.hint.inCall"),children:AE}):null;return i?Yd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[Qo(eg,{color:a,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),Qo("div",{className:"UserList__collaborator-name",children:r.username}),Yd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[l&&Qo("div",{className:"UserList__collaborator-status-icon-is-followed",title:h("userList.hint.followStatus"),children:Oi}),c]})]}):Yd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Qo(eg,{color:a,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&Qo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as XH,randomId as KH}from"@hellixit/common";import{deepCopyElement as $H}from"@hellixit/element";import{CaptureUpdateAction as tg}from"@hellixit/element";var og=O({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of XH)if(r.some(l=>l.type===i))return{captureUpdate:tg.EVENTUALLY,appState:{...o,errorMessage:h(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:KH(),status:"unpublished",elements:r.map($H),created:Date.now()},...i])).then(()=>({captureUpdate:tg.EVENTUALLY,appState:{...o,toast:{message:h("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:tg.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as sa}from"@hellixit/element";import{isFrameLikeElement as ZH}from"@hellixit/element";import{updateFrameMembershipOfSelectedElements as jH}from"@hellixit/element";import{KEYS as er,arrayToMap as qH}from"@hellixit/common";import{alignElements as JH}from"@hellixit/element";import{CaptureUpdateAction as ca}from"@hellixit/element";import{getSelectedElementsByGroup as QH}from"@hellixit/element";import{jsx as ma}from"react/jsx-runtime";var Mt=(e,o)=>{let t=o.scene.getSelectedElements(e);return QH(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>ZH(n))},da=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=JH(r,n,t.scene,o),l=qH(i);return jH(e.map(a=>l.get(a.id)||a),o,t)},eR=O({name:"alignTop",label:"labels.alignTop",icon:Hu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"start",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Hu,onClick:()=>t(null),title:`${h("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":h("labels.alignTop"),visible:Me(sa(e),o)})}),tR=O({name:"alignBottom",label:"labels.alignBottom",icon:Ru,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"end",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Ru,onClick:()=>t(null),title:`${h("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":h("labels.alignBottom"),visible:Me(sa(e),o)})}),oR=O({name:"alignLeft",label:"labels.alignLeft",icon:Nu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"start",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Nu,onClick:()=>t(null),title:`${h("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":h("labels.alignLeft"),visible:Me(sa(e),o)})}),nR=O({name:"alignRight",label:"labels.alignRight",icon:Bu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"end",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),keyTest:e=>e[er.CTRL_OR_CMD]&&e.shiftKey&&e.key===er.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Bu,onClick:()=>t(null),title:`${h("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":h("labels.alignRight"),visible:Me(sa(e),o)})}),rR=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Fu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"center",axis:"y"}),captureUpdate:ca.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Fu,onClick:()=>t(null),title:h("labels.centerVertically"),"aria-label":h("labels.centerVertically"),visible:Me(sa(e),o)})}),iR=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ou,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Mt(o,n),perform:(e,o,t,n)=>({appState:o,elements:da(e,o,n,{position:"center",axis:"x"}),captureUpdate:ca.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ma(J,{hidden:!Mt(o,n),type:"button",icon:Ou,onClick:()=>t(null),title:h("labels.centerHorizontally"),"aria-label":h("labels.centerHorizontally"),visible:Me(sa(e),o)})});import{getNonDeletedElements as Qv}from"@hellixit/element";import{isFrameLikeElement as aR}from"@hellixit/element";import{CODES as e2,KEYS as t2,arrayToMap as lR}from"@hellixit/common";import{updateFrameMembershipOfSelectedElements as sR}from"@hellixit/element";import{distributeElements as cR}from"@hellixit/element";import{CaptureUpdateAction as o2}from"@hellixit/element";import{getSelectedElementsByGroup as dR}from"@hellixit/element";import{jsx as i2}from"react/jsx-runtime";var n2=(e,o)=>{let t=o.scene.getSelectedElements(e);return dR(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>aR(n))},r2=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=cR(r,t.scene.getNonDeletedElementsMap(),n,o,t.scene),l=lR(i);return sR(e.map(a=>l.get(a.id)||a),o,t)},mR=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:r2(e,o,n,{space:"between",axis:"x"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[t2.CTRL_OR_CMD]&&e.altKey&&e.code===e2.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>i2(J,{hidden:!n2(o,n),type:"button",icon:P0,onClick:()=>t(null),title:`${h("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":h("labels.distributeHorizontally"),visible:Me(Qv(e),o)})}),pR=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:r2(e,o,n,{space:"between",axis:"y"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[t2.CTRL_OR_CMD]&&e.altKey&&e.code===e2.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>i2(J,{hidden:!n2(o,n),type:"button",icon:A0,onClick:()=>t(null),title:`${h("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":h("labels.distributeVertically"),visible:Me(Qv(e),o)})});import{getNonDeletedElements as uR}from"@hellixit/element";import{bindOrUnbindBindingElements as hR}from"@hellixit/element";import{getCommonBoundingBox as a2}from"@hellixit/element";import{newElementWith as gR}from"@hellixit/element";import{deepCopyElement as fR}from"@hellixit/element";import{resizeMultipleElements as bR}from"@hellixit/element";import{isArrowElement as l2,isElbowArrow as xR}from"@hellixit/element";import{updateFrameMembershipOfSelectedElements as s2}from"@hellixit/element";import{CODES as c2,KEYS as yR,arrayToMap as ER}from"@hellixit/common";import{CaptureUpdateAction as d2}from"@hellixit/element";var ng=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:RE,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:s2(m2(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:d2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===c2.H}),rg=O({name:"flipVertical",label:"labels.flipVertical",icon:HE,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:s2(m2(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:d2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===c2.V&&!e[yR.CTRL_OR_CMD]}),m2=(e,o,t,n,r)=>{let i=oe(uR(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),l=vR(i,o,n,r),a=ER(l);return e.map(s=>a.get(s.id)||s)},vR=(e,o,t,n)=>{if(e.every(d=>l2(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let u=d;return gR(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=a2(e);bR(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(d=>[d.id,fR(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),hR(e.filter(l2),n.scene,n.state);let{elbowArrows:l,otherElements:a}=e.reduce((d,u)=>xR(u)?{...d,elbowArrows:d.elbowArrows.concat(u)}:{...d,otherElements:d.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=a2(e),[m,p]=[r-s,i-c];return a.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),l.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};import{isTextElement as TR}from"@hellixit/element";import{getTextFromElements as IR}from"@hellixit/element";import{CODES as CR,KEYS as p2,isFirefox as SR}from"@hellixit/common";import{CaptureUpdateAction as Jt}from"@hellixit/element";var pa=O({name:"copy",label:"labels.copy",icon:_l,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Hd(r,n.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),ig=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await Lv()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),SR?{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(Pv({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),Vd=O({name:"cut",label:"labels.cut",icon:xE,trackEvent:{category:"element"},perform:(e,o,t,n)=>(pa.perform(e,o,t,n),Gl.perform(e,o,null,n)),keyTest:e=>e[p2.CTRL_OR_CMD]&&e.key===p2.X}),Xd=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:NE,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Ur(e,o,!0);try{await Wr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let l=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:h("toast.copyToClipboardAsSvg",{exportSelection:l.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(l){return console.error(l),{appState:{errorMessage:l.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Dd&&e.length>0,keywords:["svg","clipboard","copy"]}),Kd=O({name:"copyAsPng",label:"labels.copyAsPng",icon:BE,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:l}=Ur(e,o,!0);try{return await Wr("clipboard",i,o,n.files,{...o,exportingFrame:l,name:n.getName()}),{appState:{...o,toast:{message:h("toast.copyToClipboardAsPng",{exportSelection:r.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{...o,errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>oa&&e.length>0,keyTest:e=>e.code===CR.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),$d=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{vo(IR(r))}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,o,t,n)=>Dd&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(TR),keywords:["text","clipboard","copy"]});import{CODES as wR,KEYS as kR}from"@hellixit/common";import{CaptureUpdateAction as MR}from"@hellixit/element";var ua=O({name:"gridMode",icon:GE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:MR.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[kR.CTRL_OR_CMD]&&e.code===wR.QUOTE});import{CODES as PR,KEYS as AR}from"@hellixit/common";import{CaptureUpdateAction as LR}from"@hellixit/element";var tr=O({name:"zenMode",label:"buttons.zenMode",icon:OE,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:LR.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[AR.CTRL_OR_CMD]&&e.altKey&&e.code===PR.Z});import{CODES as _R,KEYS as DR}from"@hellixit/common";import{CaptureUpdateAction as HR}from"@hellixit/element";var cs=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:FE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:HR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[DR.CTRL_OR_CMD]&&e.altKey&&e.code===_R.S});import{CaptureUpdateAction as RR}from"@hellixit/element";var ds=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,o){let t=o.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...o,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:RR.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as NR}from"@hellixit/element";var ms=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,o){return{appState:{...o,isMidpointSnappingEnabled:!this.checked(o)},captureUpdate:NR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as BR,KEYS as FR}from"@hellixit/common";import{CaptureUpdateAction as OR}from"@hellixit/element";var or=O({name:"stats",label:"stats.fullTitle",icon:DE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:OR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[FR.CTRL_OR_CMD]&&e.altKey&&e.code===BR.SLASH});import{BOUND_TEXT_PADDING as u2,ROUNDNESS as h2,TEXT_ALIGN as b2,VERTICAL_ALIGN as x2,arrayToMap as y2,getFontString as zR}from"@hellixit/common";import{getOriginalContainerHeightFromCache as GR,isBoundToContainer as g2,resetOriginalContainerCache as UR,updateOriginalContainerCache as WR}from"@hellixit/element";import{computeBoundTextPosition as YR,computeContainerDimensionForBoundText as f2,getBoundTextElement as E2,redrawTextBoundingBox as v2}from"@hellixit/element";import{hasBoundTextElement as VR,isArrowElement as XR,isTextBindableContainer as ag,isTextElement as ps,isUsingAdaptiveRadius as KR}from"@hellixit/element";import{measureText as $R}from"@hellixit/element";import{syncMovedIndices as T2}from"@hellixit/element";import{newElement as ZR}from"@hellixit/element";import{CaptureUpdateAction as lg}from"@hellixit/element";var sg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>VR(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(l=>{let a=E2(l,i);if(a){let{width:s,height:c}=$R(a.originalText,zR(a),a.lineHeight),m=GR(l.id);UR(l.id);let{x:p,y:d}=YR(l,a,i);n.scene.mutateElement(a,{containerId:null,width:s,height:c,text:a.originalText,x:p,y:d}),n.scene.mutateElement(l,{boundElements:l.boundElements?.filter(u=>u.id!==a.id),height:m||l.height})}}),{elements:e,appState:o,captureUpdate:lg.IMMEDIATELY}}}),cg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=ps(r[0])||ps(r[1]),l;if(ag(r[0])?l=r[0]:ag(r[1])&&(l=r[1]),i&&l&&E2(l,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,l;ps(r[0])&&ag(r[1])?(i=r[0],l=r[1]):(i=r[1],l=r[0]),n.scene.mutateElement(i,{containerId:l.id,verticalAlign:x2.MIDDLE,textAlign:b2.CENTER,autoResize:!0,angle:XR(l)?0:l?.angle??0}),n.scene.mutateElement(l,{boundElements:(l.boundElements||[]).concat({type:"text",id:i.id})});let a=l.height;return v2(i,l,n.scene),WR(l.id,a),{elements:jR(e,l,i),appState:{...o,selectedElementIds:{[l.id]:!0}},captureUpdate:lg.IMMEDIATELY}}}),jR=(e,o,t)=>{let n=e.slice(),r=n.findIndex(l=>l.id===t.id);n.splice(r,1);let i=n.findIndex(l=>l.id===o.id);return n.splice(i+1,0,t),T2(n,y2([o,t])),n},qR=(e,o,t)=>{let n=e.slice(),r=n.findIndex(l=>l.id===o.id);n.splice(r,1);let i=n.findIndex(l=>l.id===t.id);return n.splice(i,0,o),T2(n,y2([o,t])),n},I2=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(l=>ps(l)&&!g2(l));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),l={};for(let a of r)if(ps(a)&&!g2(a)){let s=ZR({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...a.boundElements||[],{id:a.id,type:"text"}],angle:a.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:KR("rectangle")?h2.ADAPTIVE_RADIUS:h2.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:a.x-u2,y:a.y-u2,width:f2(a.width,"rectangle"),height:f2(a.height,"rectangle"),groupIds:a.groupIds,frameId:a.frameId});if(a.boundElements?.length){let c=a.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,u=p.endBinding;d?.elementId===a.id&&(d={...d,elementId:s.id}),u?.elementId===a.id&&(u={...u,elementId:s.id}),(d||u)&&n.scene.mutateElement(p,{startBinding:d,endBinding:u})})}n.scene.mutateElement(a,{containerId:s.id,verticalAlign:x2.MIDDLE,boundElements:null,textAlign:b2.CENTER,autoResize:!0}),v2(a,s,n.scene),i=qR([...i,s],s,a),l[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:l},captureUpdate:lg.IMMEDIATELY}}});import{isEmbeddableElement as h6}from"@hellixit/element";import{KEYS as D2}from"@hellixit/common";import{CaptureUpdateAction as g6}from"@hellixit/element";import{pointFrom as k2}from"@hellixit/math";import JR from"clsx";import{useCallback as C2,useEffect as S2,useLayoutEffect as QR,useRef as e6,useState as t6}from"react";import{EVENT as dg,HYPERLINK_TOOLTIP_DELAY as o6,KEYS as Zd}from"@hellixit/common";import{getElementAbsoluteCoords as gg}from"@hellixit/element";import{hitElementBoundingBox as n6}from"@hellixit/element";import{isElementLink as r6}from"@hellixit/element";import{getEmbedLink as i6,embeddableURLValidator as a6}from"@hellixit/element";import{sceneCoordsToViewportCoords as M2,viewportCoordsToSceneCoords as l6,wrapEvent as s6,isLocalLink as c6,normalizeLink as mg}from"@hellixit/common";import{isEmbeddableElement as pg}from"@hellixit/element";import{jsx as ha,jsxs as w2}from"react/jsx-runtime";var fg=380,d6=42,ug=5,P2=85,m6=500,hg=!1,jd=new Map,A2=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let l=o.getNonDeletedElementsMap(),a=Xo(),s=Ko(),c=fe(),m=e.link||"",[p,d]=t6(m),u=e6(null),b=a.showHyperlinkPopup==="editor",g=C2(()=>{if(!u.current)return;let T=mg(u.current.value)||null;if(!e.link&&T&&ce("hyperlink","create"),pg(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!T){o.mutateElement(e,{link:null}),i(e,!1);return}if(!a6(T,s.validateEmbeddable))T&&r({message:h("toast.unableToEmbed"),closable:!0}),e.link&&jd.set(e.id,e.link),o.mutateElement(e,{link:T}),i(e,!1);else{let{width:I,height:S}=e,M=i6(T);M?.error instanceof URIError&&r({message:h("toast.unrecognizedLinkFormat"),closable:!0});let k=M?M.intrinsicSize.w/M.intrinsicSize.h:1,_=jd.get(e.id)!==e.link;o.mutateElement(e,{..._?{width:M?.type==="video"?I>S?I:S*k:I,height:M?.type==="video"&&I>S?I/k:S}:{},link:T}),i(e,!0),jd.has(e.id)&&jd.delete(e.id)}}else o.mutateElement(e,{link:T})},[e,o,r,s.validateEmbeddable,a.activeEmbeddable,t,i]);QR(()=>()=>{g()},[g]),S2(()=>{b&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[b,c.formFactor,c.isTouchScreen]),S2(()=>{let T=null,I=S=>{if(b)return;T&&clearTimeout(T),u6(e,l,a,k2(S.clientX,S.clientY))&&(T=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},m6))};return window.addEventListener(dg.POINTER_MOVE,I,!1),()=>{window.removeEventListener(dg.POINTER_MOVE,I,!1),T&&clearTimeout(T)}},[a,e,b,t,l]);let x=C2(()=>{ce("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),v=()=>{ce("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:E}=L2(e,a,l);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:w2("div",{className:"hellixitboard-hyperlinkContainer",style:{top:`${E}px`,left:`${y}px`,width:fg,padding:ug},children:[b?ha("input",{className:JR("hellixitboard-hyperlinkContainer-input"),placeholder:h("labels.link.hint"),ref:u,value:p,onChange:T=>d(T.target.value),autoFocus:!0,onKeyDown:T=>{T.stopPropagation(),T[Zd.CTRL_OR_CMD]&&T.key===Zd.K&&T.preventDefault(),(T.key===Zd.ENTER||T.key===Zd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ha("a",{href:mg(e.link||""),className:"hellixitboard-hyperlinkContainer-link",target:c6(e.link)?"_self":"_blank",onClick:T=>{if(e.link&&n){let I=s6(dg.HELLIXITBOARD_LINK,T.nativeEvent);n({...e,link:mg(e.link)},I),I.defaultPrevented&&T.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ha("div",{className:"hellixitboard-hyperlinkContainer-link",children:h("labels.link.empty")}),w2("div",{className:"hellixitboard-hyperlinkContainer__buttons",children:[!b&&ha(J,{type:"button",title:h("buttons.edit"),"aria-label":h("buttons.edit"),label:h("buttons.edit"),onClick:v,className:"hellixitboard-hyperlinkContainer--edit",icon:Uo}),ha(J,{type:"button",title:h("labels.linkToElement"),"aria-label":h("labels.linkToElement"),label:h("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:jc}),m&&!pg(e)&&ha(J,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:x,className:"hellixitboard-hyperlinkContainer--remove",icon:pt})]})]})},L2=(e,o,t)=>{let[n,r]=gg(e,t),{x:i,y:l}=M2({sceneX:n+e.width/2,sceneY:r},o),a=i-o.offsetLeft-fg/2,s=l-o.offsetTop-P2;return{x:a,y:s}},bg=(e,o)=>{let t=oe(e,o);return pg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},us=null,_2=(e,o,t)=>{us&&clearTimeout(us),us=window.setTimeout(()=>p6(e,o,t),o6)},p6=(e,o,t)=>{if(!e.link)return;let n=ea();n.classList.add("hellixitboard-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=r6(e.link)?h("labels.link.goToElement"):e.link;let[r,i,l,a]=gg(e,t),[s,c,m,p]=By([r,i,l,a],e.angle,o),d=M2({sceneX:s,sceneY:c},o);Rh(n,{left:d.x,top:d.y,width:m,height:p},"top"),ce("hyperlink","tooltip","link-icon"),hg=!0},xg=()=>{us&&clearTimeout(us),hg&&(hg=!1,ea().classList.remove("hellixitboard-tooltip--visible"))},u6=(e,o,t,[n,r])=>{let{x:i,y:l}=l6({clientX:n,clientY:r},t),a=15/t.zoom.value;if(n6(k2(i,l),e,o))return!1;let[s,c,m]=gg(e,o);if(i>=s&&i<=m&&l>=c-P2&&l<=c)return!1;let{x:p,y:d}=L2(e,t,o);return!(n>=p-a&&n<=p+fg+ug*2+a&&r>=d-a&&r<=d+a+ug*2+d6)};import{jsx as f6}from"react/jsx-runtime";var hs=O({name:"hyperlink",label:(e,o)=>bg(e,o),icon:Rl,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:g6.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[D2.CTRL_OR_CMD]&&e.key===D2.K,predicate:(e,o)=>oe(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=oe(e,o);return f6(J,{type:"button",icon:Rl,"aria-label":h(bg(e,o)),title:`${h6(e[0])?h("labels.link.labelEmbed"):h("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as H2,arrayToMap as Eg,randomId as b6}from"@hellixit/common";import{elementsAreInSameGroup as x6,newElementWith as R2,selectGroupsFromGivenElements as N2}from"@hellixit/element";import{CaptureUpdateAction as B2}from"@hellixit/element";var yg=e=>e.every(o=>!o.locked),gs=O({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return yg(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=oe(o,e);return yg(t)?wi:Hr},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=yg(r),l=Eg(r),a=r.length>1&&x6(r),c=r.length===1||a?null:b6(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(a){let v=r[0].groupIds.at(-1);delete m[v]}let p=e.map(v=>{if(!l.has(v.id))return v;let y=v.groupIds;return i?c&&(y=[...y,c]):y=y.filter(E=>!o.lockedMultiSelections[E]),R2(v,{locked:i,groupIds:y.length!==v.groupIds.length?y:v.groupIds})}),d=Eg(p),u=i?{}:Object.fromEntries(r.map(v=>[v.id,!0])),b=r.map(v=>d.get(v.id)||v),g=i?{}:N2(b,o),x=i?c||(a?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:B2.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===H2.L&&e[H2.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),F2=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Hr,predicate:(e,o)=>oe(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(l=>l.locked),n=e.map(l=>{if(l.locked){let a=l.groupIds.filter(s=>!o.lockedMultiSelections[s]);return R2(l,{locked:!1,groupIds:l.groupIds.length!==a.length?a:l.groupIds})}return l}),r=Eg(n),i=t.map(l=>r.get(l.id)||l);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(l=>[l.id,!0])),selectedGroupIds:N2(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:B2.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as l8,isLinearElement as s8,isLineElement as Da}from"@hellixit/element";import{arrayToMap as c8,invariant as Lf}from"@hellixit/common";import{toggleLinePolygonState as d8,CaptureUpdateAction as cC}from"@hellixit/element";import BI from"clsx";import ZB from"fuzzy";import{useEffect as Sm,useRef as FI,useMemo as jB,useState as Cm}from"react";import{DEFAULT_SIDEBAR as HI,EVENT as km,KEYS as Mo,capitalizeString as qB,isWritableElement as JB}from"@hellixit/common";import{CaptureUpdateAction as t4}from"@hellixit/element";import{useEffect as ys,useMemo as O2,useRef as Sg,useState as y6}from"react";import{bumpVersion as fs,getLinearElementSubType as fa,mutateElement as wg,updateElbowArrowPoints as E6}from"@hellixit/element";import{pointFrom as Jd,pointRotateRads as v6}from"@hellixit/math";import{hasBoundTextElement as T6,isArrowBoundToElement as I6,isArrowElement as C6,isElbowArrow as S6,isLinearElement as Ag,isUsingAdaptiveRadius as w6}from"@hellixit/element";import{getCommonBoundingBox as k6,getElementAbsoluteCoords as M6}from"@hellixit/element";import{getBoundTextElement as Y2,getBoundTextMaxHeight as P6,getBoundTextMaxWidth as A6,redrawTextBoundingBox as L6}from"@hellixit/element";import{wrapText as _6}from"@hellixit/element";import{assertNever as D6,CLASSES as H6,getFontString as vg,isProdEnv as R6,mapFind as N6,reduceToCommonValue as B6,ROUNDNESS as Tg,sceneCoordsToViewportCoords as F6,updateActiveTool as z2}from"@hellixit/common";import{measureText as G2}from"@hellixit/element";import{LinearElementEditor as O6}from"@hellixit/element";import{newArrowElement as Ig,newElement as z6,newLinearElement as G6}from"@hellixit/element";import{ShapeCache as U6}from"@hellixit/element";import{updateBindings as W6}from"@hellixit/element";import{jsx as Pg}from"react/jsx-runtime";var Y6=8,V6=10,bs=["rectangle","diamond","ellipse"],xs=["line","sharpArrow","curvedArrow","elbowArrow"],X6=new Set(bs),K6=new Set(xs),ba=e=>X6.has(e),Qd=e=>e==="arrow"||K6.has(e),Io=ge(null),Es=new Map,vs=new Map,$6=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Sg(null);return ys(()=>{if(o.length===0){e.updateEditorAtom(Io,null);return}let n=xa(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(Io,null),t.current=null)},[o,e]),ys(()=>()=>{Es.clear(),vs.clear()},[]),Pg(Z6,{app:e,elements:o})},Z6=({app:e,elements:o})=>{let t=xa(o),n=O2(()=>t==="generic"?X2(o):[],[t,o]),r=O2(()=>t==="linear"?Mg(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>fa(p)===fa(r[0])):!1,[l,a]=y6({x:0,y:0}),s=Sg(""),c=Sg(null);ys(()=>{let p=[...n,...r].sort((x,v)=>x.id.localeCompare(v.id)),d=`
5
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(x=>x.id).join(",")}`;if(d===s.current)return;s.current=d;let u;if(p.length===1){let[x,,,v,y,E]=M6(p[0],e.scene.getNonDeletedElementsMap());u=v6(Jd(x,v),Jd(y,E),p[0].angle)}else{let{minX:x,maxY:v}=k6(p);u=Jd(x,v)}let{x:b,y:g}=F6({sceneX:u[0],sceneY:u[1]},e.state);a({x:b,y:g})},[n,r,e.scene,e.state]),ys(()=>{for(let p of r){let d=kg(p.id,e4(p));vs.has(d)||vs.set(d,p)}},[r]),ys(()=>{for(let p of n)if(!Es.has(p.id)){let d=Y2(p,e.scene.getNonDeletedElementsMap());d&&Es.set(p.id,{fontSize:d.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",Ai],["sharpArrow",zi],["curvedArrow",Ui],["elbowArrow",Gi]]:t==="generic"?[["rectangle",ki],["diamond",Mi],["ellipse",Pi]]:[];return Pg("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${l.y+(V6+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${l.x-e.state.offsetLeft-Y6}px`,zIndex:2},className:H6.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let u=i&&(t==="generic"&&n[0].type===p||t==="linear"&&fa(r[0])===p);return Pg(J,{className:"Shape",type:"radio",icon:d,checked:u,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&ce("convertElementType",p,"ui"),Lg(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},j6=(e,o,t)=>{let n=A6(e,o),r=P6(e,o),i=_6(o.text,vg(o),n),l=G2(i,vg(o),o.lineHeight),a=o.fontSize;for(;(l.width>n||l.height>r)&&a>0;){a-=1;let s={...o,fontSize:a};l=G2(o.text,vg(s),o.lineHeight)}wg(o,t.getNonDeletedElementsMap(),{fontSize:a,width:l.width,height:l.height}),L6(o,e,t)},Lg=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((a,s)=>({...a,[s.id]:!0}),{}),l=n==="right"?1:-1;if(o==="generic"){let a=X2(r),c=a.every(m=>m.type===a[0].type)?bs.indexOf(a[0].type):-1;if(t=t??bs[(c+bs.length+l)%bs.length],t&&ba(t)){let m={};for(let d of a){let u=W2(d,t,e);m[u.id]=u}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let u=Y2(d,e.scene.getNonDeletedElementsMap());u&&(Es.get(d.id)&&wg(u,e.scene.getNonDeletedElementsMap(),{fontSize:Es.get(d.id)?.fontSize??u.fontSize}),j6(d,u,e.scene))}e.setState(d=>({selectedElementIds:i,activeTool:z2(d,{type:"selection"})}))}}if(o==="linear"){let a=Mg(r);if(!t){let c=B6(a,fa),m=c?xs.indexOf(c):-1;t=xs[(m+xs.length+l)%xs.length]}if(Qd(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of a){let d=vs.get(kg(p.id,t));if(d&&fa(d)===t)m.set(d.id,d),c.push(d);else{let u=W2(p,t,e);m.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(m);for(let p of c)if(Ag(p))if(S6(p)){let d=q6(p);if(d.length<2)continue;let u=[];for(let g=1;g<d.length-2;g++)u.push({start:d[g],end:d[g+1],index:g+1});let b=E6(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:u});wg(p,e.scene.getNonDeletedElementsMap(),{...b,endArrowhead:"arrow"})}else{let d=N6(["line","sharpArrow","curvedArrow"],u=>vs.get(kg(p.id,u)));if(d){let u=d.points;e.scene.mutateElement(p,{points:u})}}}let s=Mg(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new O6(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:z2(c,{type:"selection"})}))}return!0},xa=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ba(t.type))return"generic";V2(t)&&(o=!0)}return o?"linear":null},V2=e=>Ag(e)&&(!C6(e)||!I6(e)&&!T6(e)),kg=(e,o)=>`${e}:${o}`,X2=e=>e.filter(o=>ba(o.type)),Mg=e=>e.filter(o=>V2(o)),qd=20,ga=(e,o)=>e[0]===o[0],Cg=(e,o)=>e[1]===o[1],U2=(e,o)=>ga(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),q6=e=>{let o=[e.points[0]],t=J6(e.points);for(let i=1;i<t.length;++i){let l=o[o.length-1],a=[...t[i]];Math.abs(a[0]-l[0])<qd?a[0]=l[0]:Math.abs(a[1]-l[1])<qd&&(a[1]=l[1]),ga(l,a)||Cg(l,a)||o.push(Jd(l[0],a[1])),o.push(a)}let n=[o[0]];for(let i=1;i<o.length-1;++i)ga(o[i-1],o[i])&&ga(o[i],o[i+1])||Cg(o[i-1],o[i])&&Cg(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let l=r[r.length-1],a=n[i],s=n[i+1],c=ga(l,a),m=ga(a,s);if(c!==m){let p=U2(l,a),d=U2(a,s);if(p<qd||d<qd){if(d<p)c?s[0]=l[0]:s[1]=l[1];else if(m)for(let u=r.length-1;u>=0&&r[u][0]===l[0];--u)r[u][0]=a[0];else for(let u=r.length-1;u>=0&&r[u][1]===l[1];--u)r[u][1]=a[1];continue}}r.push(a)}return r.push(n[n.length-1]),r},J6=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,l]=e[t];(n!==i||r!==l)&&o.push(e[t])}return o},W2=(e,o,t)=>{if(!Q6(e.type,o)){if(!R6())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(U6.delete(e),ba(o)){let n=fs(z6({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:w6(o)?Tg.ADAPTIVE_RADIUS:Tg.PROPORTIONAL_RADIUS}:e.roundness}));return W6(n,t.scene,t.state),n}if(Qd(o))switch(o){case"line":return fs(G6({...e,type:"line"}));case"sharpArrow":return fs(Ig({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return fs(Ig({...e,type:"arrow",elbowed:!1,roundness:{type:Tg.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return fs(Ig({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return D6(o,`unhandled conversion type: ${o}`),e},Q6=(e,o)=>!!(ba(e)&&ba(o)||Qd(e)&&Qd(o)),e4=e=>Ag(e)?fa(e):e.type,K2=$6;var $2=O({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return Qe.set(Io,{type:"panel"}),{captureUpdate:t4.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>xa(e)!==null});import{canCreateLinkFromElements as _g,defaultGetElementLinkFromSelection as o4,getLinkIdAndTypeFromSelection as n4}from"@hellixit/element";import{CaptureUpdateAction as Ts}from"@hellixit/element";var em=O({name:"copyElementLink",label:"labels.copyElementLink",icon:Bi,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=oe(e,o);try{if(window.location){let i=n4(r,o);return i?(await vo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):o4(i.id,i.type)),{appState:{toast:{message:h("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ts.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Ts.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Ts.EVENTUALLY}},predicate:(e,o)=>_g(oe(e,o))}),Z2=O({name:"linkToElement",label:"labels.linkToElement",icon:jc,perform:(e,o,t,n)=>{let r=oe(e,o);return r.length!==1||!_g(r)?{elements:e,appState:o,app:n,captureUpdate:Ts.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:oe(e,o)[0].id}},captureUpdate:Ts.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=oe(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&_g(r)},trackEvent:!1});import{isDarwin as j2}from"@hellixit/common";var r4={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],clearCanvas:[N("CtrlOrCmd+Delete")],imageExport:[N("CtrlOrCmd+Shift+E")],commandPalette:[N("CtrlOrCmd+/"),N("CtrlOrCmd+Shift+P")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${h("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[j2?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[j2?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],zenMode:[N("Alt+Z")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],addToLibrary:[],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[N("Shift+3")],zoomToFit:[N("Shift+1")],zoomToFitSelectionInViewport:[N("Shift+2")],toggleEraserTool:[N("E")],toggleHandTool:[N("H")],setFrameAsActiveTool:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],toolLock:[N("Q")]},Le=(e,o=0)=>{let t=r4[e];return t&&t.length>0?t[o]||t[0]:""};var i4="\\u0300-\\u036f",a4="\\ufe20-\\ufe2f",l4="\\u20d0-\\u20ff",s4=i4+a4+l4,c4=`[${s4}]`,d4=RegExp(c4,"g"),m4=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,p4={\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"},Kr=e=>e.replace(m4,o=>p4[o]||o).replace(d4,"");import kB from"clsx";import{useEffect as MB,useState as PB}from"react";import{KEYS as AB,queryFocusableElements as aI}from"@hellixit/common";import{useCallback as u4,useState as h4}from"react";var q2=()=>{let[e,o]=h4(null),t=u4(n=>o(n),[]);return[e,t]};import{useState as eI,useCallback as tf,useMemo as tI,useEffect as of,memo as oI,useRef as pB}from"react";import{LIBRARY_DISABLED_TYPES as uB,randomId as hB,isShallowEqual as gB,KEYS as fB,isWritableElement as bB,addEventListener as xB,EVENT as yB,CLASSES as qT}from"@hellixit/common";import{useEffect as tT,useRef as oT}from"react";import{URL_HASH_KEYS as Ng,URL_QUERY_KEYS as Bg,APP_NAME as nT,EVENT as nm,DEFAULT_SIDEBAR as x4,LIBRARY_SIDEBAR_TAB as y4,arrayToMap as Fg,cloneJSON as E4,preventUnload as v4,promiseTry as rT,resolvablePromise as T4,toValidURL as I4,Queue as C4,Emitter as S4}from"@hellixit/common";import{hashElementsVersion as w4,hashString as k4}from"@hellixit/element";import{getCommonBoundingBox as Rg}from"@hellixit/element";import{MIME_TYPES as $r}from"@hellixit/common";var nr=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:l})=>{let a=Lr(e,null,{deleteInvisibleElements:!0}),s=Ti(o,null),{exportBackground:c,viewBackgroundColor:m}=s;return Ac(a,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:l},(p,d)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(p,d),x=n<g?n/g:o?.exportScale??1;return u.width=p*x,u.height=d*x,{canvas:u,scale:x}}let b=r?.(p,d)||{width:p,height:d};return u.width=b.width,u.height=b.height,{canvas:u,scale:b.scale??1}})},J2=async e=>{let{mimeType:o=$r.png,quality:t}=e;o===$r.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${$r.png}" mimeType`),o==="image/jpg"&&(o=$r.jpg),o===$r.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${$r.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await nr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async l=>{if(!l)return i(new Error("couldn't export to blob"));l&&o===$r.png&&e.appState?.exportEmbedScene&&(l=await Uy({blob:l,metadata:kl(e.elements,e.appState,e.files||{},"local")})),r(l)},o,t)})},ya=async({elements:e,appState:o=Oo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:l,reuseImages:a})=>{let s=Lr(e,null,{deleteInvisibleElements:!0}),m={...Ti(o,null),exportPadding:n};return Ar(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:l,reuseImages:a})},g4=async e=>{if(e.type==="svg"){let o=await ya(e);await vo(o.outerHTML)}else if(e.type==="png")await Nd(J2(e));else if(e.type==="json")await Hd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Q2,useState as f4}from"react";import{COLOR_PALETTE as b4}from"@hellixit/common";var Dg=ge(new Map),eT=async e=>await ya({elements:e,appState:{exportBackground:!1,viewBackgroundColor:b4.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),tm=(e,o,t,n)=>{let[r,i]=f4();return Q2(()=>{if(o)if(e){let l=t.get(e);l?i(l):(async()=>{let a=await eT(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),i(a))})()}else(async()=>{let l=await eT(o);i(l)})()},[e,o,t,i]),Q2(()=>{let l=n.current;if(l)return r&&(l.innerHTML=r.outerHTML),()=>{l.innerHTML=""}},[r,n]),r},Ea=()=>{let[e]=Q(Dg);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var Hg=ge({active:!1});async function om({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{Qe.set(Hg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}var M4=["board.hellixit.cloud","libraries.hellixit.cloud"],aT=new S4,wn=ge({status:"loaded",isInitialized:!1,libraryItems:[]}),Is=e=>E4(e),P4=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),lT=(e,o)=>{let t=[];for(let n of o)P4(e,n)&&t.push(n);return[...t,...e]},sT=(e,o)=>{let t=Fg(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Fg(e);for(let i of o){let l=r.get(i.id);l?Gg(l)!==Gg(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},Og=class{constructor(o){w(this,"currLibraryItems",[]);w(this,"prevLibraryItems",Is(this.currLibraryItems));w(this,"app");w(this,"updateQueue",[]);w(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);w(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Qe.set(wn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Qe.set(wn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Is(this.currLibraryItems);let t=Is(this.currLibraryItems);this.app.props.onLibraryChange?.(t),aT.trigger(sT(o,t),t)}catch(o){console.error(o)}}});w(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Qe.set(Dg,new Map)});w(this,"resetLibrary",()=>this.setLibrary([]));w(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Is(t))}catch{return o(this.currLibraryItems)}}));w(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:x4.name,tab:y4}}),this.setLibrary(()=>new Promise(async(l,a)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Tu(s,i):c=Al(s,i),!t||await om({title:h("alerts.confirmAddLibrary_title"),description:h("alerts.confirmAddLibrary",{numShapes:c.length}),actionLabel:h("buttons.confirm"),color:"warning"})?(t&&this.app.focusContainer(),l(n?lT(this.currLibraryItems,c):c)):a(new Ei)}catch(s){a(s)}}))));w(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Is(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},cT=Og,Ta=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((g,x)=>{let{height:v}=Rg(x.elements);return Math.max(g,v)},0),i=u=>{let b=0,g=0,x=0;for(let v of e){if(b%t===0&&(g=0),g===u){let{width:y}=Rg(v.elements);x=Math.max(x,y)}b++,g++}return x},l=0,a=0,s=0,c=0,m=0,p=0,d=0;for(let u of e){m&&m%t===0&&(a+=s+50,l=0,p=0,d++),p===0&&(s=r(d)),c=i(p);let{minX:b,minY:g,width:x,height:v}=Rg(u.elements),y=(c-x)/2,E=(s-v)/2;n.push(...u.elements.map(T=>({...T,x:T.x+l+y-b,y:T.y+a+E-g}))),l+=c+50,m++,p++}return n},A4=(e,o=M4)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},zg=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Ng.addLibrary)||new URLSearchParams(window.location.search).get(Bg.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},rr=class rr{constructor(o){w(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,l)=>{try{let a=await o.load({source:t});i(Al(a?.libraryItems||[],"published"))}catch(a){l(a)}});return n?rr.queue.push(r):r()}getLibraryItems(o){return rr.getLibraryItems(this.adapter,o,!1)}};w(rr,"queue",new C4),w(rr,"run",async(o,t)=>{let n=new rr(o);return rr.queue.push(()=>t(n))});var va=rr,Cs=0,rm=0,Gg=e=>`${e.id}:${e.name||""}:${w4(e.elements)}`,im=e=>k4(e.map(o=>Gg(o)).sort().join()),iT=async(e,o)=>{try{return rm++,await va.run(e,async t=>{let n=Fg(await t.getLibraryItems("save"));for(let[a]of o.deletedItems)n.delete(a);let r=[];for(let[a,s]of o.addedItems)n.has(a)?n.set(a,s):r.push(s);if(o.updatedItems)for(let[a,s]of o.updatedItems)n.set(a,s);let i=r.concat(Array.from(n.values())),l=im(i);return l!==Cs&&await e.save({libraryItems:i}),Cs=l,i})}finally{rm--}},L4=e=>{let{hellixitboardAPI:o}=e,t=oT(e);t.current=e;let n=oT(!1);tT(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:a,idToken:s})=>{let c=new Promise(async(p,d)=>{try{a=decodeURIComponent(a),a=I4(a),A4(a,t.current.validateLibraryUrl);let u=a.replace(/^https?:\/\/libraries\.hellixit\.cloud\//,"/library-proxy/"),g=await(await fetch(u)).blob();p(g)}catch(u){d(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Ng.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Ng.addLibrary),window.history.replaceState({},nT,`#${p.toString()}`)}else if(window.location.search.includes(Bg.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(Bg.addLibrary),window.history.replaceState({},nT,`?${p.toString()}`)}}},i=a=>{a.preventDefault();let s=zg();s&&(a.stopImmediatePropagation(),window.history.replaceState({},"",a.oldURL),r(s))},l=zg();if(l&&r(l),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(a=>{o.updateLibrary({libraryItems:a,merge:!0})}).catch(a=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${a?.message}`)})),"adapter"in t.current&&t.current.adapter){let a=t.current.adapter,s=t.current.migrationAdapter,c=T4();s?c.resolve(rT(s.load).then(async m=>{let p=null;try{if(!m)return va.getLibraryItems(a,"load");p=Al(m.libraryItems||[],"published");let d=await iT(a,sT([],p));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),va.getLibraryItems(a,"load")))):c.resolve(rT(va.getLibraryItems,a,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return Cs=im(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(nm.HASHCHANGE,i),()=>{window.removeEventListener(nm.HASHCHANGE,i)}},[o]),tT(()=>{let r=aT.on(async(l,a)=>{let s=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Cs!==im(a)&&await iT(c,l)}catch(m){console.error(`couldn't persist library update: ${m.message}`,l),s&&t.current.hellixitboardAPI&&t.current.hellixitboardAPI.updateScene({appState:{errorMessage:h("errors.saveLibraryError")}})}}),i=l=>{rm&&v4(l)};return window.addEventListener(nm.BEFORE_UNLOAD,i),()=>{window.removeEventListener(nm.BEFORE_UNLOAD,i),r(),Cs=0,rm=0}},[])};import R4 from"clsx";import{VERSIONS as _4}from"@hellixit/common";import{jsx as H4}from"react/jsx-runtime";var D4=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return H4("a",{className:"library-menu-browse-button",href:`https://libraries.hellixit.cloud/?target=${window.name||"_hellixitboard"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${_4.hellixitboardLibrary}`,target:"_hellixitboard_libraries",children:h("labels.libraries")})},dT=D4;import{jsx as N4,jsxs as B4}from"react/jsx-runtime";var am=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>B4("div",{className:R4("library-menu-control-buttons",i),style:n,children:[N4(dT,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Sa,useEffect as qg,useMemo as Jg,useRef as $T,useState as ZT}from"react";import{MIME_TYPES as iB,arrayToMap as aB,nextAnimationFrame as lB}from"@hellixit/common";import{duplicateElements as sB}from"@hellixit/element";import cB from"clsx";import F4 from"lodash.throttle";import{useEffect as O4}from"react";var z4=ge(0),mT=e=>{let[o,t]=Q(z4);return O4(()=>{let{current:n}=e;if(!n)return;let r=F4(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import RN from"clsx";import{useCallback as NN,useState as $g}from"react";import{muteFSAbortError as BN}from"@hellixit/common";import{flushSync as pT}from"react-dom";import G4 from"clsx";import{jsx as lm,jsxs as W4}from"react/jsx-runtime";var U4=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:l,...a})=>{let s=r?`Dialog__action-button--${r}`:"";return W4("button",{className:G4("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...a,children:[n&&lm("div",{style:l?{visibility:"hidden"}:{},children:n}),lm("div",{style:l?{visibility:"hidden"}:{},children:e}),l&&lm("div",{style:{position:"absolute",inset:0},children:lm(it,{})})]})},kn=U4;import{jsx as uT,jsxs as hT}from"react/jsx-runtime";var Y4=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=h("buttons.confirm"),cancelText:i=h("buttons.cancel"),className:l="",...a}=e,s=he(),c=zo(Ia),{container:m}=_e();return hT(je,{onCloseRequest:t,size:"small",...a,className:`confirm-dialog ${l}`,children:[n,hT("div",{className:"confirm-dialog-buttons",children:[uT(kn,{label:i,onClick:()=>{s({openMenu:null}),c(!1),pT(()=>{t()}),m?.focus()}}),uT(kn,{label:r,onClick:()=>{s({openMenu:null}),c(!1),pT(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},sm=Y4;import{useCallback as q4,useEffect as Yg,useRef as gT,useState as Ug}from"react";import{EDITOR_LS_KEYS as Wg,EXPORT_DATA_TYPES as J4,MIME_TYPES as fT,VERSIONS as Q4,chunk as eN,getExportSource as tN}from"@hellixit/common";var no=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};w(no,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),w(no,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import cm from"react";var V4=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,X4=/{{([\w-]+)}}/,K4=/<([\w-]+)>/,$4=/<\/([\w-]+)>/,Z4=(e,o)=>{let t=[{name:"",children:[]}];return e.split(V4).filter(Boolean).forEach(n=>{let r=n.match(K4),i=n.match($4),l=n.match(X4);if(r!==null){let a=r[1];o.hasOwnProperty(a)?t.push({name:a,children:[]}):console.warn(`Trans: missed to pass in prop ${a} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=cm.createElement(cm.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(l!==null){let a=l[1];o.hasOwnProperty(a)?t[t.length-1].children.push(o[a]):console.warn(`Trans: key ${a} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},j4=({i18nKey:e,children:o,...t})=>{let{t:n}=Ie();return cm.createElement(cm.Fragment,{},...Z4(n(e),t))},Pt=j4;import{jsx as be,jsxs as yt}from"react/jsx-runtime";var oN=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=eN(e,6),l=document.createElement("canvas");l.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,l.height=i.length*128+(i.length+1)*(n*2)-n*2;let a=l.getContext("2d");a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height);for(let[s,c]of e.entries()){let m=await nr({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:p,height:d}=m,u=Math.floor(s/6)*(128+n*2),b=s%6*(128+n*2);a.drawImage(m,b+(128-p)/2+n,u+(128-d)/2+n),a.lineWidth=r,a.strokeStyle="#ced4da",a.strokeRect(b+n/2,u+n/2,128+n,128+n)}return await Dc(new File([await Dr(l)],"preview",{type:fT.png}),{outputType:fT.jpg,maxWidthOrHeight:5e3})},nN=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=gT(null),l=gT(null);return Yg(()=>{let a=i.current;a&&(async()=>{let s=await ya({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});a.innerHTML=s.outerHTML})()},[e.elements,o]),yt("div",{className:"single-library-item",children:[e.status==="published"&&be("span",{className:"single-library-item-status",children:h("labels.statusPublished")}),be("div",{ref:i,className:"single-library-item__svg"}),be(J,{"aria-label":h("buttons.remove"),type:"button",icon:Qt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:h("buttons.remove")}),yt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[yt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[yt("div",{style:{padding:"0.5em 0"},children:[be("span",{style:{fontWeight:500,color:"#868e96"},children:h("publishDialog.itemName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",ref:l,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:a=>{n(a.target.value,t)}})]}),be("span",{className:"error",children:e.error})]})]})},rN=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:l})=>{let[a,s]=Ug({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Ug(!1);Yg(()=>{let E=no.get(Wg.PUBLISH_LIBRARY);E&&s(E)},[]);let[p,d]=Ug(o.slice());Yg(()=>{d(o.slice())},[o]);let u=E=>{s({...a,[E.target.name]:E.target.value})},b=async E=>{E.preventDefault(),m(!0);let T=[],I=!1;if(p.forEach(A=>{let H="";A.name||(H=h("publishDialog.errors.required"),I=!0),T.push({...A,error:H})}),I){d(T),m(!1);return}let S=await oN(p),M={type:J4.hellixitboardLibrary,version:Q4.hellixitboardLibrary,source:tN(),libraryItems:p},k=JSON.stringify(M,null,2),_=new Blob([k],{type:"application/json"}),P=new FormData;P.append("hellixitboardLib",_),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",a.name),P.append("authorName",a.authorName),P.append("githubHandle",a.githubHandle),P.append("name",a.name),P.append("description",a.description),P.append("twitterHandle",a.twitterHandle),P.append("website",a.website),fetch(`${C.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(A=>A.ok?A.json().then(({url:H})=>{no.delete(Wg.PUBLISH_LIBRARY),n({url:H,authorName:a.authorName,items:p})}):A.json().catch(()=>{throw new Error(A.statusText||"something went wrong")}).then(H=>{throw new Error(H.message||A.statusText||"something went wrong")}),A=>{console.error(A),r(A),m(!1)}).catch(A=>{console.error(A),r(A),m(!1)})},g=()=>{let E=[];return p.forEach((T,I)=>{E.push(be("div",{className:"single-library-item-wrapper",children:be(nN,{libItem:T,appState:t,index:I,onChange:(S,M)=>{let k=p.slice();k[M].name=S,d(k)},onRemove:l})},I))}),be("div",{className:"selected-library-items",children:E})},x=q4(()=>{i(p),no.set(Wg.PUBLISH_LIBRARY,a),e()},[p,e,i,a]),v=!!o.length,y=o.some(E=>E.status==="published");return be(je,{onCloseRequest:x,title:h("publishDialog.title"),className:"publish-library",children:v?yt("form",{onSubmit:b,children:[be("div",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteDescription",link:E=>be("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:E})})}),be("span",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteGuidelines",link:E=>be("a",{href:"https://github.com/hellixitboard/hellixitboard-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:E})})}),be("div",{className:"publish-library-note",children:h("publishDialog.noteItems")}),y&&be("span",{className:"publish-library-note publish-library-warning",children:h("publishDialog.republishWarning")}),g(),yt("div",{className:"publish-library__fields",children:[yt("label",{children:[yt("div",{children:[be("span",{children:h("publishDialog.libraryName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"name",required:!0,value:a.name,onChange:u,placeholder:h("publishDialog.placeholder.libraryName")})]}),yt("label",{style:{alignItems:"flex-start"},children:[yt("div",{children:[be("span",{children:h("publishDialog.libraryDesc")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("textarea",{name:"description",rows:4,required:!0,value:a.description,onChange:u,placeholder:h("publishDialog.placeholder.libraryDesc")})]}),yt("label",{children:[yt("div",{children:[be("span",{children:h("publishDialog.authorName")}),be("span",{"aria-hidden":"true",className:"required",children:"*"})]}),be("input",{type:"text",name:"authorName",required:!0,value:a.authorName,onChange:u,placeholder:h("publishDialog.placeholder.authorName")})]}),yt("label",{children:[be("span",{children:h("publishDialog.githubUsername")}),be("input",{type:"text",name:"githubHandle",value:a.githubHandle,onChange:u,placeholder:h("publishDialog.placeholder.githubHandle")})]}),yt("label",{children:[be("span",{children:h("publishDialog.twitterUsername")}),be("input",{type:"text",name:"twitterHandle",value:a.twitterHandle,onChange:u,placeholder:h("publishDialog.placeholder.twitterHandle")})]}),yt("label",{children:[be("span",{children:h("publishDialog.website")}),be("input",{type:"text",name:"website",pattern:"https?://.+",title:h("publishDialog.errors.website"),value:a.website,onChange:u,placeholder:h("publishDialog.placeholder.website")})]}),be("span",{className:"publish-library-note",children:be(Pt,{i18nKey:"publishDialog.noteLicense",link:E=>be("a",{href:"https://github.com/hellixitboard/hellixitboard-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:E})})})]}),yt("div",{className:"publish-library__buttons",children:[be(kn,{label:h("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),be(kn,{type:"submit",label:h("buttons.submit"),actionType:"primary",isLoading:c})]})]}):be("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:h("publishDialog.atleastOneLibItem")})})},bT=rN;import GT from"react";import{DropdownMenu as LN}from"radix-ui";import{CLASSES as _N}from"@hellixit/common";import lN from"clsx";import{useCallback as sN,useEffect as cN,useRef as dN}from"react";import{CLASSES as mN,EVENT as vT,KEYS as pN}from"@hellixit/common";import{DropdownMenu as uN}from"radix-ui";import{forwardRef as xT}from"react";import yT from"clsx";import{jsx as ET}from"react/jsx-runtime";var iN=xT(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},l)=>ET("div",{className:yT("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:l,children:e})),aN=xT(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},l)=>ET("div",{className:yT("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:l,children:e})),Et={Row:iN,Col:aN};import{jsx as dm}from"react/jsx-runtime";var TT=({children:e,onClickOutside:o,className:t="",onSelect:n,open:r=!0,align:i="end",style:l})=>{let a=fe(),s=dN(null),c=Yn({onClickOutside:o});Xi(s,sN(p=>{s.current?.closest(`.${mN.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),cN(()=>{if(!r)return;let p=u=>{u.key===pN.ESCAPE&&(u.stopImmediatePropagation(),c.onClickOutside?.())},d={capture:!0};return document.addEventListener(vT.KEYDOWN,p,d),()=>{document.removeEventListener(vT.KEYDOWN,p,d)}},[c,r]);let m=lN(`dropdown-menu ${t}`,{"dropdown-menu--mobile":a.formFactor==="phone"}).trim();return dm(xh.Provider,{value:{onSelect:n},children:dm(uN.Content,{ref:s,className:m,style:l,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:a.formFactor==="phone"?dm(Et.Col,{className:"dropdown-menu-container",children:e}):dm(Xe,{className:"dropdown-menu-container",padding:2,children:e})})})};TT.displayName="DropdownMenuContent";var IT=TT;import{jsx as gN}from"react/jsx-runtime";var hN=({children:e,className:o="",selected:t,...n})=>gN("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),CT=hN;import{DropdownMenu as fN}from"radix-ui";import{jsx as Vg}from"react/jsx-runtime";var ST=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:l,rel:a="noopener",...s})=>{let c=hd(r);return Vg(fN.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Vg("a",{...s,href:t,target:"_blank",rel:`noopener ${a}`,className:jn(i,l),title:s.title??s["aria-label"],children:Vg(qn,{icon:e,shortcut:o,children:n})})})},Ca=ST;ST.displayName="DropdownMenuItemLink";import{jsx as bN}from"react/jsx-runtime";var wT=()=>bN("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),kT=wT;wT.displayName="DropdownMenuSeparator";import{DropdownMenu as CN}from"radix-ui";import xN from"clsx";import{DropdownMenu as yN}from"radix-ui";import{useCallback as EN,useState as MT}from"react";import{jsx as Kg}from"react/jsx-runtime";var Xg=-4,vN=4,PT=({children:e,className:o})=>{let t=fe(),n=xN(`dropdown-menu dropdown-submenu ${o}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=EN(c=>{if(c){let p=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let d=c.getBoundingClientRect().width,b=window.innerWidth-p.right;b<d+20&&(l(b-d+Xg),s(Xg+8))}}},[]),[i,l]=MT(vN),[a,s]=MT(Xg);return Kg(yN.SubContent,{className:n,sideOffset:i,alignOffset:a,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Kg(Et.Col,{className:"dropdown-menu-container",children:e}):Kg(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},AT=PT;PT.displayName="DropdownMenuSubContent";import{DropdownMenu as TN}from"radix-ui";import{jsx as LT,jsxs as IN}from"react/jsx-runtime";var _T=({children:e,icon:o,shortcut:t,className:n})=>IN(TN.SubTrigger,{className:`${jn(n)} dropdown-menu__submenu-trigger`,children:[LT(qn,{icon:o,shortcut:t,children:e}),LT("div",{className:"dropdown-menu__submenu-trigger-icon",children:jE})]}),DT=_T;_T.displayName="DropdownMenuSubTrigger";import HT from"react";var mm=e=>o=>{let t=HT.Children.toArray(o).find(n=>HT.isValidElement(n)&&typeof n.type!="string"&&n?.type.displayName&&n.type.displayName===e);return t||null},RT=mm("DropdownMenuTrigger"),NT=mm("DropdownMenuContent"),BT=mm("DropdownMenuSubTrigger"),FT=mm("DropdownMenuSubContent");import{jsxs as SN}from"react/jsx-runtime";var pm=({children:e})=>{let o=BT(e),t=FT(e);return SN(CN.Sub,{children:[o,t]})};pm.Trigger=DT;pm.Content=AT;pm.displayName="DropdownMenuSub";var ir=pm;import wN from"clsx";import{DropdownMenu as kN}from"radix-ui";import{jsx as MN}from"react/jsx-runtime";var OT=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=fe(),l=wN(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return MN(kN.Trigger,{className:l,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},zT=OT;OT.displayName="DropdownMenuTrigger";import{jsx as AN}from"react/jsx-runtime";var PN=e=>AN(wt,{...e,icon:e.checked?Gc:ZE}),Co=PN;import{jsx as HN,jsxs as DN}from"react/jsx-runtime";var So=({children:e,open:o})=>{let t=RT(e),n=NT(e),r=n&&GT.isValidElement(n)?GT.cloneElement(n,{open:o}):n;return HN(LN.Root,{open:o,modal:!1,children:DN("div",{className:_N.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};So.Trigger=zT;So.Content=IT;So.Item=wt;So.ItemCheckbox=Co;So.ItemLink=Ca;So.ItemCustom=CT;So.Group=$l;So.Separator=kT;So.Sub=ir;var ie=So;So.displayName="DropdownMenu";import{jsx as Bt,jsxs as um}from"react/jsx-runtime";var FN=(e,o)=>e.filter(t=>o.includes(t.id)),ON=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:l,className:a})=>{let[s]=Q(wn),[c,m]=Q(Ia),p=()=>{let P=o.length?h("alerts.removeItemsFromsLibrary",{count:o.length}):h("alerts.resetLibrary"),A=o.length?h("confirmDialog.removeItemsFromLib"):h("confirmDialog.resetLibrary");return Bt(sm,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:A,children:Bt("p",{children:P})})},[d,u]=$g(!1),b=!!o.length,g=b?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=b?h("buttons.remove"):h("buttons.resetLibrary"),[v,y]=$g(!1),[E,T]=$g(null),I=NN(()=>um(je,{onCloseRequest:()=>T(null),title:h("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Bt("p",{children:Bt(Pt,{i18nKey:"publishSuccessDialog.content",authorName:E.authorName,link:P=>Bt("a",{href:E?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Bt(J,{type:"button",title:h("buttons.close"),"aria-label":h("buttons.close"),label:h("buttons.close"),onClick:()=>T(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[T,E]),S=(P,A)=>{y(!1),T({url:P.url,authorName:P.authorName});let H=A.slice();H.forEach(F=>{o.includes(F.id)&&(F.status="published")}),t.setLibrary(H)},M=async()=>{try{await t.updateLibrary({libraryItems:Sc({description:"Hellix IT library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:h("errors.importLibraryError")})}},k=async()=>{let P=b?g:await t.getLatestLibrary();Ny(P).catch(BN).catch(A=>{e({errorMessage:A.message})})},_=()=>um(ie,{open:c,children:[Bt(ie.Trigger,{onToggle:()=>m(!c),children:i0}),um(ie.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!b&&Bt(ie.Item,{onSelect:M,icon:Hi,"data-testid":"lib-dropdown--load",children:h("buttons.load")}),!!g.length&&Bt(ie.Item,{onSelect:k,icon:Nr,"data-testid":"lib-dropdown--export",children:h("buttons.export")}),b&&Bt(ie.Item,{icon:bE,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:h("buttons.publishLibrary")}),!!g.length&&Bt(ie.Item,{onSelect:()=>u(!0),icon:pt,children:x})]})]});return um("div",{className:RN("library-menu-dropdown-container",a),children:[_(),o.length>0&&Bt("div",{className:"library-actions-counter",children:o.length}),d&&p(),v&&Bt(bT,{onClose:()=>y(!1),libraryItems:FN(s.libraryItems,o),appState:l,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(A=>A!==P))}),E&&I()]})},UT=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Ae(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Ea(),l=se(),a=he(),[s]=Q(wn),c=async p=>{let d=p.filter(u=>!e.includes(u.id));n.setLibrary(d).catch(()=>{a({errorMessage:h("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Bt(ON,{appState:l,setAppState:a,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as KN,useEffect as $N,useState as ZN}from"react";import zN,{useCallback as GN}from"react";function UN(){return[!1,GN(o=>o(),[])]}var WT=zN.useTransition||UN;import YT from"clsx";import{memo as WN,useRef as YN,useState as VN}from"react";import{jsx as hm,jsxs as XN}from"react/jsx-runtime";var VT=WN(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:l,svgCache:a})=>{let s=YN(null),c=tm(e,o,a,s),[m,p]=VN(!1),d=fe().formFactor==="phone",u=t&&hm("div",{className:"library-unit__adder",children:r0});return XN("div",{className:YT("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[hm("div",{className:YT("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?b=>{e&&b.shiftKey?i(e,b):n(e)}:void 0,onDragStart:b=>{if(!e){b.preventDefault();return}p(!1),l(e,b)}}),u,e&&o&&(m||d||r)&&hm(os,{checked:r,onChange:(b,g)=>i(e,g),className:"library-unit__checkbox"})]})}),XT=()=>hm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as jN,jsx as gm}from"react/jsx-runtime";var fm=({children:e})=>gm("div",{className:"library-menu-items-container__grid",children:e}),Ss=KN(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:l})=>{let[,a]=WT(),[s,c]=ZN(0);return $N(()=>{s<e.length&&a(()=>{c(s+l)})},[s,e.length,a,l]),gm(jN,{children:e.map((m,p)=>p<s?gm(VT,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??p):gm(XT,{},p))})});import Zg from"clsx";import{forwardRef as eB,useRef as tB,useImperativeHandle as oB,useLayoutEffect as nB,useState as rB}from"react";import qN from"clsx";import{composeEventHandlers as JN}from"@hellixit/common";import{jsx as QN}from"react/jsx-runtime";var ut=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>QN("button",{onClick:JN(i.onClick,l=>{o()}),type:e,className:qN("hellixitboard-button",r,{selected:t}),...i,children:n});import{jsx as jg,jsxs as KT}from"react/jsx-runtime";var ar=eB(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:l,isRedacted:a=!1,icon:s,className:c,type:m,...p},d)=>{let u=tB(null);oB(d,()=>u.current),nB(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[b,g]=rB(!1);return KT("div",{className:Zg("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,o&&jg("div",{className:"ExcTextField__label",children:o}),KT("div",{className:Zg("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[jg("input",{className:Zg({"is-redacted":"value"in p&&p.value&&a&&!b}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:l,type:m}),a&&jg(ut,{onSelect:()=>g(!b),style:{border:0,userSelect:"none"},children:b?SE:Oi})]})]})});import{Fragment as jT,jsx as lt,jsxs as en}from"react/jsx-runtime";var dB=17,mB=64;function Qg({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:l,libraryReturnUrl:a,onSelectItems:s,selectedItems:c}){let m=fe(),p=$T(null),d=mT(p);qg(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:u}=Ea(),[b,g]=ZT(null),[x,v]=ZT(""),y=!o.length&&!r.length,E=!y&&!!x.trim(),T=Jg(()=>{let D=Kr(x.trim().toLowerCase());return D?o.filter(B=>{let W=B.name||"";return W.trim()&&Kr(W.toLowerCase()).includes(D)}):[]},[o,x]),I=Jg(()=>o.filter(D=>D.status!=="published"),[o]),S=Jg(()=>o.filter(D=>D.status==="published"),[o]),M=Sa((D,B)=>{let W=!c.includes(D),te=[...I,...S];if(W){if(B.shiftKey&&b){let X=te.findIndex(rt=>rt.id===b),le=te.findIndex(rt=>rt.id===D);if(X===-1||le===-1){s([...c,D]);return}let pe=aB(c),de=Math.min(X,le),Ee=Math.max(X,le),Ve=te.reduce((rt,ft,Ct)=>((Ct>=de&&Ct<=Ee||pe.has(ft.id))&&rt.push(ft.id),rt),[]);s(Ve)}else s([...c,D]);g(D)}else g(null),s(c.filter(X=>X!==D))},[b,s,S,c,I]);qg(()=>{c.length||g(null)},[c]);let k=Sa(D=>{let B;return c.includes(D)?B=o.filter(W=>c.includes(W.id)):B=o.filter(W=>W.id===D),B.map(W=>({...W,elements:sB({type:"everything",elements:W.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),_=Sa((D,B)=>{let W={itemIds:c.includes(D)?c:[D]};B.dataTransfer.setData(iB.hellixitboardlibIds,JSON.stringify(W))},[c]),P=Sa(D=>D?c.includes(D):!1,[c]),A=Sa(()=>{t(r)},[r,t]),H=Sa(D=>{D&&n(k(D))},[k,n]),F=u.size>=(T.length?T:o).length?mB:dB,Y=$T(null);qg(()=>{lB(()=>{Y.current?.focus()})},[]);let V=!E&&en(jT,{children:[!y&&lt("div",{className:"library-menu-items-container__header",children:h("labels.personalLib")}),!r.length&&!I.length?en("div",{className:"library-menu-items__no-items",children:[!S.length&&lt("div",{className:"library-menu-items__no-items__label",children:h("library.noItems")}),lt("div",{className:"library-menu-items__no-items__hint",children:S.length>0?h("library.hint_emptyPrivateLibrary"):h("library.hint_emptyLibrary")})]}):en(fm,{children:[r.length>0&&lt(Ss,{itemsRenderedPerBatch:F,items:[{id:null,elements:r}],onItemSelectToggle:M,onItemDrag:_,onClick:A,isItemSelected:P,svgCache:u}),lt(Ss,{itemsRenderedPerBatch:F,items:I,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})]}),S.length>0&&lt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:h("labels.hellixitboardLib")}),S.length>0&&lt(fm,{children:lt(Ss,{itemsRenderedPerBatch:F,items:S,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})})]}),U=E&&en(jT,{children:[en("div",{className:"library-menu-items-container__header",children:[h("library.search.heading"),!e&&en("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:D=>D.preventDefault(),onClick:D=>{v("")},children:[lt("kbd",{children:"esc"})," to clear"]})]}),T.length>0?lt(fm,{children:lt(Ss,{itemsRenderedPerBatch:F,items:T,onItemSelectToggle:M,onItemDrag:_,onClick:H,isItemSelected:P,svgCache:u})}):en("div",{className:"library-menu-items__no-items",children:[lt("div",{className:"library-menu-items__no-items__hint",children:h("library.search.noResults")}),lt(ut,{onPointerDown:D=>D.preventDefault(),onSelect:()=>{v("")},style:{width:"auto",marginTop:"1rem"},children:h("library.search.clearSearch")})]})]});return en("div",{className:"library-menu-items-container",style:r.length||I.length||S.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[en("div",{className:"library-menu-items-header",children:[!y&&lt(ar,{ref:Y,type:"search",className:cB("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:h("library.search.inputPlaceholder"),value:x,onChange:D=>v(D)}),lt(UT,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),en(Et.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:S.length>0?1:"0 1 auto",margin:y?"auto":0},ref:p,children:[e&&lt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:lt(it,{})}),V,U,y&&lt(am,{style:{padding:"16px 0",width:"100%"},id:l,libraryReturnUrl:a,theme:i})]})]})}import{jsx as lr,jsxs as QT}from"react/jsx-runtime";var Ia=ge(!1),JT=({children:e})=>lr("div",{className:"layer-ui__library",children:e}),EB=oI(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:l,theme:a,selectedItems:s,onSelectItems:c})=>{let[m]=Q(wn),p=tf(b=>{(async(x,v)=>{ce("element","addToLibrary","ui");for(let E of uB)if(x.some(T=>T.type===E))return n({errorMessage:h(`errors.libraryElementTypeError.${E}`)});let y=[{status:"unpublished",elements:x,id:hB(),created:Date.now()},...v];t(),i.setLibrary(y).catch(()=>{n({errorMessage:h("alerts.errorAddingToLibrary")})})})(b,m.libraryItems)},[t,i,n,m.libraryItems]),d=tI(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return lr(JT,{children:lr("div",{className:"layer-ui__library-message",children:QT("div",{children:[lr(it,{size:"2em"}),lr("span",{children:h("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return QT(JT,{children:[lr(Qg,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:l,libraryReturnUrl:r,theme:a,onSelectItems:c,selectedItems:s}),u&&lr(am,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:l,libraryReturnUrl:r,theme:a})]})}),ef=(e,o)=>({elements:e,pending:oe(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),vB=(e,o)=>{let t=Kn(),[n,r]=eI(()=>ef(t,e.selectedElementIds)),i=pB(new Map);return of(()=>{for(let l of n.pending)i.current.set(l.id,l.version)},[n.pending]),of(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(l=>{if(!gB(l.selectedElementIds,e.selectedElementIds))return i.current.clear(),ef(t,e.selectedElementIds);let a=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=a.get(s)?.version;if(c&&c!==i.current.get(s))return ef(t,e.selectedElementIds)}return l})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},nI=oI(()=>{let e=Ae(),{onInsertElements:o}=e,t=Ko(),n=se(),r=he(),[i,l]=eI([]),a=tI(()=>e.library,[e.library]),s=vB(n,e);of(()=>xB(document,yB.KEYDOWN,p=>{if(p.key===fB.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${qT.SIDEBAR}`))i.length>0?(p.stopPropagation(),l([])):bB(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:b}=e.lastViewportPosition;document.elementFromPoint(u,b)?.closest(`.${qT.SIDEBAR}`)&&(p.stopPropagation(),l([]))}}},{capture:!0}),[i,r,e]);let c=tf(p=>{o(Ta(p)),e.focusContainer()},[o,e]),m=tf(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return lr(EB,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:a,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:l})});import TB from"clsx";import{useRef as IB}from"react";import{createPortal as CB}from"react-dom";import{KEYS as SB}from"@hellixit/common";import{jsx as rI,jsxs as wB}from"react/jsx-runtime";var iI=e=>{let{closeOnClickOutside:o=!0}=e,t=id({className:"hellixitboard-modal-container"}),n=IB(document.body.classList.contains("hellixitboard-animations-disabled"));if(!t)return null;let r=i=>{i.key===SB.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return CB(wB("div",{className:TB("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[rI("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),rI("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as ws,jsxs as _B}from"react/jsx-runtime";function LB(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var je=e=>{let[o,t]=q2(),[n]=PB(document.activeElement),{id:r}=_e(),i=fe().formFactor==="phone";MB(()=>{if(!o)return;let c=aI(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===AB.TAB){let d=aI(o),{activeElement:u}=document,b=d.findIndex(g=>g===u);b===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):b===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let l=he(),a=zo(Ia),s=()=>{l({openMenu:null}),a(!1),n.focus(),e.onCloseRequest()};return ws(iI,{className:kB("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:LB(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:_B(Xe,{ref:t,children:[e.title&&ws("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:ws("span",{className:"Dialog__titleContent",children:e.title})}),i&&ws("button",{className:"Dialog__close",onClick:s,title:h("buttons.close"),"aria-label":h("buttons.close"),type:"button",children:Qt}),ws("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as Ge}from"@hellixit/common";var bm=[{icon:Ni,value:"hand",key:Ge.H,numericKey:null,fillable:!1,toolbar:!0},{icon:Rr,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0,toolbar:!0},{icon:ki,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0,toolbar:!0},{icon:Mi,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0,toolbar:!0},{icon:Pi,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0,toolbar:!0},{icon:Fc,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0,toolbar:!0},{icon:Ai,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0,toolbar:!0},{icon:Uo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1,toolbar:!0},{icon:Wo,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1,toolbar:!0},{icon:Li,value:"image",key:null,numericKey:Ge[9],fillable:!1,toolbar:!0},{icon:Oc,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1,toolbar:!0},{icon:Yo,value:"laser",key:Ge.K,numericKey:null,fillable:!1,toolbar:!1}],nf=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Rr,key:Ge.V,numericKey:Ge[1],fillable:!0,toolbar:!0},...bm.slice(1)]:bm,lI=(e,o)=>nf(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import ko from"clsx";import{useRef as gI,useState as GB}from"react";import{Popover as tn}from"radix-ui";import{CLASSES as fI,KEYS as mI,capitalizeString as ka,isTransparent as ym,viewportCoordsToSceneCoords as UB}from"@hellixit/common";import{shouldAllowVerticalAlign as bI,suppportsHorizontalAlign as xI,hasBoundTextElement as Em,isElbowArrow as sf,isImageElement as yI,isLinearElement as cf,isTextElement as Tm,isArrowElement as pI,hasStrokeColor as uI,toolIsArrow as vm,newElement as WB,newTextElement as hI}from"@hellixit/element";import{createIsolation as DB}from"jotai-scope";import rf from"react";import wo from"tunnel-rat";var af=rf.createContext(null),Pe=()=>rf.useContext(af),HB=DB(),sI=()=>rf.useMemo(()=>({MainMenuTunnel:wo(),WelcomeScreenMenuHintTunnel:wo(),WelcomeScreenToolbarHintTunnel:wo(),WelcomeScreenHelpHintTunnel:wo(),WelcomeScreenCenterTunnel:wo(),FooterCenterTunnel:wo(),FooterRightSlotTunnel:wo(),DefaultSidebarTriggerTunnel:wo(),DefaultSidebarTabTriggersTunnel:wo(),OverwriteConfirmDialogTunnel:wo(),TTDDialogTriggerTunnel:wo(),tunnelsJotai:HB}),[]);import{CODES as RB,KEYS as NB}from"@hellixit/common";import{CaptureUpdateAction as BB}from"@hellixit/element";var Zr=O({name:"viewMode",label:"labels.viewMode",icon:Oi,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:BB.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[NB.CTRL_OR_CMD]&&e.altKey&&e.code===RB.R});import{useEffect as FB,useState as OB}from"react";import cI from"clsx";import{capitalizeString as dI}from"@hellixit/common";import{Popover as lf}from"radix-ui";import{jsx as xm,jsxs as zB}from"react/jsx-runtime";var wa=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:l,"data-testid":a,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=OB(!1),u=t.type,b=c.type===u,g=32/2+10,{container:x}=_e();return!o.some(v=>v.type===u)&&p&&d(!1),FB(()=>{let v=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>v?.()},[e]),zB(lf.Root,{open:p,children:[xm(lf.Trigger,{asChild:!0,children:xm(J,{className:cI(r,{fillable:m,active:o.some(v=>v.type===t.type)}),type:"radio",icon:c.icon,checked:b,name:"editor-current-shape",title:l,"aria-label":l,"data-testid":a,onPointerDown:()=>{d(v=>!v),s(n)}})}),xm(lf.Content,{className:"tool-popover-content",sideOffset:g,collisionBoundary:x??void 0,children:o.map(({type:v,icon:y,title:E})=>xm(J,{className:cI(r,{active:u===v}),type:"radio",icon:y,checked:u===v,name:`${i}-option`,title:E||dI(v),keyBindingLabel:"","aria-label":E||dI(v),"data-testid":`toolbar-${v}`,onChange:()=>{e.state.activeTool.type!==v&&ce("toolbar",v,"ui"),e.setActiveTool({type:v}),s?.(v)}},v))})]})};import{Fragment as Ft,jsx as K,jsxs as ue}from"react/jsx-runtime";var Im=ko([fI.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),ks=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return uI(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>uI(n.type))},Ms=(e,o)=>Bo(e.activeTool.type)||o.some(t=>Bo(t.type)),EI=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=xi(o,e),i=!1;r.length===2&&(Em(r[0])||Em(r[1]))&&(i=!0);let l=!!(e.editingTextElement||e.newElement),a=fe(),s=document.documentElement.getAttribute("dir")==="rtl",c=Bo(e.activeTool.type)&&!ym(e.currentItemBackgroundColor)||r.some(b=>Bo(b.type)&&!ym(b.backgroundColor)),m=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&cf(r[0])&&!sf(r[0]),d=!e.croppingElementId&&r.length===1&&yI(r[0]),u=!i&&Mt(e,n);return ue("div",{className:"selected-shape-actions",children:[K("div",{children:ks(e,r)&&t("changeStrokeColor")}),Ms(e,r)&&K("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Il(e.activeTool.type)||r.some(b=>Il(b.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(b=>b.type==="freedraw"))&&t("changeStrokeShape"),(Cl(e.activeTool.type)||r.some(b=>Cl(b.type)))&&ue(Ft,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Sl(e.activeTool.type)||r.some(b=>Sl(b.type)))&&K(Ft,{children:t("changeRoundness")}),(wl(e.activeTool.type)||r.some(b=>wl(b.type)))&&K(Ft,{children:t("changeAnimation")}),(vm(e.activeTool.type)||r.some(b=>vm(b.type)))&&K(Ft,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Tm))&&ue(Ft,{children:[K("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),(e.activeTool.type==="text"||xI(r,o))&&t("changeTextAlign")]}),bI(r,o)&&t("changeVerticalAlign"),(yi(e.activeTool.type)||r.some(b=>yi(b.type)))&&K(Ft,{children:t("changeArrowhead")}),t("changeOpacity"),ue("fieldset",{children:[K("legend",{children:h("labels.layers")}),ue("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ue("fieldset",{children:[K("legend",{children:h("labels.align")}),ue("div",{className:"buttonList",children:[s?ue(Ft,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ue(Ft,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),K("div",{style:{flexBasis:"100%",height:0}}),ue("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!l&&r.length>0&&ue("fieldset",{children:[K("legend",{children:h("labels.actions")}),ue("div",{className:"buttonList",children:[a.formFactor!=="phone"&&t("duplicateSelection"),a.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor")]})]})]})},vI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=Bo(e.activeTool.type)&&!ym(e.currentItemBackgroundColor)||n.some(s=>Bo(s.type)&&!ym(s.backgroundColor)),l=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return l?K("div",{className:"compact-action-item",children:ue(tn.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:a}),title:h("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:VE})}),a&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:ue("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(Il(e.activeTool.type)||n.some(s=>Il(s.type)))&&o("changeStrokeWidth"),(Cl(e.activeTool.type)||n.some(s=>Cl(s.type)))&&ue(Ft,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Sl(e.activeTool.type)||n.some(s=>Sl(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},TI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let l=vm(e.activeTool.type)||n.some(s=>vm(s.type)),a=e.openPopup==="compactArrowProperties";return l?K("div",{className:"compact-action-item",children:ue(tn.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:a}),title:h("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactArrowProperties"})},children:(()=>{let s=xt(n,i,c=>pI(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>pI(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?Gi:s==="round"?Ui:zi})()})}),a&&K(Vo,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},II=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:l,restoreCaretPosition:a}=u1(),s=e.openPopup==="compactTextProperties";return K("div",{className:"compact-action-item",children:ue(tn.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&l(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:s}),title:h("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&l(),t({openPopup:"compactTextProperties"}))},children:u0})}),e.openPopup==="compactTextProperties"&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:ue("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(Tm))&&o("changeFontSize"),(e.activeTool.type==="text"||xI(n,i))&&o("changeTextAlign"),bI(n,i)&&o("changeVerticalAlign")]})})]})})},CI=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=wl(e.activeTool.type)||n.some(s=>wl(s.type)),l=e.openPopup==="compactAnimationProperties";if(!i)return null;let a=ue("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[K("line",{x1:"2",y1:"12",x2:"8",y2:"12",strokeDasharray:"3 2"}),K("line",{x1:"10",y1:"12",x2:"16",y2:"12",strokeDasharray:"3 2"}),K("line",{x1:"18",y1:"12",x2:"22",y2:"12",strokeDasharray:"3 2"}),K("polyline",{points:"17,8 22,12 17,16"})]});return K("div",{className:"compact-action-item",children:ue(tn.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactAnimationProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:l}),title:"Animations",onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactAnimationProperties"})},children:a})}),l&&K(Vo,{className:Im,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:K("div",{className:"selected-shape-actions",children:o("changeAnimation")})})]})})},SI=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:l,showDelete:a})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&yI(t[0]),m=t.length===1,p=Mt(e,i),d=!1;t.length===2&&(Em(t[0])||Em(t[1]))&&(d=!0);let u=document.documentElement.getAttribute("dir")==="rtl",b=e.openPopup==="compactOtherProperties";return s||t.length===0?null:K("div",{className:"compact-action-item",children:ue(tn.Root,{open:b,onOpenChange:g=>{n(g?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[K(tn.Trigger,{asChild:!0,children:K("button",{type:"button",className:ko("compact-action-button properties-trigger",{active:b}),title:h("labels.actions"),onClick:g=>{g.preventDefault(),g.stopPropagation(),n({openPopup:b?null:"compactOtherProperties"})},children:a0})}),b&&K(Vo,{className:Im,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ue("div",{className:"selected-shape-actions",children:[ue("fieldset",{children:[K("legend",{children:h("labels.layers")}),ue("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&ue("fieldset",{children:[K("legend",{children:h("labels.align")}),ue("div",{className:"buttonList",children:[u?ue(Ft,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):ue(Ft,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),K("div",{style:{flexBasis:"100%",height:0}}),ue("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically")]})]})]}),ue("fieldset",{children:[K("legend",{children:h("labels.actions")}),ue("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),l&&o("duplicateSelection"),a&&o("deleteSelectedElements")]})]})]})})]})})},YB=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&cf(t[0])&&!sf(t[0])?K("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,wI=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=xi(o,e),{container:l}=_e(),a=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&cf(i[0])&&!sf(i[0]);return ue("div",{className:"compact-shape-actions",children:[ks(e,i)&&K("div",{className:ko("compact-action-item"),children:t("changeStrokeColor")}),Ms(e,i)&&K("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),K(vI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(TI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,app:n}),K(CI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),s&&K("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(Tm))&&ue(Ft,{children:[K("div",{className:"compact-action-item",children:t("changeFontFamily")}),K(II,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,elementsMap:o})]}),!a&&i.length>0&&K("div",{className:"compact-action-item",children:t("duplicateSelection")}),!a&&i.length>0&&K("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),K(SI,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:l,app:n})]})},kI=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=xi(o,e),{container:l}=_e(),a=gI(null),s=a.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,u=p+m,b=s>=d+u,g=s>=d+2*u;return ue(Xe,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:a,children:[ue("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[ks(e,i)&&K("div",{className:ko("compact-action-item"),children:t("changeStrokeColor")}),Ms(e,i)&&K("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),K(vI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(TI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,app:n}),K(CI,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l}),K(YB,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(Tm))&&ue(Ft,{children:[K("div",{className:"compact-action-item",children:t("changeFontFamily")}),K(II,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:l,elementsMap:o})]}),K(SI,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:l,app:n,showDuplicate:!g,showDelete:!b})]}),ue("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[K("div",{className:"compact-action-item",children:t("undo")}),K("div",{className:"compact-action-item",children:t("redo")}),g&&K("div",{className:"compact-action-item",children:t("duplicateSelection")}),b&&K("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},MI=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=GB(!1),l=gI(null),a=at(),s=a==="full",c=a==="compact",m=[{type:"selection",icon:Rr,title:ka(h("toolBar.selection"))},{type:"lasso",icon:Un,title:ka(h("toolBar.lasso"))}],p=e.type==="frame",d=e.type==="laser",u=s&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",b=e.type==="embeddable",{TTDDialogTriggerTunnel:g}=Pe();return ue(Ft,{children:[K("input",{ref:l,type:"file",style:{display:"none"},onChange:async x=>{let v=x.target.files?.[0];if(!v||(x.target.value="",_r(v)))return;let E=(await t.props.onFileUpload?.(v))?.url;if(!E)return;let T=t.state.width/2+t.state.offsetLeft,I=t.state.height/2+t.state.offsetTop,{x:S,y:M}=UB({clientX:T,clientY:I},t.state),k=v.name.length>28?`${v.name.slice(0,25)}...`:v.name,_=Math.max(220,Math.min(460,k.length*11+132)),P=56,A=S-_/2,H=M-P/2,F=`file-chip-${Date.now()}-${Math.round(Math.random()*1e6)}`,Y=WB({type:"rectangle",x:A,y:H,width:_,height:P,strokeColor:"#d8d8e2",backgroundColor:"#ececf3",fillStyle:"solid",strokeWidth:1,roughness:0,roundness:{type:3,value:16},groupIds:[F],customData:{filePlaceholderUrl:E}}),V=hI({x:A+22,y:H+16,text:"\u{1F4CE}",fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#5a5a66",groupIds:[F],customData:{filePlaceholderUrl:E}}),U=hI({x:A+52,y:H+17,text:k,fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#2d2d36",groupIds:[F],customData:{filePlaceholderUrl:E}});t.scene.insertElements([Y,V,U])}}),nf(t).map(({value:x,icon:v,key:y,numericKey:E,fillable:T,toolbar:I})=>{if(I===!1||n.tools?.[x]===!1)return null;let S=h(`toolBar.${x}`),M=y&&ka(typeof y=="string"?y:y[0]),k=M?`${M} ${h("helpDialog.or")} ${E}`:`${E}`,_=x==="hand"?void 0:E||M;return(x==="selection"||x==="lasso")&&c?K(wa,{app:t,options:m,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:ka(h("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:P=>{(P==="selection"||P==="lasso")&&(t.setActiveTool({type:P}),o({preferredSelectionTool:{type:P,initialized:!0}}))},displayedOption:m.find(P=>P.type===t.state.preferredSelectionTool.type)||m[0],fillable:e.type==="selection"},"selection-popover"):K(J,{className:ko("Shape",{fillable:T}),type:"radio",icon:v,checked:e.type===x,name:"editor-current-shape",title:`${ka(S)} \u2014 ${k}`,keyBindingLabel:_,"aria-label":ka(S),"aria-keyshortcuts":k,"data-testid":`toolbar-${x}`,onPointerDown:({pointerType:P})=>{!t.state.penDetected&&P==="pen"&&t.togglePenMode(!0),x==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:P})=>{t.state.activeTool.type!==x&&ce("toolbar",x,"ui"),x==="image"?t.setActiveTool({type:x}):t.setActiveTool({type:x})}},x)}),K("div",{className:"App-toolbar__divider"}),ue(ie,{open:r,children:[K(ie.Trigger,{className:ko("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":p||b||u||d&&!t.props.isCollaborating}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),children:p?yo:b?_i:d&&!t.props.isCollaborating?Yo:u?Un:Bl}),ue(ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[K(ie.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:yo,shortcut:mI.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,children:h("toolBar.frame")}),K(ie.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:_i,"data-testid":"toolbar-embeddable",selected:b,children:h("toolBar.embeddable")}),K(ie.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:d,shortcut:mI.K.toLocaleUpperCase(),children:h("toolBar.laser")}),s&&K(ie.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Un,"data-testid":"toolbar-lasso",selected:u,children:h("toolBar.lasso")}),t.props.onFileUpload&&K(ie.Item,{onSelect:()=>l.current?.click(),icon:Yc,"data-testid":"toolbar-upload-file",children:h("toolBar.uploadFile")}),K("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&K(g.Out,{}),K(ie.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Fi,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToHellixitboard")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&K(ie.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Fr,"data-testid":"toolbar-magicframe",badge:K(ie.Item.Badge,{children:"AI"}),children:h("toolBar.magicframe")})]})]})]})},PI=({renderAction:e,zoom:o})=>K(Et.Col,{gap:1,className:fI.ZOOM_ACTIONS,children:ue(Et.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),AI=({renderAction:e,className:o})=>ue("div",{className:`undo-redo-buttons ${o}`,children:[K("div",{className:"undo-button-container",children:K($t,{label:h("buttons.undo"),children:e("undo")})}),K("div",{className:"redo-button-container",children:ue($t,{label:h("buttons.redo"),children:[" ",e("redo")]})})]}),LI=({actionManager:e,showExitZenModeBtn:o})=>K("button",{type:"button",className:ko("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(tr),children:h("buttons.exitZenMode")}),_I=({actionManager:e})=>K("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Zr),children:KE});import{useRef as VB}from"react";var df=e=>{let o=VB({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as KB,jsxs as XB}from"react/jsx-runtime";var jr=ge(null),DI=()=>{let[e,o]=Q(jr),t=De(),n=Ae();return e&&e==="clearCanvas"?KB(sm,{onConfirm:()=>{t.executeAction(Sn),n.props.onClearCanvas?.(),o(null)},onCancel:()=>o(null),title:h("clearCanvasDialog.title"),children:XB("p",{className:"clear-canvas__content",children:[" ",h("alerts.clearReset")]})}):null};var mf={};Ay(mf,{toggleTheme:()=>$B});var $B={...Gr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Gr,"commandPalette")}};import{jsx as st,jsxs as on}from"react/jsx-runtime";var QB=ge(null),Fe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},RI=e=>{switch(e){case Fe.app:return 1;case Fe.export:return 2;case Fe.editor:return 3;case Fe.tools:return 4;case Fe.elements:return 5;case Fe.links:return 6;default:return 10}},wm=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return on("div",{className:BI("shortcut",o),children:[n.map((r,i)=>st("div",{className:"shortcut-wrapper",children:st("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),st("div",{className:"shortcut-desc",children:t})]})},OI=e=>!e.altKey&&e[Mo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===Mo.P||e.key===Mo.SLASH),eF=Object.assign(e=>{let o=se(),t=he();return Sm(()=>{let n=r=>{OI(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let l=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return l&&ce("command_palette","open","shortcut"),{openDialog:l}}))};return window.addEventListener(km.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(km.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:st(tF,{...e})},{defaultItems:mf});function tF({customCommandPaletteItems:e}){let o=Ae(),t=se(),n=he(),r=Ko(),i=De(),[l,a]=Q(QB),[s,c]=Cm(null),m=FI(null),p=Yn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[d]=Q(wn),u=jB(()=>d.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:st(oF,{id:k.id,elements:k.elements}),category:"Library",order:RI("Library"),haystack:Kr(k.name),perform:()=>{o.onInsertElements(Ta([k]))}}))||[],[o,d.libraryItems]);Sm(()=>{let{uiAppState:k,customCommandPaletteItems:_,appProps:P}=p,A=V=>{let U="";return V.label&&(typeof V.label=="function"?U=h(V.label(o.scene.getNonDeletedElements(),k,o)):U=h(V.label)),U},H=V=>typeof V.icon=="function"?V.icon(k,o.scene.getNonDeletedElements()):V.icon,F=[],Y=(V,U,D)=>{let B={label:A(V),icon:H(V),category:U,shortcut:Le(V.name),keywords:V.keywords,predicate:V.predicate,viewMode:V.viewMode,perform:()=>{i.executeAction(V,"commandPalette")}};return D?D(B,V):B};if(k&&o.scene&&i){let V=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,hs,em,Z2].map(X=>Y(X,Fe.elements,(le,pe)=>({...le,predicate:pe.predicate?pe.predicate:(de,Ee,Ve,rt)=>oe(de,Ee).length>0}))),U=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>Y(X,Fe.tools)),D=[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(X=>Y(X,Fe.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>Y(X,Fe.export));F=[...V,...D,{label:A(Sn),icon:H(Sn),shortcut:Le(Sn.name),category:Fe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Qe.set(jr,"clearCanvas")}},{label:h("buttons.exportImage"),category:Fe.export,icon:Uc,shortcut:Le("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...B];let W=[{label:h("toolBar.library"),category:Fe.app,icon:Bc,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:HI.name,tab:HI.defaultTab}})}},{label:h("search.title"),category:Fe.app,icon:Kt,viewMode:!0,perform:()=>{i.executeAction(Ps)}},{label:h("labels.shapeSwitch"),category:Fe.elements,icon:Fl,perform:()=>{i.executeAction($2)}},{label:h("labels.changeStroke"),keywords:["color","outline"],category:Fe.elements,icon:Ri,viewMode:!1,predicate:(X,le)=>{let pe=oe(X,le);return pe.length>0&&ks(le,pe)},perform:()=>{n(X=>({openPopup:"elementStroke"}))}},{label:h("labels.changeBackground"),keywords:["color","fill"],icon:Ri,category:Fe.elements,viewMode:!1,predicate:(X,le)=>{let pe=oe(X,le);return pe.length>0&&Ms(le,pe)},perform:()=>{n(X=>({openPopup:"elementBackground"}))}},{label:h("labels.canvasBackground"),keywords:["color"],icon:Ri,category:Fe.editor,viewMode:!1,perform:()=>{n(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...bm.reduce((X,le)=>{let{value:pe,icon:de,key:Ee,numericKey:Ve}=le;if(P.UIOptions.tools?.[pe]===!1)return X;let ft=Ee&&qB(typeof Ee=="string"?Ee:Ee[0])||Ve,Ct={label:h(`toolBar.${pe}`),category:Fe.tools,shortcut:ft,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:zn})=>{pe==="image"?o.setActiveTool({type:pe}):o.setActiveTool({type:pe})}};return X.push(Ct),X},[]),...U,{label:h("toolBar.lock"),category:Fe.tools,icon:k.activeTool.locked?wi:Hr,shortcut:Mo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${h("labels.textToDiagram")}...`,category:Fe.tools,icon:kE,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${h("toolBar.mermaidToHellixitboard")}...`,category:Fe.tools,icon:Fi,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],te=[...F,...W,..._||[]].map(X=>({...X,icon:X.icon||Fl,order:X.order??RI(X.category),haystack:`${Kr(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));c(te),a([...te,...u].find(X=>X.label===l?.label)??null)}},[p,o,i,c,l?.label,a,n,u]);let[b,g]=Cm(""),[x,v]=Cm(null),[y,E]=Cm({}),T=k=>{n({openDialog:null},k),g("")},I=(k,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("hellixitboard-animations-disabled"),T(()=>{k.perform({actionManager:i,event:_}),a(k),requestAnimationFrame(()=>{document.body.classList.remove("hellixitboard-animations-disabled")})}))},S=df(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,r,o):k.predicate===void 0||k.predicate),M=df(k=>{let _=JB(k.target)||OI(k)||k.key===Mo.ESCAPE;if(_&&k.key!==Mo.ARROW_UP&&k.key!==Mo.ARROW_DOWN&&k.key!==Mo.ENTER)return;let P=Object.values(y).flat(),A=l&&!b&&S(l);if(k.key===Mo.ARROW_UP){k.preventDefault();let H=P.findIndex(V=>V.label===x?.label);if(A){if(H===0){v(l);return}if(x===l){let V=P[P.length-1];V&&v(V);return}}let F;H===-1?F=P.length-1:F=H===0?P.length-1:(H-1)%P.length;let Y=P[F];Y&&v(Y);return}if(k.key===Mo.ARROW_DOWN){k.preventDefault();let H=P.findIndex(V=>V.label===x?.label);if(A){if(!x||H===P.length-1){v(l);return}if(x===l){let V=P[0];V&&v(V);return}}let F=(H+1)%P.length,Y=P[F];Y&&v(Y);return}if(k.key===Mo.ENTER&&x&&setTimeout(()=>{I(x,k)}),!_){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return Sm(()=>(window.addEventListener(km.KEYDOWN,M,{capture:!0}),()=>window.removeEventListener(km.KEYDOWN,M,{capture:!0})),[M]),Sm(()=>{if(!s)return;let k=H=>{let F={};for(let Y of H)F[Y.category]?F[Y.category].push(Y):F[Y.category]=[Y];return F},_=b?.length>1?[...s.filter(S).sort((H,F)=>H.order-F.order),...u]:s.filter(S).sort((H,F)=>H.order-F.order),P=!b&&l&&S(l);if(!b){E(k(P?_.filter(H=>H.label!==l?.label):_)),v(P?l:_[0]||null);return}let A=Kr(b.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=ZB.filter(A,_,{extract:H=>H.haystack??""}).sort((H,F)=>F.score-H.score).map(H=>H.original),E(k(_)),v(_[0]??null)},[b,s,S,l,u]),on(je,{onCloseRequest:()=>T(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[st(ar,{value:b,placeholder:h("commandPalette.search.placeholder"),onChange:k=>{g(k)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&on("div",{className:"shortcuts-wrapper",children:[st(wm,{shortcut:"\u2191\u2193",children:h("commandPalette.shortcuts.select")}),st(wm,{shortcut:"\u21B5",children:h("commandPalette.shortcuts.confirm")}),st(wm,{shortcut:N("Esc"),children:h("commandPalette.shortcuts.close")})]}),on("div",{className:"commands",children:[l&&!b&&on("div",{className:"command-category",children:[on("div",{className:"command-category-title",children:[h("commandPalette.recents"),st("div",{className:"icon",style:{marginLeft:"6px"},children:ME})]}),st(NI,{command:l,isSelected:l.label===x?.label,onClick:k=>I(l,k),disabled:!S(l),onMouseMove:()=>v(l),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(y).length>0?Object.keys(y).map((k,_)=>on("div",{className:"command-category",children:[st("div",{className:"command-category-title",children:k}),y[k].map(P=>st(NI,{command:P,isSelected:P.label===x?.label,onClick:A=>I(P,A),onMouseMove:()=>v(P),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:k==="Library"?"large":"small"},P.label))]},k)):s?on("div",{className:"no-match",children:[st("div",{className:"icon",children:Kt})," ",h("commandPalette.search.noMatch")]}):null]})]})}var oF=({id:e,elements:o})=>{let t=FI(null),{svgCache:n}=Ea();return tm(e,o,n,t),st("div",{className:"library-item-icon",ref:t})},NI=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:l,size:a="small"})=>{let s=()=>{};return on("div",{className:BI("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":a==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?h("commandPalette.itemNotAvailable"):"",children:[on("div",{className:"name",children:[e.icon&&st($o,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(l,[]):e.icon}),st(Zl,{children:e.label})]}),i&&e.shortcut&&st(wm,{shortcut:e.shortcut})]})};import{getSizeFromPoints as mIe,randomInteger as i8,getUpdatedTimestamp as a8}from"@hellixit/common";import{simplify as YF}from"points-on-curve";import{getStroke as VF}from"perfect-freehand";import{pointsOnBezierCurves as Jbe}from"points-on-curve";import{invariant as exe}from"@hellixit/common";import{curve as oxe,lineSegment as nxe,pointFrom as rxe,pointDistance as ixe,pointFromArray as axe,pointFromVector as lxe,pointRotateRads as sxe,polygon as cxe,polygonFromPoints as dxe,PRECISION as mxe,segmentsIntersectAt as pxe,vector as uxe,vectorAdd as hxe,vectorFromPoint as gxe,vectorScale as fxe}from"@hellixit/math";import{getElementAbsoluteCoords as xxe}from"@hellixit/element";var pf=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as XF,pointDistance as nC,pointRotateRads as jTe}from"@hellixit/math";import{ROUGHNESS as KF,THEME as Af,isTransparent as Hs,assertNever as $F,COLOR_PALETTE as ZF,LINE_POLYGON_POINT_MERGE_DISTANCE as JTe,applyDarkModeFilter as Rs}from"@hellixit/common";import{RoughGenerator as jF}from"roughjs/bin/generator";import aTe from"roughjs/bin/rough";import{isRightAngleRads as sTe,lineSegment as cTe,pointFrom as dTe,pointRotateRads as mTe}from"@hellixit/math";import{BOUND_TEXT_PADDING as uTe,DEFAULT_REDUCED_GLOBAL_ALPHA as hTe,ELEMENT_READY_TO_ERASE_OPACITY as gTe,FRAME_STYLE as fTe,DARK_THEME_FILTER as bTe,MIME_TYPES as tC,THEME as xTe,distance as yTe,getFontString as ETe,isRTL as vTe,getVerticalOffset as TTe,invariant as ITe,applyDarkModeFilter as CTe,isSafari as STe}from"@hellixit/common";import xve from"roughjs/bin/rough";import{arrayToMap as Eve,invariant as $I,rescalePoints as vve,sizeOf as Tve}from"@hellixit/common";import{degreesToRadians as Cf,lineSegment as Cve,pointDistance as Sve,pointFrom as ht,pointFromArray as CF,pointRotateRads as _a}from"@hellixit/math";import{pointsOnBezierCurves as Mve}from"points-on-curve";import{pointCenter as D1e,pointFrom as H1e,pointRotateRads as R1e,pointsEqual as N1e,pointDistance as B1e,vectorFromPoint as F1e,curveLength as O1e,curvePointAtLength as z1e}from"@hellixit/math";import{DRAGGING_THRESHOLD as W1e,KEYS as Y1e,shouldRotateWithDiscreteAngle as V1e,getGridPoint as X1e,invariant as K1e,isShallowEqual as $1e,getFeatureFlag as Z1e}from"@hellixit/common";import{deconstructLinearOrFreeDrawElement as q1e,getSnapOutlineMidPoint as J1e,isPathALoop as Q1e,moveArrowAboveBindable as eve,projectFixedPointOntoDiagonal as tve}from"@hellixit/element";import{arrayToMap as HEe,getFeatureFlag as REe,invariant as NEe,isTransparent as BEe}from"@hellixit/common";import{PRECISION as OEe,clamp as zEe,lineSegment as GEe,pointDistance as UEe,pointDistanceSq as WEe,pointFrom as YEe,pointFromVector as VEe,pointRotateRads as XEe,pointsEqual as KEe,vectorFromPoint as $Ee,vectorNormalize as ZEe,vectorScale as jEe}from"@hellixit/math";import{invariant as a0e,isTransparent as l0e}from"@hellixit/common";import{curveIntersectLineSegment as c0e,isPointWithinBounds as d0e,lineSegment as m0e,lineSegmentIntersectionPoints as p0e,pointFrom as u0e,pointFromVector as h0e,pointRotateRads as g0e,pointsEqual as f0e,vectorFromPoint as b0e,vectorNormalize as x0e,vectorScale as y0e}from"@hellixit/math";import{ellipse as v0e,ellipseSegmentInterceptPoints as T0e}from"@hellixit/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as iF,DEFAULT_PROPORTIONAL_RADIUS as hf,invariant as Pxe,LINE_CONFIRM_THRESHOLD as aF,ROUNDNESS as gf}from"@hellixit/common";import{bezierEquation as Lxe,curve as _xe,curveCatmullRomCubicApproxPoints as Dxe,curveOffsetPoints as Hxe,lineSegment as Rxe,lineSegmentIntersectionPoints as Nxe,pointDistance as lF,pointFrom as Bxe,pointFromArray as Fxe,pointFromVector as Oxe,pointRotateRads as zxe,pointTranslate as Gxe,rectangle as Uxe,vectorFromPoint as Wxe,vectorNormalize as Yxe,vectorScale as Vxe}from"@hellixit/math";import{ROUNDNESS as Txe,assertNever as Ixe}from"@hellixit/common";import{pointsEqual as Sxe}from"@hellixit/math";var zI=e=>!!e&&e.type==="embeddable",GI=e=>!!e&&e.type==="iframe",uf=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),qr=e=>e!=null&&e.type==="text";var Mm=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Jr=e=>e!=null&&nF(e.type);var Qr=e=>e!=null&&e.type==="arrow",As=e=>Qr(e)&&e.elbowed;var nF=e=>e==="arrow"||e==="line";var Ma=e=>e!==null&&"containerId"in e&&e.containerId!==null&&qr(e);var Pm=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return lF(t,n)<=aF/o}return!1},Ls=(e,o)=>{if(o.roundness?.type===gf.PROPORTIONAL_RADIUS||o.roundness?.type===gf.LEGACY)return e*hf;if(o.roundness?.type===gf.ADAPTIVE_RADIUS){let t=o.roundness?.value??iF,n=t/hf;return e<=n?e*hf:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Pye,ARROW_LABEL_WIDTH_FRACTION as Aye,BOUND_TEXT_PADDING as Lye,DEFAULT_FONT_SIZE as _ye,TEXT_ALIGN as Dye,VERTICAL_ALIGN as Hye,getFontString as Rye,isProdEnv as Nye,invariant as Bye}from"@hellixit/common";import{pointFrom as Oye,pointRotateRads as zye}from"@hellixit/math";import{BOUND_TEXT_PADDING as aye,DEFAULT_FONT_SIZE as lye,DEFAULT_FONT_FAMILY as sye,getFontString as cye,isTestEnv as dye,normalizeEOL as mye}from"@hellixit/common";var pye="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as yye,isTestEnv as Eye}from"@hellixit/common";import{curvePointDistance as Zye,distanceToLineSegment as jye,pointRotateRads as qye}from"@hellixit/math";import{ellipse as Qye,ellipseDistanceFromPoint as e0e}from"@hellixit/math/ellipse";import{invariant as N0e,isDevEnv as B0e,isTestEnv as F0e}from"@hellixit/common";import{pointFrom as z0e,pointFromVector as G0e,pointRotateRads as U0e,pointScaleFromOrigin as W0e,pointsEqual as Y0e,triangleIncludesPoint as V0e,vectorCross as X0e,vectorFromPoint as bF,vectorScale as K0e}from"@hellixit/math";var Tf=[1,0],YI=[0,1],If=[-1,0],VI=[0,-1],_m=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Tf:o<=-r?If:t>n?YI:VI},XI=(e,o)=>_m(bF(e,o)),Dm=(e,o)=>Hm(XI(e,o)),vf=(e,o)=>e[0]===o[0]&&e[1]===o[1],Hm=e=>vf(e,Tf)||vf(e,If);import{clamp as Q0e,pointDistance as eEe,pointFrom as tEe,pointScaleFromOrigin as oEe,pointsEqual as nEe,pointTranslate as rEe,vector as iEe,vectorCross as aEe,vectorFromPoint as lEe,vectorScale as sEe}from"@hellixit/math";import{BinaryHeap as dEe,invariant as mEe,isAnyTrue as pEe,getSizeFromPoints as uEe,isDevEnv as hEe,arrayToMap as gEe}from"@hellixit/common";var s1e=10/1.5;import{SHIFT_LOCKING_ANGLE as u1e,viewportCoordsToSceneCoords as h1e}from"@hellixit/common";import{normalizeRadians as f1e,radiansBetweenAngles as b1e,radiansDifference as x1e}from"@hellixit/math";import{pointsEqual as E1e}from"@hellixit/math";var Am=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,l=e.height;return[o,t,n,r,i,l,0,r]};var SF=20,wF=15,kF=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return wF;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return SF;default:return 15}},MF=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,o,t,n,r=0)=>{if(n===null||o.length<1)return null;let i=pf(o[0]);if(i.length<1)return null;let l=t==="start"?1:i.length-1,a=i[l].data;$I(a.length===6,"Op data length is not 6");let s=ht(a[4],a[5]),c=ht(a[2],a[3]),m=ht(a[0],a[1]),p=i[l-1],d=ht(0,0);if(p.op==="move"){let B=CF(p.data);$I(B!=null,"Op data is not a point"),d=B}else p.op==="bcurveTo"&&(d=ht(p.data[4],p.data[5]));let u=(B,W)=>Math.pow(1-B,3)*s[W]+3*B*Math.pow(1-B,2)*c[W]+3*Math.pow(B,2)*(1-B)*m[W]+d[W]*Math.pow(B,3),[b,g]=t==="start"?d:s,[x,v]=[u(.3,0),u(.3,1)],y=Math.hypot(b-x,g-v),E=(b-x)/y,T=(g-v)/y,I=kF(n),S=0;{let[B,W]=t==="end"?e.points[e.points.length-1]:e.points[0],[te,X]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];S=Math.hypot(B-te,W-X)}let k=Math.min(I,S*(n==="diamond"||n==="diamond_outline"?.25:.5)),_=b-E*k*r,P=g-T*k*r,A=_-E*k,H=P-T*k;if(n==="circle"||n==="circle_outline"){let B=Math.hypot(H-P,A-_)+e.strokeWidth-2;return[_,P,B]}let F=MF(n);if(n==="cardinality_many"||n==="cardinality_one_or_many"){let[B,W]=_a(ht(_,P),ht(A,H),Cf(-F)),[te,X]=_a(ht(_,P),ht(A,H),Cf(F));return[A,H,B,W,te,X]}let[Y,V]=_a(ht(A,H),ht(_,P),-F*Math.PI/180),[U,D]=_a(ht(A,H),ht(_,P),Cf(F));if(n==="diamond"||n==="diamond_outline"){let B,W;if(t==="start"){let[te,X]=e.points.length>1?e.points[1]:[0,0];[B,W]=_a(ht(_+k*2,P),ht(_,P),Math.atan2(X-P,te-_))}else{let[te,X]=e.points.length>1?e.points[e.points.length-2]:[0,0];[B,W]=_a(ht(_-k*2,P),ht(_,P),Math.atan2(P-X,_-te))}return[_,P,Y,V,B,W,U,D]}return[_,P,Y,V,U,D]};import{pointFrom as Uve,pointCenter as Wve,pointRotateRads as Yve,vectorFromPoint as Vve,vectorNormalize as Xve,vectorSubtract as Kve,vectorAdd as $ve,vectorScale as Zve,pointFromVector as jve,clamp as qve,isCloseTo as Jve}from"@hellixit/math";import{arrayToMap as F2e}from"@hellixit/common";import{isPointWithinBounds as z2e,pointFrom as G2e}from"@hellixit/math";import{vectorCross as n2e,vectorFromPoint as r2e}from"@hellixit/math";import{arrayToMap as PF}from"@hellixit/common";import{getElementBounds as AF}from"@hellixit/element";import{isArrowElement as LF,isHellixitboardElement as _F,isFreeDrawElement as DF,isLinearElement as HF,isTextElement as RF}from"@hellixit/element";import{rangeIncludesValue as Rm,pointFrom as Pn,pointRotateRads as NF,rangeInclusive as Nm}from"@hellixit/math";var BF=e=>e.type==="diamond"?[Pn(e.width/2,0),Pn(e.width,e.height/2),Pn(e.width/2,e.height),Pn(0,e.height/2)]:[Pn(0,0),Pn(0+e.width,0),Pn(0+e.width,e.height),Pn(0,e.height)],FF=e=>HF(e)||DF(e)?e.points:BF(e),jI=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},qI=e=>{let o=FF(e),{cx:t,cy:n}=jI(o),r=Pn(t,n),i=o.map(m=>NF(m,r,e.angle)),{minX:l,minY:a,maxX:s,maxY:c}=jI(i);return[l+e.x,a+e.y,s+e.x,c+e.y]},Sf=(e,o,t=!1)=>{let n=qI(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},JI=(e,o)=>{let t=qI(e);return(Rm(t[0],Nm(o[0],o[2]))||Rm(o[0],Nm(t[0],t[2])))&&(Rm(t[1],Nm(o[1],o[3]))||Rm(o[1],Nm(t[1],t[3])))},QI=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{_F(o)&&(o=AF(o,PF(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let l of e){if(i.has(l.id))continue;if(t==="overlap"?JI(l,r):t==="inside"?Sf(l,r):Sf(l,r,!0)){if(i.add(l.id),l.boundElements)for(let s of l.boundElements)i.add(s.id);RF(l)&&l.containerId&&i.add(l.containerId),LF(l)&&(l.startBinding&&i.add(l.startBinding.elementId),l.endBinding&&i.add(l.endBinding?.elementId))}}return e.filter(l=>i.has(l.id))};import{arrayToMap as E2e,isShallowEqual as zF}from"@hellixit/common";var OF=function(){let e=null,o=null,t=null,n=(i,l,a,s)=>{if(t!==void 0&&l===o&&i===e&&a.editingGroupId===t?.editingGroupId)return t;let c={};for(let d of i){let u=d.groupIds;if(a.editingGroupId){let b=u.indexOf(a.editingGroupId);b>-1&&(u=u.slice(0,b))}if(u.length>0){let b=u[u.length-1];c[b]=!0}}let m={},p=l.reduce((d,u)=>{if(u.isDeleted)return d;let b=u.groupIds.find(g=>c[g]);return b&&(d[u.id]=!0,Array.isArray(m[b])?m[b].push(u.id):m[b]=[u.id]),d},{});for(let d of Object.keys(m))m[d].length<2&&c[d]&&(c[d]=!1);return o=l,e=i,t={editingGroupId:a.editingGroupId,selectedGroupIds:c,selectedElementIds:wf({...a.selectedElementIds,...p},s)},t},r=(i,l,a,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:l}):kf(l,i);return c.length?n(c,l,i,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:wf(i.selectedElementIds,a)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var k2e=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(l=>i.selectedElementIds[l.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),kf=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&Ma(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(l=>{Mm(l)&&eC(e,l.id).forEach(a=>!n.has(a.id)&&i.push(a)),i.push(l)}),i}return r};var wf=(e,o)=>zF(o.selectedElementIds,e)?o.selectedElementIds:e;var eC=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var UF=typeof document<"u"?document.createElement("img"):{src:""};UF.src=`data:${tC.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>')}`;var WF=typeof document<"u"?document.createElement("img"):{src:""};WF.src=`data:${tC.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>')}`;var Mf=new WeakMap;var oC=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var Ot=class Ot{};w(Ot,"rg",new jF),w(Ot,"cache",new WeakMap),w(Ot,"get",(o,t)=>{let n=Ot.cache.get(o);if(n&&(t===null||n.theme===t))return n.shape}),w(Ot,"delete",o=>{Ot.cache.delete(o),Mf.delete(o)}),w(Ot,"destroy",()=>{Ot.cache=new WeakMap}),w(Ot,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:Ot.get(o,t?t.theme:null);if(n!==void 0)return n;Mf.delete(o);let r=QF(o,Ot.rg,t||{isExporting:!1,canvasBackgroundColor:ZF.white,embedsValidationStatus:null,theme:Af.LIGHT});return t?.isExporting||Ot.cache.set(o,{shape:r,theme:t?.theme||Af.LIGHT}),r});var La=Ot,qF=e=>[8,8+e],lC=e=>[1.5,6+e];function JF(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&oC(e.type)||Jr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Mn=(e,o=!1,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?qF(e.strokeWidth):e.strokeStyle==="dotted"?lC(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:JF(e),stroke:t?Rs(e.strokeColor):e.strokeColor,preserveVertices:o||e.roughness<KF.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=Hs(e.backgroundColor)?void 0:t?Rs(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return Pm(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:t?Rs(e.backgroundColor):e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},rC=(e,o,t)=>uf(e)&&(o||zI(e)&&t?.get(e.id)!==!0)&&Hs(e.backgroundColor)&&Hs(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:GI(e)?{...e,strokeColor:Hs(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Hs(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ds=(e,o,t)=>{if(o===null)return[];let[,,n,r,i,l]=o;return[e.line(n,r,i,l,t)]},Bm=(e,o,t)=>{if(o===null)return[];let[n,r,i,l,a,s]=o;return[e.line(i,l,n,r,t),e.line(a,s,n,r,t)]},ei=(e,o)=>{let t={...o};if(e.strokeStyle==="dotted"){let n=lC(e.strokeWidth-1);t.strokeLineDash=[n[0],n[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Pf=(e,o,t,n,r,i=1)=>{if(n===null)return[];let[l,a,s]=n,c={...o,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,o.roughness||0)};return delete c.strokeLineDash,[e.circle(l,a,s*i,c)]},iC=(e,o,t,n,r,i,l,a)=>{if(n===null)return[];let s=a?Rs(e.strokeColor):e.strokeColor,c=a?Rs(l):l,m=-.25,p=.8;switch(n){case"circle":case"circle_outline":return Pf(r,i,s,At(e,o,t,n),n==="circle_outline"?c:s);case"triangle":case"triangle_outline":{let d=At(e,o,t,n);if(d===null)return[];let[u,b,g,x,v,y]=d,E={...i,fill:n==="triangle_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete E.strokeLineDash,[r.polygon([[u,b],[g,x],[v,y],[u,b]],E)]}case"diamond":case"diamond_outline":{let d=At(e,o,t,n);if(d===null)return[];let[u,b,g,x,v,y,E,T]=d,I={...i,fill:n==="diamond_outline"?c:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete I.strokeLineDash,[r.polygon([[u,b],[g,x],[v,y],[E,T],[u,b]],I)]}case"cardinality_one":return Ds(r,At(e,o,t,n),ei(e,i));case"cardinality_many":return Bm(r,At(e,o,t,n),ei(e,i));case"cardinality_one_or_many":{let d=ei(e,i);return[...Bm(r,At(e,o,t,"cardinality_many"),d),...Ds(r,At(e,o,t,"cardinality_one",m),d)]}case"cardinality_exactly_one":{let d=ei(e,i);return[...Ds(r,At(e,o,t,"cardinality_one",-.5),d),...Ds(r,At(e,o,t,"cardinality_one"),d)]}case"cardinality_zero_or_one":{let d=ei(e,i);return[...Pf(r,i,s,At(e,o,t,"circle_outline",1.5),c,p),...Ds(r,At(e,o,t,"cardinality_one",-.5),d)]}case"cardinality_zero_or_many":{let d=ei(e,i);return[...Bm(r,At(e,o,t,"cardinality_many"),d),...Pf(r,i,s,At(e,o,t,"circle_outline",1.5),c,p)]}case"bar":case"arrow":default:return Bm(r,At(e,o,t,n),ei(e,i))}};var QF=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i})=>{let l=i===Af.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let a;if(e.roundness){let s=e.width,c=e.height,m=Ls(Math.min(s,c),e);a=o.path(`M ${m} 0 L ${s-m} 0 Q ${s} 0, ${s} ${m} L ${s} ${c-m} Q ${s} ${c}, ${s-m} ${c} L ${m} ${c} Q 0 ${c}, 0 ${c-m} L 0 ${m} Q 0 0, ${m} 0`,Mn(rC(e,t,r),!0,l))}else a=o.rectangle(0,0,e.width,e.height,Mn(rC(e,t,r),!1,l));return a}case"diamond":{let a,[s,c,m,p,d,u,b,g]=Am(e);if(e.roundness){let x=Ls(Math.abs(s-b),e),v=Ls(Math.abs(p-c),e);a=o.path(`M ${s+x} ${c+v} L ${m-x} ${p-v}
6
6
  C ${m} ${p}, ${m} ${p}, ${m-x} ${p+v}
7
7
  L ${d+x} ${u-v}
8
8
  C ${d} ${u}, ${d} ${u}, ${d-x} ${u-v}
9
9
  L ${b+x} ${g+v}
10
10
  C ${b} ${g}, ${b} ${g}, ${b+x} ${g-v}
11
11
  L ${s-x} ${c+v}
12
- C ${s} ${c}, ${s} ${c}, ${s+x} ${c+v}`,Mn(e,!0,l))}else a=o.polygon([[s,c],[m,p],[d,u],[b,g]],Mn(e,!1,l));return a}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Mn(e,!1,l));case"line":case"arrow":{let a,s=Mn(e,!1,l),c=e.points.length?e.points:[XF(0,0)];if(As(e)?c.every(m=>Math.abs(m[0])<=1e6&&Math.abs(m[1])<=1e6)?a=[o.path(e8(c,16),Mn(e,!0,l))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),a=[]):e.roundness?a=[o.curve(c,s)]:s.fill?a=[o.polygon(c,s)]:a=[o.linearPath(c,s)],e.type==="arrow"){let{startArrowhead:m=null,endArrowhead:p="arrow"}=e;if(m!==null){let d=iw(e,a,"start",m,o,s,n,l);a.push(...d)}if(p!==null){let d=iw(e,a,"end",p,o,s,n,l);a.push(...d)}}return a}case"freedraw":{let a=[];if(Pm(e.points)){let s=YF(e.points,.75);a.push(o.curve(s,{...Mn(e,!1,l),stroke:"none"}))}return a.push(t8(e)),a}case"frame":case"magicframe":case"text":case"image":return null;default:return $F(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},e8=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],l=e[r+1],a=e[r],s=Dm(a,i),c=Dm(l,a),m=Math.min(o,nw(e[r],l)/2,nw(e[r],i)/2);s?i[0]<a[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<a[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),c?l[0]<a[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):l[1]<a[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var t8=e=>r8(o8(e)),o8=e=>{let o=e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]];return VF(o,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:t=>Math.sin(t*Math.PI/2),last:!0})},aw=(e,o)=>[(e[0]+o[0])/2,(e[1]+o[1])/2],n8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,r8=e=>{if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,aw(n,i[0]),"L",i[0],"Z"):t.push(n,aw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(n8,"$1")};var sw=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??i8(),updated:a8()}};import{jsx as dw}from"react/jsx-runtime";var Ha=O({name:"toggleLinearEditor",category:Fe.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&s8(r[0])&&!l8(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Lf(r,"No selected element found"),Lf(o.selectedLinearElement,"No selected linear element found"),Lf(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:cw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=h(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return dw(J,{type:"button",icon:UE,title:r,"aria-label":r,onClick:()=>o(null)})}}),kIe=O({name:"togglePolygon",category:Fe.elements,icon:Cu,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Da(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Da(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Da(s)))return!1;let i=r,l=i.some(s=>!s.polygon),a=c8(i);return{elements:e.map(s=>!a.has(s.id)||!Da(s)?s:sw(s,{backgroundColor:l?s.backgroundColor:"transparent",...d8(s,l)})),appState:o,captureUpdate:cw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(l=>!Da(l)||!l.polygon||l.points.length<3))return null;let r=n.every(l=>Da(l)&&l.polygon),i=h(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return dw(Vi,{icon:Cu,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as mw,CANVAS_SEARCH_TAB as pw,CLASSES as m8,DEFAULT_SIDEBAR as uw}from"@excalidraw/common";import{CaptureUpdateAction as p8}from"@excalidraw/element";var Ps=O({name:"searchMenu",icon:Kt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===uw.name&&o.openSidebar.tab===pw){let r=n.hellixitboardContainerValue.container?.querySelector(`.${m8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:uw.name,tab:pw},openDialog:null},captureUpdate:p8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[mw.CTRL_OR_CMD]&&e.key===mw.F});import{isImageElement as u8}from"@excalidraw/element";import{CaptureUpdateAction as h8}from"@excalidraw/element";import{jsx as g8}from"react/jsx-runtime";var _f=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Xu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:h8.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&u8(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=h("helpDialog.cropStart");return g8(J,{type:"button",icon:Xu,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as f8}from"@excalidraw/element";import{mutateElement as b8}from"@excalidraw/element";import{newFrameElement as x8}from"@excalidraw/element";import{isFrameLikeElement as Fm}from"@excalidraw/element";import{addElementsToFrame as y8,removeAllElementsFromFrame as E8}from"@excalidraw/element";import{getFrameChildren as v8}from"@excalidraw/element";import{KEYS as hw,updateActiveTool as gw}from"@excalidraw/common";import{getElementsInGroup as T8}from"@excalidraw/element";import{getCommonBounds as I8}from"@excalidraw/element";import{CaptureUpdateAction as ti}from"@excalidraw/element";var fw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Fm(t[0])},bw=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(Fm(r)){let i=v8(f8(e),r.id).filter(l=>!(l.type==="text"&&l.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((l,a)=>(l[a.id]=!0,l),{})},captureUpdate:ti.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:ti.EVENTUALLY}},predicate:(e,o,t,n)=>fw(o,n)}),xw=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return Fm(r)?{elements:E8(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:ti.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:ti.EVENTUALLY}},predicate:(e,o,t,n)=>fw(o,n)}),Fwe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:ti.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Owe=O({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:yo,viewMode:!1,perform:(e,o,t,n)=>{let r=gw(o,{type:"frame"});return jt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:gw(o,{type:"frame"})},captureUpdate:ti.EVENTUALLY}},keyTest:e=>!e[hw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===hw.F}),yw=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=oe(e,o);return r.length>0&&!r.some(i=>Fm(i))},perform:(e,o,t,n)=>{let r=oe(e,o),i=n.scene.getNonDeletedElementsMap(),[l,a,s,c]=I8(r,i),m=16,p=x8({x:l-m,y:a-m,width:s-l+m*2,height:c-a+m*2});if(o.editingGroupId){let u=T8(r,o.editingGroupId);for(let b of u){let g=b.groupIds.indexOf(o.editingGroupId);b8(b,i,{groupIds:b.groupIds.slice(0,g)})}}return{elements:y8([...n.scene.getElementsIncludingDeleted(),p],r,p,o),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:ti.IMMEDIATELY}}});import{isWindows as A8,KEYS as Bs,matchKey as Rf,arrayToMap as Ew,MOBILE_ACTION_BUTTON_BG as vw}from"@excalidraw/common";import{CaptureUpdateAction as Hf}from"@excalidraw/element";import{orderByFractionalIndex as L8}from"@excalidraw/element";import{Emitter as w8}from"@excalidraw/common";import{CaptureUpdateAction as C8,StoreChange as S8,StoreDelta as k8}from"@excalidraw/element";var Ra=class extends k8{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[l,a]=this.appState.applyTo(t,r);return[r,l,i||a]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},oi=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Ns=class e{constructor(o){this.store=o;S(this,"onHistoryChangedEmitter",new w8);S(this,"undoStack",[]);S(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Ra)return;let t=Ra.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new oi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let l=C8.IMMEDIATELY,a=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=i.applyTo(s,c,a);let p=a.elements,d=a.maybeClone(l,s,c),u=S8.create(a,d),b=Ra.applyLatestChanges(i,p,s);b.isEmpty()||(this.store.scheduleMicroAction({action:l,change:u,delta:b}),i=b),a=d}finally{r(i)}if(m)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new oi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=Ra.inverse(t);return o.push(n)}};import{useEffect as M8,useState as P8}from"react";var Df=(e,o)=>{let[t,n]=P8(o);return M8(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as Cw}from"react/jsx-runtime";var Tw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:Hf.EVENTUALLY};let[r,i]=n,l=L8(Array.from(r.values()));return{appState:i,elements:l,captureUpdate:Hf.NEVER}}return{captureUpdate:Hf.EVENTUALLY}},Iw=e=>({name:"undo",label:"buttons.undo",icon:Mu,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Tw(r,t,()=>e.undo(Ew(o),t)),keyTest:o=>o[Bs.CTRL_OR_CMD]&&Rf(o,Bs.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isUndoStackEmpty:i}=Df(e.onHistoryChangedEmitter,new oi(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=at()==="mobile";return Cw(J,{type:"button",icon:Mu,"aria-label":h("buttons.undo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...l?vw:{}}})}}),ww=e=>({name:"redo",label:"buttons.redo",icon:Pu,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Tw(r,t,()=>e.redo(Ew(o),t)),keyTest:o=>o[Bs.CTRL_OR_CMD]&&o.shiftKey&&Rf(o,Bs.Z)||A8&&o.ctrlKey&&!o.shiftKey&&Rf(o,Bs.Y),PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isRedoStackEmpty:i}=Df(e.onHistoryChangedEmitter,new oi(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=at()==="mobile";return Cw(J,{type:"button",icon:Pu,"aria-label":h("buttons.redo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...l?vw:{}}})}});import{getFontString as _8}from"@excalidraw/common";import{newElementWith as D8}from"@excalidraw/element";import{measureText as H8}from"@excalidraw/element";import{isTextElement as Sw}from"@excalidraw/element";import{CaptureUpdateAction as R8}from"@excalidraw/element";var kw=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=oe(e,o);return r.length===1&&Sw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=oe(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&Sw(i)){let l=H8(i.originalText,_8(i),i.lineHeight);return D8(i,{autoResize:!0,width:l.width,height:l.height,text:i.originalText})}return i}),captureUpdate:R8.IMMEDIATELY}}});import{isPromiseLike as N8}from"@excalidraw/common";import{jsx as B8}from"react/jsx-runtime";var Nf=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&ce(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(l){console.error("error while logging action:",l)}},Om=class{constructor(o,t,n,r){S(this,"actions",{});S(this,"updater");S(this,"getAppState");S(this,"getElementsIncludingDeleted");S(this,"app");S(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let l=this.getElementsIncludingDeleted(),a=this.getAppState(),s=c=>{Nf(r,"ui",a,l,this.app,c),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return B8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});S(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(N8(i))i.then(l=>o(l));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),l=this.getAppState(),a=null;return Nf(r,"keyboard",l,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,l,a,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Nf(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var zm=class{constructor(){S(this,"targets",new WeakMap);S(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Bf=e=>{let o=Array.from(e.values());return{x:Mw(o,t=>t.x)/o.length,y:Mw(o,t=>t.y)/o.length}},Ff=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Mw=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as Z,pointRotateRads as sr,rangeInclusive as ro,rangeIntersection as Gm,rangesOverlap as Um}from"@excalidraw/math";import{TOOL_TYPE as ni,KEYS as Pw}from"@excalidraw/common";import{getCommonBounds as Of,getDraggedElementsBounds as zf,getElementAbsoluteCoords as F8}from"@excalidraw/element";import{isBoundToContainer as Dw}from"@excalidraw/element";import{getMaximumGroups as Hw}from"@excalidraw/element";import{getSelectedElements as O8,getVisibleAndNonSelectedElements as Rw}from"@excalidraw/element";var z8=8,Aw=99999,Wm=e=>z8/e,Lt=class Lt{};S(Lt,"referenceSnapPoints",null),S(Lt,"visibleGaps",null),S(Lt,"setReferenceSnapPoints",o=>{Lt.referenceSnapPoints=o}),S(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),S(Lt,"setVisibleGaps",o=>{Lt.visibleGaps=o}),S(Lt,"getVisibleGaps",()=>Lt.visibleGaps),S(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var io=Lt,cr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,An=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[Pw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[Pw.CTRL_OR_CMD]&&!cr(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},G8=(e,o,t=.01)=>Math.abs(e-o)<=t,Fs=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let l=e[0],[a,s,c,m,p,d]=F8(l,o);r&&(a+=r.x,c+=r.x,p+=r.x,s+=r.y,m+=r.y,d+=r.y);let u=(c-a)/2,b=(m-s)/2;if((l.type==="diamond"||l.type==="ellipse")&&!n){let g=sr(Z(a,s+b),Z(p,d),l.angle),x=sr(Z(a+u,s),Z(p,d),l.angle),v=sr(Z(c,s+b),Z(p,d),l.angle),y=sr(Z(a+u,m),Z(p,d),l.angle),E=Z(p,d);i=t?[g,x,v,y]:[g,x,v,y,E]}else{let g=sr(Z(a,s),Z(p,d),l.angle),x=sr(Z(c,s),Z(p,d),l.angle),v=sr(Z(a,m),Z(p,d),l.angle),y=sr(Z(c,m),Z(p,d),l.angle),E=Z(p,d);i=t?[g,x,v,y]:[g,x,v,y,E]}}else if(e.length>1){let[l,a,s,c]=zf(e,r??{x:0,y:0}),m=s-l,p=c-a,d=Z(l,a),u=Z(s,a),b=Z(l,c),g=Z(s,c),x=Z(l+m/2,a+p/2);i=t?[d,u,b,g]:[d,u,b,g,x]}return i.map(l=>Z(Ue(l[0]),Ue(l[1])))},Nw=(e,o,t,n)=>Rw(e,o,t,n),Bw=(e,o,t,n)=>{let r=Nw(e,o,t,n),i=Hw(r,n).filter(p=>!(p.length===1&&Dw(p[0]))).map(p=>Of(p).map(d=>Ue(d))),l=i.sort((p,d)=>p[0]-d[0]),a=[],s=0;e:for(let p=0;p<l.length;p++){let d=l[p];for(let u=p+1;u<l.length;u++){if(++s>Aw)break e;let b=l[u],[,g,x,v]=d,[y,E,,T]=b;x<y&&Um(ro(g,v),ro(E,T))&&a.push({startBounds:d,endBounds:b,startSide:[Z(x,g),Z(x,v)],endSide:[Z(y,E),Z(y,T)],length:y-x,overlap:Gm(ro(g,v),ro(E,T))})}}let c=i.sort((p,d)=>p[1]-d[1]),m=[];s=0;e:for(let p=0;p<c.length;p++){let d=c[p];for(let u=p+1;u<c.length;u++){if(++s>Aw)break e;let b=c[u],[g,,x,v]=d,[y,E,T]=b;v<E&&Um(ro(g,x),ro(y,T))&&m.push({startBounds:d,endBounds:b,startSide:[Z(g,v),Z(x,v)],endSide:[Z(y,E),Z(T,E)],length:E-v,overlap:Gm(ro(g,x),ro(y,T))})}}return{horizontalGaps:a,verticalGaps:m}},Lw=(e,o,t,n,r,i,l)=>{if(!An({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let a=io.getVisibleGaps();if(a){let{horizontalGaps:s,verticalGaps:c}=a,[m,p,d,u]=zf(e,o).map(x=>Ue(x)),b=(m+d)/2,g=(p+u)/2;for(let x of s){if(!Um(ro(p,u),x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=Ue(v-b);if(x.length>d-m&&Math.abs(y)<=l.x){Math.abs(y)<l.x&&(r.length=0),l.x=Math.abs(y);let P={type:"gap",direction:"center_horizontal",gap:x,offset:y};r.push(P);continue}let[,,T]=x.endBounds,I=m-T,C=Ue(x.length-I);if(Math.abs(C)<=l.x){Math.abs(C)<l.x&&(r.length=0),l.x=Math.abs(C);let P={type:"gap",direction:"side_right",gap:x,offset:C};r.push(P);continue}let[M,,,]=x.startBounds,k=M-d,_=Ue(k-x.length);if(Math.abs(_)<=l.x){Math.abs(_)<l.x&&(r.length=0),l.x=Math.abs(_);let P={type:"gap",direction:"side_left",gap:x,offset:_};r.push(P);continue}}for(let x of c){if(!Um(ro(m,d),x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=Ue(v-g);if(x.length>u-p&&Math.abs(y)<=l.y){Math.abs(y)<l.y&&(i.length=0),l.y=Math.abs(y);let P={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(P);continue}let[,T,,]=x.startBounds,I=T-u,C=Ue(I-x.length);if(Math.abs(C)<=l.y){Math.abs(C)<l.y&&(i.length=0),l.y=Math.abs(C);let P={type:"gap",direction:"side_top",gap:x,offset:C};i.push(P);continue}let[,,,M]=x.endBounds,k=Ue(p-M),_=x.length-k;if(Math.abs(_)<=l.y){Math.abs(_)<l.y&&(i.length=0),l.y=Math.abs(_);let P={type:"gap",direction:"side_bottom",gap:x,offset:_};i.push(P);continue}}}},Fw=(e,o,t,n)=>{let r=Nw(e,o,t,n);return Hw(r,n).filter(i=>!(i.length===1&&Dw(i[0]))).flatMap(i=>Fs(i,n))},Na=(e,o,t,n,r,i,l)=>{if(!An({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let a=io.getReferenceSnapPoints();if(a)for(let s of o)for(let c of a){let m=c[0]-s[0],p=c[1]-s[1];Math.abs(m)<=l.x&&(Math.abs(m)<l.x&&(r.length=0),r.push({type:"point",points:[s,c],offset:m}),l.x=Math.abs(m)),Math.abs(p)<=l.y&&(Math.abs(p)<l.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:p}),l.y=Math.abs(p))}},Ow=(e,o,t,n,r)=>{let i=t.state,l=O8(e,i);if(!An({app:t,event:n,selectedElements:l})||l.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Ue(o.x),o.y=Ue(o.y);let a=[],s=[],c=Wm(i.zoom.value),m={x:c,y:c},p=Fs(l,r,{dragOffset:o});Na(l,p,t,n,a,s,m),Lw(l,o,t,n,a,s,m);let d={x:a[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,a.length=0,s.length=0;let u={x:Ue(o.x+d.x),y:Ue(o.y+d.y)};Na(l,Fs(l,r,{dragOffset:u}),t,n,a,s,m),Lw(l,u,t,n,a,s,m);let b=Gf(a,s),g=W8(l,u,[...a,...s].filter(x=>x.type==="gap"));return{snapOffset:d,snapLines:[...b,...g]}},Ue=e=>Math.round(e*10**6)/10**6,_w=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},Gf=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ue(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(l=>Z(Ue(l[0]),Ue(l[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Ue(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(l=>Z(Ue(l[0]),Ue(l[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:_w(i.map(l=>Z(Number(r),l[1])).sort((l,a)=>l[1]-a[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:_w(i.map(l=>Z(l[0],Number(r))).sort((l,a)=>l[0]-a[0]))})))},U8=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Ue(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},W8=(e,o,t)=>{let[n,r,i,l]=zf(e,o),a=[];for(let s of t){let[c,m,p,d]=s.gap.startBounds,[u,b,g,x]=s.gap.endBounds,v=Gm(ro(r,l),s.gap.overlap),y=Gm(ro(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(s.gap.startSide[0][0],E),Z(n,E)]},{type:"gap",direction:"horizontal",points:[Z(i,E),Z(s.gap.endSide[0][0],E)]})}break}case"center_vertical":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,s.gap.startSide[0][1]),Z(E,r)]},{type:"gap",direction:"vertical",points:[Z(E,l),Z(E,s.gap.endSide[0][1])]})}break}case"side_right":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(p,E),Z(u,E)]},{type:"gap",direction:"horizontal",points:[Z(g,E),Z(n,E)]})}break}case"side_left":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(i,E),Z(c,E)]},{type:"gap",direction:"horizontal",points:[Z(p,E),Z(u,E)]})}break}case"side_top":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,l),Z(E,m)]},{type:"gap",direction:"vertical",points:[Z(E,d),Z(E,b)]})}break}case"side_bottom":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,d),Z(E,b)]},{type:"gap",direction:"vertical",points:[Z(E,x),Z(E,r)]})}break}}}return U8(a.map(s=>({...s,points:s.points.map(c=>Z(Ue(c[0]),Ue(c[1])))})))},Uf=(e,o,t,n,r,i)=>{if(!An({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!G8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[l,a,s,c]=Of(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(l+=r.x),i.includes("n")?a+=r.y:i.includes("s")&&(c+=r.y));let m=[];if(i)switch(i){case"e":{m.push(Z(s,a),Z(s,c));break}case"w":{m.push(Z(l,a),Z(l,c));break}case"n":{m.push(Z(l,a),Z(s,a));break}case"s":{m.push(Z(l,c),Z(s,c));break}case"ne":{m.push(Z(s,a));break}case"nw":{m.push(Z(l,a));break}case"se":{m.push(Z(s,c));break}case"sw":{m.push(Z(l,c));break}}let p=Wm(t.state.zoom.value),d={x:p,y:p},u=[],b=[];Na(o,m,t,n,u,b,d);let g={x:u[0]?.offset??0,y:b[0]?.offset??0};d.x=0,d.y=0,u.length=0,b.length=0;let[x,v,y,E]=Of(e).map(C=>Ue(C)),T=[Z(x,v),Z(x,E),Z(y,v),Z(y,E)];Na(e,T,t,n,u,b,d);let I=Gf(u,b);return{snapOffset:g,snapLines:I}},zw=(e,o,t,n,r,i)=>{if(!An({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let l=[Z(n.x+r.x,n.y+r.y)],a=Wm(o.state.zoom.value),s={x:a,y:a},c=[],m=[];Na([e],l,o,t,c,m,s);let p={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let d=Fs([e],i,{boundingBoxCorners:!0,omitCenter:!0});Na([e],d,o,t,c,m,s);let u=Gf(c,m);return{snapOffset:p,snapLines:u}},Gw=(e,o,t,n,r)=>{if(!An({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Rw(e,[],o.state,r),l=Wm(o.state.zoom.value),a={x:l,y:l},s=[],c=[];for(let m of i){let p=Fs([m],r);for(let d of p){let u=d[0]-t.x;Math.abs(u)<=Math.abs(a.x)&&(Math.abs(u)<Math.abs(a.x)&&(c.length=0),c.push({type:"pointer",points:[d,Z(d[0],t.y)],direction:"vertical"}),a.x=u);let b=d[1]-t.y;Math.abs(b)<=Math.abs(a.y)&&(Math.abs(b)<Math.abs(a.y)&&(s.length=0),s.push({type:"pointer",points:[d,Z(t.x,d[1])],direction:"horizontal"}),a.y=b)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Uw=e=>e===ni.rectangle||e===ni.ellipse||e===ni.diamond||e===ni.frame||e===ni.magicframe||e===ni.image||e===ni.text;import{isElementInViewport as Y8}from"@excalidraw/element";import{memoize as V8,toBrandedType as X8}from"@excalidraw/common";var Os=class{constructor(o){S(this,"scene");S(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:l,scrollX:a,scrollY:s,height:c,width:m})=>{let p=[];for(let d of n.values())Y8(d,m,c,{zoom:r,offsetLeft:i,offsetTop:l,scrollX:a,scrollY:s},n)&&p.push(d);return p},t=({elements:n,editingTextElement:r,newElementId:i})=>{let l=X8(new Map);for(let a of n)i!==a.id&&(!r||r.type!=="text"||a.id!==r.id)&&l.set(a.id,a);return l};return V8(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:l,scrollY:a,height:s,width:c,editingTextElement:m,newElementId:p,sceneNonce:d})=>{let u=this.scene.getNonDeletedElements(),b=t({elements:u,editingTextElement:m,newElementId:p}),g=o({elementsMap:b,zoom:n,offsetLeft:r,offsetTop:i,scrollX:l,scrollY:a,height:s,width:c});return{elementsMap:b,visibleElements:g}})})());this.scene=o}destroy(){Oy.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as K8}from"@excalidraw/common";import{getElementAbsoluteCoords as $8}from"@excalidraw/element";import{jsx as q8}from"react/jsx-runtime";var Z8=5,j8=(e,o,t)=>{let[n,r]=$8(e,t),{x:i,y:l}=K8({sceneX:n+e.width,sceneY:r},o),a=i-o.offsetLeft+10,s=l-o.offsetTop;return{x:a,y:s}},Wf=({children:e,element:o,elementsMap:t})=>{let n=Xo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=j8(o,n,t);return q8("div",{className:"hellixitboard-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:Z8},children:e})};import{DEFAULT_LASER_COLOR as tO,easeOut as Yw}from"@excalidraw/common";import{LaserPointer as J8}from"@excalidraw/laser-pointer";import{SVG_NS as Ww,getSvgPathFromStroke as Q8,sceneCoordsToViewportCoords as eO}from"@excalidraw/common";var Ln=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;S(this,"currentTrail");S(this,"pastTrails",[]);S(this,"container");S(this,"trailElement");S(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Ww,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Ww,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new J8(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,l])=>{let a=eO({sceneX:i,sceneY:l},t);return[a.x,a.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return Q8(r,!0)}};var Ym=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;S(this,"localTrail");S(this,"collabTrails",new Map);S(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Ln(o,t,{...this.getTrailOptions(),fill:()=>tO})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Yw(i),Yw(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Ln(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Xr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as oO}from"react";import{unstable_batchedUpdates as Vw}from"react-dom";import{throttleRAF as nO}from"@excalidraw/common";var We=e=>o=>{Vw(e,o)},Vm=e=>nO(o=>{Vw(e,o)}),ri=(()=>{let e;try{let t=oO.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.HELLIXITBOARD_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Hellixitboard: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Yf,KEYS as zs,CLASSES as Vf,POINTER_BUTTON as rO,THEME as iO,isWritableElement as aO,getFontString as Xw,getFontFamilyString as Kw,isTestEnv as $w,MIME_TYPES as Xf,applyDarkModeFilter as lO}from"@excalidraw/common";import{getTextFromElements as sO,originalContainerCache as cO,updateBoundElements as Zw,updateOriginalContainerCache as jw}from"@excalidraw/element";import{LinearElementEditor as dO}from"@excalidraw/element";import{bumpVersion as mO}from"@excalidraw/element";import{getBoundTextElementId as pO,getContainerElement as Kf,getTextElementAngle as uO,redrawTextBoundingBox as hO,getBoundTextMaxHeight as gO,getBoundTextMaxWidth as qw,computeContainerDimensionForBoundText as Jw,computeBoundTextPosition as fO,getBoundTextElement as bO}from"@excalidraw/element";import{getTextWidth as xO}from"@excalidraw/element";import{normalizeText as Qw}from"@excalidraw/element";import{wrapText as yO}from"@excalidraw/element";import{isArrowElement as Xm,isBoundToContainer as EO,isTextElement as eC}from"@excalidraw/element";var vO=(e,o,t,n,r,i)=>{let{zoom:l}=n,a=180*t/Math.PI,s=e*(l.value-1)/2,c=o*(l.value-1)/2;return e>r&&l.value!==1&&(s=r*(l.value-1)/2),o>i&&l.value!==1&&(c=i*(l.value-1)/2),`translate(${s}px, ${c}px) scale(${l.value}) rotate(${a}deg)`},tC=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,hellixitboardContainer:l,app:a,autoSelect:s=!0})=>{let c=(D,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let W=B.style.fontFamily.replace(/"/g,"");return Kw({fontFamily:D.fontFamily})!==W||`${D.fontSize}px`!==B.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let D=a.state,B=a.scene.getElement(e);if(!B)return;let{textAlign:W,verticalAlign:te}=B,X=a.scene.getNonDeletedElementsMap();if(B&&eC(B)){let le=B.x,pe=B.y,de=Kf(B,a.scene.getNonDeletedElementsMap()),Ee=B.width,Ve=B.height,rt=B.width,ft=B.height;if(de&&B.containerId){if(Xm(de)){let bo=dO.getBoundTextElementPosition(de,B,X);le=bo.x,pe=bo.y}let fu=c(B,d),xn;if(fu?xn=jw(de.id,de.height):(xn=cO[de.id],xn||(xn=jw(de.id,de.height))),rt=qw(de,B),ft=gO(de,B),!Xm(de)&&Ve>ft){let bo=Jw(Ve,de.type);a.scene.mutateElement(de,{height:bo}),Zw(de,a.scene);return}else if(!Xm(de)&&de.height>xn.height&&Ve<ft){let bo=Jw(Ve,de.type);a.scene.mutateElement(de,{height:bo}),Zw(de,a.scene)}else{let{x:bo,y:Tl}=fO(de,B,X);le=bo,pe=Tl}}let[wt,zn]=n(le,pe);de?Ee+=.5:(rt=(D.width-8-wt)/D.zoom.value,Ee=Math.min(Ee,rt)),Ve*=1.05;let wc=Xw(B),vl=(D.height-zn)/D.zoom.value;Object.assign(d.style,{font:wc,lineHeight:B.lineHeight,width:`${Ee}px`,height:`${Ve}px`,left:`${wt}px`,top:`${zn}px`,transform:vO(Ee,Ve,uO(B,de),D,rt,vl),textAlign:W,verticalAlign:te,color:D.theme===iO.DARK?lO(B.strokeColor):B.strokeColor,opacity:B.opacity/100,maxHeight:`${vl}px`}),d.scrollTop=0,$w()&&(d.style.fontFamily=Kw(B)),a.scene.mutateElement(B,{x:le,y:pe})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("hellixitboard-wysiwyg");let u="pre",b="normal";(EO(r)||!r.autoResize)&&(u="pre-wrap",b="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:b,whiteSpace:u,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=r.originalText,p(),o&&(d.onpaste=async D=>{let B=_v(D),W=null;if(B.has(Xf.hellixitboardClipboard)||B.has(Xf.hellixitboard)){D.preventDefault(),W=await na(D);try{let de=await Rd(W);if(de.elements){let Ee=sO(de.elements);if(Ee){let{selectionStart:Ve,selectionEnd:rt,value:ft}=d;d.value=ft.slice(0,Ve)+Ee+ft.slice(rt);let wt=Ve+Ee.length;d.selectionStart=d.selectionEnd=wt,d.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse hellixitboard clipboard data")}}W=W||await na(D);let te=W.findByType(Xf.text);if(!te)return;let X=Qw(te.value);if(!X)return;let le=Kf(r,a.scene.getNonDeletedElementsMap()),pe=Xw({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(le){let de=bO(le,a.scene.getNonDeletedElementsMap()),Ee=yO(`${d.value}${X}`,pe,qw(le,de)),Ve=xO(Ee,pe);d.style.width=`${Ve}px`}},d.oninput=()=>{let D=Qw(d.value);if(d.value!==D){let B=d.selectionStart;d.value=D,d.selectionStart=B,d.selectionEnd=B}o(d.value)}),d.onkeydown=D=>{if(!D.shiftKey&&wd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(wd),p();else if(!D.shiftKey&&Cd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(Cd),p();else if(!D.shiftKey&&Sd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(Sd),p();else if(Dh.keyTest(D))a.actionManager.executeAction(Dh);else if(Hh.keyTest(D))a.actionManager.executeAction(Hh);else if(D.key===zs.ESCAPE)D.preventDefault(),C=!0,M();else if(Yr.keyTest(D))D.preventDefault(),M(),a.actionManager.executeAction(Yr);else if(D.key===zs.ENTER&&D[zs.CTRL_OR_CMD]){if(D.preventDefault(),D.isComposing||D.keyCode===229)return;C=!0,M()}else if(D.key===zs.TAB||D[zs.CTRL_OR_CMD]&&(D.code===Yf.BRACKET_LEFT||D.code===Yf.BRACKET_RIGHT)){if(D.preventDefault(),D.isComposing)return;D.shiftKey||D.code===Yf.BRACKET_LEFT?E():y(),d.dispatchEvent(new Event("input"))}};let g=4,x=" ".repeat(g),v=new RegExp(`^ {1,${g}}`),y=()=>{let{selectionStart:D,selectionEnd:B}=d,W=T(),te=d.value;W.forEach(X=>{let le=te.slice(0,X),pe=te.slice(X);te=`${le}${x}${pe}`}),d.value=te,d.selectionStart=D+g,d.selectionEnd=B+g*W.length},E=()=>{let{selectionStart:D,selectionEnd:B}=d,W=T(),te=[],X=d.value;W.forEach(le=>{let pe=X.slice(le,le+g).match(v);if(pe){let de=X.slice(0,le),Ee=X.slice(le+pe[0].length);X=`${de}${Ee}`,te.push(le)}}),d.value=X,te.length&&(D>te[te.length-1]?d.selectionStart=Math.max(D-g,te[te.length-1]):d.selectionStart=D,d.selectionEnd=Math.max(d.selectionStart,B-g*te.length))},T=()=>{let{selectionStart:D,selectionEnd:B,value:W}=d,te=W.slice(0,D).match(/[^\n]*$/)[0].length;return D=D-te,W.slice(D,B).split(`
13
- `).reduce((le,pe,de,Ee)=>le.concat(de?le[de-1]+Ee[de-1].length+1:D),[]).reverse()},I=D=>{D.target instanceof HTMLCanvasElement&&(D.preventDefault(),D.stopPropagation())},C=!1,M=()=>{if(V)return;V=!0,k();let D=a.scene.getElement(r.id);if(!D)return;let B=Kf(D,a.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let W=pO(B);!W||W!==r.id?a.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:r.id})}):Xm(B)&&mO(B)}else a.scene.mutateElement(B,{boundElements:B.boundElements?.filter(W=>!eC(W))});hO(D,B,a.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},k=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,U&&U.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",I,!0),window.removeEventListener("pointerdown",A),window.removeEventListener("pointerup",_),window.removeEventListener("blur",M),window.removeEventListener("beforeunload",M),F(),H(),Y(),d.remove()},_=D=>{window.removeEventListener("pointerup",_);let B=D?.target,W=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),te=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content"),X=(B instanceof HTMLElement||B instanceof SVGElement)&&(!!B.closest(`.${Vf.SHAPE_ACTIONS_MENU}`)||!!B.closest(".compact-shape-actions-island"));setTimeout(()=>{X||W||te||(d.onblur=M,d.focus())})},P=()=>{d.onblur=null,window.addEventListener("pointerup",_),window.addEventListener("blur",M)},A=D=>{let B=D?.target;if(D.button===rO.WHEEL){B instanceof HTMLTextAreaElement&&(D.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(D)),P();return}let W=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),te=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content");(D.target instanceof HTMLElement||D.target instanceof SVGElement)&&(D.target.closest(`.${Vf.SHAPE_ACTIONS_MENU}, .${Vf.ZOOM_ACTIONS}`)||D.target.closest(".compact-shape-actions-island"))&&!aO(D.target)||W||te?P():D.target instanceof HTMLCanvasElement&&!$w()&&requestAnimationFrame(()=>{M()})},H=a.onChangeEmitter.on(D=>{a.state.theme!==m&&p()}),F=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||d.focus()}),Y=a.onScrollChangeEmitter.on(()=>{p()}),V=!1;s&&d.select(),_();let U=null;return i&&"ResizeObserver"in window?(U=new window.ResizeObserver(()=>{p()}),U.observe(i)):window.addEventListener("resize",p),d.onpointerdown=D=>D.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",A,{capture:!0})}),window.addEventListener("beforeunload",M),l?.querySelector(".hellixitboard-textEditorContainer").appendChild(d),M};import{getGlobalCSSVariable as Km}from"@excalidraw/common";import{getCommonBounds as TO}from"@excalidraw/element";var _n=4,ao=6,oC="rgba(0,0,0,0.3)",nC=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,l,a]=TO(e),s=o/n.zoom.value,c=t/n.zoom.value,m={top:parseInt(Km("sat"))||0,bottom:parseInt(Km("sab"))||0,left:parseInt(Km("sal"))||0,right:parseInt(Km("sar"))||0},p=En().rtl,d=-n.scrollX+m.left,u=-n.scrollY+m.top,b=d+s-m.right,g=u+c-m.bottom,x=Math.min(r,d),v=Math.min(i,u),y=Math.max(l,b),E=Math.max(a,g),T=l-r,I=a-i,C=y-x,M=E-v,k=Math.max(_n*2,m.left+m.right)+ao*2,_=o*(s/C)-k,P=Math.max(_n*2,m.top+m.bottom)+ao*2,A=t*(c/M)-P,H=C>T?C*n.zoom.value/(_+k):o/(_+k),F=M>I?M*n.zoom.value/(A+P):t/(A+P);return{horizontal:d===x&&b===y?null:{x:Math.max(m.left,_n)+ao+(d-x)/C*o,y:t-ao-Math.max(_n,m.bottom),width:_,height:ao,deltaMultiplier:H},vertical:u===v&&g===E?null:{x:p?Math.max(m.left,_n):o-ao-Math.max(m.right,_n),y:Math.max(m.top,_n)+ao+(u-v)/M*t,width:ao,height:A,deltaMultiplier:F}}},$f=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(l=>l!=null&&l.x<=o&&o<=l.x+l.width&&l.y<=t&&t<=l.y+l.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var rC=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as _O}from"@excalidraw/math";import{getElementLineSegments as DO}from"@excalidraw/element";import{LinearElementEditor as HO}from"@excalidraw/element";import{isFrameLikeElement as RO,isLinearElement as NO,isTextElement as BO}from"@excalidraw/element";import{getFrameChildren as FO}from"@excalidraw/element";import{selectGroupsForSelectedElements as OO}from"@excalidraw/element";import{getContainerElement as zO}from"@excalidraw/element";import{arrayToMap as GO,easeOut as sC,isShallowEqual as UO}from"@excalidraw/common";import{simplify as IO}from"points-on-curve";import{polygonFromPoints as wO,lineSegment as iC,polygonIncludesPointNonZero as CO}from"@excalidraw/math";import{computeBoundTextPosition as SO,doBoundsIntersect as kO,getBoundTextElement as MO,getElementBounds as PO,intersectElementWithLineSegment as aC}from"@excalidraw/element";var lC=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:l,simplifyDistance:a}=e,s=o;a&&(s=IO(o,a));let c=t.filter(d=>!d.locked);l.clear(),i.clear();let m=o.reduce((d,u)=>[Math.min(d[0],u[0]),Math.min(d[1],u[1]),Math.max(d[2],u[0]),Math.max(d[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let d of c){let u=PO(d,n);kO(m,u)&&!i.has(d.id)&&!l.has(d.id)&&(AO(s,d,r)?l.add(d.id):LO(s,d,n)&&i.add(d.id))}return{selectedElementIds:[...i,...l]}},AO=(e,o,t)=>{let n=wO(e),r=t.get(o.id);return r?r.some(i=>i.some(l=>CO(l,n))):!1},LO=(e,o,t)=>{let n=e.slice(1).map((i,l)=>iC(e[l],i)).concat([iC(e[e.length-1],e[0])]),r=MO(o,t);return n.some(i=>aC(o,t,i,0,!0).length>0||!!r&&aC({...r,...SO(o,r,t)},t,i,0,!0).length>0)};var $m=class extends Ln{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let a=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(sC(s),sC(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});S(this,"intersectedElements",new Set);S(this,"enclosedElements",new Set);S(this,"elementsSegments",null);S(this,"canvasTranslate",null);S(this,"keepPreviousSelection",!1);S(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&BO(c)){let m=zO(c,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[c.id])}}for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&RO(c)){let m=FO(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of m)delete r[p.id]}}let i=OO({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),l=[...Object.keys(i.selectedElementIds)],a=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:l.length===1&&!a.length&&NO(this.app.scene.getNonDeletedElement(l[0]))?new HO(this.app.scene.getNonDeletedElement(l[0]),this.app.scene.getNonDeletedElementsMap()):null}})});S(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});S(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>_O(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!UO(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=GO(this.app.visibleElements);for(let i of this.app.visibleElements){let l=DO(i,r);this.elementsSegments.set(i.id,l)}}if(t){let{selectedElementIds:r}=lC({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as WO,easeOut as cC,THEME as YO}from"@excalidraw/common";import{computeBoundTextPosition as VO,doBoundsIntersect as XO,getBoundTextElement as KO,getElementBounds as $O,getElementLineSegments as ZO,getFreedrawOutlineAsSegments as jO,getFreedrawOutlinePoints as qO,intersectElementWithLineSegment as dC,isArrowElement as JO,isFreeDrawElement as mC,isLineElement as QO,isPointInElement as e7}from"@excalidraw/element";import{lineSegment as t7,lineSegmentsDistance as pC,pointFrom as xC,polygon as o7,polygonIncludesPointNonZero as n7}from"@excalidraw/math";import{getElementsInGroup as uC}from"@excalidraw/element";import{shouldTestInside as r7}from"@excalidraw/element";import{hasBoundTextElement as hC,isBoundToContainer as gC}from"@excalidraw/element";import{getBoundTextElementId as fC}from"@excalidraw/element";var Zm=class extends Ln{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let a=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(cC(s),cC(a))},fill:()=>n.state.theme===YO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});S(this,"elementsToErase",new Set);S(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(a=>xC(a[0],a[1]))||[];if(n.length<2)return[];let r=t7(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(a=>!a.locked),l=WO(i);for(let a of i)if(t&&this.elementsToErase.has(a.id)){if(bC(r,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=uC(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(gC(a)&&this.elementsToErase.delete(a.containerId),hC(a)){let m=fC(a);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(a.id)}}else if(!t&&!this.elementsToErase.has(a.id)&&bC(r,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=uC(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(hC(a)){let m=fC(a);m&&this.elementsToErase.add(m)}gC(a)&&this.elementsToErase.add(a.containerId),this.elementsToErase.add(a.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},bC=(e,o,t,n)=>{let r=e[1],i=mC(o)?15:o.strokeWidth/2,l=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],a=$O(o,t),s=[a[0]-i,a[1]-i,a[2]+i,a[3]+i];if(!XO(l,s))return!1;if(r7(o)&&e7(r,o,t))return!0;if(mC(o)){let m=qO(o),p=jO(o,m,t),d=Math.max(2.25,5/n);for(let b of p)if(pC(b,e)<=d)return!0;let u=o7(...m.map(([b,g])=>xC(o.x+b,o.y+g)));return!!n7(e[0],u)}let c=KO(o,t);if(JO(o)||QO(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/n),p=ZO(o,t);for(let d of p)if(pC(d,e)<=m)return!0;return!1}return dC(o,t,e,0,!0).length>0||!!c&&dC({...c,...VO(o,c,t)},t,e,0,!0).length>0};import{isDevEnv as E7}from"@excalidraw/common";import{newElement as v7}from"@excalidraw/element";import{COLOR_PALETTE as i7,DEFAULT_FONT_FAMILY as a7,DEFAULT_FONT_SIZE as l7,VERTICAL_ALIGN as s7}from"@excalidraw/common";var yC=44,EC=22,vC=66,TC=48,Gs=14,IC=304,wC=320,Zf=5.87,CC=28,SC=4,kC=2,jf=10,MC=10,PC=8,nn=12,Ba=256,ii=10,qf=4,Fa=nn*2,Jf=nn*2,AC=100,LC=140,Us=.35,_C=nn/2,dr=20,jm=nn*2,Qf=nn,He={fillStyle:"hachure",fontFamily:a7,fontSize:l7,opacity:100,roughness:1,strokeColor:i7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:s7.MIDDLE,locked:!1};import{pointFrom as Oa}from"@excalidraw/math";import{COLOR_PALETTE as BC,DEFAULT_CHART_COLOR_INDEX as c7,FONT_FAMILY as ob,FONT_SIZES as qm,ROUNDNESS as DC,DEFAULT_FONT_SIZE as d7,getAllColorsSpecificShade as m7,getFontString as nb,getLineHeight as rb,ROUGHNESS as HC}from"@excalidraw/common";import{getApproxMinLineWidth as ib,measureText as mr,newElement as tb,newLinearElement as eb,newTextElement as za,wrapText as FC}from"@excalidraw/element";var ai=m7(c7),p7=e=>e.labels?.length??e.series[0]?.values.length??0,Ga=(e,o)=>{if(!e)return!1;let t=p7(e);return t<2?!1:o==="radar"?t>=3:!0},RC=(e,o)=>{let t=o<=1?0:Math.min(vC,(o-1)*EC);return e+t},Jm=(e,o)=>{if(e==="line"){let n=RC(TC,o);return{slotWidth:n,gap:Gs,chartHeight:wC,xLabelMaxWidth:n+Gs*3+jf}}let t=RC(yC,o);return{slotWidth:t,gap:Gs,chartHeight:IC,xLabelMaxWidth:t+Gs*3+jf}},Ua=(e,o)=>{let t=(o.slotWidth+o.gap)*e.series[0].values.length+o.gap,n=o.chartHeight+o.gap*2;return{chartWidth:t,chartHeight:n}},OC=()=>{let e=Ba+Jf*2,o=Ba+Jf*2;return{chartWidth:e,chartHeight:o}},u7=(e,o,t)=>{let n=Math.abs(e-o);return Math.min(n,t-n)},Wa=(e,o)=>{if(e<=0||ai.length===0)return[];let t=ai.length,n=(o%t+t)%t,r=[n],i=Math.min(e,t),l=new Set(Array.from({length:t},(a,s)=>s).filter(a=>a!==n));for(;r.length<i;){let a=-1,s=-1,c=-1;for(let m of l){let p=r.map(b=>u7(m,b,t)),d=Math.min(...p),u=p.reduce((b,g)=>b+g,0)/p.length;(d>s||d===s&&u>c)&&(a=m,s=d,c=u)}r.push(a),l.delete(a)}return Array.from({length:e},(a,s)=>ai[r[s%r.length]])},Ya=e=>{if(ai.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*ai.length);let o=e.toString(),t=0;for(let n=0;n<o.length;n++)t=t*31+o.charCodeAt(n)|0;return Math.abs(t)%ai.length},Va=e=>ai[e],zC=(e,o)=>{let t=e.flatMap(a=>a.values.map(s=>Math.max(0,s))),n=t.filter(a=>a>0),r=Math.max(1,...t),i=n.length>0?Math.min(...n):1,l=e.length===1&&i>0&&r/i>=AC;return{renderSteps:!1,normalize:(a,s)=>{let c=Math.max(0,a);return l?Math.log10(c+1)/Math.log10(r+1):c/r}}},h7=e=>/\s/.test(e.trim()),Qm=(e,o,t)=>h7(e)?FC(e,o,t):e,GC=(e,o,t,n,r,i)=>{let l=ob.Excalifont,a=qm.sm,s=rb(l),c=nb({fontFamily:l,fontSize:a}),m=Math.min(LC,r*(e.length>8?.56:.72)),p=ib(c,s),d=e.map((g,x)=>{let v=o[x],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(V=>mr(V,c,s).width)),E=Math.max(p,m,y),T=Qm(g,c,E),I=mr(T,c,s),C=Math.cos(v),M=Math.sin(v),k=C>Us?"left":C<-Us?"right":"center",_=k==="center"?I.width/2:0,P=Math.abs(C)*_+Math.abs(M)*(I.height/2),A=Fa+P+_C,H=t+C*(r+A),F=n+M*(r+A),Y=M>Us?nn/3:M<-Us?-nn/3:0;return za({backgroundColor:i,...He,text:T,originalText:g,x:H,y:F+Y,fontFamily:l,fontSize:a,lineHeight:s,textAlign:k,verticalAlign:"middle"})}),u=Math.min(...d.map(g=>g.y)),b=Math.max(...d.map(g=>g.y+g.height));return{axisLabels:d,axisLabelTopY:u,axisLabelBottomY:b}},Xa=(e,o,t,n,r,i)=>{if(e.length<=1)return[];let l=ob["Lilita One"],a=qm.lg,s=rb(l),c=nb({fontFamily:l,fontSize:a}),m=e.map((T,I)=>{let C=T.title?.trim()||`Series ${I+1}`,M=Qm(C,c,Ba),k=mr(M,c,s),_=dr+Qf+k.width;return{label:C,displayLabel:M,color:o[I],width:_,height:k.height}}),p=Math.max(dr/2,...m.map(T=>T.height/2)),d=Math.max(r,n+p+Fa),u=jm,b=dr*.6,g=m.reduce((T,I)=>T+I.width,0)+jm*Math.max(0,m.length-1),x=g+u*2,v=p*2+b*2,y=[];y.push(tb({...He,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:BC.black,x:t-x/2,y:d-v/2,width:x,height:v,roughness:HC.architect,roundness:{type:DC.PROPORTIONAL_RADIUS}}));let E=t-g/2;return m.forEach(T=>{y.push(tb({...He,backgroundColor:T.color,type:"rectangle",x:E,y:d-dr/2,width:dr,height:dr,fillStyle:"solid",strokeColor:T.color,roughness:HC.architect,roundness:{type:DC.PROPORTIONAL_RADIUS}})),y.push(za({...He,text:T.displayLabel,originalText:T.label,autoResize:!1,x:E+dr+Qf,y:d,fontFamily:l,fontSize:a,lineHeight:s,textAlign:"left",verticalAlign:"middle"})),E+=T.width+jm}),y},g7=(e,o,t,n)=>{if(mr(e,t,n).width<=o)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(mr(i,t,n).width<=o)return i;r--}return e[0]?`${e[0]}...`:e},f7=(e,o,t,n)=>{if(mr(e,t,n).width<=o)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(l=>mr(l,t,n).width>o)&&o>=ib(t,n)?{wrapped:!0,text:FC(e,t,o)}:{wrapped:!1,text:g7(e,o,t,n)}},UC=(e,o,t)=>{let n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*n+o*r,height:e*r+o*n}},NC=e=>e.includes("..."),b7=(e,o,t,n,r)=>{let i=Math.max(CC,Math.ceil(ib(n,r))),l=Math.max(i,Math.floor(o)),a=[];for(let u=l;u>=i;u-=4)a.push(u);a[a.length-1]!==i&&a.push(i);let s=u=>{let b=NC(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,x=u.text.split(`
14
- `).length;return{ellipsified:b,visibleChars:g,lineCount:x}},c=(u,b)=>{let g=s(u),x=s(b);return g.ellipsified!==x.ellipsified?!g.ellipsified:g.visibleChars!==x.visibleChars?g.visibleChars>x.visibleChars:g.lineCount!==x.lineCount?g.lineCount<x.lineCount:u.rotatedHeight<b.rotatedHeight},m=null,p=null,d=null;for(let u of a){let{wrapped:b,text:g}=f7(e,u,n,r),x=mr(g,n,r),v=UC(x.width,x.height,Zf),y={originalText:e,text:g,metrics:x,rotatedWidth:v.width,rotatedHeight:v.height,wrapped:b},E=v.width-t;if(E<=0){(!m||c(y,m))&&(m=y);continue}(!p||E<p.overflow||E===p.overflow&&c(y,p.spec))&&(p={overflow:E,spec:y}),!NC(y.text)&&(!d||E<d.overflow||E===d.overflow&&c(y,d.spec))&&(d={overflow:E,spec:y})}return m||(d&&p&&d.overflow<=p.overflow+PC?d.spec:p.spec)},ep=e=>{if(e.type!=="text")return e.y+e.height;let o=UC(e.width,e.height,e.angle);return e.y+e.height/2+o.height/2},Ws=(e,o,t,n,r)=>{let i=He.fontFamily,l=qm.sm,a=rb(i),s=nb({fontFamily:i,fontSize:l}),c=Math.max(1,r.slotWidth+r.gap-SC*2+MC),m=t;return e.labels?.map((p,d)=>{let u=b7(p,r.xLabelMaxWidth,c,s,a),b=o+d*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=m+kC+(u.rotatedHeight-u.metrics.height)/2;return za({backgroundColor:n,...He,text:u.text,originalText:u.wrapped?p:u.text,autoResize:!u.wrapped,x:b,y:g,angle:Zf,fontSize:l,lineHeight:a,textAlign:"center",verticalAlign:"top"})})||[]},x7=(e,o,t,n,r,i=Math.max(...e.series[0].values))=>{let l=za({backgroundColor:n,...He,x:o-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),a=za({backgroundColor:n,...He,x:o-r.gap,y:t-r.chartHeight-l.height/2,text:i.toLocaleString(),textAlign:"right"});return[l,a]},y7=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:l}=Ua(e,r),a=eb({backgroundColor:n,...He,type:"line",x:o,y:t,width:i,points:[Oa(0,0),Oa(i,0)]}),s=eb({backgroundColor:n,...He,type:"line",x:o,y:t,height:l,points:[Oa(0,0),Oa(0,-l)]}),c=eb({backgroundColor:n,...He,type:"line",x:o,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ii,points:[Oa(0,0),Oa(i,0)]});return[a,s,c]},tp=(e,o,t,n,r,i=Math.max(...e.series[0].values),l)=>{let{chartWidth:a,chartHeight:s}=Ua(e,r),c=e.title?za({backgroundColor:n,...He,text:e.title,x:o+a/2,y:t-r.chartHeight-r.gap*2-d7,roundness:null,textAlign:"center",fontSize:qm.xl,fontFamily:ob["Lilita One"]}):null,m=l?tb({backgroundColor:n,...He,type:"rectangle",x:o,y:t-s,width:a,height:s,strokeColor:BC.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...c?[c]:[],...Ws(e,o,t,n,r),...x7(e,o,t,n,r,i),...y7(e,o,t,n,r)]};var WC=(e,o,t,n)=>{let r=e.series,i=Jm("bar",r.length),l=Math.max(1,...r.flatMap(T=>T.values.map(I=>Math.max(0,I)))),a=Ya(n),s=Va(a),c=Wa(r.length,a),m=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,p=r.length>1?Math.max(2,(i.slotWidth-m*(r.length-1))/r.length):i.slotWidth,d=r.length*p+m*(r.length-1),u=(i.slotWidth-d)/2,b=r[0].values.flatMap((T,I)=>r.map((C,M)=>{let _=Math.max(0,C.values[I]??0)/l*i.chartHeight,P=r.length>1?c[M]:s;return v7({backgroundColor:P,...He,type:"rectangle",fillStyle:r.length>1?"solid":He.fillStyle,strokeColor:r.length>1?P:He.strokeColor,x:o+I*(i.slotWidth+i.gap)+i.gap+u+M*(p+m),y:t-_-i.gap,width:p,height:_})})),g=tp(e,o,t,s,i,l,E7()),x=Ws(e,o,t,s,i),v=Math.max(t+i.gap/2,...x.map(T=>ep(T))),{chartWidth:y}=Ua(e,i),E=Xa(r,c,o+y/2,v,t+i.gap*5,s);return[...g,...b,...E]};import{pointFrom as ab}from"@excalidraw/math";import{isDevEnv as T7}from"@excalidraw/common";import{newElement as I7,newLinearElement as YC}from"@excalidraw/element";var VC=(e,o,t,n)=>{let r=e.series,i=Jm("line",r.length),l=Math.max(1,...r.flatMap(E=>E.values)),a=Ya(n),s=Va(a),c=Wa(r.length,a),m=r.map((E,T)=>{let I=E.values.map((P,A)=>ab(A*(i.slotWidth+i.gap),-(P/l)*i.chartHeight)),C=Math.max(...I.map(P=>P[0])),M=Math.max(...I.map(P=>P[1])),k=Math.min(...I.map(P=>P[0])),_=Math.min(...I.map(P=>P[1]));return YC({backgroundColor:"transparent",...He,type:"line",x:o+i.gap+i.slotWidth/2,y:t-i.gap,height:M-_,width:C-k,strokeColor:c[T],strokeWidth:2,points:I})}),p=r.flatMap((E,T)=>E.values.map((I,C)=>{let M=C*(i.slotWidth+i.gap)+i.gap/2,k=-(I/l)*i.chartHeight+i.gap/2;return I7({backgroundColor:c[T],...He,fillStyle:"solid",strokeColor:c[T],strokeWidth:2,type:"ellipse",x:o+M+i.slotWidth/2,y:t+k-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((E,T)=>Math.max(0,...r.map(I=>I.values[T]??0))).map((E,T)=>{let I=T*(i.slotWidth+i.gap)+i.gap/2,C=E/l*i.chartHeight+i.gap/2+i.gap;return YC({backgroundColor:s,...He,type:"line",x:o+I+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ii,points:[ab(0,0),ab(0,C)]})}),b=tp(e,o,t,s,i,l,T7()),g=Ws(e,o,t,s,i),x=Math.max(t+i.gap/2,...g.map(E=>ep(E))),{chartWidth:v}=Ua(e,i),y=Xa(r,c,o+v/2,x,t+i.gap*5,s);return[...b,...m,...u,...p,...y]};var Po=e=>{let o=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},w7=(e,o)=>e.slice(1).every(t=>Po(t[o])!==null),XC=e=>{let o=e[0].length;if(o>2){let l=e[0].every(p=>Po(p)===null),a=l?e.slice(1):e;if(a.length<1)return{ok:!1,reason:"No data rows"};if(a.some(p=>p.slice(1).some(d=>Po(d)===null)))return{ok:!1,reason:"Value is not numeric"};if(o-1>a.length){let p=l?e[0].slice(1).map(b=>b.trim()):null,d=a.map(b=>({title:b[0]?.trim()||null,values:b.slice(1).map(g=>Po(g))}));return{ok:!0,data:{title:d.length===1?d[0].title:l&&e[0][0].trim()||null,labels:p,series:d}}}let m=e[0].slice(1).map((p,d)=>{let u=d+1,b=`Series ${u}`;return{title:l&&p.trim()||b,values:a.map(g=>Po(g[u]))}});return{ok:!0,data:{title:l&&e[0][0].trim()||null,labels:a.map(p=>p[0]),series:m}}}if(o===1){if(!w7(e,0))return{ok:!1,reason:"Value is not numeric"};let l=Po(e[0][0])===null,a=l?e[0][0]:null,s=(l?e.slice(1):e).map(c=>Po(c[0]));return s.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:a,labels:null,series:[{title:a,values:s}]}}}let t=Po(e[0][1])===null,n=t?e.slice(1):e;if(n.length<2)return{ok:!1,reason:"Less than 2 rows"};if(n.some(l=>Po(l[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:n.map(l=>l[0]),series:[{title:i,values:n.map(l=>Po(l[1]))}]}}},op=e=>{let o=a=>e.replace(/\r\n?/g,`
12
+ C ${s} ${c}, ${s} ${c}, ${s+x} ${c+v}`,Mn(e,!0,l))}else a=o.polygon([[s,c],[m,p],[d,u],[b,g]],Mn(e,!1,l));return a}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Mn(e,!1,l));case"line":case"arrow":{let a,s=Mn(e,!1,l),c=e.points.length?e.points:[XF(0,0)];if(As(e)?c.every(m=>Math.abs(m[0])<=1e6&&Math.abs(m[1])<=1e6)?a=[o.path(e8(c,16),Mn(e,!0,l))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),a=[]):e.roundness?a=[o.curve(c,s)]:s.fill?a=[o.polygon(c,s)]:a=[o.linearPath(c,s)],e.type==="arrow"){let{startArrowhead:m=null,endArrowhead:p="arrow"}=e;if(m!==null){let d=iC(e,a,"start",m,o,s,n,l);a.push(...d)}if(p!==null){let d=iC(e,a,"end",p,o,s,n,l);a.push(...d)}}return a}case"freedraw":{let a=[];if(Pm(e.points)){let s=YF(e.points,.75);a.push(o.curve(s,{...Mn(e,!1,l),stroke:"none"}))}return a.push(t8(e)),a}case"frame":case"magicframe":case"text":case"image":return null;default:return $F(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},e8=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],l=e[r+1],a=e[r],s=Dm(a,i),c=Dm(l,a),m=Math.min(o,nC(e[r],l)/2,nC(e[r],i)/2);s?i[0]<a[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<a[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),c?l[0]<a[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):l[1]<a[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var t8=e=>r8(o8(e)),o8=e=>{let o=e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]];return VF(o,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:t=>Math.sin(t*Math.PI/2),last:!0})},aC=(e,o)=>[(e[0]+o[0])/2,(e[1]+o[1])/2],n8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,r8=e=>{if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,aC(n,i[0]),"L",i[0],"Z"):t.push(n,aC(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(n8,"$1")};var sC=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??i8(),updated:a8()}};import{jsx as dC}from"react/jsx-runtime";var Ha=O({name:"toggleLinearEditor",category:Fe.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&s8(r[0])&&!l8(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Lf(r,"No selected element found"),Lf(o.selectedLinearElement,"No selected linear element found"),Lf(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:cC.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=h(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return dC(J,{type:"button",icon:UE,title:r,"aria-label":r,onClick:()=>o(null)})}}),kIe=O({name:"togglePolygon",category:Fe.elements,icon:Su,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Da(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Da(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Da(s)))return!1;let i=r,l=i.some(s=>!s.polygon),a=c8(i);return{elements:e.map(s=>!a.has(s.id)||!Da(s)?s:sC(s,{backgroundColor:l?s.backgroundColor:"transparent",...d8(s,l)})),appState:o,captureUpdate:cC.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(l=>!Da(l)||!l.polygon||l.points.length<3))return null;let r=n.every(l=>Da(l)&&l.polygon),i=h(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return dC(Vi,{icon:Su,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as mC,CANVAS_SEARCH_TAB as pC,CLASSES as m8,DEFAULT_SIDEBAR as uC}from"@hellixit/common";import{CaptureUpdateAction as p8}from"@hellixit/element";var Ps=O({name:"searchMenu",icon:Kt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===uC.name&&o.openSidebar.tab===pC){let r=n.hellixitboardContainerValue.container?.querySelector(`.${m8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:uC.name,tab:pC},openDialog:null},captureUpdate:p8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[mC.CTRL_OR_CMD]&&e.key===mC.F});import{isImageElement as u8}from"@hellixit/element";import{CaptureUpdateAction as h8}from"@hellixit/element";import{jsx as g8}from"react/jsx-runtime";var _f=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Xu,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:h8.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&u8(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=h("helpDialog.cropStart");return g8(J,{type:"button",icon:Xu,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as f8}from"@hellixit/element";import{mutateElement as b8}from"@hellixit/element";import{newFrameElement as x8}from"@hellixit/element";import{isFrameLikeElement as Fm}from"@hellixit/element";import{addElementsToFrame as y8,removeAllElementsFromFrame as E8}from"@hellixit/element";import{getFrameChildren as v8}from"@hellixit/element";import{KEYS as hC,updateActiveTool as gC}from"@hellixit/common";import{getElementsInGroup as T8}from"@hellixit/element";import{getCommonBounds as I8}from"@hellixit/element";import{CaptureUpdateAction as ti}from"@hellixit/element";var fC=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Fm(t[0])},bC=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(Fm(r)){let i=v8(f8(e),r.id).filter(l=>!(l.type==="text"&&l.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((l,a)=>(l[a.id]=!0,l),{})},captureUpdate:ti.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:ti.EVENTUALLY}},predicate:(e,o,t,n)=>fC(o,n)}),xC=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return Fm(r)?{elements:E8(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:ti.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:ti.EVENTUALLY}},predicate:(e,o,t,n)=>fC(o,n)}),FCe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:ti.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),OCe=O({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:yo,viewMode:!1,perform:(e,o,t,n)=>{let r=gC(o,{type:"frame"});return jt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:gC(o,{type:"frame"})},captureUpdate:ti.EVENTUALLY}},keyTest:e=>!e[hC.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===hC.F}),yC=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=oe(e,o);return r.length>0&&!r.some(i=>Fm(i))},perform:(e,o,t,n)=>{let r=oe(e,o),i=n.scene.getNonDeletedElementsMap(),[l,a,s,c]=I8(r,i),m=16,p=x8({x:l-m,y:a-m,width:s-l+m*2,height:c-a+m*2});if(o.editingGroupId){let u=T8(r,o.editingGroupId);for(let b of u){let g=b.groupIds.indexOf(o.editingGroupId);b8(b,i,{groupIds:b.groupIds.slice(0,g)})}}return{elements:y8([...n.scene.getElementsIncludingDeleted(),p],r,p,o),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:ti.IMMEDIATELY}}});import{isWindows as A8,KEYS as Bs,matchKey as Rf,arrayToMap as EC,MOBILE_ACTION_BUTTON_BG as vC}from"@hellixit/common";import{CaptureUpdateAction as Hf}from"@hellixit/element";import{orderByFractionalIndex as L8}from"@hellixit/element";import{Emitter as C8}from"@hellixit/common";import{CaptureUpdateAction as S8,StoreChange as w8,StoreDelta as k8}from"@hellixit/element";var Ra=class extends k8{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[l,a]=this.appState.applyTo(t,r);return[r,l,i||a]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},oi=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Ns=class e{constructor(o){this.store=o;w(this,"onHistoryChangedEmitter",new C8);w(this,"undoStack",[]);w(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Ra)return;let t=Ra.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new oi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let l=S8.IMMEDIATELY,a=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=i.applyTo(s,c,a);let p=a.elements,d=a.maybeClone(l,s,c),u=w8.create(a,d),b=Ra.applyLatestChanges(i,p,s);b.isEmpty()||(this.store.scheduleMicroAction({action:l,change:u,delta:b}),i=b),a=d}finally{r(i)}if(m)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new oi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=Ra.inverse(t);return o.push(n)}};import{useEffect as M8,useState as P8}from"react";var Df=(e,o)=>{let[t,n]=P8(o);return M8(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as SC}from"react/jsx-runtime";var TC=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:Hf.EVENTUALLY};let[r,i]=n,l=L8(Array.from(r.values()));return{appState:i,elements:l,captureUpdate:Hf.NEVER}}return{captureUpdate:Hf.EVENTUALLY}},IC=e=>({name:"undo",label:"buttons.undo",icon:Mu,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>TC(r,t,()=>e.undo(EC(o),t)),keyTest:o=>o[Bs.CTRL_OR_CMD]&&Rf(o,Bs.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isUndoStackEmpty:i}=Df(e.onHistoryChangedEmitter,new oi(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=at()==="mobile";return SC(J,{type:"button",icon:Mu,"aria-label":h("buttons.undo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...l?vC:{}}})}}),CC=e=>({name:"redo",label:"buttons.redo",icon:Pu,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>TC(r,t,()=>e.redo(EC(o),t)),keyTest:o=>o[Bs.CTRL_OR_CMD]&&o.shiftKey&&Rf(o,Bs.Z)||A8&&o.ctrlKey&&!o.shiftKey&&Rf(o,Bs.Y),PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isRedoStackEmpty:i}=Df(e.onHistoryChangedEmitter,new oi(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=at()==="mobile";return SC(J,{type:"button",icon:Pu,"aria-label":h("buttons.redo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...l?vC:{}}})}});import{getFontString as _8}from"@hellixit/common";import{newElementWith as D8}from"@hellixit/element";import{measureText as H8}from"@hellixit/element";import{isTextElement as wC}from"@hellixit/element";import{CaptureUpdateAction as R8}from"@hellixit/element";var kC=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=oe(e,o);return r.length===1&&wC(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=oe(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&wC(i)){let l=H8(i.originalText,_8(i),i.lineHeight);return D8(i,{autoResize:!0,width:l.width,height:l.height,text:i.originalText})}return i}),captureUpdate:R8.IMMEDIATELY}}});import{isPromiseLike as N8}from"@hellixit/common";import{jsx as B8}from"react/jsx-runtime";var Nf=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&ce(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(l){console.error("error while logging action:",l)}},Om=class{constructor(o,t,n,r){w(this,"actions",{});w(this,"updater");w(this,"getAppState");w(this,"getElementsIncludingDeleted");w(this,"app");w(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let l=this.getElementsIncludingDeleted(),a=this.getAppState(),s=c=>{Nf(r,"ui",a,l,this.app,c),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return B8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});w(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(N8(i))i.then(l=>o(l));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),l=this.getAppState(),a=null;return Nf(r,"keyboard",l,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,l,a,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Nf(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var zm=class{constructor(){w(this,"targets",new WeakMap);w(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Bf=e=>{let o=Array.from(e.values());return{x:MC(o,t=>t.x)/o.length,y:MC(o,t=>t.y)/o.length}},Ff=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),MC=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as Z,pointRotateRads as sr,rangeInclusive as ro,rangeIntersection as Gm,rangesOverlap as Um}from"@hellixit/math";import{TOOL_TYPE as ni,KEYS as PC}from"@hellixit/common";import{getCommonBounds as Of,getDraggedElementsBounds as zf,getElementAbsoluteCoords as F8}from"@hellixit/element";import{isBoundToContainer as DC}from"@hellixit/element";import{getMaximumGroups as HC}from"@hellixit/element";import{getSelectedElements as O8,getVisibleAndNonSelectedElements as RC}from"@hellixit/element";var z8=8,AC=99999,Wm=e=>z8/e,Lt=class Lt{};w(Lt,"referenceSnapPoints",null),w(Lt,"visibleGaps",null),w(Lt,"setReferenceSnapPoints",o=>{Lt.referenceSnapPoints=o}),w(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),w(Lt,"setVisibleGaps",o=>{Lt.visibleGaps=o}),w(Lt,"getVisibleGaps",()=>Lt.visibleGaps),w(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var io=Lt,cr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,An=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[PC.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[PC.CTRL_OR_CMD]&&!cr(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},G8=(e,o,t=.01)=>Math.abs(e-o)<=t,Fs=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let l=e[0],[a,s,c,m,p,d]=F8(l,o);r&&(a+=r.x,c+=r.x,p+=r.x,s+=r.y,m+=r.y,d+=r.y);let u=(c-a)/2,b=(m-s)/2;if((l.type==="diamond"||l.type==="ellipse")&&!n){let g=sr(Z(a,s+b),Z(p,d),l.angle),x=sr(Z(a+u,s),Z(p,d),l.angle),v=sr(Z(c,s+b),Z(p,d),l.angle),y=sr(Z(a+u,m),Z(p,d),l.angle),E=Z(p,d);i=t?[g,x,v,y]:[g,x,v,y,E]}else{let g=sr(Z(a,s),Z(p,d),l.angle),x=sr(Z(c,s),Z(p,d),l.angle),v=sr(Z(a,m),Z(p,d),l.angle),y=sr(Z(c,m),Z(p,d),l.angle),E=Z(p,d);i=t?[g,x,v,y]:[g,x,v,y,E]}}else if(e.length>1){let[l,a,s,c]=zf(e,r??{x:0,y:0}),m=s-l,p=c-a,d=Z(l,a),u=Z(s,a),b=Z(l,c),g=Z(s,c),x=Z(l+m/2,a+p/2);i=t?[d,u,b,g]:[d,u,b,g,x]}return i.map(l=>Z(Ue(l[0]),Ue(l[1])))},NC=(e,o,t,n)=>RC(e,o,t,n),BC=(e,o,t,n)=>{let r=NC(e,o,t,n),i=HC(r,n).filter(p=>!(p.length===1&&DC(p[0]))).map(p=>Of(p).map(d=>Ue(d))),l=i.sort((p,d)=>p[0]-d[0]),a=[],s=0;e:for(let p=0;p<l.length;p++){let d=l[p];for(let u=p+1;u<l.length;u++){if(++s>AC)break e;let b=l[u],[,g,x,v]=d,[y,E,,T]=b;x<y&&Um(ro(g,v),ro(E,T))&&a.push({startBounds:d,endBounds:b,startSide:[Z(x,g),Z(x,v)],endSide:[Z(y,E),Z(y,T)],length:y-x,overlap:Gm(ro(g,v),ro(E,T))})}}let c=i.sort((p,d)=>p[1]-d[1]),m=[];s=0;e:for(let p=0;p<c.length;p++){let d=c[p];for(let u=p+1;u<c.length;u++){if(++s>AC)break e;let b=c[u],[g,,x,v]=d,[y,E,T]=b;v<E&&Um(ro(g,x),ro(y,T))&&m.push({startBounds:d,endBounds:b,startSide:[Z(g,v),Z(x,v)],endSide:[Z(y,E),Z(T,E)],length:E-v,overlap:Gm(ro(g,x),ro(y,T))})}}return{horizontalGaps:a,verticalGaps:m}},LC=(e,o,t,n,r,i,l)=>{if(!An({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let a=io.getVisibleGaps();if(a){let{horizontalGaps:s,verticalGaps:c}=a,[m,p,d,u]=zf(e,o).map(x=>Ue(x)),b=(m+d)/2,g=(p+u)/2;for(let x of s){if(!Um(ro(p,u),x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=Ue(v-b);if(x.length>d-m&&Math.abs(y)<=l.x){Math.abs(y)<l.x&&(r.length=0),l.x=Math.abs(y);let P={type:"gap",direction:"center_horizontal",gap:x,offset:y};r.push(P);continue}let[,,T]=x.endBounds,I=m-T,S=Ue(x.length-I);if(Math.abs(S)<=l.x){Math.abs(S)<l.x&&(r.length=0),l.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};r.push(P);continue}let[M,,,]=x.startBounds,k=M-d,_=Ue(k-x.length);if(Math.abs(_)<=l.x){Math.abs(_)<l.x&&(r.length=0),l.x=Math.abs(_);let P={type:"gap",direction:"side_left",gap:x,offset:_};r.push(P);continue}}for(let x of c){if(!Um(ro(m,d),x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=Ue(v-g);if(x.length>u-p&&Math.abs(y)<=l.y){Math.abs(y)<l.y&&(i.length=0),l.y=Math.abs(y);let P={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(P);continue}let[,T,,]=x.startBounds,I=T-u,S=Ue(I-x.length);if(Math.abs(S)<=l.y){Math.abs(S)<l.y&&(i.length=0),l.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,M]=x.endBounds,k=Ue(p-M),_=x.length-k;if(Math.abs(_)<=l.y){Math.abs(_)<l.y&&(i.length=0),l.y=Math.abs(_);let P={type:"gap",direction:"side_bottom",gap:x,offset:_};i.push(P);continue}}}},FC=(e,o,t,n)=>{let r=NC(e,o,t,n);return HC(r,n).filter(i=>!(i.length===1&&DC(i[0]))).flatMap(i=>Fs(i,n))},Na=(e,o,t,n,r,i,l)=>{if(!An({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let a=io.getReferenceSnapPoints();if(a)for(let s of o)for(let c of a){let m=c[0]-s[0],p=c[1]-s[1];Math.abs(m)<=l.x&&(Math.abs(m)<l.x&&(r.length=0),r.push({type:"point",points:[s,c],offset:m}),l.x=Math.abs(m)),Math.abs(p)<=l.y&&(Math.abs(p)<l.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:p}),l.y=Math.abs(p))}},OC=(e,o,t,n,r)=>{let i=t.state,l=O8(e,i);if(!An({app:t,event:n,selectedElements:l})||l.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Ue(o.x),o.y=Ue(o.y);let a=[],s=[],c=Wm(i.zoom.value),m={x:c,y:c},p=Fs(l,r,{dragOffset:o});Na(l,p,t,n,a,s,m),LC(l,o,t,n,a,s,m);let d={x:a[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,a.length=0,s.length=0;let u={x:Ue(o.x+d.x),y:Ue(o.y+d.y)};Na(l,Fs(l,r,{dragOffset:u}),t,n,a,s,m),LC(l,u,t,n,a,s,m);let b=Gf(a,s),g=W8(l,u,[...a,...s].filter(x=>x.type==="gap"));return{snapOffset:d,snapLines:[...b,...g]}},Ue=e=>Math.round(e*10**6)/10**6,_C=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},Gf=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ue(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(l=>Z(Ue(l[0]),Ue(l[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Ue(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(l=>Z(Ue(l[0]),Ue(l[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:_C(i.map(l=>Z(Number(r),l[1])).sort((l,a)=>l[1]-a[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:_C(i.map(l=>Z(l[0],Number(r))).sort((l,a)=>l[0]-a[0]))})))},U8=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Ue(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},W8=(e,o,t)=>{let[n,r,i,l]=zf(e,o),a=[];for(let s of t){let[c,m,p,d]=s.gap.startBounds,[u,b,g,x]=s.gap.endBounds,v=Gm(ro(r,l),s.gap.overlap),y=Gm(ro(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(s.gap.startSide[0][0],E),Z(n,E)]},{type:"gap",direction:"horizontal",points:[Z(i,E),Z(s.gap.endSide[0][0],E)]})}break}case"center_vertical":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,s.gap.startSide[0][1]),Z(E,r)]},{type:"gap",direction:"vertical",points:[Z(E,l),Z(E,s.gap.endSide[0][1])]})}break}case"side_right":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(p,E),Z(u,E)]},{type:"gap",direction:"horizontal",points:[Z(g,E),Z(n,E)]})}break}case"side_left":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[Z(i,E),Z(c,E)]},{type:"gap",direction:"horizontal",points:[Z(p,E),Z(u,E)]})}break}case"side_top":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,l),Z(E,m)]},{type:"gap",direction:"vertical",points:[Z(E,d),Z(E,b)]})}break}case"side_bottom":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[Z(E,d),Z(E,b)]},{type:"gap",direction:"vertical",points:[Z(E,x),Z(E,r)]})}break}}}return U8(a.map(s=>({...s,points:s.points.map(c=>Z(Ue(c[0]),Ue(c[1])))})))},Uf=(e,o,t,n,r,i)=>{if(!An({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!G8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[l,a,s,c]=Of(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(l+=r.x),i.includes("n")?a+=r.y:i.includes("s")&&(c+=r.y));let m=[];if(i)switch(i){case"e":{m.push(Z(s,a),Z(s,c));break}case"w":{m.push(Z(l,a),Z(l,c));break}case"n":{m.push(Z(l,a),Z(s,a));break}case"s":{m.push(Z(l,c),Z(s,c));break}case"ne":{m.push(Z(s,a));break}case"nw":{m.push(Z(l,a));break}case"se":{m.push(Z(s,c));break}case"sw":{m.push(Z(l,c));break}}let p=Wm(t.state.zoom.value),d={x:p,y:p},u=[],b=[];Na(o,m,t,n,u,b,d);let g={x:u[0]?.offset??0,y:b[0]?.offset??0};d.x=0,d.y=0,u.length=0,b.length=0;let[x,v,y,E]=Of(e).map(S=>Ue(S)),T=[Z(x,v),Z(x,E),Z(y,v),Z(y,E)];Na(e,T,t,n,u,b,d);let I=Gf(u,b);return{snapOffset:g,snapLines:I}},zC=(e,o,t,n,r,i)=>{if(!An({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let l=[Z(n.x+r.x,n.y+r.y)],a=Wm(o.state.zoom.value),s={x:a,y:a},c=[],m=[];Na([e],l,o,t,c,m,s);let p={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let d=Fs([e],i,{boundingBoxCorners:!0,omitCenter:!0});Na([e],d,o,t,c,m,s);let u=Gf(c,m);return{snapOffset:p,snapLines:u}},GC=(e,o,t,n,r)=>{if(!An({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=RC(e,[],o.state,r),l=Wm(o.state.zoom.value),a={x:l,y:l},s=[],c=[];for(let m of i){let p=Fs([m],r);for(let d of p){let u=d[0]-t.x;Math.abs(u)<=Math.abs(a.x)&&(Math.abs(u)<Math.abs(a.x)&&(c.length=0),c.push({type:"pointer",points:[d,Z(d[0],t.y)],direction:"vertical"}),a.x=u);let b=d[1]-t.y;Math.abs(b)<=Math.abs(a.y)&&(Math.abs(b)<Math.abs(a.y)&&(s.length=0),s.push({type:"pointer",points:[d,Z(t.x,d[1])],direction:"horizontal"}),a.y=b)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},UC=e=>e===ni.rectangle||e===ni.ellipse||e===ni.diamond||e===ni.frame||e===ni.magicframe||e===ni.image||e===ni.text;import{isElementInViewport as Y8}from"@hellixit/element";import{memoize as V8,toBrandedType as X8}from"@hellixit/common";var Os=class{constructor(o){w(this,"scene");w(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:l,scrollX:a,scrollY:s,height:c,width:m})=>{let p=[];for(let d of n.values())Y8(d,m,c,{zoom:r,offsetLeft:i,offsetTop:l,scrollX:a,scrollY:s},n)&&p.push(d);return p},t=({elements:n,editingTextElement:r,newElementId:i})=>{let l=X8(new Map);for(let a of n)i!==a.id&&(!r||r.type!=="text"||a.id!==r.id)&&l.set(a.id,a);return l};return V8(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:l,scrollY:a,height:s,width:c,editingTextElement:m,newElementId:p,sceneNonce:d})=>{let u=this.scene.getNonDeletedElements(),b=t({elements:u,editingTextElement:m,newElementId:p}),g=o({elementsMap:b,zoom:n,offsetLeft:r,offsetTop:i,scrollX:l,scrollY:a,height:s,width:c});return{elementsMap:b,visibleElements:g}})})());this.scene=o}destroy(){Oy.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as K8}from"@hellixit/common";import{getElementAbsoluteCoords as $8}from"@hellixit/element";import{jsx as q8}from"react/jsx-runtime";var Z8=5,j8=(e,o,t)=>{let[n,r]=$8(e,t),{x:i,y:l}=K8({sceneX:n+e.width,sceneY:r},o),a=i-o.offsetLeft+10,s=l-o.offsetTop;return{x:a,y:s}},Wf=({children:e,element:o,elementsMap:t})=>{let n=Xo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=j8(o,n,t);return q8("div",{className:"hellixitboard-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:Z8},children:e})};import{DEFAULT_LASER_COLOR as tO,easeOut as YC}from"@hellixit/common";import{LaserPointer as J8}from"@hellixit/laser-pointer";import{SVG_NS as WC,getSvgPathFromStroke as Q8,sceneCoordsToViewportCoords as eO}from"@hellixit/common";var Ln=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;w(this,"currentTrail");w(this,"pastTrails",[]);w(this,"container");w(this,"trailElement");w(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(WC,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(WC,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new J8(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,l])=>{let a=eO({sceneX:i,sceneY:l},t);return[a.x,a.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return Q8(r,!0)}};var Ym=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;w(this,"localTrail");w(this,"collabTrails",new Map);w(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Ln(o,t,{...this.getTrailOptions(),fill:()=>tO})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(YC(i),YC(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Ln(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Xr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as oO}from"react";import{unstable_batchedUpdates as VC}from"react-dom";import{throttleRAF as nO}from"@hellixit/common";var We=e=>o=>{VC(e,o)},Vm=e=>nO(o=>{VC(e,o)}),ri=(()=>{let e;try{let t=oO.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.HELLIXITBOARD_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Hellixitboard: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Yf,KEYS as zs,CLASSES as Vf,POINTER_BUTTON as rO,THEME as iO,isWritableElement as aO,getFontString as XC,getFontFamilyString as KC,isTestEnv as $C,MIME_TYPES as Xf,applyDarkModeFilter as lO}from"@hellixit/common";import{getTextFromElements as sO,originalContainerCache as cO,updateBoundElements as ZC,updateOriginalContainerCache as jC}from"@hellixit/element";import{LinearElementEditor as dO}from"@hellixit/element";import{bumpVersion as mO}from"@hellixit/element";import{getBoundTextElementId as pO,getContainerElement as Kf,getTextElementAngle as uO,redrawTextBoundingBox as hO,getBoundTextMaxHeight as gO,getBoundTextMaxWidth as qC,computeContainerDimensionForBoundText as JC,computeBoundTextPosition as fO,getBoundTextElement as bO}from"@hellixit/element";import{getTextWidth as xO}from"@hellixit/element";import{normalizeText as QC}from"@hellixit/element";import{wrapText as yO}from"@hellixit/element";import{isArrowElement as Xm,isBoundToContainer as EO,isTextElement as eS}from"@hellixit/element";var vO=(e,o,t,n,r,i)=>{let{zoom:l}=n,a=180*t/Math.PI,s=e*(l.value-1)/2,c=o*(l.value-1)/2;return e>r&&l.value!==1&&(s=r*(l.value-1)/2),o>i&&l.value!==1&&(c=i*(l.value-1)/2),`translate(${s}px, ${c}px) scale(${l.value}) rotate(${a}deg)`},tS=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,hellixitboardContainer:l,app:a,autoSelect:s=!0})=>{let c=(D,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let W=B.style.fontFamily.replace(/"/g,"");return KC({fontFamily:D.fontFamily})!==W||`${D.fontSize}px`!==B.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let D=a.state,B=a.scene.getElement(e);if(!B)return;let{textAlign:W,verticalAlign:te}=B,X=a.scene.getNonDeletedElementsMap();if(B&&eS(B)){let le=B.x,pe=B.y,de=Kf(B,a.scene.getNonDeletedElementsMap()),Ee=B.width,Ve=B.height,rt=B.width,ft=B.height;if(de&&B.containerId){if(Xm(de)){let bo=dO.getBoundTextElementPosition(de,B,X);le=bo.x,pe=bo.y}let fu=c(B,d),xn;if(fu?xn=jC(de.id,de.height):(xn=cO[de.id],xn||(xn=jC(de.id,de.height))),rt=qC(de,B),ft=gO(de,B),!Xm(de)&&Ve>ft){let bo=JC(Ve,de.type);a.scene.mutateElement(de,{height:bo}),ZC(de,a.scene);return}else if(!Xm(de)&&de.height>xn.height&&Ve<ft){let bo=JC(Ve,de.type);a.scene.mutateElement(de,{height:bo}),ZC(de,a.scene)}else{let{x:bo,y:Tl}=fO(de,B,X);le=bo,pe=Tl}}let[Ct,zn]=n(le,pe);de?Ee+=.5:(rt=(D.width-8-Ct)/D.zoom.value,Ee=Math.min(Ee,rt)),Ve*=1.05;let Cc=XC(B),vl=(D.height-zn)/D.zoom.value;Object.assign(d.style,{font:Cc,lineHeight:B.lineHeight,width:`${Ee}px`,height:`${Ve}px`,left:`${Ct}px`,top:`${zn}px`,transform:vO(Ee,Ve,uO(B,de),D,rt,vl),textAlign:W,verticalAlign:te,color:D.theme===iO.DARK?lO(B.strokeColor):B.strokeColor,opacity:B.opacity/100,maxHeight:`${vl}px`}),d.scrollTop=0,$C()&&(d.style.fontFamily=KC(B)),a.scene.mutateElement(B,{x:le,y:pe})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("hellixitboard-wysiwyg");let u="pre",b="normal";(EO(r)||!r.autoResize)&&(u="pre-wrap",b="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:b,whiteSpace:u,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=r.originalText,p(),o&&(d.onpaste=async D=>{let B=_v(D),W=null;if(B.has(Xf.hellixitboardClipboard)||B.has(Xf.hellixitboard)){D.preventDefault(),W=await na(D);try{let de=await Rd(W);if(de.elements){let Ee=sO(de.elements);if(Ee){let{selectionStart:Ve,selectionEnd:rt,value:ft}=d;d.value=ft.slice(0,Ve)+Ee+ft.slice(rt);let Ct=Ve+Ee.length;d.selectionStart=d.selectionEnd=Ct,d.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse hellixitboard clipboard data")}}W=W||await na(D);let te=W.findByType(Xf.text);if(!te)return;let X=QC(te.value);if(!X)return;let le=Kf(r,a.scene.getNonDeletedElementsMap()),pe=XC({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(le){let de=bO(le,a.scene.getNonDeletedElementsMap()),Ee=yO(`${d.value}${X}`,pe,qC(le,de)),Ve=xO(Ee,pe);d.style.width=`${Ve}px`}},d.oninput=()=>{let D=QC(d.value);if(d.value!==D){let B=d.selectionStart;d.value=D,d.selectionStart=B,d.selectionEnd=B}o(d.value)}),d.onkeydown=D=>{if(!D.shiftKey&&Cd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(Cd),p();else if(!D.shiftKey&&Sd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(Sd),p();else if(!D.shiftKey&&wd.keyTest(D))D.preventDefault(),a.actionManager.executeAction(wd),p();else if(Dh.keyTest(D))a.actionManager.executeAction(Dh);else if(Hh.keyTest(D))a.actionManager.executeAction(Hh);else if(D.key===zs.ESCAPE)D.preventDefault(),S=!0,M();else if(Yr.keyTest(D))D.preventDefault(),M(),a.actionManager.executeAction(Yr);else if(D.key===zs.ENTER&&D[zs.CTRL_OR_CMD]){if(D.preventDefault(),D.isComposing||D.keyCode===229)return;S=!0,M()}else if(D.key===zs.TAB||D[zs.CTRL_OR_CMD]&&(D.code===Yf.BRACKET_LEFT||D.code===Yf.BRACKET_RIGHT)){if(D.preventDefault(),D.isComposing)return;D.shiftKey||D.code===Yf.BRACKET_LEFT?E():y(),d.dispatchEvent(new Event("input"))}};let g=4,x=" ".repeat(g),v=new RegExp(`^ {1,${g}}`),y=()=>{let{selectionStart:D,selectionEnd:B}=d,W=T(),te=d.value;W.forEach(X=>{let le=te.slice(0,X),pe=te.slice(X);te=`${le}${x}${pe}`}),d.value=te,d.selectionStart=D+g,d.selectionEnd=B+g*W.length},E=()=>{let{selectionStart:D,selectionEnd:B}=d,W=T(),te=[],X=d.value;W.forEach(le=>{let pe=X.slice(le,le+g).match(v);if(pe){let de=X.slice(0,le),Ee=X.slice(le+pe[0].length);X=`${de}${Ee}`,te.push(le)}}),d.value=X,te.length&&(D>te[te.length-1]?d.selectionStart=Math.max(D-g,te[te.length-1]):d.selectionStart=D,d.selectionEnd=Math.max(d.selectionStart,B-g*te.length))},T=()=>{let{selectionStart:D,selectionEnd:B,value:W}=d,te=W.slice(0,D).match(/[^\n]*$/)[0].length;return D=D-te,W.slice(D,B).split(`
13
+ `).reduce((le,pe,de,Ee)=>le.concat(de?le[de-1]+Ee[de-1].length+1:D),[]).reverse()},I=D=>{D.target instanceof HTMLCanvasElement&&(D.preventDefault(),D.stopPropagation())},S=!1,M=()=>{if(V)return;V=!0,k();let D=a.scene.getElement(r.id);if(!D)return;let B=Kf(D,a.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let W=pO(B);!W||W!==r.id?a.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:r.id})}):Xm(B)&&mO(B)}else a.scene.mutateElement(B,{boundElements:B.boundElements?.filter(W=>!eS(W))});hO(D,B,a.scene)}t({viaKeyboard:S,nextOriginalText:d.value})},k=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,U&&U.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",I,!0),window.removeEventListener("pointerdown",A),window.removeEventListener("pointerup",_),window.removeEventListener("blur",M),window.removeEventListener("beforeunload",M),F(),H(),Y(),d.remove()},_=D=>{window.removeEventListener("pointerup",_);let B=D?.target,W=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),te=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content"),X=(B instanceof HTMLElement||B instanceof SVGElement)&&(!!B.closest(`.${Vf.SHAPE_ACTIONS_MENU}`)||!!B.closest(".compact-shape-actions-island"));setTimeout(()=>{X||W||te||(d.onblur=M,d.focus())})},P=()=>{d.onblur=null,window.addEventListener("pointerup",_),window.addEventListener("blur",M)},A=D=>{let B=D?.target;if(D.button===rO.WHEEL){B instanceof HTMLTextAreaElement&&(D.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(D)),P();return}let W=B instanceof HTMLElement&&B.classList.contains("properties-trigger"),te=(B instanceof HTMLElement||B instanceof SVGElement)&&!!B.closest(".properties-content");(D.target instanceof HTMLElement||D.target instanceof SVGElement)&&(D.target.closest(`.${Vf.SHAPE_ACTIONS_MENU}, .${Vf.ZOOM_ACTIONS}`)||D.target.closest(".compact-shape-actions-island"))&&!aO(D.target)||W||te?P():D.target instanceof HTMLCanvasElement&&!$C()&&requestAnimationFrame(()=>{M()})},H=a.onChangeEmitter.on(D=>{a.state.theme!==m&&p()}),F=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||d.focus()}),Y=a.onScrollChangeEmitter.on(()=>{p()}),V=!1;s&&d.select(),_();let U=null;return i&&"ResizeObserver"in window?(U=new window.ResizeObserver(()=>{p()}),U.observe(i)):window.addEventListener("resize",p),d.onpointerdown=D=>D.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",A,{capture:!0})}),window.addEventListener("beforeunload",M),l?.querySelector(".hellixitboard-textEditorContainer").appendChild(d),M};import{getGlobalCSSVariable as Km}from"@hellixit/common";import{getCommonBounds as TO}from"@hellixit/element";var _n=4,ao=6,oS="rgba(0,0,0,0.3)",nS=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,l,a]=TO(e),s=o/n.zoom.value,c=t/n.zoom.value,m={top:parseInt(Km("sat"))||0,bottom:parseInt(Km("sab"))||0,left:parseInt(Km("sal"))||0,right:parseInt(Km("sar"))||0},p=En().rtl,d=-n.scrollX+m.left,u=-n.scrollY+m.top,b=d+s-m.right,g=u+c-m.bottom,x=Math.min(r,d),v=Math.min(i,u),y=Math.max(l,b),E=Math.max(a,g),T=l-r,I=a-i,S=y-x,M=E-v,k=Math.max(_n*2,m.left+m.right)+ao*2,_=o*(s/S)-k,P=Math.max(_n*2,m.top+m.bottom)+ao*2,A=t*(c/M)-P,H=S>T?S*n.zoom.value/(_+k):o/(_+k),F=M>I?M*n.zoom.value/(A+P):t/(A+P);return{horizontal:d===x&&b===y?null:{x:Math.max(m.left,_n)+ao+(d-x)/S*o,y:t-ao-Math.max(_n,m.bottom),width:_,height:ao,deltaMultiplier:H},vertical:u===v&&g===E?null:{x:p?Math.max(m.left,_n):o-ao-Math.max(m.right,_n),y:Math.max(m.top,_n)+ao+(u-v)/M*t,width:ao,height:A,deltaMultiplier:F}}},$f=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(l=>l!=null&&l.x<=o&&o<=l.x+l.width&&l.y<=t&&t<=l.y+l.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var rS=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as _O}from"@hellixit/math";import{getElementLineSegments as DO}from"@hellixit/element";import{LinearElementEditor as HO}from"@hellixit/element";import{isFrameLikeElement as RO,isLinearElement as NO,isTextElement as BO}from"@hellixit/element";import{getFrameChildren as FO}from"@hellixit/element";import{selectGroupsForSelectedElements as OO}from"@hellixit/element";import{getContainerElement as zO}from"@hellixit/element";import{arrayToMap as GO,easeOut as sS,isShallowEqual as UO}from"@hellixit/common";import{simplify as IO}from"points-on-curve";import{polygonFromPoints as CO,lineSegment as iS,polygonIncludesPointNonZero as SO}from"@hellixit/math";import{computeBoundTextPosition as wO,doBoundsIntersect as kO,getBoundTextElement as MO,getElementBounds as PO,intersectElementWithLineSegment as aS}from"@hellixit/element";var lS=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:l,simplifyDistance:a}=e,s=o;a&&(s=IO(o,a));let c=t.filter(d=>!d.locked);l.clear(),i.clear();let m=o.reduce((d,u)=>[Math.min(d[0],u[0]),Math.min(d[1],u[1]),Math.max(d[2],u[0]),Math.max(d[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let d of c){let u=PO(d,n);kO(m,u)&&!i.has(d.id)&&!l.has(d.id)&&(AO(s,d,r)?l.add(d.id):LO(s,d,n)&&i.add(d.id))}return{selectedElementIds:[...i,...l]}},AO=(e,o,t)=>{let n=CO(e),r=t.get(o.id);return r?r.some(i=>i.some(l=>SO(l,n))):!1},LO=(e,o,t)=>{let n=e.slice(1).map((i,l)=>iS(e[l],i)).concat([iS(e[e.length-1],e[0])]),r=MO(o,t);return n.some(i=>aS(o,t,i,0,!0).length>0||!!r&&aS({...r,...wO(o,r,t)},t,i,0,!0).length>0)};var $m=class extends Ln{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let a=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(sS(s),sS(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});w(this,"intersectedElements",new Set);w(this,"enclosedElements",new Set);w(this,"elementsSegments",null);w(this,"canvasTranslate",null);w(this,"keepPreviousSelection",!1);w(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&BO(c)){let m=zO(c,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[c.id])}}for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&RO(c)){let m=FO(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of m)delete r[p.id]}}let i=OO({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),l=[...Object.keys(i.selectedElementIds)],a=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:l.length===1&&!a.length&&NO(this.app.scene.getNonDeletedElement(l[0]))?new HO(this.app.scene.getNonDeletedElement(l[0]),this.app.scene.getNonDeletedElementsMap()):null}})});w(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});w(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>_O(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!UO(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=GO(this.app.visibleElements);for(let i of this.app.visibleElements){let l=DO(i,r);this.elementsSegments.set(i.id,l)}}if(t){let{selectedElementIds:r}=lS({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as WO,easeOut as cS,THEME as YO}from"@hellixit/common";import{computeBoundTextPosition as VO,doBoundsIntersect as XO,getBoundTextElement as KO,getElementBounds as $O,getElementLineSegments as ZO,getFreedrawOutlineAsSegments as jO,getFreedrawOutlinePoints as qO,intersectElementWithLineSegment as dS,isArrowElement as JO,isFreeDrawElement as mS,isLineElement as QO,isPointInElement as e7}from"@hellixit/element";import{lineSegment as t7,lineSegmentsDistance as pS,pointFrom as xS,polygon as o7,polygonIncludesPointNonZero as n7}from"@hellixit/math";import{getElementsInGroup as uS}from"@hellixit/element";import{shouldTestInside as r7}from"@hellixit/element";import{hasBoundTextElement as hS,isBoundToContainer as gS}from"@hellixit/element";import{getBoundTextElementId as fS}from"@hellixit/element";var Zm=class extends Ln{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let a=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(cS(s),cS(a))},fill:()=>n.state.theme===YO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});w(this,"elementsToErase",new Set);w(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(a=>xS(a[0],a[1]))||[];if(n.length<2)return[];let r=t7(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(a=>!a.locked),l=WO(i);for(let a of i)if(t&&this.elementsToErase.has(a.id)){if(bS(r,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=uS(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(gS(a)&&this.elementsToErase.delete(a.containerId),hS(a)){let m=fS(a);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(a.id)}}else if(!t&&!this.elementsToErase.has(a.id)&&bS(r,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=uS(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(hS(a)){let m=fS(a);m&&this.elementsToErase.add(m)}gS(a)&&this.elementsToErase.add(a.containerId),this.elementsToErase.add(a.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},bS=(e,o,t,n)=>{let r=e[1],i=mS(o)?15:o.strokeWidth/2,l=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],a=$O(o,t),s=[a[0]-i,a[1]-i,a[2]+i,a[3]+i];if(!XO(l,s))return!1;if(r7(o)&&e7(r,o,t))return!0;if(mS(o)){let m=qO(o),p=jO(o,m,t),d=Math.max(2.25,5/n);for(let b of p)if(pS(b,e)<=d)return!0;let u=o7(...m.map(([b,g])=>xS(o.x+b,o.y+g)));return!!n7(e[0],u)}let c=KO(o,t);if(JO(o)||QO(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/n),p=ZO(o,t);for(let d of p)if(pS(d,e)<=m)return!0;return!1}return dS(o,t,e,0,!0).length>0||!!c&&dS({...c,...VO(o,c,t)},t,e,0,!0).length>0};import{isDevEnv as E7}from"@hellixit/common";import{newElement as v7}from"@hellixit/element";import{COLOR_PALETTE as i7,DEFAULT_FONT_FAMILY as a7,DEFAULT_FONT_SIZE as l7,VERTICAL_ALIGN as s7}from"@hellixit/common";var yS=44,ES=22,vS=66,TS=48,Gs=14,IS=304,CS=320,Zf=5.87,SS=28,wS=4,kS=2,jf=10,MS=10,PS=8,nn=12,Ba=256,ii=10,qf=4,Fa=nn*2,Jf=nn*2,AS=100,LS=140,Us=.35,_S=nn/2,dr=20,jm=nn*2,Qf=nn,He={fillStyle:"hachure",fontFamily:a7,fontSize:l7,opacity:100,roughness:1,strokeColor:i7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:s7.MIDDLE,locked:!1};import{pointFrom as Oa}from"@hellixit/math";import{COLOR_PALETTE as BS,DEFAULT_CHART_COLOR_INDEX as c7,FONT_FAMILY as ob,FONT_SIZES as qm,ROUNDNESS as DS,DEFAULT_FONT_SIZE as d7,getAllColorsSpecificShade as m7,getFontString as nb,getLineHeight as rb,ROUGHNESS as HS}from"@hellixit/common";import{getApproxMinLineWidth as ib,measureText as mr,newElement as tb,newLinearElement as eb,newTextElement as za,wrapText as FS}from"@hellixit/element";var ai=m7(c7),p7=e=>e.labels?.length??e.series[0]?.values.length??0,Ga=(e,o)=>{if(!e)return!1;let t=p7(e);return t<2?!1:o==="radar"?t>=3:!0},RS=(e,o)=>{let t=o<=1?0:Math.min(vS,(o-1)*ES);return e+t},Jm=(e,o)=>{if(e==="line"){let n=RS(TS,o);return{slotWidth:n,gap:Gs,chartHeight:CS,xLabelMaxWidth:n+Gs*3+jf}}let t=RS(yS,o);return{slotWidth:t,gap:Gs,chartHeight:IS,xLabelMaxWidth:t+Gs*3+jf}},Ua=(e,o)=>{let t=(o.slotWidth+o.gap)*e.series[0].values.length+o.gap,n=o.chartHeight+o.gap*2;return{chartWidth:t,chartHeight:n}},OS=()=>{let e=Ba+Jf*2,o=Ba+Jf*2;return{chartWidth:e,chartHeight:o}},u7=(e,o,t)=>{let n=Math.abs(e-o);return Math.min(n,t-n)},Wa=(e,o)=>{if(e<=0||ai.length===0)return[];let t=ai.length,n=(o%t+t)%t,r=[n],i=Math.min(e,t),l=new Set(Array.from({length:t},(a,s)=>s).filter(a=>a!==n));for(;r.length<i;){let a=-1,s=-1,c=-1;for(let m of l){let p=r.map(b=>u7(m,b,t)),d=Math.min(...p),u=p.reduce((b,g)=>b+g,0)/p.length;(d>s||d===s&&u>c)&&(a=m,s=d,c=u)}r.push(a),l.delete(a)}return Array.from({length:e},(a,s)=>ai[r[s%r.length]])},Ya=e=>{if(ai.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*ai.length);let o=e.toString(),t=0;for(let n=0;n<o.length;n++)t=t*31+o.charCodeAt(n)|0;return Math.abs(t)%ai.length},Va=e=>ai[e],zS=(e,o)=>{let t=e.flatMap(a=>a.values.map(s=>Math.max(0,s))),n=t.filter(a=>a>0),r=Math.max(1,...t),i=n.length>0?Math.min(...n):1,l=e.length===1&&i>0&&r/i>=AS;return{renderSteps:!1,normalize:(a,s)=>{let c=Math.max(0,a);return l?Math.log10(c+1)/Math.log10(r+1):c/r}}},h7=e=>/\s/.test(e.trim()),Qm=(e,o,t)=>h7(e)?FS(e,o,t):e,GS=(e,o,t,n,r,i)=>{let l=ob.Excalifont,a=qm.sm,s=rb(l),c=nb({fontFamily:l,fontSize:a}),m=Math.min(LS,r*(e.length>8?.56:.72)),p=ib(c,s),d=e.map((g,x)=>{let v=o[x],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(V=>mr(V,c,s).width)),E=Math.max(p,m,y),T=Qm(g,c,E),I=mr(T,c,s),S=Math.cos(v),M=Math.sin(v),k=S>Us?"left":S<-Us?"right":"center",_=k==="center"?I.width/2:0,P=Math.abs(S)*_+Math.abs(M)*(I.height/2),A=Fa+P+_S,H=t+S*(r+A),F=n+M*(r+A),Y=M>Us?nn/3:M<-Us?-nn/3:0;return za({backgroundColor:i,...He,text:T,originalText:g,x:H,y:F+Y,fontFamily:l,fontSize:a,lineHeight:s,textAlign:k,verticalAlign:"middle"})}),u=Math.min(...d.map(g=>g.y)),b=Math.max(...d.map(g=>g.y+g.height));return{axisLabels:d,axisLabelTopY:u,axisLabelBottomY:b}},Xa=(e,o,t,n,r,i)=>{if(e.length<=1)return[];let l=ob["Lilita One"],a=qm.lg,s=rb(l),c=nb({fontFamily:l,fontSize:a}),m=e.map((T,I)=>{let S=T.title?.trim()||`Series ${I+1}`,M=Qm(S,c,Ba),k=mr(M,c,s),_=dr+Qf+k.width;return{label:S,displayLabel:M,color:o[I],width:_,height:k.height}}),p=Math.max(dr/2,...m.map(T=>T.height/2)),d=Math.max(r,n+p+Fa),u=jm,b=dr*.6,g=m.reduce((T,I)=>T+I.width,0)+jm*Math.max(0,m.length-1),x=g+u*2,v=p*2+b*2,y=[];y.push(tb({...He,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:BS.black,x:t-x/2,y:d-v/2,width:x,height:v,roughness:HS.architect,roundness:{type:DS.PROPORTIONAL_RADIUS}}));let E=t-g/2;return m.forEach(T=>{y.push(tb({...He,backgroundColor:T.color,type:"rectangle",x:E,y:d-dr/2,width:dr,height:dr,fillStyle:"solid",strokeColor:T.color,roughness:HS.architect,roundness:{type:DS.PROPORTIONAL_RADIUS}})),y.push(za({...He,text:T.displayLabel,originalText:T.label,autoResize:!1,x:E+dr+Qf,y:d,fontFamily:l,fontSize:a,lineHeight:s,textAlign:"left",verticalAlign:"middle"})),E+=T.width+jm}),y},g7=(e,o,t,n)=>{if(mr(e,t,n).width<=o)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(mr(i,t,n).width<=o)return i;r--}return e[0]?`${e[0]}...`:e},f7=(e,o,t,n)=>{if(mr(e,t,n).width<=o)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(l=>mr(l,t,n).width>o)&&o>=ib(t,n)?{wrapped:!0,text:FS(e,t,o)}:{wrapped:!1,text:g7(e,o,t,n)}},US=(e,o,t)=>{let n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*n+o*r,height:e*r+o*n}},NS=e=>e.includes("..."),b7=(e,o,t,n,r)=>{let i=Math.max(SS,Math.ceil(ib(n,r))),l=Math.max(i,Math.floor(o)),a=[];for(let u=l;u>=i;u-=4)a.push(u);a[a.length-1]!==i&&a.push(i);let s=u=>{let b=NS(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,x=u.text.split(`
14
+ `).length;return{ellipsified:b,visibleChars:g,lineCount:x}},c=(u,b)=>{let g=s(u),x=s(b);return g.ellipsified!==x.ellipsified?!g.ellipsified:g.visibleChars!==x.visibleChars?g.visibleChars>x.visibleChars:g.lineCount!==x.lineCount?g.lineCount<x.lineCount:u.rotatedHeight<b.rotatedHeight},m=null,p=null,d=null;for(let u of a){let{wrapped:b,text:g}=f7(e,u,n,r),x=mr(g,n,r),v=US(x.width,x.height,Zf),y={originalText:e,text:g,metrics:x,rotatedWidth:v.width,rotatedHeight:v.height,wrapped:b},E=v.width-t;if(E<=0){(!m||c(y,m))&&(m=y);continue}(!p||E<p.overflow||E===p.overflow&&c(y,p.spec))&&(p={overflow:E,spec:y}),!NS(y.text)&&(!d||E<d.overflow||E===d.overflow&&c(y,d.spec))&&(d={overflow:E,spec:y})}return m||(d&&p&&d.overflow<=p.overflow+PS?d.spec:p.spec)},ep=e=>{if(e.type!=="text")return e.y+e.height;let o=US(e.width,e.height,e.angle);return e.y+e.height/2+o.height/2},Ws=(e,o,t,n,r)=>{let i=He.fontFamily,l=qm.sm,a=rb(i),s=nb({fontFamily:i,fontSize:l}),c=Math.max(1,r.slotWidth+r.gap-wS*2+MS),m=t;return e.labels?.map((p,d)=>{let u=b7(p,r.xLabelMaxWidth,c,s,a),b=o+d*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=m+kS+(u.rotatedHeight-u.metrics.height)/2;return za({backgroundColor:n,...He,text:u.text,originalText:u.wrapped?p:u.text,autoResize:!u.wrapped,x:b,y:g,angle:Zf,fontSize:l,lineHeight:a,textAlign:"center",verticalAlign:"top"})})||[]},x7=(e,o,t,n,r,i=Math.max(...e.series[0].values))=>{let l=za({backgroundColor:n,...He,x:o-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),a=za({backgroundColor:n,...He,x:o-r.gap,y:t-r.chartHeight-l.height/2,text:i.toLocaleString(),textAlign:"right"});return[l,a]},y7=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:l}=Ua(e,r),a=eb({backgroundColor:n,...He,type:"line",x:o,y:t,width:i,points:[Oa(0,0),Oa(i,0)]}),s=eb({backgroundColor:n,...He,type:"line",x:o,y:t,height:l,points:[Oa(0,0),Oa(0,-l)]}),c=eb({backgroundColor:n,...He,type:"line",x:o,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ii,points:[Oa(0,0),Oa(i,0)]});return[a,s,c]},tp=(e,o,t,n,r,i=Math.max(...e.series[0].values),l)=>{let{chartWidth:a,chartHeight:s}=Ua(e,r),c=e.title?za({backgroundColor:n,...He,text:e.title,x:o+a/2,y:t-r.chartHeight-r.gap*2-d7,roundness:null,textAlign:"center",fontSize:qm.xl,fontFamily:ob["Lilita One"]}):null,m=l?tb({backgroundColor:n,...He,type:"rectangle",x:o,y:t-s,width:a,height:s,strokeColor:BS.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...c?[c]:[],...Ws(e,o,t,n,r),...x7(e,o,t,n,r,i),...y7(e,o,t,n,r)]};var WS=(e,o,t,n)=>{let r=e.series,i=Jm("bar",r.length),l=Math.max(1,...r.flatMap(T=>T.values.map(I=>Math.max(0,I)))),a=Ya(n),s=Va(a),c=Wa(r.length,a),m=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,p=r.length>1?Math.max(2,(i.slotWidth-m*(r.length-1))/r.length):i.slotWidth,d=r.length*p+m*(r.length-1),u=(i.slotWidth-d)/2,b=r[0].values.flatMap((T,I)=>r.map((S,M)=>{let _=Math.max(0,S.values[I]??0)/l*i.chartHeight,P=r.length>1?c[M]:s;return v7({backgroundColor:P,...He,type:"rectangle",fillStyle:r.length>1?"solid":He.fillStyle,strokeColor:r.length>1?P:He.strokeColor,x:o+I*(i.slotWidth+i.gap)+i.gap+u+M*(p+m),y:t-_-i.gap,width:p,height:_})})),g=tp(e,o,t,s,i,l,E7()),x=Ws(e,o,t,s,i),v=Math.max(t+i.gap/2,...x.map(T=>ep(T))),{chartWidth:y}=Ua(e,i),E=Xa(r,c,o+y/2,v,t+i.gap*5,s);return[...g,...b,...E]};import{pointFrom as ab}from"@hellixit/math";import{isDevEnv as T7}from"@hellixit/common";import{newElement as I7,newLinearElement as YS}from"@hellixit/element";var VS=(e,o,t,n)=>{let r=e.series,i=Jm("line",r.length),l=Math.max(1,...r.flatMap(E=>E.values)),a=Ya(n),s=Va(a),c=Wa(r.length,a),m=r.map((E,T)=>{let I=E.values.map((P,A)=>ab(A*(i.slotWidth+i.gap),-(P/l)*i.chartHeight)),S=Math.max(...I.map(P=>P[0])),M=Math.max(...I.map(P=>P[1])),k=Math.min(...I.map(P=>P[0])),_=Math.min(...I.map(P=>P[1]));return YS({backgroundColor:"transparent",...He,type:"line",x:o+i.gap+i.slotWidth/2,y:t-i.gap,height:M-_,width:S-k,strokeColor:c[T],strokeWidth:2,points:I})}),p=r.flatMap((E,T)=>E.values.map((I,S)=>{let M=S*(i.slotWidth+i.gap)+i.gap/2,k=-(I/l)*i.chartHeight+i.gap/2;return I7({backgroundColor:c[T],...He,fillStyle:"solid",strokeColor:c[T],strokeWidth:2,type:"ellipse",x:o+M+i.slotWidth/2,y:t+k-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((E,T)=>Math.max(0,...r.map(I=>I.values[T]??0))).map((E,T)=>{let I=T*(i.slotWidth+i.gap)+i.gap/2,S=E/l*i.chartHeight+i.gap/2+i.gap;return YS({backgroundColor:s,...He,type:"line",x:o+I+i.slotWidth/2+i.gap/2,y:t-S,height:S,strokeStyle:"dotted",opacity:ii,points:[ab(0,0),ab(0,S)]})}),b=tp(e,o,t,s,i,l,T7()),g=Ws(e,o,t,s,i),x=Math.max(t+i.gap/2,...g.map(E=>ep(E))),{chartWidth:v}=Ua(e,i),y=Xa(r,c,o+v/2,x,t+i.gap*5,s);return[...b,...m,...u,...p,...y]};var Po=e=>{let o=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},C7=(e,o)=>e.slice(1).every(t=>Po(t[o])!==null),XS=e=>{let o=e[0].length;if(o>2){let l=e[0].every(p=>Po(p)===null),a=l?e.slice(1):e;if(a.length<1)return{ok:!1,reason:"No data rows"};if(a.some(p=>p.slice(1).some(d=>Po(d)===null)))return{ok:!1,reason:"Value is not numeric"};if(o-1>a.length){let p=l?e[0].slice(1).map(b=>b.trim()):null,d=a.map(b=>({title:b[0]?.trim()||null,values:b.slice(1).map(g=>Po(g))}));return{ok:!0,data:{title:d.length===1?d[0].title:l&&e[0][0].trim()||null,labels:p,series:d}}}let m=e[0].slice(1).map((p,d)=>{let u=d+1,b=`Series ${u}`;return{title:l&&p.trim()||b,values:a.map(g=>Po(g[u]))}});return{ok:!0,data:{title:l&&e[0][0].trim()||null,labels:a.map(p=>p[0]),series:m}}}if(o===1){if(!C7(e,0))return{ok:!1,reason:"Value is not numeric"};let l=Po(e[0][0])===null,a=l?e[0][0]:null,s=(l?e.slice(1):e).map(c=>Po(c[0]));return s.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:a,labels:null,series:[{title:a,values:s}]}}}let t=Po(e[0][1])===null,n=t?e.slice(1):e;if(n.length<2)return{ok:!1,reason:"Less than 2 rows"};if(n.some(l=>Po(l[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:n.map(l=>l[0]),series:[{title:i,values:n.map(l=>Po(l[1]))}]}}},op=e=>{let o=a=>e.replace(/\r\n?/g,`
15
15
  `).split(`
16
- `).filter(s=>s.trim().length>0).map(s=>s.split(a).map(c=>c.trim())),t=[" ",",",";"].map(a=>{let s=o(a),c=s[0]?.length??0,m=s.length>0&&s.every(p=>p.length===c);return{delimiter:a,parsed:s,numCols:c,isConsistent:m}}),r=(t.find(a=>a.isConsistent&&a.numCols>1)??t.find(a=>a.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(a=>a.length===i)?XC(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ka}from"@excalidraw/math";import{FONT_FAMILY as C7,FONT_SIZES as S7,getFontString as k7,getLineHeight as M7,ROUGHNESS as KC}from"@excalidraw/common";import{measureText as P7,newLinearElement as lb,newTextElement as A7}from"@excalidraw/element";var $C=(e,o,t,n)=>{if(!Ga(e,"radar"))return null;let r=e.labels??e.series[0].values.map((V,U)=>`Value ${U+1}`),i=e.series,{normalize:l,renderSteps:a}=zC(i,r.length),s=Ya(n),c=Va(s),m=Wa(i.length,s),{chartWidth:p,chartHeight:d}=OC(),u=o+p/2,b=t-d/2,g=Ba/2,x=r.map((V,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:v,axisLabelTopY:y,axisLabelBottomY:E}=GC(r,x,u,b,g,c),T=C7["Lilita One"],I=S7.xl,C=M7(T),M=k7({fontFamily:T,fontSize:I}),k=e.title?Qm(e.title,M,p+Fa*2):null,_=k?P7(k,M,C):null,P=k?A7({backgroundColor:c,...He,text:k,originalText:e.title??k,x:o+p/2,y:y-Fa-_.height/2,fontFamily:T,fontSize:I,lineHeight:C,textAlign:"center"}):null,A=a?Array.from({length:qf},(V,U)=>{let D=(U+1)/qf,B=g*D,W=x.map(te=>Ka(Math.cos(te)*B,Math.sin(te)*B));return W.push(Ka(W[0][0],W[0][1])),lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:B*2,height:B*2,strokeStyle:"solid",roughness:KC.architect,opacity:ii,polygon:!0,points:W})}):[],H=x.map(V=>{let U=Math.cos(V)*g,D=Math.sin(V)*g;return lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:Math.abs(U),height:Math.abs(D),strokeStyle:"solid",roughness:KC.architect,opacity:ii,points:[Ka(0,0),Ka(U,D)]})}),F=i.map((V,U)=>{let D=x.map((B,W)=>{let te=V.values[W]??0,X=l(te,W)*g;return Ka(Math.cos(B)*X,Math.sin(B)*X)});return D.push(Ka(D[0][0],D[0][1])),lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:g*2,height:g*2,strokeColor:m[U],strokeWidth:2,polygon:!0,points:D})}),Y=Xa(i,m,u,E,t+nn*5,c);return[...P?[P]:[],...v,...A,...H,...F,...Y]};var sb=(e,o,t,n,r)=>e==="line"?VC(o,t,n,r):e==="radar"?$C(o,t,n,r):WC(o,t,n,r);import{jsx as lo,jsxs as ZC}from"react/jsx-runtime";var L7=()=>ZC("div",{"data-testid":"brave-measure-text-error",children:[lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>lo("span",{style:{fontWeight:600},children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>lo("span",{style:{fontWeight:600},children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>lo("a",{href:"http://docs.excalidraw.com/docs/@hellixit/hellixitboard/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>lo("a",{href:"https://github.com/hellixitboard/hellixitboard/issues/new",children:e}),discordLink:e=>ZC("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),jC=L7;import F7 from"clsx";import O7 from"react";import{useLayoutEffect as _7,useRef as qC,useEffect as JC}from"react";import{unstable_batchedUpdates as D7}from"react-dom";import{KEYS as H7,queryFocusableElements as R7}from"@excalidraw/common";import N7 from"clsx";import{jsx as B7}from"react/jsx-runtime";var QC=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:l=0,viewportWidth:a=window.innerWidth,viewportHeight:s=window.innerHeight,className:c})=>{let m=qC(null);JC(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let u=b=>{if(b.key===H7.TAB){let g=R7(d),{activeElement:x}=document,v=g.findIndex(y=>y===x);x===d?(b.shiftKey?g[g.length-1]?.focus():g[0].focus(),b.preventDefault(),b.stopImmediatePropagation()):v===0&&b.shiftKey?(g[g.length-1]?.focus(),b.preventDefault(),b.stopImmediatePropagation()):v===g.length-1&&!b.shiftKey&&(g[0]?.focus(),b.preventDefault(),b.stopImmediatePropagation())}};return d.addEventListener("keydown",u),()=>d.removeEventListener("keydown",u)},[]);let p=qC(null);return _7(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:u,height:b}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},u>=a?(d.style.width=`${a}px`,d.style.left="0px",d.style.overflowX="scroll"):o+u-i>a?d.style.left=`${a-u-10}px`:d.style.left=`${o}px`,b>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+b-l>s?d.style.top=`${s-b}px`:d.style.top=`${t}px`}},[t,o,r,a,s,i,l]),JC(()=>{if(n){let d=u=>{m.current?.contains(u.target)||D7(()=>n(u))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),B7("div",{className:N7("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as $a,jsxs as z7}from"react/jsx-runtime";var qe="separator",eS=O7.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=Xo(),l=Kn(),a=o.reduce((s,c)=>(c&&(c===qe||!c.predicate||c.predicate(l,i,e.app.props,e.app))&&s.push(c),s),[]);return $a(QC,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:$a("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:a.map((s,c)=>{if(s===qe)return!a[c-1]||a[c-1]===qe?null:$a("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=h(s.label(l,i,e.app)):p=h(s.label)),$a("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:z7("button",{type:"button",className:F7("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[$a("div",{className:"context-menu-item__label",children:p}),$a("kbd",{className:"context-menu-item__shortcut",children:m?Le(m):""})]})},c)})})})});import{jsx as cb,jsxs as tS}from"react/jsx-runtime";var G7=({height:e,width:o,userToFollow:t,onDisconnect:n})=>cb("div",{className:"follow-mode",style:{width:o,height:e},children:tS("div",{className:"follow-mode__badge",children:[tS("div",{className:"follow-mode__badge__label",children:["Following"," ",cb("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),cb("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Qt})]})}),oS=G7;import hi from"clsx";import qW from"react";import{CLASSES as JW,DEFAULT_SIDEBAR as Tx,TOOL_TYPE as gP,arrayToMap as QW,capitalizeString as eY,isShallowEqual as Kp}from"@excalidraw/common";import{mutateElement as tY}from"@excalidraw/element";import{showSelectedShapeActions as oY}from"@excalidraw/element";import{ShapeCache as nY}from"@excalidraw/element";import U7 from"clsx";import{useState as W7,useEffect as Y7}from"react";import{THEME as V7}from"@excalidraw/common";import{jsx as db,jsxs as X7}from"react/jsx-runtime";var np=({delay:e,theme:o})=>{let[t,n]=W7(!!e);return Y7(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:X7("div",{className:U7("LoadingMessage",{"LoadingMessage--dark":o===V7.DARK}),children:[db("div",{children:db(it,{})}),db("div",{className:"LoadingMessage-text",children:h("labels.loadingScene")})]})};import K7 from"clsx";import{jsx as rS,jsxs as Z7}from"react/jsx-runtime";var $7="medium",nS={CHECKED:Si,UNCHECKED:Hr},iS=e=>Z7("label",{className:K7("ToolIcon ToolIcon__lock",`ToolIcon_size_${$7}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[rS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),rS("div",{className:"ToolIcon__icon",children:e.checked?nS.CHECKED:nS.UNCHECKED})]});import{useState as rp,useEffect as sS,useRef as J7}from"react";import Za from"clsx";import{KEYS as mb,capitalizeString as ot,viewportCoordsToSceneCoords as Q7}from"@excalidraw/common";import{newElement as ez,newTextElement as cS}from"@excalidraw/element";import j7 from"clsx";import{KEYS as aS}from"@excalidraw/common";import{jsx as q7}from"react/jsx-runtime";var lS=e=>q7(J,{className:j7("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:Ni,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:aS.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":aS.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as dS,jsx as Ke,jsxs as ip}from"react/jsx-runtime";var pb=[{type:"rectangle",icon:ki,title:ot(h("toolBar.rectangle"))},{type:"diamond",icon:Mi,title:ot(h("toolBar.diamond"))},{type:"ellipse",icon:Pi,title:ot(h("toolBar.ellipse"))}],ub=[{type:"selection",icon:Rr,title:ot(h("toolBar.selection"))},{type:"lasso",icon:Un,title:ot(h("toolBar.lasso"))}],hb=[{type:"arrow",icon:Fc,title:ot(h("toolBar.arrow"))},{type:"line",icon:Ai,title:ot(h("toolBar.line"))}],mS=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=rp(!1),[l,a]=rp("rectangle"),[s,c]=rp("arrow");sS(()=>{(n.type==="rectangle"||n.type==="diamond"||n.type==="ellipse")&&a(n.type)},[n.type]),sS(()=>{(n.type==="arrow"||n.type==="line")&&c(n.type)},[n.type]);let m=n.type==="frame",p=n.type==="laser",d=n.type==="embeddable",{TTDDialogTriggerTunnel:u}=Pe(),b=J7(null),g=(F,Y)=>{e.state.activeTool.type!==F&&ce("toolbar",F,"ui"),F==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:F})},[x,v]=rp(0),y=36,E=4,T=7,I=T*y+(T-1)*E,C=y+E,M=x>=I+1*C,k=x>=I+2*C,_=x>=I+3*C,A=["text","frame","embeddable","laser","magicframe"].filter(F=>!(M&&F==="text"||k&&F==="image"||_&&F==="frame")).includes(n.type),H=A?n.type==="text"?Wo:n.type==="image"?Li:n.type==="frame"?yo:n.type==="embeddable"?_i:n.type==="laser"?Yo:n.type==="magicframe"?Fr:Bl:Bl;return ip(dS,{children:[Ke("input",{ref:b,type:"file",style:{display:"none"},onChange:async F=>{let Y=F.target.files?.[0];if(!Y||(F.target.value="",_r(Y)))return;let U=(await e.props.onFileUpload?.(Y))?.url;if(!U)return;let D=e.state.width/2+e.state.offsetLeft,B=e.state.height/2+e.state.offsetTop,{x:W,y:te}=Q7({clientX:D,clientY:B},e.state),X=Y.name.length>28?`${Y.name.slice(0,25)}...`:Y.name,le=Math.max(220,Math.min(460,X.length*11+132)),pe=56,de=W-le/2,Ee=te-pe/2,Ve=`file-chip-${Date.now()}-${Math.round(Math.random()*1e6)}`,rt=ez({type:"rectangle",x:de,y:Ee,width:le,height:pe,strokeColor:"#d8d8e2",backgroundColor:"#ececf3",fillStyle:"solid",strokeWidth:1,roughness:0,roundness:{type:3,value:16},groupIds:[Ve],customData:{filePlaceholderUrl:U}}),ft=cS({x:de+22,y:Ee+16,text:"\u{1F4CE}",fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#5a5a66",groupIds:[Ve],customData:{filePlaceholderUrl:U}}),wt=cS({x:de+52,y:Ee+17,text:X,fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#2d2d36",groupIds:[Ve],customData:{filePlaceholderUrl:U}});e.scene.insertElements([rt,ft,wt])}}),ip("div",{className:"mobile-toolbar",ref:F=>{F&&v(F.getBoundingClientRect().width)},children:[Ke(lS,{checked:yn(e.state),onChange:o,title:h("toolBar.hand"),isMobile:!0}),Ke(Sa,{app:e,options:ub,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:ot(h("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:F=>{(F==="selection"||F==="lasso")&&(e.setActiveTool({type:F}),t({preferredSelectionTool:{type:F,initialized:!0}}))},displayedOption:ub.find(F=>F.type===e.state.preferredSelectionTool.type)||ub[0]}),Ke(J,{className:Za({active:n.type==="freedraw"}),type:"radio",icon:Uo,checked:n.type==="freedraw",name:"editor-current-shape",title:`${ot(h("toolBar.freedraw"))}`,"aria-label":ot(h("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>g("freedraw")}),Ke(J,{className:Za({active:n.type==="eraser"}),type:"radio",icon:Oc,checked:n.type==="eraser",name:"editor-current-shape",title:`${ot(h("toolBar.eraser"))}`,"aria-label":ot(h("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>g("eraser")}),Ke(Sa,{app:e,options:pb,activeTool:n,defaultOption:l,namePrefix:"shapeType",title:ot(h(l==="rectangle"?"toolBar.rectangle":l==="diamond"?"toolBar.diamond":l==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:F=>{(F==="rectangle"||F==="diamond"||F==="ellipse")&&(a(F),e.setActiveTool({type:F}))},displayedOption:pb.find(F=>F.type===l)||pb[0]}),Ke(Sa,{app:e,options:hb,activeTool:n,defaultOption:s,namePrefix:"linearElementType",title:ot(h(s==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:F=>{(F==="arrow"||F==="line")&&(c(F),e.setActiveTool({type:F}))},displayedOption:hb.find(F=>F.type===s)||hb[0]}),M&&Ke(J,{className:Za({active:n.type==="text"}),type:"radio",icon:Wo,checked:n.type==="text",name:"editor-current-shape",title:`${ot(h("toolBar.text"))}`,"aria-label":ot(h("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>g("text")}),k&&Ke(J,{className:Za({active:n.type==="image"}),type:"radio",icon:Li,checked:n.type==="image",name:"editor-current-shape",title:`${ot(h("toolBar.image"))}`,"aria-label":ot(h("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>g("image")}),_&&Ke(J,{className:Za({active:m}),type:"radio",icon:yo,checked:m,name:"editor-current-shape",title:`${ot(h("toolBar.frame"))}`,"aria-label":ot(h("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>g("frame")}),ip(ie,{open:r,children:[Ke(ie.Trigger,{className:Za("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":A||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),style:{width:y,height:y,display:"flex",alignItems:"center",justifyContent:"center"},children:H}),ip(ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[!M&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Wo,shortcut:mb.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:h("toolBar.text")}),!k&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Li,"data-testid":"toolbar-image",selected:n.type==="image",children:h("toolBar.image")}),!_&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:yo,shortcut:mb.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,children:h("toolBar.frame")}),Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:_i,"data-testid":"toolbar-embeddable",selected:d,children:h("toolBar.embeddable")}),Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:p,shortcut:mb.K.toLocaleUpperCase(),children:h("toolBar.laser")}),e.props.onFileUpload&&Ke(ie.Item,{onSelect:()=>b.current?.click(),icon:Yc,"data-testid":"toolbar-upload-file",children:h("toolBar.uploadFile")}),Ke("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ke(u.Out,{}),Ke(ie.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Fi,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToHellixitboard")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ke(dS,{children:Ke(ie.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Fr,"data-testid":"toolbar-magicframe",badge:Ke(ie.Item.Badge,{children:"AI"}),children:h("toolBar.magicframe")})})]})]})]})]})};import tz from"clsx";import{jsx as oz}from"react/jsx-runtime";var ap=({children:e,side:o,className:t})=>oz("div",{className:tz("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import nz from"clsx";import{jsx as pS,jsxs as iz}from"react/jsx-runtime";var rz="medium",lp=e=>e.penDetected?iz("label",{className:nz("ToolIcon ToolIcon__penMode",`ToolIcon_size_${rz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[pS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),pS("div",{className:"ToolIcon__icon",children:p0})]}):null;import{Fragment as uS,jsx as rn,jsxs as li}from"react/jsx-runtime";var hS=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:l,renderSidebars:a,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:b}=Pe(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let v=li("div",{className:"hellixitboard-ui-top-right",children:[l?.(!0,e),!e.viewModeEnabled&&li(uS,{children:[rn(lp,{checked:e.penMode,onChange:()=>p(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rn(b.Out,{})]}),e.viewModeEnabled&&rn(_I,{actionManager:t})]}),y=li("div",{className:"hellixitboard-ui-top-left",children:[i?.(!0,e),rn(u.Out,{})]});return li("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[y,v]})},x=()=>rn(mS,{app:m,onHandToolToggle:r,setAppState:n});return li(uS,{children:[a(),rn("div",{className:"App-welcome-screen",children:s&&rn(d.Out,{})}),!e.viewModeEnabled&&li("div",{className:"App-bottom-bar",style:{marginBottom:ao+_n},children:[rn(kI,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:n}),li(Xe,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&x(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&rn("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(v=>({...Pr(o,v)}))},children:h("buttons.scrollBackToContent")})]})]}),rn(ap,{side:"top",className:"App-top-bar",children:g()})]})};import gS,{useLayoutEffect as fS,useRef as bS,useState as xS}from"react";import{newTextElement as yS}from"@excalidraw/element";import{jsx as Dn,jsxs as sp}from"react/jsx-runtime";var az=e=>{switch(e){case"bar":return h("labels.chartType_bar");case"line":return h("labels.chartType_line");case"radar":return h("labels.chartType_radar");default:return e}},lz=e=>{let o=bS(null),[t,n]=xS(null),{theme:r}=se();fS(()=>{if(!e.spreadsheet){n(null);return}let l=sb(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!l){n(null),o.current?.replaceChildren();return}n(l);let a,s=o.current;return(async()=>(a=await Ar(l,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),a.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(a)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=az(e.chartType);return sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Dn("div",{className:"ChartPreview__canvas",ref:o}),Dn("div",{className:"ChartPreview__label",children:i})]})},sz=e=>{let o=bS(null),{theme:t}=se();return fS(()=>{if(!e.rawText)return;let n=yS({text:e.rawText,x:0,y:0}),r=o.current;return(async()=>{let i=await Ar([n],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),sp("button",{type:"button",className:"ChartPreview","aria-label":h("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Dn("div",{className:"ChartPreview__canvas",ref:o}),Dn("div",{className:"ChartPreview__label",children:h("labels.chartType_plaintext")})]})},ES=({data:e,rawText:o,onClose:t})=>{let{onInsertElements:n,focusContainer:r}=Ae(),[i,l]=xS(Math.random()),a=gS.useCallback(()=>{l(Math.random())},[]),s=gS.useCallback(()=>{t&&t()},[t]),c=(p,d)=>{n(d),ce("paste","chart",p),t(),r()},m=p=>{let d=yS({text:p,x:0,y:0});n([d]),ce("paste","chart","plaintext"),t(),r()};return Dn(je,{size:"regular",onCloseRequest:s,title:sp("div",{className:"PasteChartDialog__title",children:[Dn("div",{className:"PasteChartDialog__titleText",children:h("labels.pasteCharts")}),Dn("div",{className:"PasteChartDialog__reshuffleBtn",onClick:a,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a())},children:Ri})]}),className:"PasteChartDialog",autofocus:!1,children:sp("div",{className:"container",children:[["bar","line","radar"].map(p=>Ga(e,p)?Dn(lz,{chartType:p,spreadsheet:e,colorSeed:i,onClick:c},p):null),o&&Dn(sz,{rawText:o,onClick:m})]})})};import{Fragment as cz,jsx as vS,jsxs as dz}from"react/jsx-runtime";var Ys=({heading:e,children:o,...t})=>{let{id:n}=_e(),r=vS("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:h(`headings.${e}`)});return vS("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):dz(cz,{children:[r,o]})})};import{Popover as cp}from"radix-ui";import TS from"clsx";import dp,{useLayoutEffect as mz}from"react";import{supportsResizeObserver as pz,isShallowEqual as uz}from"@excalidraw/common";import{Fragment as xz,jsx as an,jsxs as mp}from"react/jsx-runtime";var hz=4,gz=8,fz=({shouldWrap:e,children:o,username:t})=>e?an($t,{label:t||"Unknown user",children:o}):an(xz,{children:o}),gb=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let l={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},a=e.renderAction("goToCollaborator",l);return an(fz,{username:o.username,shouldWrap:r,children:a},t)},bz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],pp=dp.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=De(),i=new Map;t.forEach((g,x)=>{let v=g.id||x;i.set(v,{...g,socketId:x})});let l=Array.from(i.values()).filter(g=>g.username?.trim()),[a,s]=dp.useState(""),c=l.filter(g=>g.username?.toLowerCase().includes(a)),m=dp.useRef(null);mz(()=>{if(m.current){let g=v=>{let y=Math.max(1,Math.min(8,Math.floor(v/38)));d(y)};if(g(m.current.clientWidth),!pz)return;let x=new ResizeObserver(v=>{for(let y of v){let{width:E}=y.contentRect;g(E)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[p,d]=dp.useState(hz),b=l.slice(0,p-1).map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}));return o?an("div",{className:TS("UserList UserList_mobile",e),children:l.map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}))}):an("div",{className:"UserList__wrapper",ref:m,children:mp("div",{className:TS("UserList",e),style:{"--max-avatars":p},children:[b,l.length>p-1&&mp(cp.Root,{children:[mp(cp.Trigger,{className:"UserList__more",children:["+",l.length-p+1]}),an(cp.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:mp(Xe,{padding:2,children:[l.length>=gz&&an(pd,{placeholder:h("quickSearch.placeholder"),onChange:s}),an(ud,{className:"dropdown-menu UserList__collaborators",placeholder:h("userList.empty"),children:c.length>0?[an("div",{className:"hint",children:h("userList.hint.text")}),c.map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,withName:!0,isBeingFollowed:g.socketId===n}))]:[]}),an(cp.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!uz(r,i,bz))return!1}return!0});import fb from"clsx";import{jsx as yz}from"react/jsx-runtime";var IS=e=>yz("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${h("helpDialog.title")} \u2014 ?`,"aria-label":h("helpDialog.title"),children:Di});import{jsx as Hn,jsxs as up}from"react/jsx-runtime";var wS=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i,FooterRightSlotTunnel:l}=Pe();return up("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Hn("div",{className:fb("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Hn(Et.Col,{gap:2,children:up(Ys,{heading:"canvasActions",children:[Hn(PI,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Hn(AI,{renderAction:o.renderAction,className:fb("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Hn(r.Out,{}),up("div",{className:fb("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[Hn(l.Out,{}),up("div",{style:{position:"relative"},children:[n&&Hn(i.Out,{}),Hn(IS,{onClick:()=>o.executeAction(Vr)})]})]}),Hn(LI,{actionManager:o,showExitZenModeBtn:t})]})},CS=wS;wS.displayName="Footer";import Lz from"clsx";import{useEffect as _S,useLayoutEffect as DS,useRef as Cb,useState as _z,forwardRef as HS,useImperativeHandle as Dz,useCallback as PS}from"react";import{CLASSES as Hz,EVENT as AS,isDevEnv as Rz,KEYS as Nz,updateObject as Bz}from"@excalidraw/common";import vz from"clsx";import{useContext as Tz}from"react";import Ez from"react";var hp=Ez.createContext({});import{jsx as bb,jsxs as SS}from"react/jsx-runtime";var xb=({children:e,className:o})=>{let t=fe(),n=Tz(hp),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return SS("div",{className:vz("sidebar__header",o),"data-testid":"sidebar-header",children:[e,SS("div",{className:"sidebar__header__buttons",children:[r&&bb($t,{label:h("labels.sidebarLock"),children:bb(ut,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":h("labels.sidebarLock"),children:l0})}),bb(ut,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":h("buttons.close"),children:Qt})]})]})};xb.displayName="SidebarHeader";import{Tabs as Iz}from"radix-ui";import{jsx as kS}from"react/jsx-runtime";var yb=({children:e,tab:o,onSelect:t,...n})=>kS(Iz.Trigger,{value:o,asChild:!0,onSelect:t,children:kS("button",{type:"button",className:"hellixitboard-button sidebar-tab-trigger",...n,children:e})});yb.displayName="SidebarTabTrigger";import{Tabs as wz}from"radix-ui";import{jsx as Cz}from"react/jsx-runtime";var Eb=({children:e,...o})=>Cz(wz.List,{className:"sidebar-triggers",...o,children:e});Eb.displayName="SidebarTabTriggers";import Sz from"clsx";import{jsx as vb,jsxs as MS}from"react/jsx-runtime";var Tb=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:l,style:a})=>{let s=he(),c=se();return MS("label",{title:n,className:"sidebar-trigger__label-element",children:[vb("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),MS("div",{className:Sz("sidebar-trigger",l),style:a,children:[t&&vb("div",{children:t}),r&&vb("div",{className:"sidebar-trigger__label",children:r})]})]})};Tb.displayName="SidebarTrigger";import{Tabs as kz}from"radix-ui";import{jsx as Mz}from"react/jsx-runtime";var Ib=({children:e,...o})=>{let t=se(),n=he();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return Mz(kz.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(l=>({...l,openSidebar:{...l.openSidebar,name:r,tab:i}})),...o,children:e})};Ib.displayName="SidebarTabs";import{Tabs as Pz}from"radix-ui";import{jsx as Az}from"react/jsx-runtime";var wb=({tab:e,children:o,...t})=>Az(Pz.Content,{...t,value:e,"data-testid":e,children:o});wb.displayName="SidebarTab";import{jsx as LS}from"react/jsx-runtime";import{createElement as Fz}from"react";var Vs=ge(!1),RS=HS(({name:e,children:o,onDock:t,docked:n,className:r,...i},l)=>{Rz()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let a=he(),s=zo(Vs);DS(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=Cb({});c.current.onCloseRequest=()=>{a({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Bz(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=Cb(null);Dz(l,()=>m.current);let p=fe(),d=PS(()=>{document.querySelector(".Dialog")||a({openSidebar:null})},[a]);return Xi(m,PS(u=>{u.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&d()},[d,n,p.canFitSidebar])),_S(()=>{let u=b=>{b.key===Nz.ESCAPE&&(!n||!p.canFitSidebar)&&d()};return document.addEventListener(AS.KEYDOWN,u),()=>{document.removeEventListener(AS.KEYDOWN,u)}},[d,n,p.canFitSidebar]),LS(Xe,{...i,className:Lz(Hz.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:LS(hp.Provider,{value:c.current,children:o})})});RS.displayName="SidebarInner";var so=Object.assign(HS((e,o)=>{let t=se(),{onStateChange:n}=e,r=Cb(t.openSidebar);_S(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,l]=_z(!1);return DS(()=>(l(!0),()=>l(!1)),[]),i&&t.openSidebar?.name===e.name?Fz(RS,{...e,ref:o,key:e.name}):null}),{Header:xb,TabTriggers:Eb,TabTrigger:yb,Tabs:Ib,Tab:wb,Trigger:Tb});so.displayName="Sidebar";import{composeEventHandlers as Xz}from"@excalidraw/common";import{useLayoutEffect as Oz,useRef as zz}from"react";import{jsx as Gz}from"react/jsx-runtime";var Rn=(e,o)=>{let t=ge(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Pe(),[,l]=i(t),a=zz({preferHost:!1,counter:0});return Oz(()=>{let s=a.current;return l(c=>{let m=c+1;return s.counter=m,m}),()=>{l(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[l]),r.__fallback||(a.current.preferHost=!0),!a.current.counter&&r.__fallback&&a.current.preferHost||a.current.counter>1&&r.__fallback?null:Gz(o,{...r})};return n.displayName=e,n};var Pb={};Ay(Pb,{ChangeCanvasBackground:()=>$S,ClearCanvas:()=>XS,CommandPalette:()=>WS,Export:()=>ZS,Help:()=>VS,LiveCollaborationTrigger:()=>qS,LoadScene:()=>zS,Preferences:()=>ln,PreferencesToggleGridModeItem:()=>kb,PreferencesToggleZenModeItem:()=>Mb,SaveAsImage:()=>US,SaveToActiveFile:()=>GS,SearchMenu:()=>YS,Socials:()=>jS,ToggleTheme:()=>KS});import Vz from"clsx";import{THEME as pr}from"@excalidraw/common";import Uz from"clsx";import{jsx as NS,jsxs as Wz}from"react/jsx-runtime";var gp=function({onChange:e,value:o,choices:t,name:n}){return NS("div",{className:"RadioGroup",children:t.map(r=>Wz("div",{className:Uz("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[NS("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as Yz,jsx as Sb,jsxs as BS}from"react/jsx-runtime";var FS=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let l=fe();return BS(Yz,{children:[BS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Sb("label",{className:"dropdown-menu-item__text",children:r}),Sb(gp,{name:i,value:e,onChange:t,choices:n})]}),o&&l.formFactor!=="phone"&&Sb("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};FS.displayName="DropdownMenuItemContentRadio";var OS=FS;import{Fragment as rk,jsx as ye,jsxs as Xs}from"react/jsx-runtime";var zS=()=>{let{t:e}=Ie(),o=De(),t=Kn();return o.isActionEnabled(aa)?ye(St,{icon:Hi,onSelect:async()=>{(!t.length||await om({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(Pt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&o.executeAction(aa)},"data-testid":"load-button",shortcut:Le("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};zS.displayName="LoadScene";var GS=()=>{let{t:e}=Ie(),o=De();return o.isActionEnabled(Yr)?ye(St,{shortcut:Le("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Yr),icon:E0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};GS.displayName="SaveToActiveFile";var US=()=>{let e=he(),{t:o}=Ie();return ye(St,{icon:Uc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Le("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};US.displayName="SaveAsImage";var WS=e=>{let o=he(),{t}=Ie();return ye(St,{icon:Fl,"data-testid":"command-palette-button",onSelect:()=>{ce("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Le("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};WS.displayName="CommandPalette";var YS=e=>{let{t:o}=Ie(),t=De();return ye(St,{icon:Kt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ps)},shortcut:Le("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};YS.displayName="SearchMenu";var VS=()=>{let{t:e}=Ie(),o=De();return ye(St,{"data-testid":"help-menu-item",icon:Di,onSelect:()=>o.executeAction(Vr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};VS.displayName="Help";var XS=()=>{let{t:e}=Ie(),o=zo(jr);return De().isActionEnabled(Cn)?ye(St,{icon:pt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};XS.displayName="ClearCanvas";var KS=e=>{let{t:o}=Ie(),t=se(),n=De(),r=Le("toggleTheme");return n.isActionEnabled(Gr)?e?.allowSystemTheme?ye(OS,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:pr.LIGHT,label:Hl,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:pr.DARK,label:Dl,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:zE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):ye(St,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===pr.DARK?pr.LIGHT:pr.DARK);else return n.executeAction(Gr)},icon:t.theme===pr.DARK?Hl:Dl,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===pr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===pr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};KS.displayName="ToggleTheme";var $S=()=>{let{t:e}=Ie(),o=se(),t=De(),n=Ko();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:Xs("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};$S.displayName="ChangeCanvasBackground";var ZS=()=>{let{t:e}=Ie(),o=he();return ye(St,{icon:Nr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};ZS.displayName="Export";var jS=()=>{let{t:e}=Ie();return Xs(rk,{children:[ye(wa,{icon:b0,href:"#","aria-label":"GitHub",children:"GitHub"}),ye(wa,{icon:y0,href:"#","aria-label":"X",children:e("labels.followUs")}),ye(wa,{icon:x0,href:"#","aria-label":"Discord",children:e("labels.discordChat")})]})};jS.displayName="Socials";var qS=({onSelect:e,isCollaborating:o})=>{let{t}=Ie();return ye(St,{"data-testid":"collab-button",icon:Wc,className:Vz({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};qS.displayName="LiveCollaborationTrigger";var JS=()=>{let{t:e}=Ie(),o=Ae(),t=se();return ye(wo,{checked:t.activeTool.locked,shortcut:Le("toolLock"),onSelect:n=>{o.toggleLock(),n.preventDefault()},children:e("labels.preferences_toolLock")})},QS=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.objectsSnapModeEnabled,shortcut:Le("objectsSnapMode"),onSelect:n=>{o.executeAction(cs),n.preventDefault()},children:e("buttons.objectsSnapMode")})},ek=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.bindingPreference==="enabled",onSelect:n=>{o.executeAction(ds),n.preventDefault()},children:e("labels.arrowBinding")})},tk=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.isMidpointSnappingEnabled,onSelect:n=>{o.executeAction(ms),n.preventDefault()},children:e("labels.midpointSnapping")})},kb=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.gridModeEnabled,shortcut:Le("gridMode"),onSelect:n=>{o.executeAction(ua),n.preventDefault()},children:e("labels.toggleGrid")})},Mb=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.zenModeEnabled,shortcut:Le("zenMode"),onSelect:n=>{o.executeAction(tr),n.preventDefault()},children:e("buttons.zenMode")})},ok=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.viewModeEnabled,shortcut:Le("viewMode"),onSelect:n=>{o.executeAction(Zr),n.preventDefault()},children:e("labels.viewMode")})},nk=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(wo,{checked:t.stats.open,shortcut:Le("stats"),onSelect:n=>{o.executeAction(or),n.preventDefault()},children:e("stats.fullTitle")})},ln=({children:e,additionalItems:o})=>{let{t}=Ie();return Xs(ir,{children:[ye(ir.Trigger,{icon:qE,children:t("labels.preferences")}),Xs(ir.Content,{className:"hellixitboard-main-menu-preferences-submenu",children:[e||Xs(rk,{children:[ye(JS,{}),ye(QS,{}),ye(kb,{}),ye(Mb,{}),ye(ok,{}),ye(nk,{}),ye(ek,{}),ye(tk,{})]}),o]})]})};ln.ToggleToolLock=JS;ln.ToggleSnapMode=QS;ln.ToggleArrowBinding=ek;ln.ToggleMidpointSnapping=tk;ln.ToggleGridMode=kb;ln.ToggleZenMode=Mb;ln.ToggleViewMode=ok;ln.ToggleElementProperties=nk;ln.displayName="Preferences";import{jsx as fp,jsxs as Ab}from"react/jsx-runtime";var Kz=Object.assign(Rn("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Pe(),n=fe(),r=se(),i=he();return fp(t.In,{children:Ab(ie,{open:r.openMenu==="canvas",children:[fp(ie.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:g0}),Ab(ie.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:Xz(o,()=>{i({openMenu:null})}),className:"main-menu",align:"start",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&Ab("fieldset",{className:"UserList-Wrapper",children:[fp("legend",{children:h("labels.collaborators")}),fp(pp,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ie.Trigger,Item:ie.Item,ItemLink:ie.ItemLink,ItemCustom:ie.ItemCustom,Group:ie.Group,Separator:ie.Separator,Sub:ir,DefaultItems:Pb}),vt=Kz;import $z from"clsx";import{forwardRef as Zz,useState as jz}from"react";import{isPromiseLike as qz}from"@excalidraw/common";import{jsx as bp,jsxs as Jz}from"react/jsx-runtime";var sn=Zz(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:l="medium",fullWidth:a,className:s,status:c,disabled:m},p)=>{let[d,u]=jz(!1),b=async x=>{let v=t?.(x);if(qz(v)){let y=window.setTimeout(()=>{u(!0)},50);try{await v}catch(E){if(E instanceof Ei)console.warn(E);else throw E}finally{clearTimeout(y),u(!1)}}},g=d?"loading":c;return i=g==="success"?"success":i,bp("button",{className:$z("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${l}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":a},s),onClick:b,type:"button","aria-label":n,ref:p,disabled:m||g==="loading"||g==="success",children:Jz("div",{className:"ExcButton__contents",children:[g==="loading"?bp(it,{className:"ExcButton__statusIcon"}):g==="success"&&bp("div",{className:"ExcButton__statusIcon",children:EE}),o&&bp("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as ja,jsxs as tG}from"react/jsx-runtime";var xp=({title:e,children:o,actionLabel:t,onClick:n})=>tG("div",{className:"OverwriteConfirm__Actions__Action",children:[ja("h4",{children:e}),ja("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ja(sn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),Qz=()=>{let{t:e}=Ie(),o=De(),t=he();return ja(xp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Bd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},eG=()=>{let{t:e}=Ie(),o=De();return ja(xp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ls,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Lb=Object.assign(({children:e})=>ja("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Qz,SaveToDisk:eG});import{jsx as ur,jsxs as ik}from"react/jsx-runtime";var yp=Object.assign(Rn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Pe(),[t,n]=Q(Hg);if(!t.active)return null;let r=()=>{t.onClose(),n(l=>({...l,active:!1}))},i=()=>{t.onConfirm(),n(l=>({...l,active:!1}))};return ur(o.In,{children:ur(je,{onCloseRequest:r,title:!1,size:916,children:ik("div",{className:"OverwriteConfirm",children:[ur("h3",{children:t.title}),ik("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[ur("div",{className:"OverwriteConfirm__Description__icon",children:Kc}),ur("div",{children:t.description}),ur("div",{className:"OverwriteConfirm__Description__spacer"}),ur(sn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),ur(Lb,{children:e})]})})})}),{Actions:Lb,Action:xp});import IG from"clsx";import{CANVAS_SEARCH_TAB as Nb,DEFAULT_SIDEBAR as wG,LIBRARY_SIDEBAR_TAB as gk,composeEventHandlers as CG}from"@excalidraw/common";import{round as oG}from"@excalidraw/math";import nG from"clsx";import rG from"lodash.debounce";import{Fragment as iG,memo as aG,useEffect as Ks,useMemo as ak,useRef as _b,useState as lk}from"react";import{CLASSES as lG,EVENT as sG,FONT_FAMILY as Db,FRAME_STYLE as Hb,getLineHeight as cG}from"@excalidraw/common";import{isElementCompletelyInViewport as dG}from"@excalidraw/element";import{measureText as $s}from"@excalidraw/element";import{KEYS as qa,randomInteger as sk,addEventListener as mG,getFontString as Ep}from"@excalidraw/common";import{newTextElement as pG}from"@excalidraw/element";import{isTextElement as pk,isFrameLikeElement as vp}from"@excalidraw/element";import{getDefaultFrameName as uk}from"@excalidraw/element/frame";import{Fragment as TG,jsx as ct,jsxs as cn}from"react/jsx-runtime";var uG=ge(""),Rb=ge(null),hG=350,hk=()=>{let e=Ae(),o=he(),t=_b(null),[n,r]=Q(uG),i=n.trim(),[l,a]=lk(!1),[s,c]=lk({nonce:null,items:[]}),m=_b(null),p=_b(void 0),[d,u]=Q(Rb),b=e.scene.getNonDeletedElementsMap();Ks(()=>{l||(i!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,mk(i,e,(E,T)=>{c({nonce:sk(),items:E}),m.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:E.length?{focusedId:null,matches:E.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[l,i,b,e,o,u,p]);let g=()=>{s.items.length>0&&u(E=>E===null?0:(E+1)%s.items.length)},x=()=>{s.items.length>0&&u(E=>E===null?0:E-1<0?s.items.length-1:E-1)};Ks(()=>{o(E=>E.searchMatches?{searchMatches:{focusedId:d!==null&&E.searchMatches?.matches[d]?.id||null,matches:E.searchMatches.matches.map((I,C)=>C===d?{...I,focus:!0}:{...I,focus:!1})}}:null)},[d,o]),Ks(()=>{if(s.items.length>0&&d!==null){let E=s.items[d];if(E){let T=e.state.zoom.value,I=pG({text:E.searchQuery,x:E.element.x+(E.matchedLines[0]?.offsetX??0),y:E.element.y+(E.matchedLines[0]?.offsetY??0),width:E.matchedLines[0]?.width,height:E.matchedLines[0]?.height,fontSize:vp(E.element)?Hb.nameFontSize:E.element.fontSize,fontFamily:vp(E.element)?Db.Assistant:E.element.fontFamily}),C=14,M=I.fontSize,k=M*T<C;if(!dG([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let _;k?M>=C?_={fitToContent:!0}:_={fitToViewport:!0,maxZoom:oG(C/M,1)}:_={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,..._,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Ks(()=>()=>{u(null),m.current=null,p.current=void 0,o({searchMatches:null}),a(!1)},[o,u]);let v=Yn({goToNextItem:g,goToPreviousItem:x,searchMatches:s});Ks(()=>{let E=T=>{if(T.key===qa.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){T.preventDefault(),T.stopPropagation(),o({openSidebar:null});return}if(T[qa.CTRL_OR_CMD]&&T.key===qa.F){if(T.preventDefault(),T.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}T.target instanceof HTMLElement&&T.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(T.key===qa.ENTER&&(T.stopPropagation(),v.goToNextItem()),T.key===qa.ARROW_UP?(T.stopPropagation(),v.goToPreviousItem()):T.key===qa.ARROW_DOWN&&(T.stopPropagation(),v.goToNextItem()))};return mG(window,sG.KEYDOWN,E,{capture:!0,passive:!1})},[o,v,e]);let y=`${s.items.length} ${s.items.length===1?h("search.singleResult"):h("search.multipleResults")}`;return cn("div",{className:"layer-ui__search",children:[ct("div",{className:"layer-ui__search-header",children:ct(ar,{className:lG.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:h("search.placeholder"),icon:Kt,onChange:E=>{r(E),a(!0);let T=E.trim();mk(T,e,(I,C)=>{c({nonce:sk(),items:I}),u(C),m.current=T,p.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(M=>({id:M.element.id,focus:!1,matchedLines:M.matchedLines}))}:null}),a(!1)})},selectOnRender:!0})}),cn("div",{className:"layer-ui__search-count",children:[s.items.length>0&&cn(TG,{children:[d!==null&&d>-1?cn("div",{children:[d+1," / ",y]}):ct("div",{children:y}),cn("div",{className:"result-nav",children:[ct(ut,{onSelect:()=>{g()},className:"result-nav-btn",children:Zc}),ct(ut,{onSelect:()=>{x()},className:"result-nav-btn",children:YE})]})]}),s.items.length===0&&i&&m.current&&ct("div",{style:{margin:"1rem auto"},children:h("search.noMatch")})]}),ct(bG,{matches:s,onItemClick:u,focusIndex:d,searchQuery:i})]})},ck=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ct("div",{tabIndex:-1,className:nG("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ct("div",{className:"preview-text",children:o.flatMap((t,n)=>ct(iG,{children:n===2?ct("b",{children:t}):t},n))})})},gG=e=>{let o=ak(()=>e.matches.items.filter(n=>vp(n.element)),[e.matches]),t=ak(()=>e.matches.items.filter(n=>pk(n.element)),[e.matches]);return cn("div",{children:[o.length>0&&cn("div",{className:"layer-ui__search-result-container",children:[cn("div",{className:"layer-ui__search-result-title",children:[ct("div",{className:"title-icon",children:yo}),ct("div",{children:h("search.frames")})]}),o.map((n,r)=>ct(ck,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&ct("div",{className:"layer-ui__divider"})]}),t.length>0&&cn("div",{className:"layer-ui__search-result-container",children:[cn("div",{className:"layer-ui__search-result-title",children:[ct("div",{className:"title-icon",children:Wo}),ct("div",{children:h("search.texts")})]}),t.map((n,r)=>ct(ck,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},fG=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,bG=aG(gG,fG),dk=(e,o,t)=>{let i=e.slice(0,o),l=i.split(/\s+/),a=i.endsWith(" "),s=l.length-2-1-(a?0:1),c=l.slice(s<=0?0:s).join(" ")+(a?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),u=!p.startsWith(" "),b=u?6:5,g=(u?"":" ")+d.slice(0,b).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:s>0,moreAfter:d.length>b}},xG=(e,o)=>{let t=e.split(`
16
+ `).filter(s=>s.trim().length>0).map(s=>s.split(a).map(c=>c.trim())),t=[" ",",",";"].map(a=>{let s=o(a),c=s[0]?.length??0,m=s.length>0&&s.every(p=>p.length===c);return{delimiter:a,parsed:s,numCols:c,isConsistent:m}}),r=(t.find(a=>a.isConsistent&&a.numCols>1)??t.find(a=>a.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(a=>a.length===i)?XS(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ka}from"@hellixit/math";import{FONT_FAMILY as S7,FONT_SIZES as w7,getFontString as k7,getLineHeight as M7,ROUGHNESS as KS}from"@hellixit/common";import{measureText as P7,newLinearElement as lb,newTextElement as A7}from"@hellixit/element";var $S=(e,o,t,n)=>{if(!Ga(e,"radar"))return null;let r=e.labels??e.series[0].values.map((V,U)=>`Value ${U+1}`),i=e.series,{normalize:l,renderSteps:a}=zS(i,r.length),s=Ya(n),c=Va(s),m=Wa(i.length,s),{chartWidth:p,chartHeight:d}=OS(),u=o+p/2,b=t-d/2,g=Ba/2,x=r.map((V,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:v,axisLabelTopY:y,axisLabelBottomY:E}=GS(r,x,u,b,g,c),T=S7["Lilita One"],I=w7.xl,S=M7(T),M=k7({fontFamily:T,fontSize:I}),k=e.title?Qm(e.title,M,p+Fa*2):null,_=k?P7(k,M,S):null,P=k?A7({backgroundColor:c,...He,text:k,originalText:e.title??k,x:o+p/2,y:y-Fa-_.height/2,fontFamily:T,fontSize:I,lineHeight:S,textAlign:"center"}):null,A=a?Array.from({length:qf},(V,U)=>{let D=(U+1)/qf,B=g*D,W=x.map(te=>Ka(Math.cos(te)*B,Math.sin(te)*B));return W.push(Ka(W[0][0],W[0][1])),lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:B*2,height:B*2,strokeStyle:"solid",roughness:KS.architect,opacity:ii,polygon:!0,points:W})}):[],H=x.map(V=>{let U=Math.cos(V)*g,D=Math.sin(V)*g;return lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:Math.abs(U),height:Math.abs(D),strokeStyle:"solid",roughness:KS.architect,opacity:ii,points:[Ka(0,0),Ka(U,D)]})}),F=i.map((V,U)=>{let D=x.map((B,W)=>{let te=V.values[W]??0,X=l(te,W)*g;return Ka(Math.cos(B)*X,Math.sin(B)*X)});return D.push(Ka(D[0][0],D[0][1])),lb({backgroundColor:"transparent",...He,type:"line",x:u,y:b,width:g*2,height:g*2,strokeColor:m[U],strokeWidth:2,polygon:!0,points:D})}),Y=Xa(i,m,u,E,t+nn*5,c);return[...P?[P]:[],...v,...A,...H,...F,...Y]};var sb=(e,o,t,n,r)=>e==="line"?VS(o,t,n,r):e==="radar"?$S(o,t,n,r):WS(o,t,n,r);import{jsx as lo,jsxs as ZS}from"react/jsx-runtime";var L7=()=>ZS("div",{"data-testid":"brave-measure-text-error",children:[lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>lo("span",{style:{fontWeight:600},children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>lo("span",{style:{fontWeight:600},children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>lo("a",{href:"http://docs.excalidraw.com/docs/@hellixit/hellixitboard/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),lo("p",{children:lo(Pt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>lo("a",{href:"https://github.com/hellixitboard/hellixitboard/issues/new",children:e}),discordLink:e=>ZS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),jS=L7;import F7 from"clsx";import O7 from"react";import{useLayoutEffect as _7,useRef as qS,useEffect as JS}from"react";import{unstable_batchedUpdates as D7}from"react-dom";import{KEYS as H7,queryFocusableElements as R7}from"@hellixit/common";import N7 from"clsx";import{jsx as B7}from"react/jsx-runtime";var QS=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:l=0,viewportWidth:a=window.innerWidth,viewportHeight:s=window.innerHeight,className:c})=>{let m=qS(null);JS(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let u=b=>{if(b.key===H7.TAB){let g=R7(d),{activeElement:x}=document,v=g.findIndex(y=>y===x);x===d?(b.shiftKey?g[g.length-1]?.focus():g[0].focus(),b.preventDefault(),b.stopImmediatePropagation()):v===0&&b.shiftKey?(g[g.length-1]?.focus(),b.preventDefault(),b.stopImmediatePropagation()):v===g.length-1&&!b.shiftKey&&(g[0]?.focus(),b.preventDefault(),b.stopImmediatePropagation())}};return d.addEventListener("keydown",u),()=>d.removeEventListener("keydown",u)},[]);let p=qS(null);return _7(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:u,height:b}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},u>=a?(d.style.width=`${a}px`,d.style.left="0px",d.style.overflowX="scroll"):o+u-i>a?d.style.left=`${a-u-10}px`:d.style.left=`${o}px`,b>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+b-l>s?d.style.top=`${s-b}px`:d.style.top=`${t}px`}},[t,o,r,a,s,i,l]),JS(()=>{if(n){let d=u=>{m.current?.contains(u.target)||D7(()=>n(u))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),B7("div",{className:N7("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as $a,jsxs as z7}from"react/jsx-runtime";var qe="separator",ew=O7.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=Xo(),l=Kn(),a=o.reduce((s,c)=>(c&&(c===qe||!c.predicate||c.predicate(l,i,e.app.props,e.app))&&s.push(c),s),[]);return $a(QS,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:$a("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:a.map((s,c)=>{if(s===qe)return!a[c-1]||a[c-1]===qe?null:$a("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=h(s.label(l,i,e.app)):p=h(s.label)),$a("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:z7("button",{type:"button",className:F7("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[$a("div",{className:"context-menu-item__label",children:p}),$a("kbd",{className:"context-menu-item__shortcut",children:m?Le(m):""})]})},c)})})})});import{jsx as cb,jsxs as tw}from"react/jsx-runtime";var G7=({height:e,width:o,userToFollow:t,onDisconnect:n})=>cb("div",{className:"follow-mode",style:{width:o,height:e},children:tw("div",{className:"follow-mode__badge",children:[tw("div",{className:"follow-mode__badge__label",children:["Following"," ",cb("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),cb("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Qt})]})}),ow=G7;import hi from"clsx";import qW from"react";import{CLASSES as JW,DEFAULT_SIDEBAR as Tx,TOOL_TYPE as gP,arrayToMap as QW,capitalizeString as eY,isShallowEqual as Kp}from"@hellixit/common";import{mutateElement as tY}from"@hellixit/element";import{showSelectedShapeActions as oY}from"@hellixit/element";import{ShapeCache as nY}from"@hellixit/element";import U7 from"clsx";import{useState as W7,useEffect as Y7}from"react";import{THEME as V7}from"@hellixit/common";import{jsx as db,jsxs as X7}from"react/jsx-runtime";var np=({delay:e,theme:o})=>{let[t,n]=W7(!!e);return Y7(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:X7("div",{className:U7("LoadingMessage",{"LoadingMessage--dark":o===V7.DARK}),children:[db("div",{children:db(it,{})}),db("div",{className:"LoadingMessage-text",children:h("labels.loadingScene")})]})};import K7 from"clsx";import{jsx as rw,jsxs as Z7}from"react/jsx-runtime";var $7="medium",nw={CHECKED:wi,UNCHECKED:Hr},iw=e=>Z7("label",{className:K7("ToolIcon ToolIcon__lock",`ToolIcon_size_${$7}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[rw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),rw("div",{className:"ToolIcon__icon",children:e.checked?nw.CHECKED:nw.UNCHECKED})]});import{useState as rp,useEffect as sw,useRef as J7}from"react";import Za from"clsx";import{KEYS as mb,capitalizeString as ot,viewportCoordsToSceneCoords as Q7}from"@hellixit/common";import{newElement as ez,newTextElement as cw}from"@hellixit/element";import j7 from"clsx";import{KEYS as aw}from"@hellixit/common";import{jsx as q7}from"react/jsx-runtime";var lw=e=>q7(J,{className:j7("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:Ni,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:aw.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":aw.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as dw,jsx as Ke,jsxs as ip}from"react/jsx-runtime";var pb=[{type:"rectangle",icon:ki,title:ot(h("toolBar.rectangle"))},{type:"diamond",icon:Mi,title:ot(h("toolBar.diamond"))},{type:"ellipse",icon:Pi,title:ot(h("toolBar.ellipse"))}],ub=[{type:"selection",icon:Rr,title:ot(h("toolBar.selection"))},{type:"lasso",icon:Un,title:ot(h("toolBar.lasso"))}],hb=[{type:"arrow",icon:Fc,title:ot(h("toolBar.arrow"))},{type:"line",icon:Ai,title:ot(h("toolBar.line"))}],mw=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=rp(!1),[l,a]=rp("rectangle"),[s,c]=rp("arrow");sw(()=>{(n.type==="rectangle"||n.type==="diamond"||n.type==="ellipse")&&a(n.type)},[n.type]),sw(()=>{(n.type==="arrow"||n.type==="line")&&c(n.type)},[n.type]);let m=n.type==="frame",p=n.type==="laser",d=n.type==="embeddable",{TTDDialogTriggerTunnel:u}=Pe(),b=J7(null),g=(F,Y)=>{e.state.activeTool.type!==F&&ce("toolbar",F,"ui"),F==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:F})},[x,v]=rp(0),y=36,E=4,T=7,I=T*y+(T-1)*E,S=y+E,M=x>=I+1*S,k=x>=I+2*S,_=x>=I+3*S,A=["text","frame","embeddable","laser","magicframe"].filter(F=>!(M&&F==="text"||k&&F==="image"||_&&F==="frame")).includes(n.type),H=A?n.type==="text"?Wo:n.type==="image"?Li:n.type==="frame"?yo:n.type==="embeddable"?_i:n.type==="laser"?Yo:n.type==="magicframe"?Fr:Bl:Bl;return ip(dw,{children:[Ke("input",{ref:b,type:"file",style:{display:"none"},onChange:async F=>{let Y=F.target.files?.[0];if(!Y||(F.target.value="",_r(Y)))return;let U=(await e.props.onFileUpload?.(Y))?.url;if(!U)return;let D=e.state.width/2+e.state.offsetLeft,B=e.state.height/2+e.state.offsetTop,{x:W,y:te}=Q7({clientX:D,clientY:B},e.state),X=Y.name.length>28?`${Y.name.slice(0,25)}...`:Y.name,le=Math.max(220,Math.min(460,X.length*11+132)),pe=56,de=W-le/2,Ee=te-pe/2,Ve=`file-chip-${Date.now()}-${Math.round(Math.random()*1e6)}`,rt=ez({type:"rectangle",x:de,y:Ee,width:le,height:pe,strokeColor:"#d8d8e2",backgroundColor:"#ececf3",fillStyle:"solid",strokeWidth:1,roughness:0,roundness:{type:3,value:16},groupIds:[Ve],customData:{filePlaceholderUrl:U}}),ft=cw({x:de+22,y:Ee+16,text:"\u{1F4CE}",fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#5a5a66",groupIds:[Ve],customData:{filePlaceholderUrl:U}}),Ct=cw({x:de+52,y:Ee+17,text:X,fontSize:22,textAlign:"left",verticalAlign:"top",strokeColor:"#2d2d36",groupIds:[Ve],customData:{filePlaceholderUrl:U}});e.scene.insertElements([rt,ft,Ct])}}),ip("div",{className:"mobile-toolbar",ref:F=>{F&&v(F.getBoundingClientRect().width)},children:[Ke(lw,{checked:yn(e.state),onChange:o,title:h("toolBar.hand"),isMobile:!0}),Ke(wa,{app:e,options:ub,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:ot(h("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:F=>{(F==="selection"||F==="lasso")&&(e.setActiveTool({type:F}),t({preferredSelectionTool:{type:F,initialized:!0}}))},displayedOption:ub.find(F=>F.type===e.state.preferredSelectionTool.type)||ub[0]}),Ke(J,{className:Za({active:n.type==="freedraw"}),type:"radio",icon:Uo,checked:n.type==="freedraw",name:"editor-current-shape",title:`${ot(h("toolBar.freedraw"))}`,"aria-label":ot(h("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>g("freedraw")}),Ke(J,{className:Za({active:n.type==="eraser"}),type:"radio",icon:Oc,checked:n.type==="eraser",name:"editor-current-shape",title:`${ot(h("toolBar.eraser"))}`,"aria-label":ot(h("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>g("eraser")}),Ke(wa,{app:e,options:pb,activeTool:n,defaultOption:l,namePrefix:"shapeType",title:ot(h(l==="rectangle"?"toolBar.rectangle":l==="diamond"?"toolBar.diamond":l==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:F=>{(F==="rectangle"||F==="diamond"||F==="ellipse")&&(a(F),e.setActiveTool({type:F}))},displayedOption:pb.find(F=>F.type===l)||pb[0]}),Ke(wa,{app:e,options:hb,activeTool:n,defaultOption:s,namePrefix:"linearElementType",title:ot(h(s==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:F=>{(F==="arrow"||F==="line")&&(c(F),e.setActiveTool({type:F}))},displayedOption:hb.find(F=>F.type===s)||hb[0]}),M&&Ke(J,{className:Za({active:n.type==="text"}),type:"radio",icon:Wo,checked:n.type==="text",name:"editor-current-shape",title:`${ot(h("toolBar.text"))}`,"aria-label":ot(h("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>g("text")}),k&&Ke(J,{className:Za({active:n.type==="image"}),type:"radio",icon:Li,checked:n.type==="image",name:"editor-current-shape",title:`${ot(h("toolBar.image"))}`,"aria-label":ot(h("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>g("image")}),_&&Ke(J,{className:Za({active:m}),type:"radio",icon:yo,checked:m,name:"editor-current-shape",title:`${ot(h("toolBar.frame"))}`,"aria-label":ot(h("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>g("frame")}),ip(ie,{open:r,children:[Ke(ie.Trigger,{className:Za("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":A||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),style:{width:y,height:y,display:"flex",alignItems:"center",justifyContent:"center"},children:H}),ip(ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[!M&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Wo,shortcut:mb.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:h("toolBar.text")}),!k&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Li,"data-testid":"toolbar-image",selected:n.type==="image",children:h("toolBar.image")}),!_&&Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:yo,shortcut:mb.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,children:h("toolBar.frame")}),Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:_i,"data-testid":"toolbar-embeddable",selected:d,children:h("toolBar.embeddable")}),Ke(ie.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:p,shortcut:mb.K.toLocaleUpperCase(),children:h("toolBar.laser")}),e.props.onFileUpload&&Ke(ie.Item,{onSelect:()=>b.current?.click(),icon:Yc,"data-testid":"toolbar-upload-file",children:h("toolBar.uploadFile")}),Ke("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ke(u.Out,{}),Ke(ie.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Fi,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToHellixitboard")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ke(dw,{children:Ke(ie.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Fr,"data-testid":"toolbar-magicframe",badge:Ke(ie.Item.Badge,{children:"AI"}),children:h("toolBar.magicframe")})})]})]})]})]})};import tz from"clsx";import{jsx as oz}from"react/jsx-runtime";var ap=({children:e,side:o,className:t})=>oz("div",{className:tz("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import nz from"clsx";import{jsx as pw,jsxs as iz}from"react/jsx-runtime";var rz="medium",lp=e=>e.penDetected?iz("label",{className:nz("ToolIcon ToolIcon__penMode",`ToolIcon_size_${rz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[pw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),pw("div",{className:"ToolIcon__icon",children:p0})]}):null;import{Fragment as uw,jsx as rn,jsxs as li}from"react/jsx-runtime";var hw=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:l,renderSidebars:a,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:b}=Pe(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let v=li("div",{className:"hellixitboard-ui-top-right",children:[l?.(!0,e),!e.viewModeEnabled&&li(uw,{children:[rn(lp,{checked:e.penMode,onChange:()=>p(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rn(b.Out,{})]}),e.viewModeEnabled&&rn(_I,{actionManager:t})]}),y=li("div",{className:"hellixitboard-ui-top-left",children:[i?.(!0,e),rn(u.Out,{})]});return li("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[y,v]})},x=()=>rn(mw,{app:m,onHandToolToggle:r,setAppState:n});return li(uw,{children:[a(),rn("div",{className:"App-welcome-screen",children:s&&rn(d.Out,{})}),!e.viewModeEnabled&&li("div",{className:"App-bottom-bar",style:{marginBottom:ao+_n},children:[rn(kI,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:n}),li(Xe,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&x(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&rn("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(v=>({...Pr(o,v)}))},children:h("buttons.scrollBackToContent")})]})]}),rn(ap,{side:"top",className:"App-top-bar",children:g()})]})};import gw,{useLayoutEffect as fw,useRef as bw,useState as xw}from"react";import{newTextElement as yw}from"@hellixit/element";import{jsx as Dn,jsxs as sp}from"react/jsx-runtime";var az=e=>{switch(e){case"bar":return h("labels.chartType_bar");case"line":return h("labels.chartType_line");case"radar":return h("labels.chartType_radar");default:return e}},lz=e=>{let o=bw(null),[t,n]=xw(null),{theme:r}=se();fw(()=>{if(!e.spreadsheet){n(null);return}let l=sb(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!l){n(null),o.current?.replaceChildren();return}n(l);let a,s=o.current;return(async()=>(a=await Ar(l,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),a.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(a)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=az(e.chartType);return sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Dn("div",{className:"ChartPreview__canvas",ref:o}),Dn("div",{className:"ChartPreview__label",children:i})]})},sz=e=>{let o=bw(null),{theme:t}=se();return fw(()=>{if(!e.rawText)return;let n=yw({text:e.rawText,x:0,y:0}),r=o.current;return(async()=>{let i=await Ar([n],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),sp("button",{type:"button",className:"ChartPreview","aria-label":h("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Dn("div",{className:"ChartPreview__canvas",ref:o}),Dn("div",{className:"ChartPreview__label",children:h("labels.chartType_plaintext")})]})},Ew=({data:e,rawText:o,onClose:t})=>{let{onInsertElements:n,focusContainer:r}=Ae(),[i,l]=xw(Math.random()),a=gw.useCallback(()=>{l(Math.random())},[]),s=gw.useCallback(()=>{t&&t()},[t]),c=(p,d)=>{n(d),ce("paste","chart",p),t(),r()},m=p=>{let d=yw({text:p,x:0,y:0});n([d]),ce("paste","chart","plaintext"),t(),r()};return Dn(je,{size:"regular",onCloseRequest:s,title:sp("div",{className:"PasteChartDialog__title",children:[Dn("div",{className:"PasteChartDialog__titleText",children:h("labels.pasteCharts")}),Dn("div",{className:"PasteChartDialog__reshuffleBtn",onClick:a,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a())},children:Ri})]}),className:"PasteChartDialog",autofocus:!1,children:sp("div",{className:"container",children:[["bar","line","radar"].map(p=>Ga(e,p)?Dn(lz,{chartType:p,spreadsheet:e,colorSeed:i,onClick:c},p):null),o&&Dn(sz,{rawText:o,onClick:m})]})})};import{Fragment as cz,jsx as vw,jsxs as dz}from"react/jsx-runtime";var Ys=({heading:e,children:o,...t})=>{let{id:n}=_e(),r=vw("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:h(`headings.${e}`)});return vw("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):dz(cz,{children:[r,o]})})};import{Popover as cp}from"radix-ui";import Tw from"clsx";import dp,{useLayoutEffect as mz}from"react";import{supportsResizeObserver as pz,isShallowEqual as uz}from"@hellixit/common";import{Fragment as xz,jsx as an,jsxs as mp}from"react/jsx-runtime";var hz=4,gz=8,fz=({shouldWrap:e,children:o,username:t})=>e?an($t,{label:t||"Unknown user",children:o}):an(xz,{children:o}),gb=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let l={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},a=e.renderAction("goToCollaborator",l);return an(fz,{username:o.username,shouldWrap:r,children:a},t)},bz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],pp=dp.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=De(),i=new Map;t.forEach((g,x)=>{let v=g.id||x;i.set(v,{...g,socketId:x})});let l=Array.from(i.values()).filter(g=>g.username?.trim()),[a,s]=dp.useState(""),c=l.filter(g=>g.username?.toLowerCase().includes(a)),m=dp.useRef(null);mz(()=>{if(m.current){let g=v=>{let y=Math.max(1,Math.min(8,Math.floor(v/38)));d(y)};if(g(m.current.clientWidth),!pz)return;let x=new ResizeObserver(v=>{for(let y of v){let{width:E}=y.contentRect;g(E)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[p,d]=dp.useState(hz),b=l.slice(0,p-1).map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}));return o?an("div",{className:Tw("UserList UserList_mobile",e),children:l.map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:g.socketId===n}))}):an("div",{className:"UserList__wrapper",ref:m,children:mp("div",{className:Tw("UserList",e),style:{"--max-avatars":p},children:[b,l.length>p-1&&mp(cp.Root,{children:[mp(cp.Trigger,{className:"UserList__more",children:["+",l.length-p+1]}),an(cp.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:mp(Xe,{padding:2,children:[l.length>=gz&&an(pd,{placeholder:h("quickSearch.placeholder"),onChange:s}),an(ud,{className:"dropdown-menu UserList__collaborators",placeholder:h("userList.empty"),children:c.length>0?[an("div",{className:"hint",children:h("userList.hint.text")}),c.map(g=>gb({actionManager:r,collaborator:g,socketId:g.socketId,withName:!0,isBeingFollowed:g.socketId===n}))]:[]}),an(cp.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!uz(r,i,bz))return!1}return!0});import fb from"clsx";import{jsx as yz}from"react/jsx-runtime";var Iw=e=>yz("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${h("helpDialog.title")} \u2014 ?`,"aria-label":h("helpDialog.title"),children:Di});import{jsx as Hn,jsxs as up}from"react/jsx-runtime";var Cw=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i,FooterRightSlotTunnel:l}=Pe();return up("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Hn("div",{className:fb("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Hn(Et.Col,{gap:2,children:up(Ys,{heading:"canvasActions",children:[Hn(PI,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Hn(AI,{renderAction:o.renderAction,className:fb("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Hn(r.Out,{}),up("div",{className:fb("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[Hn(l.Out,{}),up("div",{style:{position:"relative"},children:[n&&Hn(i.Out,{}),Hn(Iw,{onClick:()=>o.executeAction(Vr)})]})]}),Hn(LI,{actionManager:o,showExitZenModeBtn:t})]})},Sw=Cw;Cw.displayName="Footer";import Lz from"clsx";import{useEffect as _w,useLayoutEffect as Dw,useRef as Sb,useState as _z,forwardRef as Hw,useImperativeHandle as Dz,useCallback as Pw}from"react";import{CLASSES as Hz,EVENT as Aw,isDevEnv as Rz,KEYS as Nz,updateObject as Bz}from"@hellixit/common";import vz from"clsx";import{useContext as Tz}from"react";import Ez from"react";var hp=Ez.createContext({});import{jsx as bb,jsxs as ww}from"react/jsx-runtime";var xb=({children:e,className:o})=>{let t=fe(),n=Tz(hp),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return ww("div",{className:vz("sidebar__header",o),"data-testid":"sidebar-header",children:[e,ww("div",{className:"sidebar__header__buttons",children:[r&&bb($t,{label:h("labels.sidebarLock"),children:bb(ut,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":h("labels.sidebarLock"),children:l0})}),bb(ut,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":h("buttons.close"),children:Qt})]})]})};xb.displayName="SidebarHeader";import{Tabs as Iz}from"radix-ui";import{jsx as kw}from"react/jsx-runtime";var yb=({children:e,tab:o,onSelect:t,...n})=>kw(Iz.Trigger,{value:o,asChild:!0,onSelect:t,children:kw("button",{type:"button",className:"hellixitboard-button sidebar-tab-trigger",...n,children:e})});yb.displayName="SidebarTabTrigger";import{Tabs as Cz}from"radix-ui";import{jsx as Sz}from"react/jsx-runtime";var Eb=({children:e,...o})=>Sz(Cz.List,{className:"sidebar-triggers",...o,children:e});Eb.displayName="SidebarTabTriggers";import wz from"clsx";import{jsx as vb,jsxs as Mw}from"react/jsx-runtime";var Tb=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:l,style:a})=>{let s=he(),c=se();return Mw("label",{title:n,className:"sidebar-trigger__label-element",children:[vb("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),Mw("div",{className:wz("sidebar-trigger",l),style:a,children:[t&&vb("div",{children:t}),r&&vb("div",{className:"sidebar-trigger__label",children:r})]})]})};Tb.displayName="SidebarTrigger";import{Tabs as kz}from"radix-ui";import{jsx as Mz}from"react/jsx-runtime";var Ib=({children:e,...o})=>{let t=se(),n=he();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return Mz(kz.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(l=>({...l,openSidebar:{...l.openSidebar,name:r,tab:i}})),...o,children:e})};Ib.displayName="SidebarTabs";import{Tabs as Pz}from"radix-ui";import{jsx as Az}from"react/jsx-runtime";var Cb=({tab:e,children:o,...t})=>Az(Pz.Content,{...t,value:e,"data-testid":e,children:o});Cb.displayName="SidebarTab";import{jsx as Lw}from"react/jsx-runtime";import{createElement as Fz}from"react";var Vs=ge(!1),Rw=Hw(({name:e,children:o,onDock:t,docked:n,className:r,...i},l)=>{Rz()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let a=he(),s=zo(Vs);Dw(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=Sb({});c.current.onCloseRequest=()=>{a({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Bz(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=Sb(null);Dz(l,()=>m.current);let p=fe(),d=Pw(()=>{document.querySelector(".Dialog")||a({openSidebar:null})},[a]);return Xi(m,Pw(u=>{u.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&d()},[d,n,p.canFitSidebar])),_w(()=>{let u=b=>{b.key===Nz.ESCAPE&&(!n||!p.canFitSidebar)&&d()};return document.addEventListener(Aw.KEYDOWN,u),()=>{document.removeEventListener(Aw.KEYDOWN,u)}},[d,n,p.canFitSidebar]),Lw(Xe,{...i,className:Lz(Hz.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:Lw(hp.Provider,{value:c.current,children:o})})});Rw.displayName="SidebarInner";var so=Object.assign(Hw((e,o)=>{let t=se(),{onStateChange:n}=e,r=Sb(t.openSidebar);_w(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,l]=_z(!1);return Dw(()=>(l(!0),()=>l(!1)),[]),i&&t.openSidebar?.name===e.name?Fz(Rw,{...e,ref:o,key:e.name}):null}),{Header:xb,TabTriggers:Eb,TabTrigger:yb,Tabs:Ib,Tab:Cb,Trigger:Tb});so.displayName="Sidebar";import{composeEventHandlers as Xz}from"@hellixit/common";import{useLayoutEffect as Oz,useRef as zz}from"react";import{jsx as Gz}from"react/jsx-runtime";var Rn=(e,o)=>{let t=ge(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Pe(),[,l]=i(t),a=zz({preferHost:!1,counter:0});return Oz(()=>{let s=a.current;return l(c=>{let m=c+1;return s.counter=m,m}),()=>{l(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[l]),r.__fallback||(a.current.preferHost=!0),!a.current.counter&&r.__fallback&&a.current.preferHost||a.current.counter>1&&r.__fallback?null:Gz(o,{...r})};return n.displayName=e,n};var Pb={};Ay(Pb,{ChangeCanvasBackground:()=>$w,ClearCanvas:()=>Xw,CommandPalette:()=>Ww,Export:()=>Zw,Help:()=>Vw,LiveCollaborationTrigger:()=>qw,LoadScene:()=>zw,Preferences:()=>ln,PreferencesToggleGridModeItem:()=>kb,PreferencesToggleZenModeItem:()=>Mb,SaveAsImage:()=>Uw,SaveToActiveFile:()=>Gw,SearchMenu:()=>Yw,Socials:()=>jw,ToggleTheme:()=>Kw});import Vz from"clsx";import{THEME as pr}from"@hellixit/common";import Uz from"clsx";import{jsx as Nw,jsxs as Wz}from"react/jsx-runtime";var gp=function({onChange:e,value:o,choices:t,name:n}){return Nw("div",{className:"RadioGroup",children:t.map(r=>Wz("div",{className:Uz("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[Nw("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as Yz,jsx as wb,jsxs as Bw}from"react/jsx-runtime";var Fw=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let l=fe();return Bw(Yz,{children:[Bw("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[wb("label",{className:"dropdown-menu-item__text",children:r}),wb(gp,{name:i,value:e,onChange:t,choices:n})]}),o&&l.formFactor!=="phone"&&wb("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};Fw.displayName="DropdownMenuItemContentRadio";var Ow=Fw;import{Fragment as rk,jsx as ye,jsxs as Xs}from"react/jsx-runtime";var zw=()=>{let{t:e}=Ie(),o=De(),t=Kn();return o.isActionEnabled(aa)?ye(wt,{icon:Hi,onSelect:async()=>{(!t.length||await om({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(Pt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&o.executeAction(aa)},"data-testid":"load-button",shortcut:Le("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};zw.displayName="LoadScene";var Gw=()=>{let{t:e}=Ie(),o=De();return o.isActionEnabled(Yr)?ye(wt,{shortcut:Le("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Yr),icon:E0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Gw.displayName="SaveToActiveFile";var Uw=()=>{let e=he(),{t:o}=Ie();return ye(wt,{icon:Uc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Le("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};Uw.displayName="SaveAsImage";var Ww=e=>{let o=he(),{t}=Ie();return ye(wt,{icon:Fl,"data-testid":"command-palette-button",onSelect:()=>{ce("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Le("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Ww.displayName="CommandPalette";var Yw=e=>{let{t:o}=Ie(),t=De();return ye(wt,{icon:Kt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ps)},shortcut:Le("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};Yw.displayName="SearchMenu";var Vw=()=>{let{t:e}=Ie(),o=De();return ye(wt,{"data-testid":"help-menu-item",icon:Di,onSelect:()=>o.executeAction(Vr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Vw.displayName="Help";var Xw=()=>{let{t:e}=Ie(),o=zo(jr);return De().isActionEnabled(Sn)?ye(wt,{icon:pt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};Xw.displayName="ClearCanvas";var Kw=e=>{let{t:o}=Ie(),t=se(),n=De(),r=Le("toggleTheme");return n.isActionEnabled(Gr)?e?.allowSystemTheme?ye(Ow,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:pr.LIGHT,label:Hl,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:pr.DARK,label:Dl,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:zE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):ye(wt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===pr.DARK?pr.LIGHT:pr.DARK);else return n.executeAction(Gr)},icon:t.theme===pr.DARK?Hl:Dl,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===pr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===pr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};Kw.displayName="ToggleTheme";var $w=()=>{let{t:e}=Ie(),o=se(),t=De(),n=Ko();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:Xs("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};$w.displayName="ChangeCanvasBackground";var Zw=()=>{let{t:e}=Ie(),o=he();return ye(wt,{icon:Nr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};Zw.displayName="Export";var jw=()=>{let{t:e}=Ie();return Xs(rk,{children:[ye(Ca,{icon:b0,href:"#","aria-label":"GitHub",children:"GitHub"}),ye(Ca,{icon:y0,href:"#","aria-label":"X",children:e("labels.followUs")}),ye(Ca,{icon:x0,href:"#","aria-label":"Discord",children:e("labels.discordChat")})]})};jw.displayName="Socials";var qw=({onSelect:e,isCollaborating:o})=>{let{t}=Ie();return ye(wt,{"data-testid":"collab-button",icon:Wc,className:Vz({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};qw.displayName="LiveCollaborationTrigger";var Jw=()=>{let{t:e}=Ie(),o=Ae(),t=se();return ye(Co,{checked:t.activeTool.locked,shortcut:Le("toolLock"),onSelect:n=>{o.toggleLock(),n.preventDefault()},children:e("labels.preferences_toolLock")})},Qw=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.objectsSnapModeEnabled,shortcut:Le("objectsSnapMode"),onSelect:n=>{o.executeAction(cs),n.preventDefault()},children:e("buttons.objectsSnapMode")})},ek=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.bindingPreference==="enabled",onSelect:n=>{o.executeAction(ds),n.preventDefault()},children:e("labels.arrowBinding")})},tk=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.isMidpointSnappingEnabled,onSelect:n=>{o.executeAction(ms),n.preventDefault()},children:e("labels.midpointSnapping")})},kb=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.gridModeEnabled,shortcut:Le("gridMode"),onSelect:n=>{o.executeAction(ua),n.preventDefault()},children:e("labels.toggleGrid")})},Mb=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.zenModeEnabled,shortcut:Le("zenMode"),onSelect:n=>{o.executeAction(tr),n.preventDefault()},children:e("buttons.zenMode")})},ok=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.viewModeEnabled,shortcut:Le("viewMode"),onSelect:n=>{o.executeAction(Zr),n.preventDefault()},children:e("labels.viewMode")})},nk=()=>{let{t:e}=Ie(),o=De(),t=se();return ye(Co,{checked:t.stats.open,shortcut:Le("stats"),onSelect:n=>{o.executeAction(or),n.preventDefault()},children:e("stats.fullTitle")})},ln=({children:e,additionalItems:o})=>{let{t}=Ie();return Xs(ir,{children:[ye(ir.Trigger,{icon:qE,children:t("labels.preferences")}),Xs(ir.Content,{className:"hellixitboard-main-menu-preferences-submenu",children:[e||Xs(rk,{children:[ye(Jw,{}),ye(Qw,{}),ye(kb,{}),ye(Mb,{}),ye(ok,{}),ye(nk,{}),ye(ek,{}),ye(tk,{})]}),o]})]})};ln.ToggleToolLock=Jw;ln.ToggleSnapMode=Qw;ln.ToggleArrowBinding=ek;ln.ToggleMidpointSnapping=tk;ln.ToggleGridMode=kb;ln.ToggleZenMode=Mb;ln.ToggleViewMode=ok;ln.ToggleElementProperties=nk;ln.displayName="Preferences";import{jsx as fp,jsxs as Ab}from"react/jsx-runtime";var Kz=Object.assign(Rn("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Pe(),n=fe(),r=se(),i=he();return fp(t.In,{children:Ab(ie,{open:r.openMenu==="canvas",children:[fp(ie.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:g0}),Ab(ie.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:Xz(o,()=>{i({openMenu:null})}),className:"main-menu",align:"start",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&Ab("fieldset",{className:"UserList-Wrapper",children:[fp("legend",{children:h("labels.collaborators")}),fp(pp,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ie.Trigger,Item:ie.Item,ItemLink:ie.ItemLink,ItemCustom:ie.ItemCustom,Group:ie.Group,Separator:ie.Separator,Sub:ir,DefaultItems:Pb}),vt=Kz;import $z from"clsx";import{forwardRef as Zz,useState as jz}from"react";import{isPromiseLike as qz}from"@hellixit/common";import{jsx as bp,jsxs as Jz}from"react/jsx-runtime";var sn=Zz(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:l="medium",fullWidth:a,className:s,status:c,disabled:m},p)=>{let[d,u]=jz(!1),b=async x=>{let v=t?.(x);if(qz(v)){let y=window.setTimeout(()=>{u(!0)},50);try{await v}catch(E){if(E instanceof Ei)console.warn(E);else throw E}finally{clearTimeout(y),u(!1)}}},g=d?"loading":c;return i=g==="success"?"success":i,bp("button",{className:$z("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${l}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":a},s),onClick:b,type:"button","aria-label":n,ref:p,disabled:m||g==="loading"||g==="success",children:Jz("div",{className:"ExcButton__contents",children:[g==="loading"?bp(it,{className:"ExcButton__statusIcon"}):g==="success"&&bp("div",{className:"ExcButton__statusIcon",children:EE}),o&&bp("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as ja,jsxs as tG}from"react/jsx-runtime";var xp=({title:e,children:o,actionLabel:t,onClick:n})=>tG("div",{className:"OverwriteConfirm__Actions__Action",children:[ja("h4",{children:e}),ja("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ja(sn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),Qz=()=>{let{t:e}=Ie(),o=De(),t=he();return ja(xp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Bd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},eG=()=>{let{t:e}=Ie(),o=De();return ja(xp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ls,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Lb=Object.assign(({children:e})=>ja("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Qz,SaveToDisk:eG});import{jsx as ur,jsxs as ik}from"react/jsx-runtime";var yp=Object.assign(Rn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Pe(),[t,n]=Q(Hg);if(!t.active)return null;let r=()=>{t.onClose(),n(l=>({...l,active:!1}))},i=()=>{t.onConfirm(),n(l=>({...l,active:!1}))};return ur(o.In,{children:ur(je,{onCloseRequest:r,title:!1,size:916,children:ik("div",{className:"OverwriteConfirm",children:[ur("h3",{children:t.title}),ik("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[ur("div",{className:"OverwriteConfirm__Description__icon",children:Kc}),ur("div",{children:t.description}),ur("div",{className:"OverwriteConfirm__Description__spacer"}),ur(sn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),ur(Lb,{children:e})]})})})}),{Actions:Lb,Action:xp});import IG from"clsx";import{CANVAS_SEARCH_TAB as Nb,DEFAULT_SIDEBAR as CG,LIBRARY_SIDEBAR_TAB as gk,composeEventHandlers as SG}from"@hellixit/common";import{round as oG}from"@hellixit/math";import nG from"clsx";import rG from"lodash.debounce";import{Fragment as iG,memo as aG,useEffect as Ks,useMemo as ak,useRef as _b,useState as lk}from"react";import{CLASSES as lG,EVENT as sG,FONT_FAMILY as Db,FRAME_STYLE as Hb,getLineHeight as cG}from"@hellixit/common";import{isElementCompletelyInViewport as dG}from"@hellixit/element";import{measureText as $s}from"@hellixit/element";import{KEYS as qa,randomInteger as sk,addEventListener as mG,getFontString as Ep}from"@hellixit/common";import{newTextElement as pG}from"@hellixit/element";import{isTextElement as pk,isFrameLikeElement as vp}from"@hellixit/element";import{getDefaultFrameName as uk}from"@hellixit/element/frame";import{Fragment as TG,jsx as ct,jsxs as cn}from"react/jsx-runtime";var uG=ge(""),Rb=ge(null),hG=350,hk=()=>{let e=Ae(),o=he(),t=_b(null),[n,r]=Q(uG),i=n.trim(),[l,a]=lk(!1),[s,c]=lk({nonce:null,items:[]}),m=_b(null),p=_b(void 0),[d,u]=Q(Rb),b=e.scene.getNonDeletedElementsMap();Ks(()=>{l||(i!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,mk(i,e,(E,T)=>{c({nonce:sk(),items:E}),m.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:E.length?{focusedId:null,matches:E.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[l,i,b,e,o,u,p]);let g=()=>{s.items.length>0&&u(E=>E===null?0:(E+1)%s.items.length)},x=()=>{s.items.length>0&&u(E=>E===null?0:E-1<0?s.items.length-1:E-1)};Ks(()=>{o(E=>E.searchMatches?{searchMatches:{focusedId:d!==null&&E.searchMatches?.matches[d]?.id||null,matches:E.searchMatches.matches.map((I,S)=>S===d?{...I,focus:!0}:{...I,focus:!1})}}:null)},[d,o]),Ks(()=>{if(s.items.length>0&&d!==null){let E=s.items[d];if(E){let T=e.state.zoom.value,I=pG({text:E.searchQuery,x:E.element.x+(E.matchedLines[0]?.offsetX??0),y:E.element.y+(E.matchedLines[0]?.offsetY??0),width:E.matchedLines[0]?.width,height:E.matchedLines[0]?.height,fontSize:vp(E.element)?Hb.nameFontSize:E.element.fontSize,fontFamily:vp(E.element)?Db.Assistant:E.element.fontFamily}),S=14,M=I.fontSize,k=M*T<S;if(!dG([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let _;k?M>=S?_={fitToContent:!0}:_={fitToViewport:!0,maxZoom:oG(S/M,1)}:_={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,..._,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Ks(()=>()=>{u(null),m.current=null,p.current=void 0,o({searchMatches:null}),a(!1)},[o,u]);let v=Yn({goToNextItem:g,goToPreviousItem:x,searchMatches:s});Ks(()=>{let E=T=>{if(T.key===qa.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){T.preventDefault(),T.stopPropagation(),o({openSidebar:null});return}if(T[qa.CTRL_OR_CMD]&&T.key===qa.F){if(T.preventDefault(),T.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}T.target instanceof HTMLElement&&T.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(T.key===qa.ENTER&&(T.stopPropagation(),v.goToNextItem()),T.key===qa.ARROW_UP?(T.stopPropagation(),v.goToPreviousItem()):T.key===qa.ARROW_DOWN&&(T.stopPropagation(),v.goToNextItem()))};return mG(window,sG.KEYDOWN,E,{capture:!0,passive:!1})},[o,v,e]);let y=`${s.items.length} ${s.items.length===1?h("search.singleResult"):h("search.multipleResults")}`;return cn("div",{className:"layer-ui__search",children:[ct("div",{className:"layer-ui__search-header",children:ct(ar,{className:lG.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:h("search.placeholder"),icon:Kt,onChange:E=>{r(E),a(!0);let T=E.trim();mk(T,e,(I,S)=>{c({nonce:sk(),items:I}),u(S),m.current=T,p.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(M=>({id:M.element.id,focus:!1,matchedLines:M.matchedLines}))}:null}),a(!1)})},selectOnRender:!0})}),cn("div",{className:"layer-ui__search-count",children:[s.items.length>0&&cn(TG,{children:[d!==null&&d>-1?cn("div",{children:[d+1," / ",y]}):ct("div",{children:y}),cn("div",{className:"result-nav",children:[ct(ut,{onSelect:()=>{g()},className:"result-nav-btn",children:Zc}),ct(ut,{onSelect:()=>{x()},className:"result-nav-btn",children:YE})]})]}),s.items.length===0&&i&&m.current&&ct("div",{style:{margin:"1rem auto"},children:h("search.noMatch")})]}),ct(bG,{matches:s,onItemClick:u,focusIndex:d,searchQuery:i})]})},ck=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ct("div",{tabIndex:-1,className:nG("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ct("div",{className:"preview-text",children:o.flatMap((t,n)=>ct(iG,{children:n===2?ct("b",{children:t}):t},n))})})},gG=e=>{let o=ak(()=>e.matches.items.filter(n=>vp(n.element)),[e.matches]),t=ak(()=>e.matches.items.filter(n=>pk(n.element)),[e.matches]);return cn("div",{children:[o.length>0&&cn("div",{className:"layer-ui__search-result-container",children:[cn("div",{className:"layer-ui__search-result-title",children:[ct("div",{className:"title-icon",children:yo}),ct("div",{children:h("search.frames")})]}),o.map((n,r)=>ct(ck,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&ct("div",{className:"layer-ui__divider"})]}),t.length>0&&cn("div",{className:"layer-ui__search-result-container",children:[cn("div",{className:"layer-ui__search-result-title",children:[ct("div",{className:"title-icon",children:Wo}),ct("div",{children:h("search.texts")})]}),t.map((n,r)=>ct(ck,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},fG=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,bG=aG(gG,fG),dk=(e,o,t)=>{let i=e.slice(0,o),l=i.split(/\s+/),a=i.endsWith(" "),s=l.length-2-1-(a?0:1),c=l.slice(s<=0?0:s).join(" ")+(a?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),u=!p.startsWith(" "),b=u?6:5,g=(u?"":" ")+d.slice(0,b).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:s>0,moreAfter:d.length>b}},xG=(e,o)=>{let t=e.split(`
17
17
  `),n=[],r=0;for(let i=0;i<t.length;i++){let l=t[i],a=t[i+1];if(a){let s=o.indexOf(a,r);if(s>l.length+r){let c=s-(l.length+r);for(;c>0;)l+=" ",c--}}n.push(l),r=r+l.length}return n.join(`
18
18
  `)},yG=(e,o,t)=>{let r=xG(e.text,e.originalText).split(`
19
- `),i=[],l=0,a=0;for(let p of r){let d=l,u=d+p.length-1;i.push({line:p,startIndex:d,endIndex:u,lineNumber:a}),l=u+1,a++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,u=p.line.slice(0,s-p.startIndex),b=c.slice(0,d);c=c.slice(d);let g=$s(u,Ep(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let T=$s(p.line,Ep(e),e.lineHeight),I=e.textAlign==="center"?(e.width-T.width)/2:e.width-T.width;g.width+=I}let{width:x,height:v}=$s(b,Ep(e),e.lineHeight),y=g.width,E=p.lineNumber*g.height;m.push({offsetX:y,offsetY:E,width:x,height:v,showOnCanvas:!0}),s+=d}}return m},EG=(e,o,t,n)=>{let r=e.name??uk(e),i=r.slice(t,t+o.length),l=r.slice(0,t),a=Ep({fontSize:Hb.nameFontSize,fontFamily:Db.Assistant}),s=cG(Db.Assistant),c=$s(l,a,s);l===""&&(c.width=0);let m=$s(i,a,s),p=c.width,d=-c.height-Hb.strokeWidth,u=m.width;return[{offsetX:p,offsetY:d,width:u,height:m.height,showOnCanvas:p+u<=e.width*n}]},vG=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),mk=rG((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>pk(d)),i=n.filter(d=>vp(d));r.sort((d,u)=>d.y-u.y),i.sort((d,u)=>d.y-u.y);let l=[],a=new RegExp(vG(e),"gi");for(let d of r){let u=null,b=d.originalText;for(;(u=a.exec(b))!==null;){let g=dk(b,u.index,e),x=yG(d,e,u.index);x.length>0&&l.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:x})}}let s=[];for(let d of i){let u=null,b=d.name??uk(d);for(;(u=a.exec(b))!==null;){let g=dk(b,u.index,e),x=EG(d,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...l],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},hG);import{jsx as Ao,jsxs as fk}from"react/jsx-runtime";import{createElement as SG}from"react";var bk=Rn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Pe();return Ao(o.In,{children:Ao(so.Trigger,{...e,className:"default-sidebar-trigger",name:wG.name})})});bk.displayName="DefaultSidebarTrigger";var xk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Pe();return Ao(o.In,{children:e})};xk.displayName="DefaultTabTriggers";var Tp=Object.assign(Rn("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=se(),l=he(),{DefaultSidebarTabTriggersTunnel:a}=Pe(),s=i.openSidebar?.tab===Nb;return SG(so,{...r,name:"default",key:"default",className:IG("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:CG(t,c=>{l({defaultSidebarDockedPreference:c})})},fk(so.Tabs,{children:[Ao(so.Header,{children:fk(so.TabTriggers,{children:[Ao(so.TabTrigger,{tab:Nb,children:Kt}),Ao(so.TabTrigger,{tab:gk,children:Bc}),Ao(a.Out,{})]})}),Ao(so.Tab,{tab:gk,children:Ao(nI,{})}),Ao(so.Tab,{tab:Nb,children:Ao(hk,{})}),e]}))}),{Trigger:bk,TabTriggers:xk});import{useEffect as F9,useState as O9}from"react";import{useState as zb,useRef as Nk,useEffect as Gb,useDeferredValue as VG}from"react";import{EDITOR_LS_KEYS as XG,debounce as KG,isDevEnv as $G}from"@excalidraw/common";import{useEffect as yk,useRef as Ek,useState as vk}from"react";import{EVENT as Tk,KEYS as Ik}from"@excalidraw/common";import{jsx as Ip}from"react/jsx-runtime";var kG=300,wk=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n,errorLine:r})=>{let i=Ek(null),l=Ek(n);l.current=n;let[a,s]=vk({type:"loading"}),[c,m]=vk(!1),{theme:p}=se();if(yk(()=>{let d=!1,u=setTimeout(()=>{d||m(!0)},kG);return import("./components/TTDDialog/CodeMirrorEditor-MJK6LQ6P.js").then(b=>{d||s({type:"ready",component:b.default})}).catch(()=>{d||s({type:"fallback"})}).finally(()=>{clearTimeout(u)}),()=>{d=!0,clearTimeout(u)}},[]),yk(()=>{if(a.type!=="fallback"||!l.current)return;let d=i.current;if(d){let u=b=>{b[Ik.CTRL_OR_CMD]&&b.key===Ik.ENTER&&(b.preventDefault(),l.current?.())};return d.focus(),d.addEventListener(Tk.KEYDOWN,u),()=>{d.removeEventListener(Tk.KEYDOWN,u)}}},[a.type]),a.type==="ready"){let d=a.component;return Ip(d,{value:e,onChange:t,onKeyboardSubmit:n,placeholder:o,theme:p,errorLine:r})}return a.type==="fallback"?Ip("textarea",{className:"ttd-dialog-input",onChange:d=>t(d.target.value),value:e,placeholder:o,ref:i}):c?Ip("div",{className:"ttd-dialog-input ttd-dialog-input--loading",children:Ip(it,{})}):null};import LG from"clsx";var Ck=/(?:Parse|Lexical) error on line (\d+)[.:]/i,Sk=/Trying to inactivate an inactive participant \((.+)\)/i,MG=/^\s*-+\^\s*$/,Zs=e=>Ck.test(e),wp=e=>Zs(e)||Sk.test(e),kk=e=>MG.test(e),Bb=e=>{let o=e.match(Sk);return o?.[1]?o[1].trim():null},PG=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),AG=(e,o)=>{let t=Bb(e);if(!t)return null;let n=new RegExp(`^\\s*deactivate\\s+${PG(t)}(?:\\s+%%.*)?\\s*$`),r=o.split(/\r?\n/);for(let i=r.length-1;i>=0;i--)if(n.test(r[i]))return i+1;return null},js=(e,o)=>{let t=e.match(Ck);return t?Number.parseInt(t[1],10):o?AG(e,o):null},hr=(e,o)=>(e.match(o)||[]).length,Mk=(e,o)=>{if(!Zs(e))return null;let t=js(e,o),n=t?`Syntax error near line ${t}.`:"Syntax error in Mermaid diagram.",r=[];if(o){let i=hr(o,/\[/g),l=hr(o,/\]/g);i!==l&&r.push("Unbalanced square brackets in a node label.");let a=hr(o,/\(/g),s=hr(o,/\)/g);a!==s&&r.push("Unbalanced parentheses in a node shape.");let c=hr(o,/\{/g),m=hr(o,/\}/g);c!==m&&r.push("Unbalanced braces in a decision node.");let p=hr(o,/^\s*subgraph\b/gm),d=hr(o,/^\s*end\s*$/gm);p>d&&r.push("A block is missing an `end` statement.")}return(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&r.push("An extra character/token may appear after a node or label definition."),r.length===0&&(r.push("A node or edge line is malformed (missing/extra delimiters)."),r.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:n,likelyCauses:[...new Set(r)]}},Pk=e=>Zs(e)?e.replace(/\n\s*Expecting[\s\S]*$/,"").trimEnd():e;import{jsx as co,jsxs as Cp}from"react/jsx-runtime";var Sp=({error:e,canvasRef:o,loaded:t,hideErrorDetails:n,sourceText:r,autoFixAvailable:i,onApplyAutoFix:l})=>{let a=e?n?h("chat.errors.mermaidParseError"):Pk(e.message):null,s=e&&!n?Mk(e.message,r):null,c=!!i&&!!l&&!n,m=a?.split(/\r?\n/)??[];return Cp("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&co("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:Cp("div",{className:"ttd-dialog-output-error-content",children:[co("div",{className:"ttd-dialog-output-error-icon",children:Kc}),s&&Cp("div",{className:"ttd-dialog-output-error-summary",children:[co("div",{className:"ttd-dialog-output-error-summary__headline",children:s.summary}),co("div",{className:"ttd-dialog-output-error-summary__label",children:"Likely causes:"}),co("ul",{className:"ttd-dialog-output-error-summary__causes",children:s.likelyCauses.map(p=>co("li",{children:p},p))})]}),co("div",{className:"ttd-dialog-output-error-message",children:m.map((p,d)=>Cp("span",{className:kk(p)?"ttd-dialog-output-error-message__caret":void 0,children:[p,d<m.length-1?`
19
+ `),i=[],l=0,a=0;for(let p of r){let d=l,u=d+p.length-1;i.push({line:p,startIndex:d,endIndex:u,lineNumber:a}),l=u+1,a++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,u=p.line.slice(0,s-p.startIndex),b=c.slice(0,d);c=c.slice(d);let g=$s(u,Ep(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let T=$s(p.line,Ep(e),e.lineHeight),I=e.textAlign==="center"?(e.width-T.width)/2:e.width-T.width;g.width+=I}let{width:x,height:v}=$s(b,Ep(e),e.lineHeight),y=g.width,E=p.lineNumber*g.height;m.push({offsetX:y,offsetY:E,width:x,height:v,showOnCanvas:!0}),s+=d}}return m},EG=(e,o,t,n)=>{let r=e.name??uk(e),i=r.slice(t,t+o.length),l=r.slice(0,t),a=Ep({fontSize:Hb.nameFontSize,fontFamily:Db.Assistant}),s=cG(Db.Assistant),c=$s(l,a,s);l===""&&(c.width=0);let m=$s(i,a,s),p=c.width,d=-c.height-Hb.strokeWidth,u=m.width;return[{offsetX:p,offsetY:d,width:u,height:m.height,showOnCanvas:p+u<=e.width*n}]},vG=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),mk=rG((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>pk(d)),i=n.filter(d=>vp(d));r.sort((d,u)=>d.y-u.y),i.sort((d,u)=>d.y-u.y);let l=[],a=new RegExp(vG(e),"gi");for(let d of r){let u=null,b=d.originalText;for(;(u=a.exec(b))!==null;){let g=dk(b,u.index,e),x=yG(d,e,u.index);x.length>0&&l.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:x})}}let s=[];for(let d of i){let u=null,b=d.name??uk(d);for(;(u=a.exec(b))!==null;){let g=dk(b,u.index,e),x=EG(d,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:d,searchQuery:e,preview:g,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...l],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},hG);import{jsx as Ao,jsxs as fk}from"react/jsx-runtime";import{createElement as wG}from"react";var bk=Rn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Pe();return Ao(o.In,{children:Ao(so.Trigger,{...e,className:"default-sidebar-trigger",name:CG.name})})});bk.displayName="DefaultSidebarTrigger";var xk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Pe();return Ao(o.In,{children:e})};xk.displayName="DefaultTabTriggers";var Tp=Object.assign(Rn("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=se(),l=he(),{DefaultSidebarTabTriggersTunnel:a}=Pe(),s=i.openSidebar?.tab===Nb;return wG(so,{...r,name:"default",key:"default",className:IG("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:SG(t,c=>{l({defaultSidebarDockedPreference:c})})},fk(so.Tabs,{children:[Ao(so.Header,{children:fk(so.TabTriggers,{children:[Ao(so.TabTrigger,{tab:Nb,children:Kt}),Ao(so.TabTrigger,{tab:gk,children:Bc}),Ao(a.Out,{})]})}),Ao(so.Tab,{tab:gk,children:Ao(nI,{})}),Ao(so.Tab,{tab:Nb,children:Ao(hk,{})}),e]}))}),{Trigger:bk,TabTriggers:xk});import{useEffect as F9,useState as O9}from"react";import{useState as zb,useRef as Nk,useEffect as Gb,useDeferredValue as VG}from"react";import{EDITOR_LS_KEYS as XG,debounce as KG,isDevEnv as $G}from"@hellixit/common";import{useEffect as yk,useRef as Ek,useState as vk}from"react";import{EVENT as Tk,KEYS as Ik}from"@hellixit/common";import{jsx as Ip}from"react/jsx-runtime";var kG=300,Ck=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n,errorLine:r})=>{let i=Ek(null),l=Ek(n);l.current=n;let[a,s]=vk({type:"loading"}),[c,m]=vk(!1),{theme:p}=se();if(yk(()=>{let d=!1,u=setTimeout(()=>{d||m(!0)},kG);return import("./components/TTDDialog/CodeMirrorEditor-MJK6LQ6P.js").then(b=>{d||s({type:"ready",component:b.default})}).catch(()=>{d||s({type:"fallback"})}).finally(()=>{clearTimeout(u)}),()=>{d=!0,clearTimeout(u)}},[]),yk(()=>{if(a.type!=="fallback"||!l.current)return;let d=i.current;if(d){let u=b=>{b[Ik.CTRL_OR_CMD]&&b.key===Ik.ENTER&&(b.preventDefault(),l.current?.())};return d.focus(),d.addEventListener(Tk.KEYDOWN,u),()=>{d.removeEventListener(Tk.KEYDOWN,u)}}},[a.type]),a.type==="ready"){let d=a.component;return Ip(d,{value:e,onChange:t,onKeyboardSubmit:n,placeholder:o,theme:p,errorLine:r})}return a.type==="fallback"?Ip("textarea",{className:"ttd-dialog-input",onChange:d=>t(d.target.value),value:e,placeholder:o,ref:i}):c?Ip("div",{className:"ttd-dialog-input ttd-dialog-input--loading",children:Ip(it,{})}):null};import LG from"clsx";var Sk=/(?:Parse|Lexical) error on line (\d+)[.:]/i,wk=/Trying to inactivate an inactive participant \((.+)\)/i,MG=/^\s*-+\^\s*$/,Zs=e=>Sk.test(e),Cp=e=>Zs(e)||wk.test(e),kk=e=>MG.test(e),Bb=e=>{let o=e.match(wk);return o?.[1]?o[1].trim():null},PG=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),AG=(e,o)=>{let t=Bb(e);if(!t)return null;let n=new RegExp(`^\\s*deactivate\\s+${PG(t)}(?:\\s+%%.*)?\\s*$`),r=o.split(/\r?\n/);for(let i=r.length-1;i>=0;i--)if(n.test(r[i]))return i+1;return null},js=(e,o)=>{let t=e.match(Sk);return t?Number.parseInt(t[1],10):o?AG(e,o):null},hr=(e,o)=>(e.match(o)||[]).length,Mk=(e,o)=>{if(!Zs(e))return null;let t=js(e,o),n=t?`Syntax error near line ${t}.`:"Syntax error in Mermaid diagram.",r=[];if(o){let i=hr(o,/\[/g),l=hr(o,/\]/g);i!==l&&r.push("Unbalanced square brackets in a node label.");let a=hr(o,/\(/g),s=hr(o,/\)/g);a!==s&&r.push("Unbalanced parentheses in a node shape.");let c=hr(o,/\{/g),m=hr(o,/\}/g);c!==m&&r.push("Unbalanced braces in a decision node.");let p=hr(o,/^\s*subgraph\b/gm),d=hr(o,/^\s*end\s*$/gm);p>d&&r.push("A block is missing an `end` statement.")}return(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&r.push("An extra character/token may appear after a node or label definition."),r.length===0&&(r.push("A node or edge line is malformed (missing/extra delimiters)."),r.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:n,likelyCauses:[...new Set(r)]}},Pk=e=>Zs(e)?e.replace(/\n\s*Expecting[\s\S]*$/,"").trimEnd():e;import{jsx as co,jsxs as Sp}from"react/jsx-runtime";var wp=({error:e,canvasRef:o,loaded:t,hideErrorDetails:n,sourceText:r,autoFixAvailable:i,onApplyAutoFix:l})=>{let a=e?n?h("chat.errors.mermaidParseError"):Pk(e.message):null,s=e&&!n?Mk(e.message,r):null,c=!!i&&!!l&&!n,m=a?.split(/\r?\n/)??[];return Sp("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&co("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:Sp("div",{className:"ttd-dialog-output-error-content",children:[co("div",{className:"ttd-dialog-output-error-icon",children:Kc}),s&&Sp("div",{className:"ttd-dialog-output-error-summary",children:[co("div",{className:"ttd-dialog-output-error-summary__headline",children:s.summary}),co("div",{className:"ttd-dialog-output-error-summary__label",children:"Likely causes:"}),co("ul",{className:"ttd-dialog-output-error-summary__causes",children:s.likelyCauses.map(p=>co("li",{children:p},p))})]}),co("div",{className:"ttd-dialog-output-error-message",children:m.map((p,d)=>Sp("span",{className:kk(p)?"ttd-dialog-output-error-message__caret":void 0,children:[p,d<m.length-1?`
20
20
  `:""]},`error-line-${d}`))}),!n&&co("div",{className:"ttd-dialog-output-error-autofix-slot",children:c?co(ut,{className:"ttd-dialog-panel-button ttd-dialog-output-error-autofix",onSelect:l,children:h("mermaid.autoFixAvailable")}):null})]})},"error"),t?co("div",{className:LG("ttd-dialog-output-canvas-container",{invisible:!!e}),children:co("div",{ref:o,className:"ttd-dialog-output-canvas-content"})},"canvas"):co(it,{size:"2rem"})]})};import Ja from"clsx";import{Fragment as _G}from"react";import{jsx as Qa,jsxs as el}from"react/jsx-runtime";var si=({label:e,children:o,panelActions:t=[],onTextSubmitInProgess:n,renderTopRight:r,renderSubmitShortcut:i,className:l,panelActionJustifyContent:a="flex-start"})=>{let s=c=>{if(c?.variant==="link")return el("button",{className:Ja("ttd-dialog-panel-action-link",c.className),onClick:c.action,disabled:c?.disabled||n,type:"button",children:[c.label,c.icon&&Qa("span",{className:"ttd-dialog-panel-action-link__icon",children:c.icon})]});if(c?.variant==="button")return el(ut,{className:Ja("ttd-dialog-panel-button",c.className),onSelect:c.action?c.action:()=>{},disabled:c?.disabled||n,children:[el("div",{className:Ja({invisible:n}),children:[c?.label,c?.icon&&Qa("span",{children:c.icon})]}),n&&Qa(it,{})]});if(c?.variant==="rateLimit")return Qa("div",{className:Ja("ttd-dialog-panel__rate-limit",c.className),children:c.label})};return el("div",{className:Ja("ttd-dialog-panel",l),children:[(e||r)&&el("div",{className:"ttd-dialog-panel__header",children:[typeof e=="string"?Qa("label",{children:e}):e,r?.()]}),o,el("div",{className:Ja("ttd-dialog-panel-button-container",{invisible:!t.length}),style:{justifyContent:a},children:[t.filter(Boolean).map(c=>Qa(_G,{children:s(c)},c.label)),!n&&i?.()]})]})};import{jsx as DG}from"react/jsx-runtime";var Ak=({children:e})=>DG("div",{className:"ttd-dialog-panels",children:e});import{jsx as Lk,jsxs as HG}from"react/jsx-runtime";var _k=()=>HG("div",{className:"ttd-dialog-submit-shortcut",children:[Lk("div",{className:"ttd-dialog-submit-shortcut__key",children:N("CtrlOrCmd")}),Lk("div",{className:"ttd-dialog-submit-shortcut__key",children:N("Enter")})]});var RG=(e,o)=>{let t=js(e,o);return t==null?null:t-1},Dk=(e,o,t)=>{if(o<0||o>=e.length)return null;let n=t(e[o]);if(n===e[o])return null;let r=[...e];return r[o]=n,r.join(`
21
21
  `)},NG=e=>{let o=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(o)return o[1];let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return t?t[1]:e},Hk=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,"$1 "),Rk=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),BG=(e,o)=>{let t=new RegExp(`^\\s*deactivate\\s+${Rk(o)}(?:\\s+%%.*)?\\s*$`),n=e.split(/\r?\n/);for(let r=n.length-1;r>=0;r--)if(t.test(n[r]))return n.filter((i,l)=>l!==r).join(`
22
22
  `);return null},FG=(e,o)=>{let t=new RegExp(`^\\s*deactivate\\s+${Rk(o)}(?:\\s+%%.*)?\\s*$`),n=e.split(/\r?\n/),r=!1,i=n.filter(l=>t.test(l)?(r=!0,!1):!0);return r?i.join(`
23
23
  `):null},OG=e=>{let o=(e.match(/^\s*subgraph\b/gm)||[]).length,t=(e.match(/^\s*end\s*$/gm)||[]).length,n=o-t;if(n<=0)return null;let r=Array.from({length:n},()=>"end").join(`
24
24
  `);return`${e.trimEnd()}
25
- ${r}`},zG=e=>e.replace(/[“”]/g,'"').replace(/[‘’]/g,"'"),Fb=(e,o)=>{if(!wp(o)||!e.trim())return[];let t=[],n=new Set,r=l=>{!l||l===e||n.has(l)||(n.add(l),t.push(l))},i=Bb(o);if(i&&(r(BG(e,i)),r(FG(e,i))),Zs(o)){let l=e.split(/\r?\n/),a=RG(o,e),s=a==null?[]:[a,a-1,a+1];for(let m of s)r(Dk(l,m,p=>NG(p))),r(Dk(l,m,p=>Hk(p)));r(Hk(e)),r(OG(e));let c=zG(e);r(c===e?null:c)}return t};import{DEFAULT_EXPORT_PADDING as GG,EDITOR_LS_KEYS as UG,THEME as WG}from"@excalidraw/common";import{convertToHellixitboardElements as YG}from"@excalidraw/element";import{getCommonBounds as kp}from"@excalidraw/element";var Ob=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},tl=async({canvasRef:e,mermaidToHellixitboardLib:o,mermaidDefinition:t,setError:n,data:r,theme:i})=>{let l=e.current,a=l?.parentElement;if(!l||!a)return{success:!1};if(!t)return Ob({canvasRef:e,setError:n}),{success:!1};let s;try{let c=await o.api;try{s=await c.parseMermaidToHellixitboard(t)}catch(u){let b=u;if(!t.includes('"'))return{success:!1,error:b};try{s=await c.parseMermaidToHellixitboard(t.replace(/"/g,"'"))}catch{return{success:!1,error:b}}}let{elements:m,files:p={}}=s;n(null),r.current={elements:YG(m,{regenerateIds:!0}),files:p};let d=await nr({elements:r.current.elements,files:r.current.files,exportPadding:GG,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:i===WG.DARK}});return a.style.background="var(--default-bg-color)",l.replaceChildren(d),{success:!0}}catch(c){return a.style.background="var(--default-bg-color)",t&&n(c),{success:!1,error:c}}},ol=e=>{no.set(UG.MERMAID_TO_HELLIXITBOARD,e)},qs=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&ol(t))};import{Fragment as t9,jsx as Lo,jsxs as Fk}from"react/jsx-runtime";var ZG=`flowchart TD
25
+ ${r}`},zG=e=>e.replace(/[“”]/g,'"').replace(/[‘’]/g,"'"),Fb=(e,o)=>{if(!Cp(o)||!e.trim())return[];let t=[],n=new Set,r=l=>{!l||l===e||n.has(l)||(n.add(l),t.push(l))},i=Bb(o);if(i&&(r(BG(e,i)),r(FG(e,i))),Zs(o)){let l=e.split(/\r?\n/),a=RG(o,e),s=a==null?[]:[a,a-1,a+1];for(let m of s)r(Dk(l,m,p=>NG(p))),r(Dk(l,m,p=>Hk(p)));r(Hk(e)),r(OG(e));let c=zG(e);r(c===e?null:c)}return t};import{DEFAULT_EXPORT_PADDING as GG,EDITOR_LS_KEYS as UG,THEME as WG}from"@hellixit/common";import{convertToHellixitboardElements as YG}from"@hellixit/element";import{getCommonBounds as kp}from"@hellixit/element";var Ob=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},tl=async({canvasRef:e,mermaidToHellixitboardLib:o,mermaidDefinition:t,setError:n,data:r,theme:i})=>{let l=e.current,a=l?.parentElement;if(!l||!a)return{success:!1};if(!t)return Ob({canvasRef:e,setError:n}),{success:!1};let s;try{let c=await o.api;try{s=await c.parseMermaidToHellixitboard(t)}catch(u){let b=u;if(!t.includes('"'))return{success:!1,error:b};try{s=await c.parseMermaidToHellixitboard(t.replace(/"/g,"'"))}catch{return{success:!1,error:b}}}let{elements:m,files:p={}}=s;n(null),r.current={elements:YG(m,{regenerateIds:!0}),files:p};let d=await nr({elements:r.current.elements,files:r.current.files,exportPadding:GG,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:i===WG.DARK}});return a.style.background="var(--default-bg-color)",l.replaceChildren(d),{success:!0}}catch(c){return a.style.background="var(--default-bg-color)",t&&n(c),{success:!1,error:c}}},ol=e=>{no.set(UG.MERMAID_TO_HELLIXITBOARD,e)},qs=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&ol(t))};import{Fragment as t9,jsx as Lo,jsxs as Fk}from"react/jsx-runtime";var ZG=`flowchart TD
26
26
  A[Christmas] -->|Get money| B(Go shopping)
27
27
  B --> C{Let me think}
28
28
  C -->|One| D[Laptop]
29
29
  C -->|Two| E[iPhone]
30
- C -->|Three| F[Car]`,Bk=KG(ol,300),jG=500,qG=4,JG=30,QG=e=>e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:"",e9=({mermaidToHellixitboardLib:e,isActive:o})=>{let[t,n]=zb(()=>no.get(XG.MERMAID_TO_HELLIXITBOARD)||ZG),r=VG(t),[i,l]=zb(null),[a,s]=zb(null),c=i?.message?js(i.message,r):null,m=Nk(null),p=Nk({elements:[],files:null}),d=Ae(),{theme:u}=se();Gb(()=>{o&&((async()=>{try{if(!r.trim()){Ob({canvasRef:m,setError:l});return}let v=await tl({canvasRef:m,data:p,mermaidToHellixitboardLib:e,setError:l,mermaidDefinition:r,theme:u});if(!v.success){let y=v.error??new Error("Invalid mermaid definition");l(y)}}catch(v){$G()&&console.error("Failed to parse mermaid definition",v)}})(),Bk(r))},[r,e,o,u]),Gb(()=>()=>{Bk.flush()},[]),Gb(()=>{let x=i?.message??"",v=r;if(!(o&&wp(x)&&!!v.trim()&&e.loaded)){s(null);return}let E=Fb(v,x);if(!E.length){s(null);return}let T=!1,I=setTimeout(async()=>{try{let C=await e.api,M=new Set([v]),k=E.map(P=>({text:P,depth:1})),_=0;for(;k.length>0&&_<JG;){let P=k.shift();if(!(!P||M.has(P.text))){M.add(P.text),_+=1;try{await C.parseMermaidToHellixitboard(P.text),T||s(P.text);return}catch(A){if(P.depth>=qG)continue;let H=QG(A);if(!H)continue;let F=Fb(P.text,H);for(let Y of F)M.has(Y)||k.push({text:Y,depth:P.depth+1})}}}}catch{}T||s(null)},jG);return()=>{T=!0,clearTimeout(I)}},[r,i?.message,o,e]);let b=()=>{qs({app:d,data:p,text:t,shouldSaveMermaidDataToStorage:!0})},g=()=>{a&&n(a)};return Fk(t9,{children:[Lo("div",{className:"ttd-dialog-desc",children:Lo(Pt,{i18nKey:"mermaid.description",flowchartLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/flowchart.html",target:"_blank",rel:"noreferrer",children:x}),sequenceLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",target:"_blank",rel:"noreferrer",children:x}),classLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",target:"_blank",rel:"noreferrer",children:x}),erdLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/entityRelationshipDiagram.html",target:"_blank",rel:"noreferrer",children:x})})}),Fk(Ak,{children:[Lo(si,{children:Lo(wk,{input:t,placeholder:h("mermaid.inputPlaceholder"),onChange:x=>n(x),errorLine:c,onKeyboardSubmit:()=>{b()}})}),Lo(si,{panelActions:[{action:()=>{b()},label:h("mermaid.button"),icon:Wn,variant:"button"}],renderSubmitShortcut:()=>Lo(_k,{}),children:Lo(Sp,{canvasRef:m,loaded:e.loaded,error:i,sourceText:t,autoFixAvailable:!!a,onApplyAutoFix:g})})]})]})},Ok=e9;import{useRef as S9}from"react";import{useRef as zk,useEffect as l9,useLayoutEffect as s9}from"react";import{KEYS as c9}from"@excalidraw/common";import{jsx as Ub,jsxs as o9}from"react/jsx-runtime";var Mp=()=>o9("div",{className:"chat-interface__welcome-screen__welcome-message",children:[Ub("h3",{children:h("chat.placeholder.title")}),Ub("p",{children:h("chat.placeholder.description")}),Ub("p",{children:h("chat.placeholder.hint")})]});import n9 from"clsx";import{useState as r9,useEffect as i9}from"react";import{Fragment as a9,jsx as gt,jsxs as _o}from"react/jsx-runtime";var Wb=({message:e,onMermaidTabClick:o,onAiRepairClick:t,onDeleteMessage:n,onInsertMessage:r,onRetry:i,rateLimitRemaining:l,isLastMessage:a,renderWarning:s,allowFixingParseError:c})=>{let[m,p]=r9(!1);i9(()=>{if(!e.error||!a)return;if(e.error&&!e.lastAttemptAt){p(!0);return}let u=Date.now()-e.lastAttemptAt,b=Math.max(0,5e3-u);if(b===0){p(!0);return}p(!1);let g=setTimeout(()=>{p(!0)},b);return()=>clearTimeout(g)},[e.error,e.lastAttemptAt,a]);let d=u=>u.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(e.type==="warning"){let u=s?.(e);return gt("div",{className:"chat-message chat-message--system",children:_o("div",{className:"chat-message__content",children:[_o("div",{className:"chat-message__header",children:[gt("span",{className:"chat-message__role",children:h("chat.role.system")}),gt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),gt("div",{className:"chat-message__body",children:gt("div",{className:"chat-message__text",children:u||(e.warningType==="messageLimitExceeded"?h("chat.rateLimit.messageLimit"):h("chat.rateLimit.generalRateLimit"))})})]})})}return _o("div",{className:`chat-message chat-message--${e.type}`,children:[_o("div",{className:"chat-message__content",children:[_o("div",{className:"chat-message__header",children:[gt("span",{className:"chat-message__role",children:e.type==="user"?h("chat.role.user"):h("chat.role.assistant")}),gt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),gt("div",{className:"chat-message__body",children:e.error?_o(a9,{children:[gt("div",{className:"chat-message__error",children:e.content}),e.errorType!=="parse"&&_o("div",{className:"chat-message__error_message",children:["Error: ",e.error||h("chat.errors.generationFailed")]}),e.errorType==="parse"&&c&&_o("div",{className:"chat-message__error_message",children:[gt("p",{children:h("chat.errors.invalidDiagram")}),_o("div",{className:"chat-message__error-actions",children:[o&&gt("button",{className:"chat-message__error-link",onClick:()=>o(e),type:"button",children:h("chat.errors.fixInMermaid")}),t&&gt("button",{className:"chat-message__error-link",onClick:()=>t(e),disabled:l===0,type:"button",children:h("chat.errors.aiRepair")})]})]})]}):_o("div",{className:"chat-message__text",children:[e.content,e.isGenerating&&gt("span",{className:"chat-message__cursor",children:"\u258B"})]})})]}),e.type==="assistant"&&!e.isGenerating&&_o("div",{className:"chat-message__actions",children:[!e.error&&r&&gt("button",{className:"chat-message__action",onClick:()=>r(e),type:"button","aria-label":h("chat.insert"),title:h("chat.insert"),children:IE}),o&&e.content&&gt("button",{className:"chat-message__action",onClick:()=>o(e),type:"button","aria-label":h("chat.viewAsMermaid"),title:h("chat.viewAsMermaid"),children:Wu}),n&&e.errorType!=="network"&&gt("button",{className:"chat-message__action chat-message__action--danger",onClick:()=>n(e.id),type:"button","aria-label":h("chat.deleteMessage"),title:h("chat.deleteMessage"),children:pt}),e.errorType==="network"&&i&&a&&gt("button",{className:n9("chat-message__action",{invisible:!m}),onClick:()=>i(e),type:"button","aria-label":h("chat.retry"),title:h("chat.retry"),children:TE})]})]})};import{jsx as Nn,jsxs as Yb}from"react/jsx-runtime";var Vb=({chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,rateLimits:l,onAbort:a,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:m,onInsertMessage:p,onRetry:d,renderWelcomeScreen:u,renderWarning:b})=>{let g=zk(null),x=zk(null);s9(()=>{g.current?.scrollIntoView()},[o]),l9(()=>{x.current&&x.current.focus()},[e]);let v=M=>{let k=M.target.value;n(k)},y=()=>{if(i&&a){a();return}let M=t.trim();M&&(r({prompt:M}),n(""))},E=M=>{M.key===c9.ENTER&&!M.shiftKey&&(M.preventDefault(),i||y())},T=t.trim().length>3&&!i&&(l?.rateLimitRemaining??1)>0,I=i&&!!a,C=M=>{let k=M.target;k.style.height="auto",k.style.height=`${Math.min(k.scrollHeight,120)}px`};return Yb("div",{className:"chat-interface",children:[Yb("div",{className:"chat-interface__messages",children:[o.length===0?Nn("div",{className:"chat-interface__welcome-screen",children:u?u({rateLimits:l??null}):Nn(Mp,{})}):o.map((M,k)=>Nn(Wb,{message:M,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:m,onInsertMessage:p,onRetry:d,rateLimitRemaining:l?.rateLimitRemaining,isLastMessage:k===o.length-1,renderWarning:b,allowFixingParseError:M.errorType==="parse"&&k===o.length-1},M.id)),Nn("div",{ref:g,id:"messages-end"})]}),Nn("div",{className:"chat-interface__input-container",children:Nn("div",{className:"chat-interface__input-outer",children:Yb("div",{className:"chat-interface__input-wrapper",style:{borderColor:i?"var(--dialog-border-color)":void 0},children:[Nn("textarea",{ref:x,autoFocus:!0,className:"chat-interface__input",value:t,onChange:v,onKeyDown:E,placeholder:i?h("chat.generating"):l?.rateLimitRemaining===0?h("chat.rateLimit.messageLimitInputPlaceholder"):o.length>0?h("chat.inputPlaceholderWithMessages"):h("chat.inputPlaceholder",{shortcut:"Shift + Enter"}),disabled:l?.rateLimitRemaining===0,rows:1,cols:30,onInput:C}),Nn("button",{className:"chat-interface__send-button",onClick:y,disabled:!T&&!I,type:"button",children:Nn($o,{size:"1.5em",icon:i?L0:Wn})})]})})})]})};import{randomId as d9}from"@excalidraw/common";var Pp=ge(null),Ap=ge(!1),gr=ge(null),mo=ge({id:d9(),messages:[],currentPrompt:""});import{findLastIndex as Xb,randomId as m9}from"@excalidraw/common";var fr=(e,o)=>{let{messages:t}=e,n=Xb(t,l=>l.type==="assistant");if(n===-1)return e;let r=t[n],i=t.slice();return i[n]={...r,...o},{...e,messages:i}},br=e=>{let{messages:o}=e,t=Xb(o,n=>n.type==="assistant");return o[t]},Js=(e,o)=>{let t=o.map(n=>({...n,id:m9(),timestamp:new Date}));return{...e,messages:[...e.messages,...t]}},Gk=e=>{let o=Xb(e.messages??[],t=>t.type==="assistant");return o!==-1?{...e,messages:e.messages.filter((t,n)=>n!==o)}:e},Uk=e=>{let o=[];for(let t of e.messages)t.content&&(t.type==="user"||t.type==="assistant")&&o.push({role:t.type,content:t.content});return o};var Qs=()=>{let[e,o]=Q(mo);return{addUserMessage:l=>{o(a=>Js(a,[{type:"user",content:l}]))},addAssistantMessage:()=>{o(l=>Js(l,[{type:"assistant",content:"",isGenerating:!0}]))},setAssistantError:(l,a="other",s)=>{let c=s?JSON.stringify({name:s instanceof Error?s.name:"Error",message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0}):void 0;o(m=>fr(m,{isGenerating:!1,error:l,errorType:a,errorDetails:c}))},chatHistory:e,setChatHistory:o,setLastRetryAttempt:()=>{o(l=>fr(l,{lastAttemptAt:Date.now()}))}}};import{useCallback as ec,useEffect as Wk,useRef as p9}from"react";import{randomId as u9}from"@excalidraw/common";var h9=e=>{let o=e.trim();return o.length<=50?o:`${o.substring(0,47)}...`},g9=ge([]),f9=ge(!1),b9=ge(!1),Lp=({persistenceAdapter:e})=>{let[o]=Q(mo),[t,n]=Q(g9),[r,i]=Q(f9),[l,a]=Q(b9),s=p9(t);s.current=t;let c=o?.messages[o?.messages.length-1],m=ec(async()=>{if(!(l||r)){i(!0);try{let g=await e.loadChats();n(g),a(!0)}catch(g){console.warn("Failed to load chats:",g),n([]),a(!0)}finally{i(!1)}}},[l,r,n,i,a,e]);Wk(()=>{m()},[]);let p=ec(async()=>{if(o.messages.length===0)return;let g=o.messages.find(C=>C.type==="user");if(!g||typeof g.content!="string")return;let x=h9(g.content),v=s.current,y=v.find(C=>C.id===o.id),E=!y||y.messages.length!==o.messages.length||y.messages.some((C,M)=>C.id!==o.messages[M]?.id||C.content!==o.messages[M]?.content),T={id:o.id,title:x,messages:o.messages.filter(C=>C.type==="user"||C.type==="assistant").map(C=>({...C,timestamp:C.timestamp instanceof Date?C.timestamp:new Date(C.timestamp)})),currentPrompt:o.currentPrompt,timestamp:E?Date.now():y?.timestamp??Date.now()},I=[...v.filter(C=>C.id!==o.id),T].sort((C,M)=>M.timestamp-C.timestamp).slice(0,10);n(I);try{await e.saveChats(I)}catch(C){console.warn("Failed to save chats:",C)}},[o,n,e]);Wk(()=>{c?.isGenerating||p()},[o.messages?.length,c?.id,c?.isGenerating]);let d=ec(async g=>{let x=s.current.filter(v=>v.id!==g);n(x);try{await e.saveChats(x)}catch(v){console.warn("Failed to save after delete:",v)}return x},[n,e]),u=ec(g=>g,[]),b=ec(async()=>(await p(),u9()),[p]);return{savedChats:t,saveCurrentChat:p,deleteChat:d,restoreChat:u,createNewChatId:b}};import{useCallback as Vk,useEffect as _p,useMemo as Xk,useRef as ci}from"react";var Yk=e=>{let o=e.trim();if(!o)return!1;let t=(o.match(/\[/g)||[]).length,n=(o.match(/\]/g)||[]).length,r=(o.match(/\{/g)||[]).length,i=(o.match(/\}/g)||[]).length,l=(o.match(/\(/g)||[]).length,a=(o.match(/\)/g)||[]).length;if(t!==n||r!==i||l!==a)return!1;let s=o.split(`
31
- `).pop()?.trim()||"";return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(m=>m.test(s))};var Kb=300,x9=3e3,y9=100,Kk=100,$k=({mermaidToHellixitboardLib:e,canvasRef:o})=>{let[t]=Q(mo),[,n]=Q(gr),[r,i]=Q(Ap),l=ci(!1),a=Xk(()=>br(t),[t]),s=ci(a);_p(()=>{s.current=a},[a]);let c=ci({elements:[],files:null}),m=ci(0),p=ci(null),d=ci(!1),u=ci(Kb),{theme:b}=se(),g=Vk(async y=>{if(!y.trim()||!e.loaded||l.current)return!1;l.current=!0;let E=performance.now(),T=await tl({canvasRef:o,data:c,mermaidToHellixitboardLib:e,setError:n,mermaidDefinition:y,theme:b});return performance.now()-E<y9?u.current=Kb:u.current=x9,l.current=!1,T.success},[o,e,n,b]),x=Xk(()=>{let y=async E=>{let T=Date.now(),I=T-m.current,C=u.current;if(!Yk(E)){d.current||(m.current=Math.max(m.current,T-C+Kk),d.current=!0),p.current=E;return}if(d.current=!1,I<C){p.current=E;return}p.current=null;let M=await g(E);m.current=Date.now(),M||(m.current=m.current-C+Kk,d.current=!0)};return y.flush=async()=>{if(p.current){let E=p.current;p.current=null,await g(E),m.current=Date.now()}},y.cancel=()=>{p.current=null},y},[g]),v=Vk(()=>{m.current=0,p.current=null,d.current=!1,u.current=Kb},[]);return _p(()=>{a?.content&&a?.isGenerating?x(a.content):a?.isGenerating||(x.flush(),v(),a?.content&&x(a.content))},[v,x,a?.isGenerating,a?.content]),_p(()=>{let y=s.current;!y?.content||y.error||r&&g(y.content)},[t?.id,g,r]),_p(()=>{if(t.messages?.filter(y=>y.type==="assistant").length)r||i(!0);else{let y=o.current;if(y){let E=y.parentElement;E&&(E.style.background="",y.replaceChildren())}i(!1)}},[t.messages,i,o,r]),{data:c}};import{useRef as E9}from"react";import{parseMermaidToExcalidraw as v9}from"@excalidraw/mermaid-to-excalidraw";import{isFiniteNumber as Zk}from"@excalidraw/math";var $b=3,Zb=1e4,jk=({onTextSubmit:e})=>{let[,o]=Q(gr),[t,n]=Q(Pp),[r,i]=Q(mo),{addUserMessage:l,addAssistantMessage:a,setAssistantError:s}=Qs(),c=E9(null),m=u=>u.length>Zb||u.length<$b||t?.rateLimitRemaining===0?(u.length<$b&&o(new Error(h("chat.errors.promptTooShort",{min:$b}))),u.length>Zb&&o(new Error(h("chat.errors.promptTooLong",{max:Zb}))),!1):!0;return{onGenerate:async({prompt:u,isRepairFlow:b=!1})=>{if(!m(u))return;c.current&&c.current.abort(),o(null);let g=new AbortController;c.current=g,b?i(x=>fr(x,{isGenerating:!0,content:"",error:void 0,errorType:void 0,errorDetails:void 0})):(l(u),a());try{ce("ai","generate","ttd");let v=[...Uk(r).slice(-3),{role:"user",content:u}],{generatedResponse:y,error:E,rateLimit:T,rateLimitRemaining:I}=await e({messages:v,onStreamCreated:()=>{b&&i(C=>fr(C,{content:"",error:"",isGenerating:!0}))},onChunk:C=>{i(M=>{let k=br(M);return fr(M,{content:k.content+C})})},signal:g.signal});if(i(C=>fr(C,{isGenerating:!1})),Zk(T)&&Zk(I)&&n({rateLimit:T,rateLimitRemaining:I}),(E?.status===429||I===0)&&i(C=>(E?.status===429&&(C=Gk(C)),C={...C,messages:C.messages.filter(k=>k.type!=="warning"||k.warningType==="rateLimitExceeded"||k.warningType==="messageLimitExceeded")},Js(C,[{type:"warning",warningType:I===0?"messageLimitExceeded":"rateLimitExceeded"}]))),E){if(E.name==="AbortError"||E.message==="Aborted"||g.signal.aborted)return;let M=new Error(E.message||h("chat.errors.requestFailed"));E.status!==429&&s(M.message,"network"),o(M);return}try{await v9(y??""),ce("ai","mermaid parse success","ttd")}catch(C){ce("ai","mermaid parse failed","ttd");let M=new Error(C.message||h("chat.errors.mermaidParseError"));s(M.message,"parse"),o(M)}}catch(x){let v=new Error(x.message||h("chat.errors.generationFailed"));s(v.message,"other"),o(v)}finally{c.current=null}},handleAbort:()=>{c.current&&c.current.abort()}}};import{useCallback as di,useState as T9}from"react";var qk=({persistenceAdapter:e})=>{let o=zo(gr),[t,n]=Q(mo),[r,i]=T9(!1),{restoreChat:l,deleteChat:a,createNewChatId:s}=Lp({persistenceAdapter:e}),c=di(x=>{let v=x.messages.map(T=>({...T,timestamp:T.timestamp instanceof Date?T.timestamp:new Date(T.timestamp)})),y={id:x.id,messages:v,currentPrompt:""},E=br(y);o(E?.error?new Error(E?.error):null),n(y)},[o,n]),m=di(async()=>{let x=await s();n({id:x,messages:[],currentPrompt:""}),o(null)},[s,n,o]),p=di(x=>{let v=l(x);c(v),i(!1)},[l,c]),d=di(async(x,v)=>{v.stopPropagation();let y=x===t.id,E=await a(x);if(y)if(E.length>0){let T=E[0];c(T)}else await m()},[t.id,a,c,m]),u=di(async()=>{await m(),i(!1)},[m]),b=di(()=>{i(x=>!x)},[]),g=di(()=>{i(!1)},[]);return{isMenuOpen:r,onRestoreChat:p,handleDeleteChat:d,handleNewChat:u,handleMenuToggle:b,handleMenuClose:g}};import I9 from"clsx";import{Fragment as w9,jsx as mi,jsxs as jb}from"react/jsx-runtime";var Jk=({isOpen:e,onToggle:o,onClose:t,onNewChat:n,onRestoreChat:r,onDeleteChat:i,isNewChatBtnVisible:l,savedChats:a,activeSessionId:s,disabled:c})=>jb("div",{className:"ttd-chat-history-menu",children:[l&&mi(sn,{onClick:n,disabled:c,children:h("chat.newChat")}),a.length>0&&mi("div",{className:"ttd-dialog-panel__menu-wrapper",children:jb(ie,{open:e,children:[mi(ie.Trigger,{onToggle:o,className:"ttd-dialog-menu-trigger",disabled:c,title:h("chat.menu"),"aria-label":h("chat.menu"),children:PE}),mi(ie.Content,{onClickOutside:t,onSelect:t,children:mi(w9,{children:a.map(m=>jb(ie.ItemCustom,{className:I9("ttd-chat-menu-item",{"ttd-chat-menu-item--active":m.id===s}),onClick:()=>{r(m)},children:[mi("span",{className:"ttd-chat-menu-item__title",children:m.title}),mi("button",{className:"ttd-chat-menu-item__delete",onClick:p=>i(m.id,p),title:h("chat.deleteChat"),"aria-label":h("chat.deleteChat"),type:"button",children:pt})]},m.id))})})]})})]});import{jsx as nl,jsxs as C9}from"react/jsx-runtime";var Qk=({chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,generatedResponse:l,isMenuOpen:a,onMenuToggle:s,onMenuClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:u,activeSessionId:b,onAbort:g,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:T,onViewAsMermaid:I,renderWelcomeScreen:C,renderWarning:M})=>{let[k]=Q(Pp),P=(()=>{let H=[];return k&&H.push({label:h("chat.rateLimitRemaining",{count:k.rateLimitRemaining}),variant:"rateLimit",className:k.rateLimitRemaining<5?"ttd-dialog-panel__rate-limit--danger":""}),l&&H.push({action:I,label:h("chat.viewAsMermaid"),icon:nl($o,{icon:Wn}),variant:"link"}),H})(),A=()=>P.length===2?"space-between":P.length===1&&P[0].variant==="rateLimit"?"flex-start":"flex-end";return nl(si,{label:C9("div",{className:"ttd-dialog-panel__label-wrapper",children:[nl("div",{className:"ttd-dialog-panel__label-group"}),nl("div",{className:"ttd-dialog-panel__header-right",children:nl(Jk,{isNewChatBtnVisible:!!o.length,isOpen:a,onToggle:s,onClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:u,activeSessionId:b,disabled:i})})]}),className:"ttd-dialog-chat-panel",panelActionJustifyContent:A(),panelActions:P,children:nl(Vb,{chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,generatedResponse:l,onAbort:g,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:T,rateLimits:k,renderWelcomeScreen:C,renderWarning:M})})};import{jsx as eM}from"react/jsx-runtime";var tM=({canvasRef:e,error:o,loaded:t,onInsert:n,hideErrorDetails:r})=>{let i=[{action:n,label:h("chat.insert"),icon:Wn,variant:"button"}];return eM(si,{panelActionJustifyContent:"flex-end",panelActions:i,className:"ttd-dialog-preview-panel",children:eM(Sp,{canvasRef:e,error:o,loaded:t,hideErrorDetails:r})})};import{jsx as qb,jsxs as P9}from"react/jsx-runtime";var k9=({mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r})=>{let i=Ae(),l=he(),a=S9(null),[s,c]=Q(gr),[m,p]=Q(mo),d=Ii(Ap),{savedChats:u}=Lp({persistenceAdapter:r}),b=br(m),{setLastRetryAttempt:g}=Qs(),{data:x}=$k({canvasRef:a,mermaidToHellixitboardLib:e}),{onGenerate:v,handleAbort:y}=jk({onTextSubmit:o}),{isMenuOpen:E,onRestoreChat:T,handleDeleteChat:I,handleNewChat:C,handleMenuToggle:M,handleMenuClose:k}=qk({persistenceAdapter:r}),_=()=>{typeof b?.content=="string"&&(ol(b.content),l({openDialog:{name:"ttd",tab:"mermaid"}}))},P=D=>{let B=D.content||"";B&&(ol(B),l({openDialog:{name:"ttd",tab:"mermaid"}}))},A=async D=>{let B=D.content||"";if(!B.trim()||!e.loaded)return;let W={current:{elements:[],files:null}};(await tl({canvasRef:a,data:W,mermaidToHellixitboardLib:e,setError:c,mermaidDefinition:B,theme:i.state.theme})).success&&qs({app:i,data:W,text:B,shouldSaveMermaidDataToStorage:!0})},H=async D=>{let B=D.content||"",W=D.error||"";if(!B)return;let te=`Fix the error in this Mermaid diagram. The diagram is:
30
+ C -->|Three| F[Car]`,Bk=KG(ol,300),jG=500,qG=4,JG=30,QG=e=>e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:"",e9=({mermaidToHellixitboardLib:e,isActive:o})=>{let[t,n]=zb(()=>no.get(XG.MERMAID_TO_HELLIXITBOARD)||ZG),r=VG(t),[i,l]=zb(null),[a,s]=zb(null),c=i?.message?js(i.message,r):null,m=Nk(null),p=Nk({elements:[],files:null}),d=Ae(),{theme:u}=se();Gb(()=>{o&&((async()=>{try{if(!r.trim()){Ob({canvasRef:m,setError:l});return}let v=await tl({canvasRef:m,data:p,mermaidToHellixitboardLib:e,setError:l,mermaidDefinition:r,theme:u});if(!v.success){let y=v.error??new Error("Invalid mermaid definition");l(y)}}catch(v){$G()&&console.error("Failed to parse mermaid definition",v)}})(),Bk(r))},[r,e,o,u]),Gb(()=>()=>{Bk.flush()},[]),Gb(()=>{let x=i?.message??"",v=r;if(!(o&&Cp(x)&&!!v.trim()&&e.loaded)){s(null);return}let E=Fb(v,x);if(!E.length){s(null);return}let T=!1,I=setTimeout(async()=>{try{let S=await e.api,M=new Set([v]),k=E.map(P=>({text:P,depth:1})),_=0;for(;k.length>0&&_<JG;){let P=k.shift();if(!(!P||M.has(P.text))){M.add(P.text),_+=1;try{await S.parseMermaidToHellixitboard(P.text),T||s(P.text);return}catch(A){if(P.depth>=qG)continue;let H=QG(A);if(!H)continue;let F=Fb(P.text,H);for(let Y of F)M.has(Y)||k.push({text:Y,depth:P.depth+1})}}}}catch{}T||s(null)},jG);return()=>{T=!0,clearTimeout(I)}},[r,i?.message,o,e]);let b=()=>{qs({app:d,data:p,text:t,shouldSaveMermaidDataToStorage:!0})},g=()=>{a&&n(a)};return Fk(t9,{children:[Lo("div",{className:"ttd-dialog-desc",children:Lo(Pt,{i18nKey:"mermaid.description",flowchartLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/flowchart.html",target:"_blank",rel:"noreferrer",children:x}),sequenceLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",target:"_blank",rel:"noreferrer",children:x}),classLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",target:"_blank",rel:"noreferrer",children:x}),erdLink:x=>Lo("a",{href:"https://mermaid.js.org/syntax/entityRelationshipDiagram.html",target:"_blank",rel:"noreferrer",children:x})})}),Fk(Ak,{children:[Lo(si,{children:Lo(Ck,{input:t,placeholder:h("mermaid.inputPlaceholder"),onChange:x=>n(x),errorLine:c,onKeyboardSubmit:()=>{b()}})}),Lo(si,{panelActions:[{action:()=>{b()},label:h("mermaid.button"),icon:Wn,variant:"button"}],renderSubmitShortcut:()=>Lo(_k,{}),children:Lo(wp,{canvasRef:m,loaded:e.loaded,error:i,sourceText:t,autoFixAvailable:!!a,onApplyAutoFix:g})})]})]})},Ok=e9;import{useRef as w9}from"react";import{useRef as zk,useEffect as l9,useLayoutEffect as s9}from"react";import{KEYS as c9}from"@hellixit/common";import{jsx as Ub,jsxs as o9}from"react/jsx-runtime";var Mp=()=>o9("div",{className:"chat-interface__welcome-screen__welcome-message",children:[Ub("h3",{children:h("chat.placeholder.title")}),Ub("p",{children:h("chat.placeholder.description")}),Ub("p",{children:h("chat.placeholder.hint")})]});import n9 from"clsx";import{useState as r9,useEffect as i9}from"react";import{Fragment as a9,jsx as gt,jsxs as _o}from"react/jsx-runtime";var Wb=({message:e,onMermaidTabClick:o,onAiRepairClick:t,onDeleteMessage:n,onInsertMessage:r,onRetry:i,rateLimitRemaining:l,isLastMessage:a,renderWarning:s,allowFixingParseError:c})=>{let[m,p]=r9(!1);i9(()=>{if(!e.error||!a)return;if(e.error&&!e.lastAttemptAt){p(!0);return}let u=Date.now()-e.lastAttemptAt,b=Math.max(0,5e3-u);if(b===0){p(!0);return}p(!1);let g=setTimeout(()=>{p(!0)},b);return()=>clearTimeout(g)},[e.error,e.lastAttemptAt,a]);let d=u=>u.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(e.type==="warning"){let u=s?.(e);return gt("div",{className:"chat-message chat-message--system",children:_o("div",{className:"chat-message__content",children:[_o("div",{className:"chat-message__header",children:[gt("span",{className:"chat-message__role",children:h("chat.role.system")}),gt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),gt("div",{className:"chat-message__body",children:gt("div",{className:"chat-message__text",children:u||(e.warningType==="messageLimitExceeded"?h("chat.rateLimit.messageLimit"):h("chat.rateLimit.generalRateLimit"))})})]})})}return _o("div",{className:`chat-message chat-message--${e.type}`,children:[_o("div",{className:"chat-message__content",children:[_o("div",{className:"chat-message__header",children:[gt("span",{className:"chat-message__role",children:e.type==="user"?h("chat.role.user"):h("chat.role.assistant")}),gt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),gt("div",{className:"chat-message__body",children:e.error?_o(a9,{children:[gt("div",{className:"chat-message__error",children:e.content}),e.errorType!=="parse"&&_o("div",{className:"chat-message__error_message",children:["Error: ",e.error||h("chat.errors.generationFailed")]}),e.errorType==="parse"&&c&&_o("div",{className:"chat-message__error_message",children:[gt("p",{children:h("chat.errors.invalidDiagram")}),_o("div",{className:"chat-message__error-actions",children:[o&&gt("button",{className:"chat-message__error-link",onClick:()=>o(e),type:"button",children:h("chat.errors.fixInMermaid")}),t&&gt("button",{className:"chat-message__error-link",onClick:()=>t(e),disabled:l===0,type:"button",children:h("chat.errors.aiRepair")})]})]})]}):_o("div",{className:"chat-message__text",children:[e.content,e.isGenerating&&gt("span",{className:"chat-message__cursor",children:"\u258B"})]})})]}),e.type==="assistant"&&!e.isGenerating&&_o("div",{className:"chat-message__actions",children:[!e.error&&r&&gt("button",{className:"chat-message__action",onClick:()=>r(e),type:"button","aria-label":h("chat.insert"),title:h("chat.insert"),children:IE}),o&&e.content&&gt("button",{className:"chat-message__action",onClick:()=>o(e),type:"button","aria-label":h("chat.viewAsMermaid"),title:h("chat.viewAsMermaid"),children:Wu}),n&&e.errorType!=="network"&&gt("button",{className:"chat-message__action chat-message__action--danger",onClick:()=>n(e.id),type:"button","aria-label":h("chat.deleteMessage"),title:h("chat.deleteMessage"),children:pt}),e.errorType==="network"&&i&&a&&gt("button",{className:n9("chat-message__action",{invisible:!m}),onClick:()=>i(e),type:"button","aria-label":h("chat.retry"),title:h("chat.retry"),children:TE})]})]})};import{jsx as Nn,jsxs as Yb}from"react/jsx-runtime";var Vb=({chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,rateLimits:l,onAbort:a,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:m,onInsertMessage:p,onRetry:d,renderWelcomeScreen:u,renderWarning:b})=>{let g=zk(null),x=zk(null);s9(()=>{g.current?.scrollIntoView()},[o]),l9(()=>{x.current&&x.current.focus()},[e]);let v=M=>{let k=M.target.value;n(k)},y=()=>{if(i&&a){a();return}let M=t.trim();M&&(r({prompt:M}),n(""))},E=M=>{M.key===c9.ENTER&&!M.shiftKey&&(M.preventDefault(),i||y())},T=t.trim().length>3&&!i&&(l?.rateLimitRemaining??1)>0,I=i&&!!a,S=M=>{let k=M.target;k.style.height="auto",k.style.height=`${Math.min(k.scrollHeight,120)}px`};return Yb("div",{className:"chat-interface",children:[Yb("div",{className:"chat-interface__messages",children:[o.length===0?Nn("div",{className:"chat-interface__welcome-screen",children:u?u({rateLimits:l??null}):Nn(Mp,{})}):o.map((M,k)=>Nn(Wb,{message:M,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:m,onInsertMessage:p,onRetry:d,rateLimitRemaining:l?.rateLimitRemaining,isLastMessage:k===o.length-1,renderWarning:b,allowFixingParseError:M.errorType==="parse"&&k===o.length-1},M.id)),Nn("div",{ref:g,id:"messages-end"})]}),Nn("div",{className:"chat-interface__input-container",children:Nn("div",{className:"chat-interface__input-outer",children:Yb("div",{className:"chat-interface__input-wrapper",style:{borderColor:i?"var(--dialog-border-color)":void 0},children:[Nn("textarea",{ref:x,autoFocus:!0,className:"chat-interface__input",value:t,onChange:v,onKeyDown:E,placeholder:i?h("chat.generating"):l?.rateLimitRemaining===0?h("chat.rateLimit.messageLimitInputPlaceholder"):o.length>0?h("chat.inputPlaceholderWithMessages"):h("chat.inputPlaceholder",{shortcut:"Shift + Enter"}),disabled:l?.rateLimitRemaining===0,rows:1,cols:30,onInput:S}),Nn("button",{className:"chat-interface__send-button",onClick:y,disabled:!T&&!I,type:"button",children:Nn($o,{size:"1.5em",icon:i?L0:Wn})})]})})})]})};import{randomId as d9}from"@hellixit/common";var Pp=ge(null),Ap=ge(!1),gr=ge(null),mo=ge({id:d9(),messages:[],currentPrompt:""});import{findLastIndex as Xb,randomId as m9}from"@hellixit/common";var fr=(e,o)=>{let{messages:t}=e,n=Xb(t,l=>l.type==="assistant");if(n===-1)return e;let r=t[n],i=t.slice();return i[n]={...r,...o},{...e,messages:i}},br=e=>{let{messages:o}=e,t=Xb(o,n=>n.type==="assistant");return o[t]},Js=(e,o)=>{let t=o.map(n=>({...n,id:m9(),timestamp:new Date}));return{...e,messages:[...e.messages,...t]}},Gk=e=>{let o=Xb(e.messages??[],t=>t.type==="assistant");return o!==-1?{...e,messages:e.messages.filter((t,n)=>n!==o)}:e},Uk=e=>{let o=[];for(let t of e.messages)t.content&&(t.type==="user"||t.type==="assistant")&&o.push({role:t.type,content:t.content});return o};var Qs=()=>{let[e,o]=Q(mo);return{addUserMessage:l=>{o(a=>Js(a,[{type:"user",content:l}]))},addAssistantMessage:()=>{o(l=>Js(l,[{type:"assistant",content:"",isGenerating:!0}]))},setAssistantError:(l,a="other",s)=>{let c=s?JSON.stringify({name:s instanceof Error?s.name:"Error",message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0}):void 0;o(m=>fr(m,{isGenerating:!1,error:l,errorType:a,errorDetails:c}))},chatHistory:e,setChatHistory:o,setLastRetryAttempt:()=>{o(l=>fr(l,{lastAttemptAt:Date.now()}))}}};import{useCallback as ec,useEffect as Wk,useRef as p9}from"react";import{randomId as u9}from"@hellixit/common";var h9=e=>{let o=e.trim();return o.length<=50?o:`${o.substring(0,47)}...`},g9=ge([]),f9=ge(!1),b9=ge(!1),Lp=({persistenceAdapter:e})=>{let[o]=Q(mo),[t,n]=Q(g9),[r,i]=Q(f9),[l,a]=Q(b9),s=p9(t);s.current=t;let c=o?.messages[o?.messages.length-1],m=ec(async()=>{if(!(l||r)){i(!0);try{let g=await e.loadChats();n(g),a(!0)}catch(g){console.warn("Failed to load chats:",g),n([]),a(!0)}finally{i(!1)}}},[l,r,n,i,a,e]);Wk(()=>{m()},[]);let p=ec(async()=>{if(o.messages.length===0)return;let g=o.messages.find(S=>S.type==="user");if(!g||typeof g.content!="string")return;let x=h9(g.content),v=s.current,y=v.find(S=>S.id===o.id),E=!y||y.messages.length!==o.messages.length||y.messages.some((S,M)=>S.id!==o.messages[M]?.id||S.content!==o.messages[M]?.content),T={id:o.id,title:x,messages:o.messages.filter(S=>S.type==="user"||S.type==="assistant").map(S=>({...S,timestamp:S.timestamp instanceof Date?S.timestamp:new Date(S.timestamp)})),currentPrompt:o.currentPrompt,timestamp:E?Date.now():y?.timestamp??Date.now()},I=[...v.filter(S=>S.id!==o.id),T].sort((S,M)=>M.timestamp-S.timestamp).slice(0,10);n(I);try{await e.saveChats(I)}catch(S){console.warn("Failed to save chats:",S)}},[o,n,e]);Wk(()=>{c?.isGenerating||p()},[o.messages?.length,c?.id,c?.isGenerating]);let d=ec(async g=>{let x=s.current.filter(v=>v.id!==g);n(x);try{await e.saveChats(x)}catch(v){console.warn("Failed to save after delete:",v)}return x},[n,e]),u=ec(g=>g,[]),b=ec(async()=>(await p(),u9()),[p]);return{savedChats:t,saveCurrentChat:p,deleteChat:d,restoreChat:u,createNewChatId:b}};import{useCallback as Vk,useEffect as _p,useMemo as Xk,useRef as ci}from"react";var Yk=e=>{let o=e.trim();if(!o)return!1;let t=(o.match(/\[/g)||[]).length,n=(o.match(/\]/g)||[]).length,r=(o.match(/\{/g)||[]).length,i=(o.match(/\}/g)||[]).length,l=(o.match(/\(/g)||[]).length,a=(o.match(/\)/g)||[]).length;if(t!==n||r!==i||l!==a)return!1;let s=o.split(`
31
+ `).pop()?.trim()||"";return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(m=>m.test(s))};var Kb=300,x9=3e3,y9=100,Kk=100,$k=({mermaidToHellixitboardLib:e,canvasRef:o})=>{let[t]=Q(mo),[,n]=Q(gr),[r,i]=Q(Ap),l=ci(!1),a=Xk(()=>br(t),[t]),s=ci(a);_p(()=>{s.current=a},[a]);let c=ci({elements:[],files:null}),m=ci(0),p=ci(null),d=ci(!1),u=ci(Kb),{theme:b}=se(),g=Vk(async y=>{if(!y.trim()||!e.loaded||l.current)return!1;l.current=!0;let E=performance.now(),T=await tl({canvasRef:o,data:c,mermaidToHellixitboardLib:e,setError:n,mermaidDefinition:y,theme:b});return performance.now()-E<y9?u.current=Kb:u.current=x9,l.current=!1,T.success},[o,e,n,b]),x=Xk(()=>{let y=async E=>{let T=Date.now(),I=T-m.current,S=u.current;if(!Yk(E)){d.current||(m.current=Math.max(m.current,T-S+Kk),d.current=!0),p.current=E;return}if(d.current=!1,I<S){p.current=E;return}p.current=null;let M=await g(E);m.current=Date.now(),M||(m.current=m.current-S+Kk,d.current=!0)};return y.flush=async()=>{if(p.current){let E=p.current;p.current=null,await g(E),m.current=Date.now()}},y.cancel=()=>{p.current=null},y},[g]),v=Vk(()=>{m.current=0,p.current=null,d.current=!1,u.current=Kb},[]);return _p(()=>{a?.content&&a?.isGenerating?x(a.content):a?.isGenerating||(x.flush(),v(),a?.content&&x(a.content))},[v,x,a?.isGenerating,a?.content]),_p(()=>{let y=s.current;!y?.content||y.error||r&&g(y.content)},[t?.id,g,r]),_p(()=>{if(t.messages?.filter(y=>y.type==="assistant").length)r||i(!0);else{let y=o.current;if(y){let E=y.parentElement;E&&(E.style.background="",y.replaceChildren())}i(!1)}},[t.messages,i,o,r]),{data:c}};import{useRef as E9}from"react";import{parseMermaidToExcalidraw as v9}from"@hellixit/mermaid-to-hellixitboard";import{isFiniteNumber as Zk}from"@hellixit/math";var $b=3,Zb=1e4,jk=({onTextSubmit:e})=>{let[,o]=Q(gr),[t,n]=Q(Pp),[r,i]=Q(mo),{addUserMessage:l,addAssistantMessage:a,setAssistantError:s}=Qs(),c=E9(null),m=u=>u.length>Zb||u.length<$b||t?.rateLimitRemaining===0?(u.length<$b&&o(new Error(h("chat.errors.promptTooShort",{min:$b}))),u.length>Zb&&o(new Error(h("chat.errors.promptTooLong",{max:Zb}))),!1):!0;return{onGenerate:async({prompt:u,isRepairFlow:b=!1})=>{if(!m(u))return;c.current&&c.current.abort(),o(null);let g=new AbortController;c.current=g,b?i(x=>fr(x,{isGenerating:!0,content:"",error:void 0,errorType:void 0,errorDetails:void 0})):(l(u),a());try{ce("ai","generate","ttd");let v=[...Uk(r).slice(-3),{role:"user",content:u}],{generatedResponse:y,error:E,rateLimit:T,rateLimitRemaining:I}=await e({messages:v,onStreamCreated:()=>{b&&i(S=>fr(S,{content:"",error:"",isGenerating:!0}))},onChunk:S=>{i(M=>{let k=br(M);return fr(M,{content:k.content+S})})},signal:g.signal});if(i(S=>fr(S,{isGenerating:!1})),Zk(T)&&Zk(I)&&n({rateLimit:T,rateLimitRemaining:I}),(E?.status===429||I===0)&&i(S=>(E?.status===429&&(S=Gk(S)),S={...S,messages:S.messages.filter(k=>k.type!=="warning"||k.warningType==="rateLimitExceeded"||k.warningType==="messageLimitExceeded")},Js(S,[{type:"warning",warningType:I===0?"messageLimitExceeded":"rateLimitExceeded"}]))),E){if(E.name==="AbortError"||E.message==="Aborted"||g.signal.aborted)return;let M=new Error(E.message||h("chat.errors.requestFailed"));E.status!==429&&s(M.message,"network"),o(M);return}try{await v9(y??""),ce("ai","mermaid parse success","ttd")}catch(S){ce("ai","mermaid parse failed","ttd");let M=new Error(S.message||h("chat.errors.mermaidParseError"));s(M.message,"parse"),o(M)}}catch(x){let v=new Error(x.message||h("chat.errors.generationFailed"));s(v.message,"other"),o(v)}finally{c.current=null}},handleAbort:()=>{c.current&&c.current.abort()}}};import{useCallback as di,useState as T9}from"react";var qk=({persistenceAdapter:e})=>{let o=zo(gr),[t,n]=Q(mo),[r,i]=T9(!1),{restoreChat:l,deleteChat:a,createNewChatId:s}=Lp({persistenceAdapter:e}),c=di(x=>{let v=x.messages.map(T=>({...T,timestamp:T.timestamp instanceof Date?T.timestamp:new Date(T.timestamp)})),y={id:x.id,messages:v,currentPrompt:""},E=br(y);o(E?.error?new Error(E?.error):null),n(y)},[o,n]),m=di(async()=>{let x=await s();n({id:x,messages:[],currentPrompt:""}),o(null)},[s,n,o]),p=di(x=>{let v=l(x);c(v),i(!1)},[l,c]),d=di(async(x,v)=>{v.stopPropagation();let y=x===t.id,E=await a(x);if(y)if(E.length>0){let T=E[0];c(T)}else await m()},[t.id,a,c,m]),u=di(async()=>{await m(),i(!1)},[m]),b=di(()=>{i(x=>!x)},[]),g=di(()=>{i(!1)},[]);return{isMenuOpen:r,onRestoreChat:p,handleDeleteChat:d,handleNewChat:u,handleMenuToggle:b,handleMenuClose:g}};import I9 from"clsx";import{Fragment as C9,jsx as mi,jsxs as jb}from"react/jsx-runtime";var Jk=({isOpen:e,onToggle:o,onClose:t,onNewChat:n,onRestoreChat:r,onDeleteChat:i,isNewChatBtnVisible:l,savedChats:a,activeSessionId:s,disabled:c})=>jb("div",{className:"ttd-chat-history-menu",children:[l&&mi(sn,{onClick:n,disabled:c,children:h("chat.newChat")}),a.length>0&&mi("div",{className:"ttd-dialog-panel__menu-wrapper",children:jb(ie,{open:e,children:[mi(ie.Trigger,{onToggle:o,className:"ttd-dialog-menu-trigger",disabled:c,title:h("chat.menu"),"aria-label":h("chat.menu"),children:PE}),mi(ie.Content,{onClickOutside:t,onSelect:t,children:mi(C9,{children:a.map(m=>jb(ie.ItemCustom,{className:I9("ttd-chat-menu-item",{"ttd-chat-menu-item--active":m.id===s}),onClick:()=>{r(m)},children:[mi("span",{className:"ttd-chat-menu-item__title",children:m.title}),mi("button",{className:"ttd-chat-menu-item__delete",onClick:p=>i(m.id,p),title:h("chat.deleteChat"),"aria-label":h("chat.deleteChat"),type:"button",children:pt})]},m.id))})})]})})]});import{jsx as nl,jsxs as S9}from"react/jsx-runtime";var Qk=({chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,generatedResponse:l,isMenuOpen:a,onMenuToggle:s,onMenuClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:u,activeSessionId:b,onAbort:g,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:T,onViewAsMermaid:I,renderWelcomeScreen:S,renderWarning:M})=>{let[k]=Q(Pp),P=(()=>{let H=[];return k&&H.push({label:h("chat.rateLimitRemaining",{count:k.rateLimitRemaining}),variant:"rateLimit",className:k.rateLimitRemaining<5?"ttd-dialog-panel__rate-limit--danger":""}),l&&H.push({action:I,label:h("chat.viewAsMermaid"),icon:nl($o,{icon:Wn}),variant:"link"}),H})(),A=()=>P.length===2?"space-between":P.length===1&&P[0].variant==="rateLimit"?"flex-start":"flex-end";return nl(si,{label:S9("div",{className:"ttd-dialog-panel__label-wrapper",children:[nl("div",{className:"ttd-dialog-panel__label-group"}),nl("div",{className:"ttd-dialog-panel__header-right",children:nl(Jk,{isNewChatBtnVisible:!!o.length,isOpen:a,onToggle:s,onClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:u,activeSessionId:b,disabled:i})})]}),className:"ttd-dialog-chat-panel",panelActionJustifyContent:A(),panelActions:P,children:nl(Vb,{chatId:e,messages:o,currentPrompt:t,onPromptChange:n,onGenerate:r,isGenerating:i,generatedResponse:l,onAbort:g,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:T,rateLimits:k,renderWelcomeScreen:S,renderWarning:M})})};import{jsx as eM}from"react/jsx-runtime";var tM=({canvasRef:e,error:o,loaded:t,onInsert:n,hideErrorDetails:r})=>{let i=[{action:n,label:h("chat.insert"),icon:Wn,variant:"button"}];return eM(si,{panelActionJustifyContent:"flex-end",panelActions:i,className:"ttd-dialog-preview-panel",children:eM(wp,{canvasRef:e,error:o,loaded:t,hideErrorDetails:r})})};import{jsx as qb,jsxs as P9}from"react/jsx-runtime";var k9=({mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r})=>{let i=Ae(),l=he(),a=w9(null),[s,c]=Q(gr),[m,p]=Q(mo),d=Ii(Ap),{savedChats:u}=Lp({persistenceAdapter:r}),b=br(m),{setLastRetryAttempt:g}=Qs(),{data:x}=$k({canvasRef:a,mermaidToHellixitboardLib:e}),{onGenerate:v,handleAbort:y}=jk({onTextSubmit:o}),{isMenuOpen:E,onRestoreChat:T,handleDeleteChat:I,handleNewChat:S,handleMenuToggle:M,handleMenuClose:k}=qk({persistenceAdapter:r}),_=()=>{typeof b?.content=="string"&&(ol(b.content),l({openDialog:{name:"ttd",tab:"mermaid"}}))},P=D=>{let B=D.content||"";B&&(ol(B),l({openDialog:{name:"ttd",tab:"mermaid"}}))},A=async D=>{let B=D.content||"";if(!B.trim()||!e.loaded)return;let W={current:{elements:[],files:null}};(await tl({canvasRef:a,data:W,mermaidToHellixitboardLib:e,setError:c,mermaidDefinition:B,theme:i.state.theme})).success&&qs({app:i,data:W,text:B,shouldSaveMermaidDataToStorage:!0})},H=async D=>{let B=D.content||"",W=D.error||"";if(!B)return;let te=`Fix the error in this Mermaid diagram. The diagram is:
32
32
 
33
33
  \`\`\`mermaid
34
34
  ${B}
@@ -36,7 +36,7 @@ ${B}
36
36
 
37
37
  The exception/error is: ${W}
38
38
 
39
- Please fix the Mermaid syntax and regenerate a valid diagram.`;await v({prompt:te,isRepairFlow:!0})},F=async D=>{let B=m.messages.findIndex(W=>W.id===D.id);if(B>0){let W=m.messages[B-1];W.type==="user"&&typeof W.content=="string"&&(g(),await v({prompt:W.content,isRepairFlow:!0}))}},Y=()=>{qs({app:i,data:x})},V=D=>{let B=m.messages.findIndex(te=>te.id===D&&te.type==="assistant"),W=m.messages.slice(0,B-1);p({...m,messages:W})},U=D=>{p(B=>({...B,currentPrompt:D}))};return P9("div",{className:`ttd-dialog-layout ${d?"ttd-dialog-layout--split":"ttd-dialog-layout--chat-only"}`,children:[qb(Qk,{chatId:m.id,messages:m.messages,currentPrompt:m.currentPrompt,onPromptChange:U,onGenerate:v,isGenerating:b?.isGenerating??!1,generatedResponse:b?.content,isMenuOpen:E,onMenuToggle:M,onMenuClose:k,onNewChat:C,onRestoreChat:T,onDeleteChat:I,savedChats:u,activeSessionId:m.id,onAbort:y,onMermaidTabClick:P,onAiRepairClick:H,onDeleteMessage:V,onInsertMessage:A,onRetry:F,onViewAsMermaid:_,renderWarning:n,renderWelcomeScreen:t}),d&&qb(tM,{canvasRef:a,hideErrorDetails:b?.errorType==="parse",error:s,loaded:e.loaded,onInsert:Y})]})},M9=({mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r})=>qb(k9,{mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r}),oM=M9;import{Tabs as A9}from"radix-ui";import{useRef as nM}from"react";import{isMemberOf as L9}from"@excalidraw/common";import{jsx as _9}from"react/jsx-runtime";var rM=e=>{let o=he(),t=nM(null),n=nM(0);return _9(A9.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let l=i.offsetHeight||0;l>n.current&&(n.current=l,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&L9(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};rM.displayName="TTDDialogTabs";var iM=rM;import{Tabs as D9}from"radix-ui";import{jsx as H9}from"react/jsx-runtime";var Jb=({children:e,...o})=>H9(D9.List,{className:"ttd-dialog-triggers",...o,children:e});Jb.displayName="TTDDialogTabTriggers";import{Tabs as R9}from"radix-ui";import{jsx as aM}from"react/jsx-runtime";var Dp=({children:e,tab:o,onSelect:t,...n})=>aM(R9.Trigger,{value:o,asChild:!0,onSelect:t,children:aM("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});Dp.displayName="TTDDialogTabTrigger";import{Tabs as N9}from"radix-ui";import{jsx as B9}from"react/jsx-runtime";var Hp=({tab:e,children:o,...t})=>B9(N9.Content,{...t,value:e,children:o});Hp.displayName="TTDDialogTab";import{jsx as dn,jsxs as Qb}from"react/jsx-runtime";var Rp=e=>{let o=se();return o.openDialog?.name!=="ttd"?null:dn(z9,{...e,tab:o.openDialog.tab})};Rp.WelcomeMessage=Mp;var z9=Rn("TTDDialogBase",({tab:e,...o})=>{let t=Ae(),[n,r]=O9({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw").then(i=>({parseMermaidToHellixitboard:i.parseMermaidToExcalidraw}))});return F9(()=>{(async()=>{await n.api,r(l=>({...l,loaded:!0}))})()},[n.api]),dn(je,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1520,title:!1,...o,autofocus:!1,children:Qb(iM,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?dn("p",{className:"dialog-mermaid-title",children:h("mermaid.title")}):Qb(Jb,{children:[dn(Dp,{tab:"text-to-diagram",children:Qb("div",{className:"ttd-dialog-tab-trigger__content",children:[h("labels.textToDiagram"),dn("div",{className:"ttd-dialog-tab-trigger__badge",children:h("chat.aiBeta")})]})}),dn(Dp,{tab:"mermaid",children:h("mermaid.label")})]}),!("__fallback"in o)&&dn(Hp,{className:"ttd-dialog-content",tab:"text-to-diagram",children:dn(oM,{mermaidToHellixitboardLib:n,onTextSubmit:o.onTextSubmit,renderWelcomeScreen:o.renderWelcomeScreen,renderWarning:o.renderWarning,persistenceAdapter:o.persistenceAdapter})}),dn(Hp,{className:"ttd-dialog-content",tab:"mermaid",children:dn(Ok,{mermaidToHellixitboardLib:n,isActive:e==="mermaid"})})]})})});import{round as KM}from"@excalidraw/math";import eW from"clsx";import tW from"lodash.throttle";import{useEffect as $M,useMemo as ux,useState as oW,memo as nW}from"react";import{STATS_PANELS as Up}from"@excalidraw/common";import{getCommonBounds as rW}from"@excalidraw/element";import{getUncroppedWidthAndHeight as iW}from"@excalidraw/element";import{isImageElement as hx}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as aW}from"@excalidraw/element";import{elementsAreInSameGroup as lW}from"@excalidraw/element";import{degreesToRadians as hM,radiansToDegrees as xM}from"@excalidraw/math";import{getBoundTextElement as gM}from"@excalidraw/element";import{isArrowElement as fM,isElbowArrow as Q9}from"@excalidraw/element";import{updateBindings as bM}from"@excalidraw/element";import K9 from"clsx";import{useEffect as pM,useRef as Bp,useState as $9}from"react";import{EVENT as al,KEYS as Z9,cloneJSON as ex}from"@excalidraw/common";import{deepCopyElement as j9}from"@excalidraw/element";import{CaptureUpdateAction as uM}from"@excalidraw/element";import{pointFrom as xr,pointRotateRads as Np}from"@excalidraw/math";import{getBoundTextElement as G9,isBindingElement as U9,unbindBindingElement as lM}from"@excalidraw/element";import{isFrameLikeElement as dM}from"@excalidraw/element";import{getSelectedGroupIds as W9,getElementsInGroup as Y9,isInGroup as V9}from"@excalidraw/element";import{getFrameChildren as X9}from"@excalidraw/element";import{updateBindings as sM}from"@excalidraw/element";import{DRAGGING_THRESHOLD as cM}from"@excalidraw/common";var mM=.01,tc=10,zt=(e,o)=>!(o==="angle"&&dM(e)),Oe=(e,o)=>{let t=e+o/2;return t-t%o},rl=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var pi=(e,o,t,n,r,i,l=!0)=>{if(U9(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<cM&&Math.abs(o-t.y)<cM)return;lM(t,"start",n),lM(t,"end",n)}let a=n.getNonDeletedElementsMap(),s=a.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Np(xr(t.x,t.y),xr(c,m),t.angle),u=e-p,b=o-d,[g,x]=Np(xr(e,o),xr(c+u,m+b),-t.angle);n.mutateElement(s,{x:g,y:x},{informMutation:l,isDragging:!1}),sM(s,n,r);let v=G9(t,i);if(v){let y=a.get(v.id);y&&n.mutateElement(y,{x:v.x+u,y:v.y+b},{informMutation:l,isDragging:!1})}if(dM(t)){let y=X9(i,t.id);y.forEach(E=>{let T=a.get(E.id);if(!T)return;let[I,C]=[E.x+E.width/2,E.y+E.height/2],[M,k]=Np(xr(E.x,E.y),xr(I,C),E.angle),_=Math.round(M+u),P=Math.round(k+b),[A,H]=Np(xr(_,P),xr(I+u,C+b),-E.angle);n.mutateElement(T,{x:A,y:H},{informMutation:l,isDragging:!1}),sM(T,n,r,{simultaneouslyUpdated:y})})}},il=(e,o)=>{let n=W9(o).map(r=>Y9(e,r).reduce((i,l)=>(i[l.id]=!0,i),{}));return e.filter(r=>!V9(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as tx,jsxs as J9}from"react/jsx-runtime";var q9=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:l,property:a,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=Ae(),u=he(),b=Bp(null),g=Bp(null),[x,v]=$9(n.toString()),y=Bp(null);y.current||(y.current={originalAppState:ex(c),originalElements:r,lastUpdatedValue:x,updatePending:!1}),pM(()=>{let I=n.toString();v(I),y.current.lastUpdatedValue=I},[n]);let E=(I,C,M)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let k=Number(I);if(isNaN(k)){v(n.toString());return}let _=Number(k.toFixed(2)),P=Number(n);(isNaN(P)||Math.abs(_-P)>=mM)&&(y.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:l,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:a,originalAppState:M,setInputValue:A=>v(String(A)),app:d,setAppState:u}),d.syncActionResult({captureUpdate:uM.IMMEDIATELY}))},T=Bp({});return T.current.handleInputValue=E,pM(()=>{let I=b.current,C=T.current;return()=>{let M=I?.value;M&&C.handleInputValue?.(M,y.current.originalElements,y.current.originalAppState),window.removeEventListener(al.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(al.POINTER_UP,C.onPointerUp,!1)}},[i]),i?J9("div",{className:K9("drag-input-container",!i&&"disabled"),"data-testid":e,children:[tx("div",{className:"drag-input-label",ref:g,onPointerDown:I=>{if(b.current&&i){document.body.classList.add("hellixitboard-cursor-resize");let C=Number(b.current.value);isNaN(C)&&(C=0);let M=null,k=d.scene.getNonDeletedElements().reduce((V,U)=>(V.set(U.id,j9(U)),V),new Map),_=r.map(V=>k.get(V.id)),P=ex(c),A=0,H=0,F=V=>{if(M&&k!==null&&_!==null){let U=V.clientX-M.x;U!==0&&(H+=U,Math.abs(H)>=m&&(H=Math.sign(H)*Math.floor(Math.abs(H)/m),A+=H,t({accumulatedChange:A,instantChange:H,originalElements:_,originalElementsMap:k,shouldKeepAspectRatio:l,shouldChangeByStepSize:V.shiftKey,property:a,scene:s,originalAppState:P,setInputValue:D=>v(String(D)),app:d,setAppState:u}),H=0))}M={x:V.clientX,y:V.clientY}},Y=()=>{window.removeEventListener(al.POINTER_MOVE,F,!1),d.syncActionResult({captureUpdate:uM.IMMEDIATELY}),p?.({app:d,setAppState:u,originalElements:_,originalAppState:P}),M=null,A=0,H=0,_=null,k=null,document.body.classList.remove("hellixitboard-cursor-resize"),window.removeEventListener(al.POINTER_UP,Y,!1)};T.current.onPointerMove=F,T.current.onPointerUp=Y,window.addEventListener(al.POINTER_MOVE,F,!1),window.addEventListener(al.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:o?tx($o,{icon:o}):e}),tx("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===Z9.ENTER&&(E(C.value,r,c),d.focusContainer())}},ref:b,value:x,onChange:I=>{y.current.updatePending=!0,v(I.target.value)},onFocus:I=>{I.target.select(),y.current.originalElements=r,y.current.originalAppState=ex(c)},onBlur:I=>{x?i&&E(I.target.value,y.current.originalElements,y.current.originalAppState):v(n.toString())},disabled:!i})]}):null},dt=q9;import{jsx as nU}from"react/jsx-runtime";var eU=15,tU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let l=r.getNonDeletedElementsMap(),a=o[0];if(a&&!Q9(a)){let s=l.get(a.id);if(!s)return;if(n!==void 0){let b=hM(n);r.mutateElement(s,{angle:b}),bM(s,r,i.state);let g=gM(s,l);g&&!fM(s)&&r.mutateElement(g,{angle:b});return}let c=Math.round(xM(a.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=Oe(p,eU)),p=p<0?p+360:p;let d=hM(p);r.mutateElement(s,{angle:d}),bM(s,r,i.state);let u=gM(s,l);u&&!fM(s)&&r.mutateElement(u,{angle:d})}},oU=({element:e,scene:o,appState:t,property:n})=>nU(dt,{label:"A",icon:Xc,value:Math.round(xM(e.angle)%360*100)/100,elements:[e],dragInputCallback:tU,editable:zt(e,"angle"),scene:o,appState:t,property:n}),yM=oU;import{jsx as iU}from"react/jsx-runtime";var EM=5,rU=({property:e,scene:o,appState:t,setAppState:n})=>iU(dt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:l,setInputValue:a})=>{n(s=>{let c;return r?c=r:i&&(c=l?Oe(s.gridStep+EM*Math.sign(i),EM):s.gridStep+i),c?(c=Dy(c),a(c),{gridStep:c}):(a(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),vM=rU;import{clamp as Fp,round as ox}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Op}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as TM,getUncroppedWidthAndHeight as CM}from"@excalidraw/element";import{resizeSingleElement as IM}from"@excalidraw/element";import{isImageElement as SM}from"@excalidraw/element";import{isFrameLikeElement as nx}from"@excalidraw/element";import{getElementsInResizingFrame as rx}from"@excalidraw/element";import{replaceAllElementsInFrame as kM}from"@excalidraw/element";import{jsx as dU}from"react/jsx-runtime";var wM=10,aU=e=>e.type==="image",lU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:l,originalAppState:a,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),u=o[0],b=d.get(u.id);if(u&&b){let g=n||aU(u),x=u.width/u.height;if(a.croppingElementId===u.id){let v=d.get(u.id);if(!v||!SM(v)||!v.crop)return;let y=v.crop,E={...y},T=v.scale[0]===-1,I=v.scale[1]===-1,{width:C,height:M}=CM(v),k=y.naturalWidth/C,_=y.naturalHeight/M,P=T?y.width+y.x:y.naturalWidth-y.x,A=I?y.height+y.y:y.naturalHeight-y.y,H=TM*k,F=TM*_;if(i!==void 0){if(l==="width"){let B=i*k,W=Fp(B,H,P);E={...E,width:W,x:T?y.x+y.width-W:y.x}}else if(l==="height"){let B=i*_,W=Fp(B,F,A);E={...E,height:W,y:I?y.y+y.height-W:y.y}}c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/C),height:E.height/(y.naturalHeight/M)});return}let Y=l==="width"?s:0,V=l==="height"?s:0,U=Fp(y.width+Y,H,P),D=Fp(y.height+V,H,A);E={...y,x:T?y.x+y.width-U:y.x,y:I?y.y+y.height-D:y.y,width:U,height:D},c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/C),height:E.height/(y.naturalHeight/M)});return}if(i!==void 0){let v=Math.max(l==="width"?i:g?i*x:u.width,Op),y=Math.max(l==="height"?i:g?i/x:u.height,Op);if(IM(v,y,b,u,t,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:g}),nx(b)){let E=rx(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap()),T=kM(c.getElementsIncludingDeleted(),E,b,m);c.replaceAllElements(T)}return}{let v=l==="width"?e:0,y=l==="height"?e:0,E=Math.max(0,u.width+v);l==="width"&&(r?E=Oe(E,wM):E=Math.round(E));let T=Math.max(0,u.height+y);if(l==="height"&&(r?T=Oe(T,wM):T=Math.round(T)),g&&(l==="width"?T=Math.round(E/x*100)/100:E=Math.round(T*x*100)/100),T=Math.max(Op,T),E=Math.max(Op,E),IM(E,T,b,u,t,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:g}),nx(b)){let I=rx(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},sU=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],l=i&&r.get(i.id);if(l&&nx(l)){let a=rx(o.scene.getElementsIncludingDeleted(),l,n,o.scene.getNonDeletedElementsMap()),s=kM(o.scene.getElementsIncludingDeleted(),a,l,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},cU=({property:e,element:o,scene:t,appState:n})=>{let r=ox(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&SM(o)&&o.crop){let{width:i,height:l}=CM(o);if(e==="width"){let a=i/o.crop.naturalWidth;r=ox(o.crop.width*a,2)}if(e==="height"){let a=l/o.crop.naturalHeight;r=ox(o.crop.height*a,2)}}return dU(dt,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:lU,value:r,editable:zt(o,e),scene:t,appState:n,property:e,dragFinishedCallback:sU})},ix=cU;import{getBoundTextElement as mU,redrawTextBoundingBox as pU}from"@excalidraw/element";import{hasBoundTextElement as uU,isTextElement as PM}from"@excalidraw/element";import{jsx as bU}from"react/jsx-runtime";var MM=4,hU=4,gU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),l=o[0];if(l){let a=i.get(l.id);if(!a||!PM(a))return;let s;if(n!==void 0)s=Math.max(Math.round(n),MM);else if(l.type==="text"){let c=Math.round(l.fontSize),m=Math.round(e);s=Math.max(c+m,MM),t&&(s=Oe(s,hU))}s&&(r.mutateElement(a,{fontSize:s}),pU(a,r.getContainerElement(a),r))}},fU=({element:e,scene:o,appState:t,property:n})=>{let r=PM(e)?e:uU(e)?mU(e,o.getNonDeletedElementsMap()):null;return r?bU(dt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:gU,icon:Br,appState:t,scene:o,property:n}):null},AM=fU;import{degreesToRadians as LM,radiansToDegrees as HM}from"@excalidraw/math";import{getBoundTextElement as _M}from"@excalidraw/element";import{isArrowElement as DM}from"@excalidraw/element";import{isInGroup as ax}from"@excalidraw/element";import{jsx as vU}from"react/jsx-runtime";var xU=15,yU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let l=i.getNonDeletedElementsMap(),a=o.map(c=>l.get(c.id)).filter(c=>c&&!ax(c)&&zt(c,r)),s=o.filter(c=>!ax(c)&&zt(c,r));if(n!==void 0){let c=LM(n);for(let m of a){if(!m)continue;i.mutateElement(m,{angle:c});let p=_M(m,l);p&&!DM(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<a.length;c++){let m=a[c];if(!m)continue;let p=s[c],d=Math.round(HM(p.angle)*100)/100,u=Math.round(e),b=(d+u)%360;t&&(b=Oe(b,xU)),b=b<0?b+360:b;let g=LM(b);i.mutateElement(m,{angle:g});let x=_M(m,l);x&&!DM(m)&&i.mutateElement(x,{angle:g})}i.triggerUpdate()},EU=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!ax(s)&&zt(s,"angle")),i=r.map(s=>Math.round(HM(s.angle)%360*100)/100),l=new Set(i).size===1?i[0]:"Mixed",a=r.some(s=>zt(s,"angle"));return vU(dt,{label:"A",icon:Xc,value:l,elements:e,dragInputCallback:yU,editable:a,appState:t,scene:o,property:n})},RM=EU;import{pointFrom as NM}from"@excalidraw/math";import{useMemo as TU}from"react";import{MIN_WIDTH_OR_HEIGHT as yr}from"@excalidraw/common";import{getElementsInResizingFrame as lx,isFrameLikeElement as sx,replaceAllElementsInFrame as OM,updateBoundElements as IU}from"@excalidraw/element";import{rescalePointsInElement as wU,resizeSingleElement as BM}from"@excalidraw/element";import{getBoundTextElement as CU,handleBindTextResize as SU}from"@excalidraw/element";import{isTextElement as zM}from"@excalidraw/element";import{jsx as _U}from"react/jsx-runtime";var ll=10,kU=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,l=n.width*t,a=n.height*t,s=e+r*t,c=o+i*t;return{width:l,height:a,x:s,y:c,...wU(n,l,a,!1),...zM(n)?{fontSize:n.fontSize*t}:{}}},MU=(e,o,t,n,r,i,l,a)=>{let s=a.getNonDeletedElementsMap(),c=kU(e,o,n,i);a.mutateElement(r,c);let m=CU(i,l);if(m){let p=m.fontSize*n;IU(r,a);let d=s.get(m.id);d&&zM(d)&&(a.mutateElement(d,{fontSize:p}),SU(r,a,t==="width"?"e":"s",!0))}},FM=(e,o,t,n,r,i,l,a,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<a.length;p++){let d=a[p],u=l[p];MU(r[0],r[1],i,m,u,d,s,c)}},PU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:l,property:a,setAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=il(o,n);if(i!==void 0){for(let g of p){let x=rl(g,m,t);if(x.length>1){let v=x.map(H=>H.latest),y=x.map(H=>H.original),[E,T,I,C]=kp(y),M=I-E,k=C-T,_=M/k,P=Math.max(yr,a==="width"?Math.max(0,i):M),A=Math.max(yr,a==="height"?Math.max(0,i):k);FM(P,A,k,_,NM(E,T),a,v,y,t,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&zt(y,a)){let T=a==="width"?Math.max(0,i):y.width;a==="width"&&(r?T=Oe(T,ll):T=Math.round(T));let I=a==="height"?Math.max(0,i):y.height;if(a==="height"&&(r?I=Oe(I,ll):I=Math.round(I)),T=Math.max(yr,T),I=Math.max(yr,I),BM(T,I,y,E,t,l,a==="width"?"e":"s",{shouldInformMutation:!1}),sx(y)){let C=lx(l.getElementsIncludingDeleted(),y,n,l.getNonDeletedElementsMap()),M=OM(l.getElementsIncludingDeleted(),C,y,c);l.replaceAllElements(M)}}}}l.triggerUpdate();return}let d=a==="width"?e:0,u=a==="height"?e:0,b=[];for(let g of p){let x=rl(g,m,t);if(x.length>1){let v=x.map(H=>H.latest),y=x.map(H=>H.original),[E,T,I,C]=kp(y),M=I-E,k=C-T,_=M/k,P=Math.max(0,M+d);a==="width"&&(r?P=Oe(P,ll):P=Math.round(P));let A=Math.max(0,k+u);a==="height"&&(r?A=Oe(A,ll):A=Math.round(A)),P=Math.max(yr,P),A=Math.max(yr,A),FM(P,A,k,_,NM(E,T),a,v,y,t,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&zt(y,a)){let T=Math.max(0,E.width+d);a==="width"&&(r?T=Oe(T,ll):T=Math.round(T));let I=Math.max(0,E.height+u);if(a==="height"&&(r?I=Oe(I,ll):I=Math.round(I)),T=Math.max(yr,T),I=Math.max(yr,I),BM(T,I,y,E,t,l,a==="width"?"e":"s",{shouldInformMutation:!1}),sx(y)){let C=lx(l.getElementsIncludingDeleted(),y,n,l.getNonDeletedElementsMap());b.push(...C)}}}}s({elementsToHighlight:b}),l.triggerUpdate()},AU=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],l=i&&r.get(i.id);if(l&&sx(l)){let a=lx(o.scene.getElementsIncludingDeleted(),l,n,o.scene.getNonDeletedElementsMap()),s=OM(o.scene.getElementsIncludingDeleted(),a,l,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},LU=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let l=TU(()=>n.map(c=>{let m=rl(c,t);if(m.length>1){let[d,u,b,g]=kp(m.map(x=>x.latest));return Math.round((e==="width"?b-d:g-u)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,n,e]),a=new Set(l).size===1?Math.round(l[0]*100)/100:"Mixed",s=l.length>0;return _U(dt,{label:e==="width"?"W":"H",elements:o,dragInputCallback:PU,value:a,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:AU})},cx=LU;import{getBoundTextElement as DU,redrawTextBoundingBox as GM}from"@excalidraw/element";import{hasBoundTextElement as HU,isTextElement as RU}from"@excalidraw/element";import{isInGroup as NU}from"@excalidraw/element";import{jsx as GU}from"react/jsx-runtime";var UM=4,BU=4,FU=(e,o)=>e.reduce((t,n)=>{if(!n||NU(n))return t;if(RU(n))return t.push(n),t;if(HU(n)){let r=DU(n,o);if(r)return t.push(r),t}return t},[]),OU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),l=o.map(s=>i.get(s.id)),a;if(n){a=Math.max(Math.round(n),UM);for(let s of l)r.mutateElement(s,{fontSize:a}),GM(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<l.length;c++){let m=l[c],p=s[c],d=Math.round(p.fontSize),u=Math.round(e),b=Math.max(d+u,UM);t&&(b=Oe(b,BU)),r.mutateElement(m,{fontSize:b}),GM(m,r.getContainerElement(m),r)}r.triggerUpdate()}},zU=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=FU(e,r);if(!i.length)return null;let l=i.map(c=>Math.round(c.fontSize*10)/10),a=new Set(l).size===1?l[0]:"Mixed",s=l.length>0;return GU(dt,{label:"F",icon:Br,elements:i,dragInputCallback:OU,value:a,editable:s,scene:o,property:n,appState:t})},WM=zU;import{pointFrom as Er,pointRotateRads as zp}from"@excalidraw/math";import{useMemo as UU}from"react";import{isTextElement as WU}from"@excalidraw/element";import{getCommonBounds as dx}from"@excalidraw/element";import{jsx as $U}from"react/jsx-runtime";var YU=(e,o,t,n,r,i,l)=>{for(let a=0;a<n.length;a++){let s=n[a],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=zp(Er(s.x,s.y),Er(c,m),s.angle),u=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(d+t):d;pi(u,b,s,i,l,r,!1)}},VU=(e,o,t,n,r,i)=>{let l=r.getNonDeletedElementsMap(),[a,s,,]=dx(t),c=e-a,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],u=l.get(d.id);if(u&&(!WU(u)||!u.containerId)){let[b,g]=[u.x+u.width/2,u.y+u.height/2],[x,v]=zp(Er(u.x,u.y),Er(b,g),u.angle);pi(x+c,v+m,d,r,i,n,!1)}}},XU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:l,originalAppState:a,app:s})=>{let c=l.getNonDeletedElementsMap();if(r!==void 0){for(let u of il(o,a)){let b=rl(u,c,t);if(b.length>1){let[g,x,,]=dx(b.map(E=>E.latest));VU(i==="x"?r:g,i==="y"?r:x,b.map(E=>E.original),t,l,s.state)}else{let g=b[0]?.original,x=b[0]?.latest;if(g&&x&&zt(x,i)){let[v,y]=[g.x+g.width/2,g.y+g.height/2],[E,T]=zp(Er(g.x,g.y),Er(v,y),g.angle);pi(i==="x"?r:E,i==="y"?r:T,g,l,s.state,t,!1)}}}l.triggerUpdate();return}let m=n?Oe(e,tc):e;YU(i,i==="x"?m:0,i==="y"?m:0,o,t,l,s.state),l.triggerUpdate()},KU=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let l=UU(()=>n.map(s=>{let c=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,x]=dx(c);return Math.round((e==="x"?g:x)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[u,b]=zp(Er(m.x,m.y),Er(p,d),m.angle);return Math.round((e==="x"?u:b)*100)/100}),[n,t,e]),a=new Set(l).size===1?l[0]:"Mixed";return $U(dt,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:XU,value:a,property:e,scene:r,appState:i})},mx=KU;import{clamp as oc,pointFrom as Gp,pointRotateRads as VM,round as YM}from"@excalidraw/math";import{getFlipAdjustedCropPosition as ZU,getUncroppedWidthAndHeight as jU}from"@excalidraw/element";import{isImageElement as XM}from"@excalidraw/element";import{jsx as QU}from"react/jsx-runtime";var qU=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:l,scene:a,originalAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=t[0],[d,u]=[p.x+p.width/2,p.y+p.height/2],[b,g]=VM(Gp(p.x,p.y),Gp(d,u),p.angle);if(s.croppingElementId===p.id){let T=m.get(p.id);if(!T||!XM(T)||!T.crop)return;let I=T.crop,C=I,M=T.scale[0]===-1,k=T.scale[1]===-1,{width:_,height:P}=jU(T);if(i!==void 0){if(l==="x"){let F=i*(I.naturalWidth/_);M?C={...I,x:oc(I.naturalWidth-F-I.width,0,I.naturalWidth-I.width)}:C={...I,x:oc(i*(I.naturalWidth/_),0,I.naturalWidth-I.width)}}l==="y"&&(C={...I,y:oc(i*(I.naturalHeight/P),0,I.naturalHeight-I.height)}),a.mutateElement(T,{crop:C});return}let A=(l==="x"?o:0)*(M?-1:1),H=(l==="y"?o:0)*(k?-1:1);C={...I,x:oc(I.x+A,0,I.naturalWidth-I.width),y:oc(I.y+H,0,I.naturalHeight-I.height)},a.mutateElement(T,{crop:C});return}if(i!==void 0){pi(l==="x"?i:b,l==="y"?i:g,p,a,c.state,n);return}let x=l==="x"?e:0,v=l==="y"?e:0,y=l==="x"?Math.round(r?Oe(p.x+x,tc):b+x):b,E=l==="y"?Math.round(r?Oe(p.y+v,tc):g+v):g;pi(y,E,p,a,c.state,n)},JU=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,l]=VM(Gp(o.x,o.y),Gp(o.x+o.width/2,o.y+o.height/2),o.angle),a=YM(e==="x"?i:l,2);if(r.croppingElementId===o.id&&XM(o)&&o.crop){let s=ZU(o);s&&(a=YM(e==="x"?s.x:s.y,2))}return QU(dt,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:qU,scene:n,value:a,property:e,appState:r})},px=JU;import{Fragment as gx,jsx as ne,jsxs as Gt}from"react/jsx-runtime";var sW=50,nc=e=>{let o=Xo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=cr(e.app);return ne(cW,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Re=({children:e,columns:o=1,heading:t,style:n,...r})=>ne("div",{className:eW("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Re.displayName="StatsRow";var Wp=({children:e,order:o,style:t,...n})=>ne("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});Wp.displayName="StatsRows";nc.StatsRow=Re;nc.StatsRows=Wp;var cW=nW(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:l})=>{let a=e.scene,s=a.getNonDeletedElements(),c=a.getNonDeletedElementsMap(),m=he(),p=n.length===1?n[0]:null,d=n.length>1?n:null,u=r.croppingElementId&&hx(p),b=u?iW(p):null,[g,x]=oW({width:0,height:0}),v=ux(()=>tW(T=>{let I=rW(T);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},sW),[]);$M(()=>{v(s)},[i,s,v]),$M(()=>()=>v.cancel(),[v]);let y=ux(()=>il(n,r),[n,r]),E=ux(()=>aW(n),[n]);return ne("div",{className:"exc-stats",children:Gt(Xe,{padding:3,children:[Gt("div",{className:"title",children:[ne("h2",{children:h("stats.title")}),ne("div",{className:"close",onClick:o,children:Qt})]}),Gt(Jl,{label:ne("h3",{children:h("stats.generalStats")}),open:!!(r.stats.panels&Up.generalStats),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Up.generalStats}})),children:[Gt(Wp,{children:[ne(Re,{heading:!0,children:h("stats.scene")}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.shapes")}),ne("div",{children:s.length})]}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.width")}),ne("div",{children:g.width})]}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.height")}),ne("div",{children:g.height})]}),l&&Gt(gx,{children:[ne(Re,{heading:!0,children:"Canvas"}),ne(Re,{children:ne(vM,{property:"gridStep",scene:a,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!E&&n.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Jl,{label:ne("h3",{children:h("stats.elementProperties")}),open:!!(r.stats.panels&Up.elementProperties),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Up.elementProperties}})),children:Gt(Wp,{children:[p&&Gt(gx,{children:[u&&ne(Re,{heading:!0,children:h("labels.unCroppedDimension")}),r.croppingElementId&&hx(p)&&b&&Gt(Re,{columns:2,children:[ne("div",{children:h("stats.width")}),ne("div",{children:KM(b.width,2)})]}),r.croppingElementId&&hx(p)&&b&&Gt(Re,{columns:2,children:[ne("div",{children:h("stats.height")}),ne("div",{children:KM(b.height,2)})]}),ne(Re,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?h("labels.imageCropping"):h(`element.${p.type}`)}),ne(Re,{children:ne(px,{element:p,property:"x",elementsMap:c,scene:a,appState:r})}),ne(Re,{children:ne(px,{element:p,property:"y",elementsMap:c,scene:a,appState:r})}),ne(Re,{children:ne(ix,{property:"width",element:p,scene:a,appState:r})}),ne(Re,{children:ne(ix,{property:"height",element:p,scene:a,appState:r})}),ne(Re,{children:ne(yM,{property:"angle",element:p,scene:a,appState:r})}),ne(Re,{children:ne(AM,{property:"fontSize",element:p,scene:a,appState:r})})]}),d&&Gt(gx,{children:[lW(d)&&ne(Re,{heading:!0,children:h("element.group")}),Gt(Re,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:h("stats.shapes")}),ne("div",{children:n.length})]}),ne(Re,{children:ne(mx,{property:"x",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(mx,{property:"y",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(cx,{property:"width",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(cx,{property:"height",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(RM,{property:"angle",elements:d,scene:a,appState:r})}),ne(Re,{children:ne(WM,{property:"fontSize",elements:d,scene:a,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as dW,useEffect as ZM,useState as jM}from"react";import{normalizeLink as mW,KEYS as fx}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as pW,getLinkIdAndTypeFromSelection as uW}from"@excalidraw/element";import{jsx as sl,jsxs as Yp}from"react/jsx-runtime";var hW=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=pW})=>{let i=n.getNonDeletedElementsMap(),l=i.get(e)?.link??null,[a,s]=jM(l),[c,m]=jM(!1);ZM(()=>{let d=oe(i,t),u=l;if(d.length>0&&r){let b=uW(d,t);b&&(u=mW(r(b.id,b.type)))}s(u)},[i,t,t.selectedElementIds,l,r]);let p=dW(()=>{if(a&&a!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:a})}if(!a&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,a,i,c,n,o]);return ZM(()=>{let d=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===fx.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===fx.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),Yp("div",{className:"ElementLinkDialog",children:[Yp("div",{className:"ElementLinkDialog__header",children:[sl("h2",{children:h("elementLink.title")}),sl("p",{children:h("elementLink.desc")})]}),Yp("div",{className:"ElementLinkDialog__input",children:[sl(ar,{value:a??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===fx.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),l&&a&&sl(J,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:pt})]}),Yp("div",{className:"ElementLinkDialog__actions",children:[sl(kn,{label:h("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),sl(kn,{label:h("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},qM=hW;import gW,{useState as fW}from"react";import{Fragment as bW,jsx as bx}from"react/jsx-runtime";var JM=({children:e,onClose:o})=>{let[t,n]=fW(!!e),{container:r}=_e(),i=gW.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return bx(bW,{children:t&&bx(je,{size:"small",onCloseRequest:i,title:h("errorDialog.title"),children:bx("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import xW from"react";import{isDarwin as QM,isFirefox as eP,isWindows as yW}from"@excalidraw/common";import{KEYS as Ye}from"@excalidraw/common";import{Fragment as oP,jsx as G,jsxs as Ut}from"react/jsx-runtime";var EW=({onReportIssue:e})=>Ut("div",{className:"HelpDialog__header",children:[Ut("a",{className:"HelpDialog__btn",href:"#",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),h("helpDialog.documentation")]}),Ut("a",{className:"HelpDialog__btn",href:"#",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),h("helpDialog.blog")]}),Ut("a",{className:"HelpDialog__btn",href:"https://www.hellixit.cloud",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),"Website"]}),e&&Ut("button",{className:"HelpDialog__btn",onClick:e,style:{cursor:"pointer"},type:"button",children:[G("div",{className:"HelpDialog__link-icon",children:Ut("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[G("circle",{cx:"12",cy:"12",r:"10"}),G("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),G("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),"Found an issue? Submit"]})]}),vW=e=>Ut(oP,{children:[G("h3",{children:e.title}),G("div",{className:"HelpDialog__islands-container",children:e.children})]}),Vp=e=>Ut("div",{className:`HelpDialog__island ${e.className}`,children:[G("h4",{className:"HelpDialog__island-title",children:e.caption}),G("div",{className:"HelpDialog__island-content",children:e.children})]});function*TW(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var IW=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(l=>G(wW,{children:IW(l)},l)));return Ut("div",{className:"HelpDialog__shortcut",children:[G("div",{children:e}),G("div",{className:"HelpDialog__key-container",children:[...TW(n,t?h("helpDialog.or"):null)]})]})},wW=e=>G("kbd",{className:"HelpDialog__key",...e}),tP=({onClose:e,onReportIssue:o})=>{let t=xW.useCallback(()=>{e&&e()},[e]);return G(oP,{children:Ut(je,{onCloseRequest:t,title:h("helpDialog.title"),className:"HelpDialog",children:[G(EW,{onReportIssue:o}),Ut(vW,{title:h("helpDialog.shortcuts"),children:[Ut(Vp,{className:"HelpDialog__island--tools",caption:h("helpDialog.tools"),children:[G($,{label:h("toolBar.hand"),shortcuts:[Ye.H]}),G($,{label:h("toolBar.selection"),shortcuts:[Ye.V,Ye[1]]}),G($,{label:h("toolBar.rectangle"),shortcuts:[Ye.R,Ye[2]]}),G($,{label:h("toolBar.diamond"),shortcuts:[Ye.D,Ye[3]]}),G($,{label:h("toolBar.ellipse"),shortcuts:[Ye.O,Ye[4]]}),G($,{label:h("toolBar.arrow"),shortcuts:[Ye.A,Ye[5]]}),G($,{label:h("toolBar.line"),shortcuts:[Ye.L,Ye[6]]}),G($,{label:h("toolBar.freedraw"),shortcuts:[Ye.P,Ye[7]]}),G($,{label:h("toolBar.text"),shortcuts:[Ye.T,Ye[8]]}),G($,{label:h("toolBar.image"),shortcuts:[Ye[9]]}),G($,{label:h("toolBar.eraser"),shortcuts:[Ye.E,Ye[0]]}),G($,{label:h("toolBar.frame"),shortcuts:[Ye.F]}),G($,{label:h("toolBar.laser"),shortcuts:[Ye.K]}),G($,{label:h("labels.eyeDropper"),shortcuts:[Ye.I,"Shift+S","Shift+G"]}),G($,{label:h("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),G($,{label:h("helpDialog.editText"),shortcuts:[N("Enter")]}),G($,{label:h("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),G($,{label:h("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),G($,{label:h("helpDialog.curvedArrow"),shortcuts:["A",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),G($,{label:h("helpDialog.curvedLine"),shortcuts:["L",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),G($,{label:h("helpDialog.cropStart"),shortcuts:[h("helpDialog.doubleClick"),N("Enter")],isOr:!0}),G($,{label:h("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),G($,{label:h("toolBar.lock"),shortcuts:[Ye.Q]}),G($,{label:h("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),G($,{label:h("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),G($,{label:h("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ut(Vp,{className:"HelpDialog__island--view",caption:h("helpDialog.view"),children:[G($,{label:h("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),G($,{label:h("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),G($,{label:h("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),G($,{label:h("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),G($,{label:h("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),G($,{label:h("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),G($,{label:h("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),G($,{label:h("buttons.zenMode"),shortcuts:[N("Alt+Z")]}),G($,{label:h("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),G($,{label:h("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),G($,{label:h("labels.viewMode"),shortcuts:[N("Alt+R")]}),G($,{label:h("labels.toggleTheme"),shortcuts:[N("Alt+Shift+D")]}),G($,{label:h("stats.fullTitle"),shortcuts:[N("Alt+/")]}),G($,{label:h("search.title"),shortcuts:[Le("searchMenu")]}),G($,{label:"Search canvas globally",shortcuts:[N("CtrlOrCmd+Shift+F")]}),G($,{label:"Open workspaces",shortcuts:["Shift+W"]}),G($,{label:h("commandPalette.title"),shortcuts:eP?[Le("commandPalette")]:[Le("commandPalette"),Le("commandPalette",1)]})]}),Ut(Vp,{className:"HelpDialog__island--editor",caption:h("helpDialog.editor"),children:[G($,{label:h("helpDialog.createFlowchart"),shortcuts:[N("CtrlOrCmd+Arrow Key")],isOr:!0}),G($,{label:h("helpDialog.navigateFlowchart"),shortcuts:[N("Alt+Arrow Key")],isOr:!0}),G($,{label:h("labels.moveCanvas"),shortcuts:[N(`Space+${h("helpDialog.drag")}`),N(`Wheel+${h("helpDialog.drag")}`)],isOr:!0}),G($,{label:h("buttons.clearReset"),shortcuts:[N("CtrlOrCmd+Delete")]}),G($,{label:h("labels.delete"),shortcuts:[N("Delete")]}),G($,{label:h("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),G($,{label:h("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),G($,{label:h("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),G($,{label:h("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),G($,{label:h("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),G($,{label:h("labels.multiSelect"),shortcuts:[N(`Shift+${h("helpDialog.click")}`)]}),G($,{label:h("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${h("helpDialog.click")}`)]}),G($,{label:h("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${h("helpDialog.drag")}`)]}),(oa||eP)&&G($,{label:h("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),G($,{label:h("labels.copyStyles"),shortcuts:[N("CtrlOrCmd+Alt+C")]}),G($,{label:h("labels.pasteStyles"),shortcuts:[N("CtrlOrCmd+Alt+V")]}),G($,{label:h("labels.sendToBack"),shortcuts:[QM?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),G($,{label:h("labels.bringToFront"),shortcuts:[QM?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),G($,{label:h("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),G($,{label:h("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),G($,{label:h("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),G($,{label:h("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),G($,{label:h("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),G($,{label:h("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),G($,{label:h("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${h("helpDialog.drag")}`)]}),G($,{label:h("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),G($,{label:h("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),G($,{label:h("buttons.redo"),shortcuts:yW?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),G($,{label:h("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),G($,{label:h("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),G($,{label:h("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),G($,{label:h("labels.flipVertical"),shortcuts:[N("Shift+V")]}),G($,{label:h("labels.showStroke"),shortcuts:[N("S")]}),G($,{label:h("labels.showBackground"),shortcuts:[N("G")]}),G($,{label:h("labels.showFonts"),shortcuts:[N("Shift+F")]}),G($,{label:h("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),G($,{label:h("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]}),G(Vp,{className:"HelpDialog__island--collab",caption:h("helpDialog.collaboration"),children:G($,{label:h("helpDialog.cursorChat"),shortcuts:["/"]})})]})]})})};import{CANVAS_SEARCH_TAB as CW,DEFAULT_SIDEBAR as SW}from"@excalidraw/common";import{isFlowchartNodeElement as kW,isImageElement as nP,isLinearElement as rP,isLineElement as MW,isTextBindableContainer as PW,isTextElement as AW}from"@excalidraw/element";import{isNodeInFlowchart as LW}from"@excalidraw/element";import{jsx as xx}from"react/jsx-runtime";var Ce=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,_W=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:l,lastPointerDownWith:a}=e,s=e.multiElement!==null;if(e.openSidebar?.name===SW.name&&e.openSidebar.tab===CW&&e.searchMatches?.matches.length)return h("hints.dismissSearch",{shortcut:Ce("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Ht(e))return h("hints.eraserRevert",{shortcut:Ce("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return h("hints.arrowBindModifiers",{shortcut_1:Ce("Ctrl"),shortcut_2:Ce("Alt")});if(r.type==="arrow"||r.type==="line")return s?h("hints.linearElementMulti",{shortcut_1:Ce("Escape"),shortcut_2:Ce("Enter")}):r.type==="arrow"?h("hints.arrowTool",{shortcut:Ce("A")}):h("hints.linearElement");if(r.type==="freedraw")return h("hints.freeDraw");if(r.type==="text")return h("hints.text");if(r.type==="embeddable")return h("hints.embeddable");if(i&&a==="mouse"&&c.length===1){let m=c[0];return rP(m)&&m.points.length===2?h("hints.lockAngle",{shortcut:Ce("Shift")}):nP(m)?h("hints.resizeImage",{shortcut_1:Ce("Shift"),shortcut_2:Ce("Alt")}):h("hints.resize",{shortcut_1:Ce("Shift"),shortcut_2:Ce("Alt")})}if(l&&a==="mouse")return h("hints.rotate",{shortcut:Ce("Shift")});if(c.length===1&&AW(c[0]))return h("hints.text_selected",{shortcut:Ce("Enter")});if(e.editingTextElement)return h("hints.text_editing",{shortcut_1:Ce("Escape"),shortcut_2:Ce(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return h("hints.leaveCropEditor",{shortcut_1:Ce("Enter"),shortcut_2:Ce("Escape")});if(c.length===1&&nP(c[0]))return h("hints.enterCropEditor",{shortcut:Ce("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return h("hints.deepBoxSelect",{shortcut:Ce("CtrlOrCmd")});if(cr(n)&&e.selectedElementsAreBeingDragged)return h("hints.disableSnapping",{shortcut:Ce("CtrlOrCmd")});if(!c.length&&!o)return h("hints.canvasPanning",{shortcut_1:Ce(h("keys.mmb")),shortcut_2:Ce("Space")});if(c.length===1){if(rP(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?h("hints.lineEditor_pointSelected",{shortcut_1:Ce("Delete"),shortcut_2:Ce(["CtrlOrCmd","D"])}):h("hints.lineEditor_nothingSelected",{shortcut_1:Ce("Shift"),shortcut_2:Ce("Alt")}):MW(c[0])?h("hints.lineEditor_line_info",{shortcut:Ce("Enter")}):h("hints.lineEditor_info",{shortcut_1:Ce("CtrlOrCmd"),shortcut_2:Ce(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&PW(c[0])){let m=h("hints.bindTextToElement",{shortcut:Ce("Enter")}),p=h("hints.createFlowchart",{shortcut:Ce(["CtrlOrCmd","\u2191\u2193"])});return kW(c[0])?LW(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},iP=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=_W({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let l=(Array.isArray(r)?r.map(a=>a.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((a,s)=>{if(s%2===1){let c=a[0]==="<"&&a.match(/^<kbd>([^<]+)<\/kbd>$/);return xx("kbd",{children:c?c[1]:a},s)}return a});return xx("div",{className:"HintViewer",children:xx("span",{children:l})})};import{useEffect as sP,useRef as cP,useState as ui}from"react";import{DEFAULT_EXPORT_PADDING as FW,EXPORT_IMAGE_TYPES as yx,isFirefox as OW,EXPORT_SCALES as zW,cloneJSON as dP}from"@excalidraw/common";import{useCallback as DW,useRef as HW,useState as RW}from"react";var NW=2e3,aP=()=>{let[e,o]=RW(null),t=HW(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},NW)},r=DW(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import BW from"clsx";import{jsx as lP}from"react/jsx-runtime";var rc=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>lP("div",{className:BW("Switch",{toggled:t,disabled:r}),children:lP("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Ne,jsxs as vr}from"react/jsx-runtime";var GW=()=>vr("div",{children:[Ne("h3",{children:h("canvasError.cannotShowPreview")}),Ne("p",{children:Ne("span",{children:h("canvasError.canvasTooBig")})}),vr("em",{children:["(",h("canvasError.canvasTooBigTip"),")"]})]}),UW=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i,exportWithDarkMode:l})=>{let a=Me(o,e),[s,c]=ui(i),[m,p]=ui(a),[d,u]=ui(e.exportBackground),[b,g]=ui(e.exportEmbedScene),[x,v]=ui(e.exportScale),y=cP(null),E=cP(0),[T,I]=ui(null),{onCopy:C,copyStatus:M,resetCopyStatus:k}=aP();sP(()=>{k()},[s,d,l,x,b,k]);let{exportedElements:_,exportingFrame:P}=Ur(o,e,m);return sP(()=>{let A=y.current;if(!A)return;let H=A.offsetWidth,F=A.offsetHeight;if(!H)return;let Y=++E.current,V=()=>Y!==E.current;return nr({elements:_,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:l,exportScale:x,exportEmbedScene:b},files:t,exportPadding:FW,maxWidthOrHeight:Math.max(H,F),exportingFrame:P}).then(async U=>{if(!V()){try{await Dr(U)}catch(D){throw D.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):D}V()||(I(null),A.replaceChildren(U))}}).catch(U=>{V()||(console.error(U),I(U))}),()=>{E.current+=1}},[e,t,_,P,s,d,l,x,b]),vr("div",{className:"ImageExportModal",children:[Ne("h3",{children:h("imageExportDialog.header")}),vr("div",{className:"ImageExportModal__preview",children:[Ne("div",{className:"ImageExportModal__preview__canvas",ref:y,children:T&&Ne(GW,{})}),Ne("div",{className:"ImageExportModal__preview__filename",children:!vi&&Ne("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:A=>{c(A.target.value),n.executeAction(Vh,"ui",A.target.value)}})})]}),vr("div",{className:"ImageExportModal__settings",children:[Ne("h3",{children:h("imageExportDialog.header")}),a&&Ne(ic,{label:h("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ne(rc,{name:"exportOnlySelected",checked:m,onChange:A=>{p(A)}})}),Ne(ic,{label:h("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ne(rc,{name:"exportBackgroundSwitch",checked:d,onChange:A=>{u(A),n.executeAction(Xh,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ne(rc,{name:"exportDarkModeSwitch",checked:l,onChange:A=>{n.executeAction(Fv,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.embedScene"),tooltip:h("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ne(rc,{name:"exportEmbedSwitch",checked:b,onChange:A=>{g(A),n.executeAction(Bd,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.scale"),name:"exportScale",children:Ne(gp,{name:"exportScale",value:x,onChange:A=>{v(A),n.executeAction(Nv,"ui",A)},choices:zW.map(A=>({value:A,label:`${A}\xD7`}))})}),vr("div",{className:"ImageExportModal__settings__buttons",children:[Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToPng"),onClick:()=>r(yx.png,_,{exportingFrame:P}),icon:Yu,children:h("imageExportDialog.button.exportToPng")}),Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToSvg"),onClick:()=>r(yx.svg,_,{exportingFrame:P}),icon:Yu,children:h("imageExportDialog.button.exportToSvg")}),(oa||OW)&&Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.copyPngToClipboard"),status:M,onClick:async()=>{await r(yx.clipboard,_,{exportingFrame:P}),C()},icon:Bi,children:h("imageExportDialog.button.copyPngToClipboard")})]})]})]})},ic=({label:e,children:o,tooltip:t,name:n})=>vr("div",{className:"ImageExportModal__settings__setting",title:e,children:[vr("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ne($t,{label:t,long:!0,children:yE})]}),Ne("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),mP=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:l})=>{let[{appStateSnapshot:a,elementsSnapshot:s}]=ui(()=>({appStateSnapshot:dP(o),elementsSnapshot:dP(e)}));return Ne(je,{onCloseRequest:i,size:"wide",title:!1,children:Ne(UW,{elementsSnapshot:s,appStateSnapshot:a,files:t,actionManager:n,onExportImage:r,name:l,exportWithDarkMode:o.exportWithDarkMode})})};import YW from"react";import{getFrame as VW}from"@excalidraw/common";import{jsx as WW}from"react/jsx-runtime";var Ex={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},vx=({children:e,color:o})=>WW("div",{className:"Card",style:{"--card-color":Ex[o].base,"--card-color-darker":Ex[o].darker,"--card-color-darkest":Ex[o].darkest},children:e});import{Fragment as KW,jsx as Do,jsxs as Xp}from"react/jsx-runtime";var XW=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:l,onCloseRequest:a})=>{let{onExportToBackend:s}=i;return Do("div",{className:"ExportDialog ExportDialog--json",children:Xp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Xp(vx,{color:"lime",children:[Do("div",{className:"Card-icon",children:I0}),Do("h2",{children:h("exportDialog.disk_title")}),Xp("div",{className:"Card-details",children:[h("exportDialog.disk_details"),!vi&&r.renderAction("changeProjectName")]}),Do(J,{className:"Card-button",type:"button",title:h("exportDialog.disk_button"),"aria-label":h("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ls,"ui")}})]}),s&&Xp(vx,{color:"pink",children:[Do("div",{className:"Card-icon",children:Rl}),Do("h2",{children:h("exportDialog.link_title")}),Do("div",{className:"Card-details",children:h("exportDialog.link_details")}),Do(J,{className:"Card-button",type:"button",title:h("exportDialog.link_button"),"aria-label":h("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ce("export","link",`ui (${VW()})`),await s(e,o,n),a()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,l)]})})},pP=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:l})=>{let a=YW.useCallback(()=>{l({openDialog:null})},[l]);return Do(KW,{children:o.openDialog?.name==="jsonExport"&&Do(je,{onCloseRequest:a,title:h("buttons.export"),children:Do(XW,{elements:e,appState:o,setAppState:l,files:t,actionManager:n,onCloseRequest:a,exportOpts:r,canvas:i})})})};import $W from"clsx";import{jsx as uP,jsxs as jW}from"react/jsx-runtime";var ZW="small",hP=e=>jW("label",{className:$W("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${ZW}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[uP("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),uP("div",{className:"ToolIcon__icon",children:Yo})]});import{Fragment as bP,jsx as ee,jsxs as Wt}from"react/jsx-runtime";var rY=({UIOptions:e})=>Wt(vt,{__fallback:!0,children:[ee(vt.DefaultItems.LoadScene,{}),ee(vt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(vt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(vt.DefaultItems.SaveAsImage,{}),ee(vt.DefaultItems.SearchMenu,{}),ee(vt.DefaultItems.Help,{}),ee(vt.DefaultItems.ClearCanvas,{}),ee(vt.Separator,{}),ee(vt.Group,{title:"Hellix IT links",children:ee(vt.DefaultItems.Socials,{})}),ee(vt.Separator,{}),ee(vt.DefaultItems.ToggleTheme,{}),ee(vt.DefaultItems.ChangeCanvasBackground,{})]}),iY=()=>Wt(yp,{__fallback:!0,children:[ee(yp.Actions.SaveToDisk,{}),ee(yp.Actions.ExportToImage,{})]}),aY=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:l,onHandToolToggle:a,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:u,onExportImage:b,renderWelcomeScreen:g,children:x,app:v,isCollaborating:y,generateLinkForSelection:E,onReportIssue:T})=>{let I=fe(),M=at()==="compact",k=sI(),_=M?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},P=k.tunnelsJotai.Provider,[A,H]=Q(Xn),F=()=>u.canvasActions.export?ee(pP,{elements:r,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,Y=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:ee(mP,{elements:r,appState:o,files:t,actionManager:e,onExportImage:b,onCloseRequest:()=>n({openDialog:null}),name:v.getName()}),V=()=>Wt("div",{style:{position:"relative"},children:[ee(k.MainMenuTunnel.Out,{}),g&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),U=()=>{let X=M;return ee(Ys,{heading:"selectedShapeActions",className:hi("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:X?ee(Xe,{className:hi("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:ee(SI,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v,setAppState:n})}):ee(Xe,{className:JW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:ee(EI,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v})})})},D=()=>{let X=oY(o,r),le=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return ee(ap,{side:"top",children:Wt("div",{className:"App-menu App-menu_top",children:[Wt(Et.Col,{gap:_.menuTopGap,className:hi("App-menu_top__left"),children:[V(),ee("div",{className:hi("selected-shape-actions-container",{"selected-shape-actions-container--compact":M}),children:X&&U()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&ee(Ys,{heading:"shapes",className:"shapes-section",children:pe=>Wt("div",{style:{position:"relative"},children:[g&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Et.Col,{gap:_.toolbarColGap,align:"start",children:Wt(Et.Row,{gap:_.toolbarRowGap,className:hi("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Wt(Xe,{padding:_.islandPadding,className:hi("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":M}),children:[ee(iP,{appState:o,isMobile:I.formFactor==="phone",editorInterface:I,app:v}),pe,Wt(Et.Row,{gap:_.toolbarInnerRowGap,children:[ee(lp,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:h("toolBar.penMode"),penDetected:o.penDetected}),ee(iS,{checked:o.activeTool.locked,onChange:l,title:h("toolBar.lock")}),ee("div",{className:"App-toolbar__divider"}),ee(MI,{setAppState:n,activeTool:o.activeTool,UIOptions:u,app:v})]})]}),y&&ee(Xe,{style:{marginLeft:_.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(hP,{title:h("toolBar.laser"),checked:o.activeTool.type===gP.laser,onChange:()=>v.setActiveTool({type:gP.laser}),isMobile:!0})})]})})]})}),Wt("div",{className:hi("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":M}),children:[o.collaborators.size>0&&ee(pp,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(I.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!W||o.openSidebar?.name!==Tx.name)&&ee(k.DefaultSidebarTriggerTunnel.Out,{}),le&&ee(nc,{app:v,onClose:()=>{e.executeAction(or)},renderCustomStats:d})]})]})})},B=()=>ee(Tp,{__fallback:!0,onDock:X=>{ce("sidebar",`toggleDock (${X?"dock":"undock"})`,`(${I.formFactor==="phone"?"mobile":"desktop"})`)}}),W=Ii(Vs),te=Wt(bP,{children:[x,ee(rY,{UIOptions:u}),ee(Tp.Trigger,{__fallback:!0,icon:$E,title:eY(h("toolBar.library")),onToggle:X=>{X&&ce("sidebar",`${Tx.name} (open)`,`button (${I.formFactor==="phone"?"mobile":"desktop"})`)},tab:Tx.defaultTab}),ee(iY,{}),o.openDialog?.name==="ttd"&&ee(Rp,{__fallback:!0}),o.isLoading&&ee(np,{delay:250}),o.errorMessage&&ee(JM,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),A&&I.formFactor!=="phone"&&ee(p1,{colorPickerType:A.colorPickerType,onCancel:()=>{H(null)},onChange:(X,le,pe,{altKey:de})=>{if(!(X!=="elementBackground"&&X!=="elementStroke"))if(pe.length){for(let Ee of pe)tY(Ee,QW(r),{[de&&A.swapPreviewOnAlt?X==="elementBackground"?"strokeColor":"backgroundColor":X==="elementBackground"?"backgroundColor":"strokeColor"]:le}),nY.delete(Ee);v.scene.triggerUpdate()}else n(X==="elementBackground"?{currentItemBackgroundColor:le}:{currentItemStrokeColor:le})},onSelect:(X,le)=>{H(pe=>pe?.keepOpenOnAlt&&le.altKey?pe:null),A?.onSelect?.(X,le)}}),o.openDialog?.name==="help"&&ee(tP,{onClose:()=>{n({openDialog:null})},onReportIssue:T}),ee(DI,{}),o.openDialog?.name==="elementLinkSelector"&&ee(qM,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:v.scene,appState:o,generateLinkForSelection:E}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),Y(),F(),o.openDialog?.name==="charts"&&ee(ES,{data:o.openDialog.data,rawText:o.openDialog.rawText,onClose:()=>n({openDialog:null})}),I.formFactor==="phone"&&ee(hS,{app:v,appState:o,elements:r,actionManager:e,renderJSONExportDialog:F,renderImageExportDialog:Y,setAppState:n,onHandToolToggle:a,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:B,renderWelcomeScreen:g,UIOptions:u}),I.formFactor!=="phone"&&Wt(bP,{children:[Wt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&W&&I.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&ee(k.WelcomeScreenCenterTunnel.Out,{}),D(),ee(CS,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),(o.toast||o.scrolledOutside)&&Wt("div",{className:"floating-status-stack",children:[o.toast&&ee(Ld,{message:o.toast.message,onClose:()=>n({toast:null}),duration:o.toast.duration,closable:o.toast.closable}),!o.toast&&o.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(X=>({...Pr(r,X)}))},children:h("buttons.scrollBackToContent")})]})]}),B()]})]});return ee(ih.Provider,{value:o,children:ee(P,{children:ee(af.Provider,{value:k,children:te})})})},fP=e=>{let{startBoundElement:o,cursorButton:t,scrollX:n,scrollY:r,...i}=e;return i},lY=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:l,...a}=o;return Kp(fP(n),fP(l),{selectedElementIds:Kp,selectedGroupIds:Kp})&&Kp(r,a)},xP=qW.memo(aY,lY);import sY from"clsx";import{jsx as yP,jsxs as dY}from"react/jsx-runtime";var cY="small",$p=e=>dY("label",{className:sY("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${cY}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[yP("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),yP("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as mY,useRef as pY}from"react";import{jsx as EP}from"react/jsx-runtime";var vP=({trails:e})=>{let o=pY(null);return mY(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),EP("div",{className:"SVGLayer",children:EP("svg",{ref:o})})};import jY,{useEffect as qY,useRef as FP}from"react";import{CURSOR_TYPE as OP,isShallowEqual as JY,sceneCoordsToViewportCoords as QY}from"@excalidraw/common";import{clamp as Sx,pointFrom as cl,pointsEqual as yY,bezierEquation as DP,pointRotateRads as Zp,pointDistance as EY}from"@excalidraw/math";import{arrayToMap as vY,BIND_MODE_TIMEOUT as ac,DEFAULT_TRANSFORM_HANDLE_SPACING as Ax,FRAME_STYLE as uo,getFeatureFlag as TY,invariant as SP,THEME as Tr}from"@excalidraw/common";import{deconstructDiamondElement as kx,deconstructRectanguloidElement as HP,elementCenterPoint as dl,getDiamondBaseCorners as IY,FOCUS_POINT_SIZE as wY,getOmitSidesForEditorInterface as Ix,getTransformHandles as CY,getTransformHandlesFromCoords as SY,hasBoundingBox as kY,hitElementItself as MY,isArrowElement as PY,isBindableElement as RP,isElbowArrow as ml,isFrameLikeElement as pl,isImageElement as kP,isLinearElement as AY,isLineElement as LY,maxBindingDistance_simple as _Y,isTextElement as MP,LinearElementEditor as mn}from"@excalidraw/element";import{renderSelectionElement as DY}from"@excalidraw/element";import{getElementsInGroup as Mx,getSelectedGroupIds as HY,isSelectedViaGroup as RY,selectGroupsFromGivenElements as NY}from"@excalidraw/element";import{getCommonBounds as Px,getElementAbsoluteCoords as jp}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as PP,isFocusPointVisible as BY}from"@excalidraw/element";import{pointFrom as Tt}from"@excalidraw/math";import{THEME as uY}from"@excalidraw/common";var hY="#ff6b6b",gY="#ff0000",TP=1,IP=2,wP=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===uY.LIGHT||o.zenModeEnabled?hY:gY,n=(o.zenModeEnabled?TP*1.5:TP)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,bY(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,xY(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,fY(r,e,o));e.restore()},fY=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];po(n,r,o)}for(let n of e.points)CP(n,t,o)},bY=(e,o,t)=>{CP(e.points[0],t,o),t.zenModeEnabled||po(e.points[0],e.points[1],o)},CP=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?IP*1.5:IP)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},po=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},xY=(e,o,t,n,r)=>{let i=8/n.zoom.value,l=i/2,a=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||po(Tt(e[0],e[1]-i),Tt(e[0],e[1]+i),r),po(Tt(s[0]-a,s[1]-l),Tt(s[0]-a,s[1]+l),r),po(Tt(s[0]+a,s[1]-l),Tt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(po(Tt(o[0],o[1]-i),Tt(o[0],o[1]+i),r),po(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||po(Tt(e[0]-i,e[1]),Tt(e[0]+i,e[1]),r),po(Tt(s[0]-l,s[1]-a),Tt(s[0]+l,s[1]-a),r),po(Tt(s[0]-l,s[1]+a),Tt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(po(Tt(o[0]-i,o[1]),Tt(o[0]+i,o[1]),r),po(e,o,r))}};var FY=(e,o)=>{SP(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;SP(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Lx(t,e,o),e.restore()},OY=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r)||o.selectedLinearElement?.isDragging)return;let i=mn.getElement(n,t);if(!i)return;let l=mn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Lx(l,e,o),e.restore()},Lx=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Ml(o,e[0],e[1],mn.POINT_HANDLE_SIZE/t.zoom.value,!1)},zY=(e,o,t)=>{e.save(),e.translate(o.scrollX,o.scrollY),Lx(t,e,o),e.restore()},wx=(e,o,t,n,r,i,l)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Ml(e,t[0],t[1],(l?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!l||r)},GY=(e,o,t,n,r)=>{let i=o.element.frameId&&t.get(o.element.frameId);switch(i&&pl(i)&&(e.translate(i.x,i.y),e.beginPath(),uo.radius&&e.roundRect?e.roundRect(-1,-1,i.width+1,i.height+1,uo.radius/n.zoom.value):e.rect(-1,-1,i.width+1,i.height+1),e.clip(),e.translate(-i.x,-i.y)),o.element.type){case"magicframe":case"frame":e.save(),e.translate(o.element.x,o.element.y),e.lineWidth=uo.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",uo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.element.width,o.element.height,uo.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.element.width,o.element.height),e.restore();break;default:e.save();let l=dl(o.element,t);switch(e.translate(l[0],l[1]),e.rotate(o.element.angle),e.translate(-l[0],-l[1]),e.translate(o.element.x,o.element.y),e.lineWidth=Sx(1.75,o.element.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.element.type){case"ellipse":e.beginPath(),e.ellipse(o.element.width/2,o.element.height/2,o.element.width/2,o.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[a,s]=kx(o.element);a.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break;default:{let[a,s]=HP(o.element);a.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break}e.restore();break}if(n.isMidpointSnappingEnabled&&(pl(o.element)||RP(o.element))){let l=n.selectedLinearElement,a=l?.elementId&&mn.getElement(l?.elementId,t),s=r&&MY({point:r,element:o.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=a&&ml(a)||n.activeTool.type==="arrow"&&n.currentItemArrowType==="elbow";if(!s||c){e.save();let m=dl(o.element,t),p;if(o.element.type==="diamond"){let g=dl(o.element,t);p=IY(o.element).map(x=>{let v=DP(x,.5),y=Zp(v,g,o.element.angle);return cl(y[0],y[1])})}else p=[{x:o.element.width,y:o.element.height/2},{x:o.element.width/2,y:o.element.height},{x:0,y:o.element.height/2},{x:o.element.width/2,y:0}].map(x=>{let v=cl(x.x+o.element.x,x.y+o.element.y),y=Zp(v,m,o.element.angle);return cl(y[0],y[1])});let d=r&&p.reduce((g,x,v)=>{let y=EY(x,r);return v===-1||y<g.distance?{idx:v,distance:y}:g},{idx:-1,distance:1/0}),u=4/n.zoom.value,b=_Y(n.zoom)+o.element.strokeWidth/2;p.forEach((g,x)=>{let v=(!s||c)&&d?.idx===x&&d.distance<=b,y=!v&&(c||x===d?.idx&&d.distance<=b*2);v?(e.fillStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill()):y&&(e.fillStyle=n.theme===Tr.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},UY=(e,o,t,n,r,i,l)=>{let a=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=ac-(l?.runtime??(a?0:ac)),c=Sx(1/ac*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&pl(p)&&(o.translate(p.x,p.y),o.beginPath(),uo.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,uo.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=uo.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,uo.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,uo.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let u=dl(t,n),b=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(o.translate(b,g),o.rotate(t.angle),o.translate(-b,-g),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=Sx(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[x,v]=kx(t,m);x.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),v.forEach(y=>{let[E,T,I,C]=y;o.beginPath(),o.moveTo(E[0]-t.x+m,E[1]-t.y+m),o.bezierCurveTo(T[0]-t.x+m,T[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break;default:{let[x,v]=HP(t,m);x.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),v.forEach(y=>{let[E,T,I,C]=y;o.beginPath(),o.moveTo(E[0]-t.x+m,E[1]-t.y+m),o.bezierCurveTo(T[0]-t.x+m,T[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!a||(l?.runtime??0)>ac)return;let d=.5*(Math.min(t.width,t.height)/2);if(!pl(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/ac*s;if(o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-u*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore(),r.isMidpointSnappingEnabled){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let b=5/r.zoom.value,g=5/r.zoom.value,x=b+g,v;if(t.type==="diamond"){let[,y]=kx(t),E=dl(t,n);v=y.map(T=>{let I=DP(T,.5),C=Zp(I,E,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=dl(t,n);v=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(T=>{let I=cl(T.x+t.x,T.y+t.y),C=Zp(I,y,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}v.forEach(y=>{o.clearRect(y.x-x,y.y-x,x*2,x*2)}),o.fillStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,v.forEach(y=>{o.beginPath(),o.arc(y.x,y.y,b,0,2*Math.PI),o.fill()}),o.restore()}}return{runtime:(l?.runtime??0)+i}},WY=(e,o,t,n,r,i,l)=>{if(t===null)return;if(TY("COMPLEX_BINDINGS"))return UY(e,o,t.element,n,r,i,l);o.save(),o.translate(r.scrollX,r.scrollY);let a=e.lastPointerMoveCoords?cl(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null;GY(o,t,n,r,a),o.restore()},NP=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:l,y2:a,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,u=l-r,b=a-i,x=(t.padding??Ax*2)/o.zoom.value,v=8/o.zoom.value,y=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let E=s.length;for(let T=0;T<E;++T)e.strokeStyle=s[T],p&&e.setLineDash([v,y+(v+y)*(E-1)]),e.lineDashOffset=(v+y)*T,Pl(e,r-x,i-x,u+x*2,b+x*2,c,m,n);e.restore()},YY=(e,o,t,n)=>{let[r,i,l,a]=jp(t,n),s=l-r,c=a-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=uo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Pl(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,uo.radius/o.zoom.value),e.restore()},AP=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},l=t.filter(m=>m.groupIds.length===0),a=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,u,b]=Px(m);return{angle:0,x1:p,x2:u,y1:d,y2:b,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:d+(b-d)/2,activeEmbeddable:!1}},c=m=>{let p=Mx(t,m);return s(p)};Object.entries(NY(a,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(l.map(m=>s([m]))).forEach(m=>NP(e,o,m))},Cx=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=mn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=mn,l=o.selectedLinearElement?.isEditing?i:i/2,a=ml(t),s=LY(t);if(r.forEach((c,m)=>{if(a&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&yY(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),wx(e,o,c,l,d,!1,p)}),ml(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{mn.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom)||wx(e,o,cl((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else mn.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(ml(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&wx(e,o,m,i/2,!1,!0,!1)});e.restore()},VY=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},XY=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ml(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},LP=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,l=i?.elementId&&r.get(i.elementId);if(!l||!RP(l)||l.isDeleted)return;let a=PP(i.fixedPoint,l,r);if(!BY(a,e,l,r,o,t))return;let s=o.selectedLinearElement,c=!!s?.isDragging,m=t==="start"?0:e.points.length-1,p=!!s?.selectedPointsIndices?.includes(m);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&zY(n,o,a),!(p&&c)){let d=PP(i.fixedPoint,l,r),u=s?.hoveredFocusPointBinding===t,b=mn.getPointAtIndexGlobalCoordinates(e,m,r);VY(n,o,b,d),XY(n,o,d,wY/1.5,u)}},_P=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let l=n[i];if(l!==void 0){let[a,s,c,m]=l;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Ml(e,a+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(a,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):Pl(e,a,s,c,m,a+c/2,s+m/2,r,!0),e.restore()}})},KY=(e,o,t,n,r)=>{let[i,l,,,a,s]=jp(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,u=a-i+p,b=s-l+p,g=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,b);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-b],[0,d],[g,d],[d,0],[d,x]],[[u-d,-b],[d,d],[-g+d,d],[0,0],[0,x]],[[-u,b],[0,-d],[g,-d],[d,0],[d,-x]],[[u-d,b],[d,-d],[-g+d,-d],[0,0],[0,-x]]].forEach(y=>{let[[E,T],[I,C],[M,k],[_,P],[A,H]]=y;e.save(),e.translate(a,s),e.rotate(n.angle),e.beginPath(),e.moveTo(E+I,T+C),e.lineTo(E+M,T+k),e.stroke(),e.beginPath(),e.moveTo(E+_,T+P),e.lineTo(E+A,T+H),e.stroke(),e.restore()}),e.restore()},$Y=(e,o,t,n)=>{o.save();let r=Ax*2/t.zoom.value,i=e.width+r*2,l=e.height+r*2,a=e.x+i/2,s=e.y+l/2,c=-(i/2+r),m=-(l/2+r);o.translate(a+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(c,m,i,l),o.restore()},ZY=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:l,appState:a,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,u]=Mc(o,l),b=m,g=Pc({canvas:o,scale:l,normalizedWidth:d,normalizedHeight:u});g.save(),g.scale(a.zoom.value,a.zoom.value);let x;if(n.forEach(I=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===I.id&&I&&(x=I)}),x&&Cx(g,a,x,t),a.selectionElement&&!a.isCropping)try{DY(a.selectionElement,g,a,s.selectionColor)}catch(I){console.error(I)}if(a.editingTextElement&&MP(a.editingTextElement)){let I=i.get(a.editingTextElement.id);I&&!I.autoResize&&$Y(I,g,a,s.selectionColor)}if(a.isBindingEnabled&&a.suggestedBinding?b={...m,bindingHighlight:WY(e,g,a.suggestedBinding,i,a,p,m?.bindingHighlight)}:b={...m,bindingHighlight:void 0},a.frameToHighlight&&YY(g,a,a.frameToHighlight,t),a.elementsToHighlight&&AP(g,a,a.elementsToHighlight),a.activeLockedId){let I=i.get(a.activeLockedId),C=I?[I]:Mx(i,a.activeLockedId);AP(g,a,C,{colors:["#ced4da"],dashed:!0})}let v=r.some(I=>pl(I));r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Cx(g,a,r[0],t);let y=a.selectedLinearElement,E=y&&mn.getElement(y.elementId,i);if(E&&(a.selectedLinearElement.isDragging||(y.segmentMidPointHoveredCoords?FY(g,a):(ml(E)?y.hoverPointIndex===0||y.hoverPointIndex===E.points.length-1:y.hoverPointIndex>=0)&&OY(g,a,t)),PY(E)&&(LP({arrow:E,elementsMap:i,appState:a,context:g,type:"start"}),LP({arrow:E,elementsMap:i,appState:a,context:g,type:"end"}))),!a.multiElement&&!a.newElement&&!a.selectedLinearElement?.isEditing){let I=kY(r,a,c),C=r.length===1&&AY(r[0]);C&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Cx(g,a,r[0],t);let M=s.selectionColor||"#000";if(I){let k=vY(r),_=[];for(let A of t.values()){let H=[],F=s.remoteSelectedElementIds.get(A.id);if(C&&ml(A)&&(A.startBinding||A.endBinding)||(k.has(A.id)&&!RY(a,A)&&H.push(M),F&&H.push(...F.map(Y=>Xr(Y,a.collaborators.get(Y))))),H.length){let[Y,V,U,D,B,W]=jp(A,t,!0);_.push({angle:A.angle,x1:Y,y1:V,x2:U,y2:D,selectionColors:A.locked?["#ced4da"]:H,dashed:!!F||A.locked,cx:B,cy:W,activeEmbeddable:a.activeEmbeddable?.element===A&&a.activeEmbeddable.state==="active",padding:A.id===a.croppingElementId||kP(A)?0:void 0})}}let P=A=>{let H=Mx(t,A),[F,Y,V,U]=Px(H);_.push({angle:0,x1:F,x2:V,y1:Y,y2:U,selectionColors:H.some(D=>D.locked)?["#ced4da"]:["#000"],dashed:!0,cx:F+(V-F)/2,cy:Y+(U-Y)/2,activeEmbeddable:!1})};for(let A of HY(a))P(A);a.editingGroupId&&P(a.editingGroupId),_.forEach(A=>NP(g,a,A))}if(g.save(),g.translate(a.scrollX,a.scrollY),r.length===1){g.fillStyle="#fff";let k=CY(r[0],a.zoom,t,"mouse",Ix(c));if(!a.viewModeEnabled&&I&&!MP(a.editingTextElement)&&!a.croppingElementId&&_P(g,s,a,k,r[0].angle),a.croppingElementId&&!a.isCropping){let _=t.get(a.croppingElementId);_&&kP(_)&&KY(g,s,a,_,t)}}else if(r.length>1&&!a.isRotating&&!r.some(k=>k.locked)){let k=Ax*2/a.zoom.value;g.fillStyle="#fff";let[_,P,A,H]=Px(r,t),F=g.getLineDash();g.setLineDash([2/a.zoom.value]);let Y=g.lineWidth;g.lineWidth=1/a.zoom.value,g.strokeStyle=M,Pl(g,_-k,P-k,A-_+k*2,H-P+k*2,(_+A)/2,(P+H)/2,0),g.lineWidth=Y,g.setLineDash(F);let V=SY([_,P,A,H,(_+A)/2,(P+H)/2],0,a.zoom,"mouse",v?{...Ix(c),rotation:!0}:Ix(c));r.some(U=>!U.locked)&&_P(g,s,a,V,0)}g.restore()}a.searchMatches?.matches.forEach(({id:I,focus:C,matchedLines:M})=>{let k=t.get(I);if(k){let[_,P,,,A,H]=jp(k,t,!0);g.save(),a.theme===Tr.LIGHT?C?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":C?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let F=pl(k)?a.zoom.value:1;g.translate(a.scrollX,a.scrollY),g.translate(A,H),g.rotate(k.angle),M.forEach(Y=>{(Y.showOnCanvas||C)&&g.fillRect(_+Y.offsetX/F-A,P+Y.offsetY/F-H,Y.width/F,Y.height/F)}),g.restore()}}),wP(g,a),g.restore(),jv({context:g,renderConfig:s,appState:a,normalizedWidth:d,normalizedHeight:u});let T;return s.renderScrollbars&&(T=nC(t,d,u,a),g.save(),g.fillStyle=oC,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(I=>{I&&Ud(g,I.x,I.y,I.width,I.height,ao/2)}),g.restore()),{scrollBars:T,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:b}},BP=e=>{let o=ZY(e);return e.callback(o),o};var mt=class mt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(mt.animations.set(o,{animation:t,lastTime:0,state:n}),mt.isRunning||(mt.isRunning=!0,ri()?requestAnimationFrame(mt.tick):setTimeout(mt.tick,0)))}static tick(){if(mt.animations.size>0){for(let[o,t]of mt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(mt.animations.delete(o),mt.animations.size===0){mt.isRunning=!1;return}}ri()?requestAnimationFrame(mt.tick):setTimeout(mt.tick,0)}}static running(o){return mt.animations.has(o)}static cancel(o){mt.animations.delete(o)}};S(mt,"isRunning",!1),S(mt,"animations",new Map);var lc=mt;import{jsx as oV}from"react/jsx-runtime";var zP="animateInteractiveScene",eV=e=>{let o=FP(!1),t=FP(null);return qY(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,l=new Map,a=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&l.set(m,c.username),c.userState&&a.set(m,c.userState),r.set(m,QY({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:l,remotePointerUserStates:a,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},lc.running(zP)||lc.start(zP,({deltaTime:c,state:m})=>{let p=BP({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),oV("canvas",{className:"hellixitboard__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?OP.GRAB:OP.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:h("labels.drawingCanvas")})},GP=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),tV=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:JY(GP(e.appState),GP(o.appState)),_x=jY.memo(eV,tV);import nV,{useEffect as UP,useRef as WP}from"react";import{isShallowEqual as YP}from"@excalidraw/common";import{jsx as aV}from"react/jsx-runtime";var rV=e=>{let o=WP(null),t=WP(!1);return UP(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),UP(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("hellixitboard__canvas","static")),zy({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},ri())}),aV("div",{className:"hellixitboard__canvas-wrapper",ref:o})},VP=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),iV=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:YP(VP(e.appState),VP(o.appState))&&YP(e.renderConfig,o.renderConfig),Dx=nV.memo(rV,iV);import{useEffect as uV,useRef as hV}from"react";import{throttleRAF as lV}from"@excalidraw/common";import{getTargetFrame as sV,isInvisiblySmallElement as cV,renderElement as dV,shouldApplyFrameClip as mV}from"@excalidraw/element";var XP=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:l,renderConfig:a})=>{if(e){let[s,c]=Mc(e,i),m=Pc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(l.zoom.value,l.zoom.value),t&&t.type!=="selection"){if(cV(t))return;if((t.frameId||l.frameToHighlight?.id)&&l.frameRendering.enabled&&l.frameRendering.clip){let d=sV(t,n,l);d&&mV(t,d,l,n)&&Fy(d,m,a,l)}dV(t,n,r,o,m,a,l)}else m.clearRect(0,0,s,c);m.restore()}},pV=lV(e=>{XP(e)}),KP=(e,o)=>{if(o){pV(e);return}XP(e)};import{jsx as fV}from"react/jsx-runtime";var gV=e=>{let o=hV(null);return uV(()=>{o.current&&KP({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ri())}),fV("canvas",{className:"hellixitboard__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},$P=gV;var qp=class{constructor(o){this.getState=o;S(this,"listeners",[]);S(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:l,once:a,matchesImmediately:s}=this.normalize(o,t,n);return l?s&&(queueMicrotask(()=>{let c=this.getState();l(i(c),c)}),a)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:l,once:a}):s?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:m=>c(m),once:!0})})})}isStateChangePredicateOptions(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,l=t,a=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:m,once:p}=o;r=c,i=d=>d,l=m?(d,u)=>m(u):void 0,a=p??!1,s=c(this.getState())}else if(typeof o=="function"){let c=o;r=(m,p)=>c(m)!==c(p),i=m=>c(m)}else if(Array.isArray(o)){let c=o;r=(m,p)=>c.some(d=>m[d]!==p[d]),i=m=>m}else{let c=o;r=(m,p)=>m[c]!==p[c],i=m=>m[c]}return{predicate:r,getValue:i,callback:l,once:a,matchesImmediately:s}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as bV,getElementsInGroup as xV,selectGroupsFromGivenElements as yV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as EV}from"@excalidraw/common";import{flushSync as vV}from"react-dom";import{jsx as IV}from"react/jsx-runtime";var TV=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:xV(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=bV(n),{x:l,y:a}=EV({sceneX:r,sceneY:i},e.state);return IV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-a+e.state.offsetTop}px`,left:`${l-e.state.offsetLeft}px`},onClick:()=>{vV(()=>{let s=yV(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(gs)},title:h("labels.elementLock.unlock"),children:s0})},ZP=TV;import{Fragment as wK,jsx as Te,jsxs as su}from"react/jsx-runtime";var eL=go.createContext(null),tL=go.createContext(null),dy={formFactor:"desktop",desktopUIMode:"full",userAgent:JA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},py=go.createContext(dy);py.displayName="EditorInterfaceContext";var TK={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},uy=go.createContext({container:null,id:null});uy.displayName="HellixitboardContainerContext";var hy=go.createContext([]);hy.displayName="HellixitboardElementsContext";var gy=go.createContext({...Oo(),width:0,height:0,offsetLeft:0,offsetTop:0});gy.displayName="HellixitboardAppStateContext";var fy=go.createContext(()=>{console.warn("Uninitialized HellixitboardSetAppStateContext context!")});fy.displayName="HellixitboardSetAppStateContext";var by=go.createContext(null);by.displayName="HellixitboardActionManagerContext";var yl=go.createContext(null);yl.displayName="HellixitboardAPIContext";var du=go.createContext(null);du.displayName="HellixitboardAPISetContext";var Ae=()=>On(eL),Ko=()=>On(tL),fe=()=>On(py),at=()=>cu(fe()),_e=()=>On(uy),Kn=()=>On(hy),Xo=()=>On(gy),he=()=>On(fy),De=()=>On(by),mu=()=>On(yl),gc=!1,ay=0,fc=null,kr=!1,bc=!1,ly=!1,xc={horizontal:null,vertical:null},Mr=0,yc=!1,sy=new Map,cy=!1,$A=0,ZA=!1,Ec=null,ve={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},my=class e extends go.Component{constructor(t){super(t);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"sessionExportThemeOverride");S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"editorInterface",dy);S(this,"stylesPanelMode",cu(dy));S(this,"hellixitboardContainerRef",go.createRef());S(this,"_contextMenuPos",null);S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");S(this,"library");S(this,"libraryItemsFromStorage");S(this,"id");S(this,"store");S(this,"history");S(this,"hellixitboardContainerValue");S(this,"files",{});S(this,"imageCache",new Map);S(this,"iFrameRefs",new Map);S(this,"embedsValidationStatus",new Map);S(this,"initializedEmbeds",new Set);S(this,"elementsPendingErasure",new Set);S(this,"_initialized",!1);S(this,"editorLifecycleEvents",new eX(TK));S(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));S(this,"appStateObserver",new qp(()=>this.state));S(this,"onStateChange",this.appStateObserver.onStateChange);S(this,"flowChartCreator",new WX);S(this,"flowChartNavigator",new YX);S(this,"bindModeHandler",null);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"previousPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new zm);S(this,"laserTrails",new Ym(this.animationFrameHandler,this));S(this,"eraserTrail",new Zm(this.animationFrameHandler,this));S(this,"lassoTrail",new $m(this.animationFrameHandler,this));S(this,"onChangeEmitter",new gi);S(this,"onPointerDownEmitter",new gi);S(this,"onPointerUpEmitter",new gi);S(this,"onUserFollowEmitter",new gi);S(this,"onScrollChangeEmitter",new gi);S(this,"missingPointerEventCleanupEmitter",new gi);S(this,"onRemoveEventListenersEmitter",new gi);S(this,"api");S(this,"updateEditorAtom",(t,...n)=>{let r=Qe.set(t,...n);return this.triggerRender(),r});S(this,"previousHoveredBindableElement",null);S(this,"getEffectiveGridSize",()=>cr(this)?this.state.gridSize:null);S(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&Yx(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(we(this.interactiveCanvas,ze.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));S(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),hc.delete(t)});S(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Fn(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=$x(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else xl(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);S(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),l=Be({clientX:i.x,clientY:i.y},this.state),a=Be({clientX:i.right,clientY:i.bottom},this.state);return n={x:l.x,y:l.y,width:a.x-l.x,height:a.y-l.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});S(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});S(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ul.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!wA(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:l,y:a}=tu({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=BX(i);if(i.id===this.state.editingFrame){let p=m;c=Te("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===j.ESCAPE||d.key===j.ENTER)&&this.resetEditingFrame(i)},style:{background:t?QV(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${pn.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?pn.nameColorDarkTheme:pn.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-l-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return Te("div",{id:this.getFrameNameDOMId(i),className:Gx.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+pn.nameOffsetY-a+this.state.offsetTop}px`,left:`${l-this.state.offsetLeft}px`,zIndex:2,fontSize:pn.nameFontSize,color:t?pn.nameColorDarkTheme:pn.nameColorLightTheme,lineHeight:pn.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:ze.MOVE,pointerEvents:this.state.viewModeEnabled?hl.disabled:hl.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});S(this,"focusContainer",()=>{this.hellixitboardContainerRef.current?.focus()});S(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());S(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());S(this,"getSceneElements",()=>this.scene.getNonDeletedElements());S(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});S(this,"onExportImage",async(t,n,r)=>{ce("export",t,"ui");let i=await Wr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(jV).catch(l=>{console.error(l),this.setState({errorMessage:l.message})});this.state.exportEmbedScene&&i&&Lc(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:hn.magicframe}),ce("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Vx(t[0])&&t[0];if(!n&&t.some(i=>Vt(i)||i.frameId)){this.setActiveTool({type:hn.magicframe});return}ce("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,l,a,s]=fl(t),c=50;r=yA({...pn,x:i-c,y:l-c,width:a-i+c*2,height:s-l+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Xn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Dt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Dt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?Sr(a,{[i?"strokeColor":"backgroundColor"]:n}):a),captureUpdate:Dt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});S(this,"syncActionResult",We(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,l=t?.appState?.zenModeEnabled||!1,a=t?.appState?.theme||this.props.theme||ul.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(l=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&GA(m)&&Ro(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:l,theme:a,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",We(()=>{kr=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",t=>{t.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",We(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Oo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let a=l.files[0],s=await a.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),a)}),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(l=>{console.error(l)})}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let n=Lr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ti(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...Pr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:Dt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),ty(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??iX(t,n));S(this,"refreshEditorInterface",()=>{let t=this.hellixitboardContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=cX(),l=JA(typeof navigator<"u"?navigator.userAgent:""),a=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:DV,s=zx(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:l,canFitSidebar:n>a,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});S(this,"reconcileStylesPanelMode",t=>{let n=cu(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});S(this,"setDesktopUIMode",t=>{let n=dX(t);this.editorInterface=zx(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});S(this,"onResize",We(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>hc.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(xc=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",mA(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},HV));S(this,"onCut",We(t=>{!this.hellixitboardContainerRef.current?.contains(document.activeElement)||cc(t.target)||(this.actionManager.executeAction(Vd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onCopy",We(t=>{!this.hellixitboardContainerRef.current?.contains(document.activeElement)||cc(t.target)||(this.actionManager.executeAction(pa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onTouchStart",t=>{if(aX&&t.preventDefault(),!gc){gc=!0,t.touches.length===1&&(fc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(ay),ay=window.setTimeout(e.resetTapTwice,RV);return}if(gc&&t.touches.length===1&&fc){let n=t.touches[0];Ir(re(n.clientX,n.clientY),re(fc.x,fc.y))<=nX&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),gc=!1,clearTimeout(ay)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):ve.pointers.clear()});S(this,"pasteFromClipboard",We(async t=>{let n=!!cy,r=document.activeElement,i=this.hellixitboardContainerRef.current?.contains(r);if(t&&!i)return;let l=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(l instanceof HTMLCanvasElement)||cc(r)))return;let a=await na(t),s=a.getFiles(),c=await Rd(a,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",t=>{let n=Lr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,l,a]=fl(n),s=gl(r,l)/2,c=gl(i,a)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:u}=Be({clientX:m,clientY:p},this.state),b=d-s,g=u-c,[x,v]=It(b,g,this.getEffectiveGridSize()),{duplicatedElements:y}=Ux({type:"everything",elements:n.map(k=>Sr(k,{x:k.x+x-r,y:k.y+v-i})),randomizeSeed:!t.retainSeed}),E=this.scene.getElementsIncludingDeleted(),T=[...E,...y];T=this.props.onDuplicate?.(T,E)||T,NA(T,ou(y));let C=this.getTopLayerFrameAtSceneCoords({x:d,y:u});if(C){let k=OX(y,C);Jx(T,k,C,this.state)}this.scene.replaceAllElements(T),y.forEach(k=>{if(Ro(k)&&Wx(k)){let _=PA(k,this.scene.getElementsMapIncludingDeleted());LX(k,_,this.scene)}}),sX&&Gn.loadElementsFonts(y).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let M=iK(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Qe.get(Vs)?this.state.openSidebar:null,...ho({editingGroupId:null,selectedElementIds:M.reduce((k,_)=>(Wx(_)||(k[_.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(y,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(t,n)=>{this.setState(t,n)});S(this,"removePointer",t=>{Mr&&this.resetContextMenuTimer(),ve.pointers.delete(t.pointerId)});S(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ce("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...gn(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});S(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});S(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(uv)});S(this,"zoomCanvas",t=>{this.setState({...In({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:No(t)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(ty(t)?s=KX(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):ty(t)&&this.setState({toast:{message:h("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,l=this.state.scrollX,a=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=ts({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,l=s.scrollX,a=s.scrollY}else{let s=Pr(r,this.state);l=s.scrollX,a=s.scrollY}if(n?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,p=ZV({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:l,scrollY:a,zoom:i.value},interpolateValue:(d,u,b,g)=>{if(g==="zoom")return d*Math.pow(u/d,qV(b))},onStep:({scrollX:d,scrollY:u,zoom:b})=>{this.setState({scrollX:d,scrollY:u,zoom:{value:b}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{p(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:l,scrollY:a,zoom:i})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});S(this,"setToast",t=>{this.setState({toast:t})});S(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,MV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});S(this,"addFiles",We(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},l=Array.isArray(t)?t:Object.values(t);for(let a of l)if(!r[a.id]&&(i[a.id]=a,r[a.id]=a,a.mimeType===un.svg))try{let s=$y(MA(Zy(a.dataURL)),un.svg);a.dataURL!==s&&(a.version=(a.version??1)+1,a.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",We(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:l}=t;if(l){let a=n||void 0,s=r?mX({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:l,elements:a,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));S(this,"applyDeltas",(t,n)=>{let r=WA.squash(...t),i={...this.state},l=new Map(this.scene.getElementsMapIncludingDeleted());return WA.applyTo(r,l,i,n)});S(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});S(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let l=i?{name:i}:null;return l&&n&&(l.tab=n),this.setState({openSidebar:l}),!!i});S(this,"updateCurrentCursorPosition",We(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));S(this,"getEditorUIOffsets",()=>{let t=this.hellixitboardContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.hellixitboardContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.hellixitboardContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return En().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});S(this,"onKeyDown",We(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,s){let c=a[s];return typeof c=="function"?c.bind(a):s==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():c}})),!pA(t.target)){if((t.key===j.ESCAPE||t.key===j.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=oe(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&fi(a[0])&&t.key===j.ENTER){this.startImageCropping(a[0]);return}if(t.key===j.ESCAPE)this.updateEditorAtom(Io,null);else if(t.key===j.TAB&&(document.activeElement===this.hellixitboardContainerRef?.current||document.activeElement?.classList.contains(Gx.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=xa(a);Qe.get(Io)?.type==="panel"&&Lg(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(Io,{type:"panel"})}if(t.key===j.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let s=Jp(t.key);if(t[j.CTRL_OR_CMD]&&s&&!t.shiftKey){t.preventDefault();let c=oe(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&wX(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,DA(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Kx(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let c=oe(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&s){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),DA(t.key));if(m){this.setState(d=>({selectedElementIds:ke({[m]:!0},d)}));let p=this.scene.getNonDeletedElementsMap().get(m);p&&!Kx([p],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[j.CTRL_OR_CMD]&&t.key===j.P&&!t.shiftKey&&!t.altKey){this.setToast({message:h("commandPalette.shortcutHint",{shortcut:Le("commandPalette")})}),t.preventDefault();return}if(t[j.CTRL_OR_CMD]&&t.key.toLowerCase()===j.V&&(cy=t.shiftKey,clearTimeout($A),$A=window.setTimeout(()=>{cy=!1},100)),t[j.CTRL_OR_CMD]&&cc(t.target)&&(t.code===oA.MINUS||t.code===oA.EQUAL)){t.preventDefault();return}if(cc(t.target)&&t.key!==j.ESCAPE||Jp(t.key)&&pA(t.target))return;if(t.key===j.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===j.E&&t.shiftKey&&t[j.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===j.PAGE_UP||t.key===j.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===j.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(s=>({scrollX:s.scrollX+a})):this.translateCanvas(s=>({scrollY:s.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===j.ALT&&(Bn("COMPLEX_BINDINGS")?this.handleSkipBindMode():lu({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===j.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=lI(t.key,this);if(this.state.viewModeEnabled&&!gA(a,["laser","hand"]))return;if(a){this.state.activeTool.type!==a&&ce("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(s=>({currentItemArrowType:s.currentItemArrowType===Cr.sharp?Cr.round:s.currentItemArrowType===Cr.round?Cr.elbow:Cr.sharp})),a==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:a}),t.stopPropagation();return}else if(t.key===j.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[j.CTRL_OR_CMD]&&!t.repeat&&(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),lu({app:this,event:t})),Jp(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),s=new Set;a.filter(d=>bn(d)).filter(d=>{let u=d.startBinding&&!a.some(g=>g.id===d.startBinding?.elementId),b=d.endBinding&&!a.some(g=>g.id===d.endBinding?.elementId);return u||b}).forEach(d=>s.add(d.id)),a=a.filter(d=>!s.has(d.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?lA:this.getEffectiveGridSize())||(t.shiftKey?AV:lA),m=0,p=0;t.key===j.ARROW_LEFT?m=-c:t.key===j.ARROW_RIGHT?m=c:t.key===j.ARROW_UP?p=-c:t.key===j.ARROW_DOWN&&(p=c),a.forEach(d=>{this.scene.mutateElement(d,{x:d.x+m,y:d.y+p},{informMutation:!1,isDragging:!1}),ru(d,this.scene,{simultaneouslyUpdated:a})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===j.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let s=a[0];if(t[j.CTRL_OR_CMD]||oy(s))_t(s)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)&&(this.store.scheduleCapture(),Xt(s)||this.actionManager.executeAction(Ha));else if(Ro(s)||AX(s)){let c;Ro(s)||(c=s);let m=jx(s,this.state,this.scene.getNonDeletedElementsMap()),p=m.x,d=m.y;this.startTextEditing({sceneX:p,sceneY:d,container:c}),t.preventDefault();return}else Vt(s)&&this.setState({editingFrame:s.id})}}if(t.key===j.SPACE&&ve.pointers.size===0&&(kr=!0,we(this.interactiveCanvas,ze.GRAB),t.preventDefault()),(t.key===j.G||t.key===j.S)&&!t.altKey&&!t[j.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===j.G&&(Bo(this.state.activeTool.type)||a.some(s=>Bo(s.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===j.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[j.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===j.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(s=>Ro(s)||Zx(s,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}t[j.CTRL_OR_CMD]&&(t.key===j.BACKSPACE||t.key===j.DELETE)&&this.updateEditorAtom(jr,"clearCanvas");let r=t.key.toLocaleLowerCase(),i=r===j.S&&t.shiftKey&&!t[j.CTRL_OR_CMD],l=t.key===j.I||r===j.G&&t.shiftKey;(i||l)&&this.openEyeDropper({type:i?"stroke":"background"})}));S(this,"onKeyUp",We(t=>{if(t.key===j.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?we(this.interactiveCanvas,ze.GRAB):nu(this.state.activeTool.type)?Zt(this.interactiveCanvas):(jt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),kr=!1),t.key===j.ALT&&lu({app:this,event:t}),(t.key===j.ALT&&this.state.bindMode==="skip"||!t[j.CTRL_OR_CMD]&&!mc(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Bn("COMPLEX_BINDINGS"))){let n=Be({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ho(re(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=xe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());bn(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[j.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&Yt(()=>{this.setState({isBindingEnabled:n})}),lu({app:this,event:t})}if(Jp(t.key)){bA(this.scene.getSelectedElements(this.state).filter(bl),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(ny).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...VA(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...VA(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Dt.IMMEDIATELY})),!t[j.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ke({[n.id]:!0},r)})),Kx([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(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Dt.IMMEDIATELY})}}));S(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);S(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=gn(this.state,t);r.type==="hand"?we(this.interactiveCanvas,ze.GRAB):kr||jt(this.interactiveCanvas,{...this.state,activeTool:r}),XV(document.activeElement)&&this.focusContainer(),TX(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let l={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:nu(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...l,activeTool:r,...n?{}:{selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...l,activeTool:r,selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null}:{...i,...l,activeTool:r}})});S(this,"setOpenDialog",t=>{this.setState({openDialog:t})});S(this,"setCursor",t=>{we(this.interactiveCanvas,t)});S(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>ve.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${h("labels.untitled")}-${uA()}`);S(this,"onGestureStart",We(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),ve.initialScale=this.state.zoom.value}));S(this,"onGestureChange",We(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ve.initialScale;n&&this.setState(r=>({...In({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:No(n*t.scale)},r)}))}));S(this,"onGestureEnd",We(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),ve.initialScale=null}));S(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:l=!0})=>{let a=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(Zx(i,this.scene.getNonDeletedElementsMap())||(a=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Ro(m[0])?c=m[0]:i?c=Zx(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,n):c=this.getTextElementAtPosition(t,n);let p=c?.fontFamily||this.state.currentItemFontFamily,d=c?.lineHeight||dA(p),u=this.state.currentItemFontSize;if(!c&&a&&i&&!bl(i)){let v=qX(Fx({fontSize:u,fontFamily:p}),d),y=JX(u,d),E=Math.max(i.height,y),T=Math.max(i.width,v);this.scene.mutateElement(i,{height:E,width:T}),t=i.x+T/2,n=i.y+E/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let b=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),g=c||EA({x:s?s.elementCenterX:t,y:s?s.elementCenterY: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,text:"",fontSize:u,fontFamily:p,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?FV.MIDDLE:iA,containerId:a?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?bl(i)?0:i.angle:0,frameId:b?b.id:null});if(!c&&a&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:g.id})}),this.setState({editingTextElement:g}),!c)if(i&&a){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(g,x+1)}else this.scene.insertElement(g);l||c||i?this.handleTextWysiwyg(g,{isExistingElement:!!c}):this.setState({newElement:g,multiElement:null})});S(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Be(t,this.state);if(n.length===1&&_t(n[0])){let a=n[0];if((t[j.CTRL_OR_CMD]&&ny(a)||oy(a))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==a.id)){this.actionManager.executeAction(Ha);return}else if(this.state.selectedLinearElement&&Xt(n[0])){let s=xe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),xe.deleteFixedSegment(n[0],this.scene,c);let m=xe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===a.id&&oy(a))return}if(n.length===1&&fi(n[0])){this.startImageCropping(n[0]);return}if(Zt(this.interactiveCanvas),nK(this.state).length>0){let a=this.getElementAtPosition(r,i),s=a&&oK(a,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ho({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Zt(this.interactiveCanvas),!t[j.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(r,i);if(Yx(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(TA(s)||!$V(s.backgroundColor)||uc({point:re(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=jx(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});S(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let l=r.length-1;l>=0;l--){let a=r[l];if(n&&a.id===n.id&&(i=l),a.link&&l>=i&&kc(a,this.scene.getNonDeletedElementsMap(),this.state,re(t.x,t.y),this.editorInterface.formFactor==="phone"))return a}});S(this,"handleElementLinkClick",t=>{let n=Ir(re(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),re(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>aA)return;let r=Be(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),l=kc(this.hitLinkElement,i,this.state,re(r.x,r.y),this.editorInterface.formFactor==="phone"),a=Be(this.lastPointerUpEvent,this.state),s=kc(this.hitLinkElement,i,this.state,re(a.x,a.y),this.editorInterface.formFactor==="phone");if(l&&s){xg();let c=this.hitLinkElement.link;if(c){c=Bx(c);let m;if(this.props.onLinkOpen&&(m=KV(ae.HELLIXITBOARD_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},m)),!m?.defaultPrevented){let p=WV(c)?"_self":"_blank",d=window.open(void 0,p);d&&(d.opener=null,d.location=c)}}}});S(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&AA(t,i,n));return r.length?r[r.length-1]:null});S(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},ve.pointers.has(t.pointerId)&&ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let l=ve.initialScale;if(ve.pointers.size===2&&ve.lastCenter&&l&&ve.initialDistance){let g=Bf(ve.pointers),x=g.x-ve.lastCenter.x,v=g.y-ve.lastCenter.y;ve.lastCenter=g;let y=Ff(Array.from(ve.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/ve.initialDistance,T=E?No(l*E):this.state.zoom.value;this.setState(I=>{let C=In({viewportX:g.x,viewportY:g.y,nextZoom:T},I);return this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(x/T),scrollY:C.scrollY+2*(v/T),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else ve.lastCenter=ve.initialDistance=ve.initialScale=null;if(kr||bc||ly||yn(this.state))return;let s=$f(xc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?Zt(this.interactiveCanvas):jt(this.interactiveCanvas,this.state)),!this.state.newElement&&Uw(this.state.activeTool.type)){let{originOffset:g,snapLines:x}=Gw(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(v=>{let y=dc(v.snapLines,x),E=v.originSnapOffset?dc(v.originSnapOffset,g):g;return v.snapLines===y&&v.originSnapOffset===E?null:{snapLines:y,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:xe.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Yt(()=>{this.setState({selectedLinearElement:g})})}if(vX(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&mc(this.state)){let x=re(r,i),v=this.scene.getNonDeletedElementsMap(),y=Ho(x,this.scene.getNonDeletedElements(),v,ry(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:iy(x,y,v,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:x}=this.state,{x:v,y,points:E}=g,T=E[E.length-1],{lastCommittedPoint:I}=x;if(jt(this.interactiveCanvas,this.state),T===I)bl(this.state.newElement)&&mc(this.state)&&Ho(re(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ry(this.state.zoom))?(this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Zt(this.interactiveCanvas),this.setState(M=>({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...M.selectedElementIds,[g.id]:!0},M),selectedLinearElement:new xe(g,this.scene.getNonDeletedElementsMap())})))):Ir(re(r-v,i-y),T)>=Nx?(this.scene.mutateElement(g,{points:[...E,re(r-v,i-y)]},{informMutation:!1,isDragging:!1}),fn(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:E[E.length-1],selectedPointsIndices:[g.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length-1}}})):we(this.interactiveCanvas,ze.POINTER);else if(E.length>2&&I&&Ir(re(r-v,i-y),I)<Nx)we(this.interactiveCanvas,ze.POINTER),this.scene.mutateElement(g,{points:E.slice(0,-1)},{informMutation:!1,isDragging:!1}),this.setState({selectedLinearElement:{...x,selectedPointsIndices:x.selectedPointsIndices?.includes(g.points.length)?[...x.selectedPointsIndices.filter(C=>C!==g.points.length&&C!==g.points.length-1),g.points.length-1]:x.selectedPointsIndices,lastCommittedPoint:g.points[g.points.length-1],initialState:{...x.initialState,lastClickedPoint:g.points.length-1}}});else{SA(E,this.state.zoom.value)&&we(this.interactiveCanvas,ze.POINTER);let C=this.scene.getNonDeletedElementsMap();if(ny(g)){let k=Ho(re(r,i),this.scene.getNonDeletedElements(),C);Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,k)}fn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let M=xe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);M&&this.setState(M)}return}if(this.state.activeTool.type==="arrow"){let g=Ho(re(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ry(this.state.zoom)),x=re(r,i),v=this.scene.getNonDeletedElementsMap();g&&!fK(x,g,v)&&this.setState({suggestedBinding:{element:g,midPoint:iy(x,g,v,this.state.zoom)}})}let c=!!t.buttons,m=this.state.activeTool.type==="laser";if(c||!m&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let p=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&Xt(d[0]))&&!(_t(d[0])&&(this.editorInterface.userAgent.isMobileDevice||d[0].points.length===2))){let g=FA(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){we(this.interactiveCanvas,BA(g));return}}}else if(d.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=OA(fl(d),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){we(this.interactiveCanvas,BA({transformHandleType:g}));return}}if(Ht(this.state))return;let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),b=null;if(u&&u.locked?b=null:b=u,this.handleIframeLikeElementHover({hitElement:b,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])we(this.interactiveCanvas,ze.POINTER),_2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(xg(),m)return;b&&(b.link||Fn(b))&&this.state.selectedElementIds[b.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?we(this.interactiveCanvas,Ro(b)?ze.TEXT:ze.CROSSHAIR):this.state.viewModeEnabled?we(this.interactiveCanvas,ze.GRAB):this.state.openDialog?.name==="elementLinkSelector"?we(this.interactiveCanvas,ze.AUTO):s?we(this.interactiveCanvas,ze.AUTO):t[j.CTRL_OR_CMD]?we(this.interactiveCanvas,ze.AUTO):(b||this.isHittingCommonBoundingBoxOfSelectedElements(n,d))&&!b?.locked&&(!b||!Xt(b)||!(b.startBinding||b.endBinding))&&(this.state.activeTool.type!=="lasso"||d.length>0)&&we(this.interactiveCanvas,ze.MOVE),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&b?this.setState(g=>({hoveredElementIds:dc(g.hoveredElementIds,ho({editingGroupId:g.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!b&&this.setState(g=>({hoveredElementIds:dc(g.hoveredElementIds,{})}))});S(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",t=>{yc=!0});S(this,"handleCanvasPointerDown",t=>{if(!t.ctrlKey){let b=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==b&&this.setState({isBindingEnabled:b})}let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(b=>({searchMatches:b.searchMatches&&{focusedId:null,matches:b.searchMatches.matches.map(g=>({...g,focus:!1}))}})),this.updateEditorAtom(Rb,null)),Qe.get(Io)&&this.updateEditorAtom(Io,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let b=this.state.newElement;this.updateScene({...b.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(g=>g.id!==b.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:ke(Object.keys(this.state.selectedElementIds).filter(g=>g!==b.id).reduce((g,x)=>(g[x]=this.state.selectedElementIds[x],g),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Dt.EVENTUALLY:Dt.NEVER});return}let a=document.getSelection();if(a?.anchorNode&&a.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(b=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=zx(this.editorInterface,{isTouchScreen:!0})),bc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===wr.ERASER&&this.state.activeTool.type!==hn.eraser){this.setState({activeTool:gn(this.state,{type:hn.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let b=()=>{g(),x?.(),Ht(this.state)&&this.setState({activeTool:gn(this.state,{...this.state.activeTool.lastActiveTool||{type:hn.selection},lastActiveToolBeforeEraser:null})})},g=$e(window,ae.POINTER_UP,b,{once:!0}),x;requestAnimationFrame(()=>{x=this.missingPointerEventCleanupEmitter.once(b)})});return}if(t.button!==wr.MAIN&&t.button!==wr.TOUCH&&t.button!==wr.ERASER||ve.pointers.size>1)return;let s=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,s)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,s))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let b=s.hit.element&&this.isASelectedElement(s.hit.element);!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!b&&(this.lassoTrail.startPath(s.origin.x,s.origin.y,t.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&s.hit.element&&!b&&(this.setState(g=>{let x={...g.selectedElementIds,[s.hit.element.id]:!0},v=[];Object.keys(g.selectedElementIds).forEach(E=>{let T=this.scene.getElement(E);T&&v.push(T)});let y=s.hit.element;if(Vt(y))qx(v,y.id).forEach(E=>{delete x[E.id]});else if(y.frameId)x[y.frameId]&&delete x[y.id];else{let E=y.groupIds,T=new Set(E.flatMap(I=>bi(this.scene.getNonDeletedElements(),I)).filter(I=>Vt(I)).map(I=>I.id));T.size>0&&v.forEach(I=>{I.frameId&&T.has(I.frameId)&&(delete x[I.id],I.groupIds.flatMap(C=>bi(this.scene.getNonDeletedElements(),C)).forEach(C=>{delete x[C.id]}))})}return{...ho({editingGroupId:g.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),g,this),showHyperlinkPopup:y.link||Fn(y)?"info":!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,s):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="custom"?jt(this.interactiveCanvas,this.state):this.state.activeTool.type===hn.frame||this.state.activeTool.type===hn.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(s),p=this.onPointerUpFromPointerDownHandler(s),d=this.onKeyDownFromPointerDownHandler(s),u=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(b=>p(b||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ae.POINTER_MOVE,m),window.addEventListener(ae.POINTER_UP,p),window.addEventListener(ae.KEYDOWN,d),window.addEventListener(ae.KEYUP,u),s.eventListeners.onMove=m,s.eventListeners.onUp=p,s.eventListeners.onKeyUp=u,s.eventListeners.onKeyDown=d)});S(this,"handleCanvasPointerUp",t=>{if(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpEvent=t,!t.ctrlKey){let l=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==l&&this.setState({isBindingEnabled:l})}let n=Be({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let l=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,l)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(yc=!1,Mr?yc=!0:Mr=window.setTimeout(()=>{Mr=0,yc||this.handleCanvasContextMenu(t)},BV))});S(this,"resetContextMenuTimer",()=>{clearTimeout(Mr),Mr=0,yc=!1});S(this,"maybeCleanupAfterMissingPointerUp",t=>{Ec?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ve.pointers.size<=1&&(t.button===wr.WHEEL||t.button===wr.MAIN&&kr||yn(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;bc=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);we(this.interactiveCanvas,ze.GRABBING);let{clientX:i,clientY:l}=t,a=Vm(c=>{let m=i-c.clientX,p=l-c.clientY;if(i=c.clientX,l=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=b=>{document.body.removeEventListener(ae.PASTE,d),b.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ae.PASTE,d),window.removeEventListener(ae.POINTER_UP,u)},100)};document.body.addEventListener(ae.PASTE,d),window.addEventListener(ae.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=We(Ec=()=>{Ec=null,bc=!1,kr||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?we(this.interactiveCanvas,ze.GRAB):jt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ae.POINTER_MOVE,a),window.removeEventListener(ae.POINTER_UP,s),window.removeEventListener(ae.BLUR,s),a.flush()});return window.addEventListener(ae.BLUR,s),window.addEventListener(ae.POINTER_MOVE,a,{passive:!0}),window.addEventListener(ae.POINTER_UP,s),!0});S(this,"clearSelectionIfNotUsingSelection",()=>{nu(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(t,n)=>{if(nu(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),l=this.scene.getSelectedElements(this.state);if(l.length===1&&!this.state.selectedLinearElement?.isEditing&&!Xt(l[0])&&!(_t(l[0])&&(this.editorInterface.userAgent.isMobileDevice||l[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=FA(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);a!=null&&(a.transformHandleType==="rotation"?(this.setState({resizingElement:a.element}),n.resize.handleType=a.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:a.element}),n.resize.handleType=a.transformHandleType))}else l.length>1&&(n.resize.handleType=OA(fl(l),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=Ox(lK(n.resize.handleType,l,i,n.origin.x,n.origin.y)),l.length===1&&_t(l[0])&&l[0].points.length===2&&(n.resize.arrowDirection=sK(n.resize.handleType,l[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,u=xe.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let b=this.scene.getNonDeletedElementsMap(),g=xe.getElement(d.elementId,b);if(g&&bn(g)){let{hitFocusPoint:x,pointerOffset:v}=yK(g,n,b,this.state);if(x)return this.setState({selectedLinearElement:{...d,hoveredFocusPointBinding:x,draggedFocusPointBinding:x,pointerOffset:v}}),!1}}let a=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=a.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:a});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?ke({[d.selectedLinearElement.elementId]:!0},this.state):ke({},d)}));else if(m!=null){if(t[j.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...tK(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!RA(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let u={...d.selectedElementIds,[m.id]:!0},b=[];if(Object.keys(d.selectedElementIds).forEach(g=>{let x=this.scene.getElement(g);x&&b.push(x)}),Vt(m))qx(b,m.id).forEach(g=>{delete u[g.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let g=m.groupIds,x=new Set(g.flatMap(v=>bi(this.scene.getNonDeletedElements(),v)).filter(v=>Vt(v)).map(v=>v.id));x.size>0&&b.forEach(v=>{v.frameId&&x.has(v.frameId)&&(delete u[v.id],v.groupIds.flatMap(y=>bi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(g=>d.selectedGroupIds[g])||(u={[m.id]:!0})),{...ho({editingGroupId:d.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||Fn(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,l=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(r,i);TA(l)&&(a=l,r=l.x+l.width/2,i=l.y+l.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:a,autoEdit:!1}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})})});S(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,l]=It(r.origin.x,r.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),s=t.pressure===.5,c=hX({type:n,x:i,y:l,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:a?a.id:null,points:[re(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let d={...p.selectedElementIds};return delete d[c.id],{selectedElementIds:ke(d,p)}});let m=Ho(re(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:m,suggestedBinding:null})});S(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[l,a]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=gX({type:"iframe",x:l,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:r,height:i});return this.scene.insertElement(s),s});S(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,l]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=iu(r);if(!a)return;a.error instanceof URIError&&this.setToast({message:h("toast.unrecognizedLinkFormat"),closable:!0});let s=xA({type:"embeddable",x:i,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});S(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,l]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=r?this.getTopLayerFrameAtSceneCoords({x:i,y:l}):null,s=100/this.state.zoom.value;return xX({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null,x:i-s/2,y:l-s/2,width:s,height:s})});S(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:l}=this.state;if(fn(l,"selectedLinearElement is expected to be set"),i.type==="line"&&SA(i.points,this.state.zoom.value)){Yt(()=>{this.setState({selectedLinearElement:{...l,lastCommittedPoint:i.points[i.points.length-1],initialState:{...l.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(kt);return}if(Xt(i)&&i.points.length>1){this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:a,y:s}=i,{lastCommittedPoint:c}=l,m=mc(this.state)&&Ho(re(this.lastPointerMoveCoords?.x??a+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(bn(i)&&m||i.points.length>1&&c&&Ir(re(r.origin.x-a,r.origin.y-s),c)<Nx){this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:ke({...p.selectedElementIds,[i.id]:!0},p)})),we(this.interactiveCanvas,ze.POINTER)}else{let[i,l]=It(r.origin.x,r.origin.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?fX({type:n,x:i,y:l,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===Cr.round?{type:Qp.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Cr.elbow,fixedSegments:this.state.currentItemArrowType===Cr.elbow?[]:null}):yX({type:n,x:i,y:l,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:Qp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),u=re(r.origin.x,r.origin.y),b=this.scene.getNonDeletedElementsMap(),g=mc(this.state)?Ho(u,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(d,{points:[re(0,0),re(0,0)]}),this.scene.insertElement(d),bn(d)&&hK(d,new Map([[0,{point:re(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:rA(t.nativeEvent)}),Yt(()=>{this.setState(x=>{let v=null,y=x.selectedElementIds;if(_t(d)){v=new xe(d,this.scene.getNonDeletedElementsMap());let E=d.points.length-1;v={...v,selectedPointsIndices:[E],initialState:{...v.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:E,origin:re(r.origin.x,r.origin.y)}}}return y=this.state.activeTool.locked?x.selectedElementIds:ke({[d.id]:!0},x),{...x,bindMode:"orbit",newElement:d,startBoundElement:g,suggestedBinding:g&&bn(d)?{element:g,midPoint:iy(u,g,b,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:v}})}),bn(d)&&Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,g)}});S(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=It(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:l?l.id:null},s;t==="embeddable"?s=xA({type:"embeddable",...a}):s=bX({type:t,...a}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=It(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...pn},a=n===hn.magicframe?yA(l):uX(l);this.scene.insertElement(a),this.setState({multiElement:null,newElement:a})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(bn(i)){if(i.startBinding){let l=this.scene.getElement(i.startBinding.elementId);au(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}if(i.endBinding){let l=this.scene.getElement(i.endBinding.elementId);au(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}}else Xx(i)&&i.boundElements?.forEach(l=>{if(l.type==="arrow"){let a=this.scene.getElement(l.id);a?.startBinding?.elementId===i.id&&au(a,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),a?.endBinding?.elementId===i.id&&au(a,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Wx(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Sr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(t,n)=>{if(!_r(n))throw new Error(h("errors.unsupportedFileType"));let r=n.type;if(we(this.interactiveCanvas,"wait"),r===un.svg)try{n=wu(MA(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(h("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||Ky(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(h("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await Dc(n,{maxWidthOrHeight:PV})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>sA)throw new Error(h("errors.fileTooBig",{maxSize:`${Math.trunc(sA/1024/1024)}MB`}))}let a=this.files[i]?.dataURL||await Iu(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:a,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(i)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(h("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Sr(r,{fileId:n})});S(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Be({clientX:t,clientY:n},this.state),l=await Cc({description:"Image",extensions:Object.keys(LV),multiple:!0});this.insertImages(l,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(kt)})}});S(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,i),a=l*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-a/2,c=t.y+t.height/2-l/2;return{x:s,y:c,width:a,height:l,crop:null}});S(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await PX({imageCache:this.imageCache,fileIds:t.map(l=>l.fileId),files:n});return i.size&&(this.store.scheduleAction(Dt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(l=>pc(l)&&i.has(l.fileId)?Sr(l,{status:"error"}):l))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(t=MX(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let l of r)i.has(l.fileId)&&hc.delete(l);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",wV(()=>{this.addNewImagesToImageCache()},_V));S(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ae.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ae.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ae.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ae.TOUCH_END,this.onTouchEnd))});S(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,l=YA(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);l.forEach(d=>this.scene.insertElement(d));let a=await Promise.all(l.map(async(d,u)=>{try{return await this.initializeImage(d,await Ll(t[u]))}catch(b){return this.setState({errorMessage:b.message||h("errors.imageInsertError")}),Sr(d,{isDeleted:!0})}})),s=ou(a),c=YA(a.filter(d=>!d.isDeleted),n,r,i),m=ou(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:Dt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(kt)})});S(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Be(t,this.state),i=await na(t),l=i.getFiles();if(l.length===1){let{file:p,fileHandle:d}=l[0];if(p&&(p.type===un.png||p.type===un.svg))try{let u=await _c(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Dt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(h("alerts.couldNotLoadInvalidFile"))}}let a=l.map(p=>p.file).filter(p=>_r(p));if(a.length>0&&this.isToolSupported("image"))return this.insertImages(a,n,r);let s=i.getData(un.hellixitboardlibIds),c=i.getData(un.hellixitboardlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(b=>d.includes(b.id))}else c&&(p=Xy(c));p?.length&&(p=p.map(d=>({...d,elements:Ux({type:"everything",elements:d.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Ta(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(l.length>0){let{file:p,fileHandle:d}=l[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(un.text);if(m){let p=m.value;if(p&&$x(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||iu(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:Bx(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});S(this,"loadFileToCanvas",async(t,n)=>{t=await Ll(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await vu(t,this.state,r,n)}catch(l){let a=l instanceof Ry;if(a&&l.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:h("errors.imageToolNotSupported")});return}let s=a?h("alerts.cannotRestoreFromImage"):h("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===un.hellixitboard?(QA(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Dt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Dt.IMMEDIATELY})):i.type===un.hellixitboardlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(l=>{console.error(l),this.setState({errorMessage:h("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==wr.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=Be(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),l=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},l),s=i||a?"element":"canvas";this._contextMenuPos={sceneX:n,sceneY:r,elementId:i?.id??null};let c=this.hellixitboardContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,u=t.clientY-m;ce("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ho({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:_t(i)?new xe(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:d,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,l=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){zA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:l.x,y:l.y,width:gl(t.origin.x,l.x),height:gl(t.origin.y,l.y),shouldMaintainAspectRatio:sc(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a)return;let[s,c]=It(l.x,l.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=pc(a)&&this.imageCache.get(a.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[a]);let{snapOffset:d,snapLines:u}=zw(a,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:u}),bn(a)||zA({newElement:a,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:gl(t.originInGrid.x,s),height:gl(t.originInGrid.y,c),shouldMaintainAspectRatio:fi(a)?!sc(n):sc(n),shouldResizeFromCenter:nA(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:a}),(this.state.activeTool.type===hn.frame||this.state.activeTool.type===hn.magicframe)&&this.setState({elementsToHighlight:Qx(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[l,a]=It(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&fi(s)){let c=t.originalElements.get(s.id),m=pc(s)&&this.imageCache.get(s.fileId)?.image;if(c&&fi(c)&&m&&!(m instanceof Promise)){let[p,d]=It(i.x,i.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:b,snapLines:g}=Uf([s],[c],this,n,u,r);this.scene.mutateElement(s,VX(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,l+b.x,a+b.y,n.shiftKey?c.width/c.height:void 0)),ru(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});S(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Vt(p)),l=t.resize.handleType;if(i.length>0&&l==="rotation"||r.length===1&&Xt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:l&&l!=="rotation",isRotating:l==="rotation",activeEmbeddable:null});let a=t.lastCoords,[s,c]=It(a.x-t.resize.offset.x,a.y-t.resize.offset.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{qx(this.scene.getNonDeletedElements(),p.id).forEach(u=>{m.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=It(a.x,a.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y},b=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:g,snapLines:x}=Uf(r,oe(b,this.state),this,n,u,l);s+=g.x,c+=g.y,this.setState({snapLines:x})}if(cK(t.originalElements,l,r,this.scene,rA(n),nA(n),r.some(p=>fi(p))?!sc(n):sc(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{Qx(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>p.add(u))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});S(this,"getContextMenuItems",t=>{let n=[];n.push(Kd,Xd);let r=this._contextMenuPos,i=this.props.onAddComment,l=i&&r?{name:"addComment",label:"labels.addComment",trackEvent:!1,perform:()=>(i(r.elementId,r.sceneX,r.sceneY),!1)}:null,a=this.props.onToggleComments,s=a?{name:"toggleComments",label:this.props.commentsVisible?"labels.hideComments":"labels.showComments",trackEvent:!1,perform:()=>(a(),!1)}:null;if(t==="canvas")return this.state.viewModeEnabled?[...n,ua,tr,Zr,or]:[ig,qe,Kd,Xd,$d,qe,oh,F2,qe,ua,cs,ds,ms,tr,Zr,or,l&&qe,l,s];if(n.push($d),this.state.viewModeEnabled)return[pa,...n];let c=this.editorInterface.formFactor==="desktop"?[qe,Ju,Qu,eh,th]:[];return[qe,Vd,pa,ig,qe,bw,xw,yw,qe,_f,qe,...n,qe,Zh,jh,qe,Jh,kw,sg,cg,I2,Qh,qe,og,...c,qe,ng,rg,qe,Ha,qe,hs,em,qe,nh,gs,qe,Gl,l&&qe,l,s]});S(this,"handleWheel",We(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(Gx.FRAME_NAME))){t[j.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),bc)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),l=OV*100,a=Math.abs(r),s=r;a>l&&(s=l*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,a/20),this.translateCanvas(m=>({...In({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:No(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:l})=>({scrollX:l-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:l,scrollY:a})=>({scrollX:l-n/i.value,scrollY:a-r/i.value}))}));S(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:l}=Be({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(l);let a={x:i,y:l,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:r,pointersMap:ve.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",mA(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(this,"updateDOMRect",t=>{if(this.hellixitboardContainerRef?.current){let n=this.hellixitboardContainerRef.current,{width:r,height:i,left:l,top:a}=n.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&l===p&&a===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:l,offsetTop:a},()=>{t&&t()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});S(this,"watchState",()=>{});let n=Oo(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:a=!1,theme:s=n.theme,name:c=`${h("labels.untitled")}-${uA()}`}=t;this.state={...n,theme:s,exportWithDarkMode:s===ul.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:a,gridModeEnabled:l??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=cu(this.editorInterface),this.id=SV(),this.library=new cT(this),this.actionManager=new Om(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new UA,this.canvas=document.createElement("canvas"),this.rc=CV.canvas(this.canvas),this.renderer=new Os(this.scene),this.visibleElements=[],this.store=new pK(this),this.history=new Ns(this.store),this.hellixitboardContainerValue={container:this.hellixitboardContainerRef.current,id:this.id},this.fonts=new Gn(this.scene),this.history=new Ns(this.store),this.actionManager.registerAll(qc),this.actionManager.registerAction(Iw(this.history)),this.actionManager.registerAction(ww(this.history)),this.api=this.createHellixitboardAPI()}createHellixitboardAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.hellixitboard__embeddable");if(!i)break;for(let l of i)l.contentWindow===t.source&&(r=l.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(eu).includes(i)&&sy.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){fn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=Ho(re(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=xe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Yt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;fn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,l=n-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?xe.handlePointerMove(r,this,i,l,this.state.selectedLinearElement):xe.handlePointDragging(r,this,i,l,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||Xt(t))return;let r=()=>{if(this.bindModeHandler=null,fn(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!b&&!g||b&&g)return}let{x:p,y:d}=this.lastPointerMoveCoords,u=Ho(re(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){fn(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Yt(()=>{fn(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;fn(g,"Last event must exist");let x=p-this.state.selectedLinearElement.pointerOffset.x,v=d-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?xe.handlePointerMove(g,this,x,v,this.state.selectedLinearElement):xe.handlePointDragging(g,this,x,v,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),b=d?n:t.startBinding&&p.get(t.startBinding.elementId),g=u?n:t.endBinding&&p.get(t.endBinding.elementId),x=b&&XA(b,p),v=g&&XA(g,p);i=!!(x&&v&&b.id!==g.id&&gK(x,v))}let l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=l?"startBinding":a?"endBinding":null,c=l?"endBinding":a?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Yt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,rX)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==wr.MAIN||kr||!gA(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=re(Be({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=re(Be({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Ir(t,n)>aA)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ve.pointers.size<2&&Yx(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[1]))))return!1;let a=i;if(this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:a,state:"active"},selectedElementIds:{[a.id]:!0},newElement:null,selectionElement:null})},100),xl(a)))return!0;let s=this.getHTMLIFrameElement(a);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let c=sy.get(a.id);switch(c||(sy.set(a.id,eu.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:a.id}),"*")),c){case eu.PLAYING:case eu.BUFFERING:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return s.src.includes("player.vimeo.com")&&s.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(l=>Fn(l)&&this.embedsValidationStatus.get(l.id)===!0||xl(l));return Te(wK,{children:i.map(l=>{let{x:a,y:s}=tu({sceneX:l.x,sceneY:l.y},this.state),c=wA(l,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(l.id);if(c&&!m&&this.initializedEmbeds.add(l.id),!(c||m))return null;let d;if(xl(l)){d=null;let g=(l.customData?.generationData??this.magicGenerations.get(l.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(g.status==="done"){let x=g.html;d={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>x}}else if(g.status==="pending")d={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>kA(`
39
+ Please fix the Mermaid syntax and regenerate a valid diagram.`;await v({prompt:te,isRepairFlow:!0})},F=async D=>{let B=m.messages.findIndex(W=>W.id===D.id);if(B>0){let W=m.messages[B-1];W.type==="user"&&typeof W.content=="string"&&(g(),await v({prompt:W.content,isRepairFlow:!0}))}},Y=()=>{qs({app:i,data:x})},V=D=>{let B=m.messages.findIndex(te=>te.id===D&&te.type==="assistant"),W=m.messages.slice(0,B-1);p({...m,messages:W})},U=D=>{p(B=>({...B,currentPrompt:D}))};return P9("div",{className:`ttd-dialog-layout ${d?"ttd-dialog-layout--split":"ttd-dialog-layout--chat-only"}`,children:[qb(Qk,{chatId:m.id,messages:m.messages,currentPrompt:m.currentPrompt,onPromptChange:U,onGenerate:v,isGenerating:b?.isGenerating??!1,generatedResponse:b?.content,isMenuOpen:E,onMenuToggle:M,onMenuClose:k,onNewChat:S,onRestoreChat:T,onDeleteChat:I,savedChats:u,activeSessionId:m.id,onAbort:y,onMermaidTabClick:P,onAiRepairClick:H,onDeleteMessage:V,onInsertMessage:A,onRetry:F,onViewAsMermaid:_,renderWarning:n,renderWelcomeScreen:t}),d&&qb(tM,{canvasRef:a,hideErrorDetails:b?.errorType==="parse",error:s,loaded:e.loaded,onInsert:Y})]})},M9=({mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r})=>qb(k9,{mermaidToHellixitboardLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r}),oM=M9;import{Tabs as A9}from"radix-ui";import{useRef as nM}from"react";import{isMemberOf as L9}from"@hellixit/common";import{jsx as _9}from"react/jsx-runtime";var rM=e=>{let o=he(),t=nM(null),n=nM(0);return _9(A9.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let l=i.offsetHeight||0;l>n.current&&(n.current=l,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&L9(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};rM.displayName="TTDDialogTabs";var iM=rM;import{Tabs as D9}from"radix-ui";import{jsx as H9}from"react/jsx-runtime";var Jb=({children:e,...o})=>H9(D9.List,{className:"ttd-dialog-triggers",...o,children:e});Jb.displayName="TTDDialogTabTriggers";import{Tabs as R9}from"radix-ui";import{jsx as aM}from"react/jsx-runtime";var Dp=({children:e,tab:o,onSelect:t,...n})=>aM(R9.Trigger,{value:o,asChild:!0,onSelect:t,children:aM("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});Dp.displayName="TTDDialogTabTrigger";import{Tabs as N9}from"radix-ui";import{jsx as B9}from"react/jsx-runtime";var Hp=({tab:e,children:o,...t})=>B9(N9.Content,{...t,value:e,children:o});Hp.displayName="TTDDialogTab";import{jsx as dn,jsxs as Qb}from"react/jsx-runtime";var Rp=e=>{let o=se();return o.openDialog?.name!=="ttd"?null:dn(z9,{...e,tab:o.openDialog.tab})};Rp.WelcomeMessage=Mp;var z9=Rn("TTDDialogBase",({tab:e,...o})=>{let t=Ae(),[n,r]=O9({loaded:!1,api:import("@hellixit/mermaid-to-hellixitboard").then(i=>({parseMermaidToHellixitboard:i.parseMermaidToExcalidraw}))});return F9(()=>{(async()=>{await n.api,r(l=>({...l,loaded:!0}))})()},[n.api]),dn(je,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1520,title:!1,...o,autofocus:!1,children:Qb(iM,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?dn("p",{className:"dialog-mermaid-title",children:h("mermaid.title")}):Qb(Jb,{children:[dn(Dp,{tab:"text-to-diagram",children:Qb("div",{className:"ttd-dialog-tab-trigger__content",children:[h("labels.textToDiagram"),dn("div",{className:"ttd-dialog-tab-trigger__badge",children:h("chat.aiBeta")})]})}),dn(Dp,{tab:"mermaid",children:h("mermaid.label")})]}),!("__fallback"in o)&&dn(Hp,{className:"ttd-dialog-content",tab:"text-to-diagram",children:dn(oM,{mermaidToHellixitboardLib:n,onTextSubmit:o.onTextSubmit,renderWelcomeScreen:o.renderWelcomeScreen,renderWarning:o.renderWarning,persistenceAdapter:o.persistenceAdapter})}),dn(Hp,{className:"ttd-dialog-content",tab:"mermaid",children:dn(Ok,{mermaidToHellixitboardLib:n,isActive:e==="mermaid"})})]})})});import{round as KM}from"@hellixit/math";import eW from"clsx";import tW from"lodash.throttle";import{useEffect as $M,useMemo as ux,useState as oW,memo as nW}from"react";import{STATS_PANELS as Up}from"@hellixit/common";import{getCommonBounds as rW}from"@hellixit/element";import{getUncroppedWidthAndHeight as iW}from"@hellixit/element";import{isImageElement as hx}from"@hellixit/element";import{frameAndChildrenSelectedTogether as aW}from"@hellixit/element";import{elementsAreInSameGroup as lW}from"@hellixit/element";import{degreesToRadians as hM,radiansToDegrees as xM}from"@hellixit/math";import{getBoundTextElement as gM}from"@hellixit/element";import{isArrowElement as fM,isElbowArrow as Q9}from"@hellixit/element";import{updateBindings as bM}from"@hellixit/element";import K9 from"clsx";import{useEffect as pM,useRef as Bp,useState as $9}from"react";import{EVENT as al,KEYS as Z9,cloneJSON as ex}from"@hellixit/common";import{deepCopyElement as j9}from"@hellixit/element";import{CaptureUpdateAction as uM}from"@hellixit/element";import{pointFrom as xr,pointRotateRads as Np}from"@hellixit/math";import{getBoundTextElement as G9,isBindingElement as U9,unbindBindingElement as lM}from"@hellixit/element";import{isFrameLikeElement as dM}from"@hellixit/element";import{getSelectedGroupIds as W9,getElementsInGroup as Y9,isInGroup as V9}from"@hellixit/element";import{getFrameChildren as X9}from"@hellixit/element";import{updateBindings as sM}from"@hellixit/element";import{DRAGGING_THRESHOLD as cM}from"@hellixit/common";var mM=.01,tc=10,zt=(e,o)=>!(o==="angle"&&dM(e)),Oe=(e,o)=>{let t=e+o/2;return t-t%o},rl=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var pi=(e,o,t,n,r,i,l=!0)=>{if(U9(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<cM&&Math.abs(o-t.y)<cM)return;lM(t,"start",n),lM(t,"end",n)}let a=n.getNonDeletedElementsMap(),s=a.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Np(xr(t.x,t.y),xr(c,m),t.angle),u=e-p,b=o-d,[g,x]=Np(xr(e,o),xr(c+u,m+b),-t.angle);n.mutateElement(s,{x:g,y:x},{informMutation:l,isDragging:!1}),sM(s,n,r);let v=G9(t,i);if(v){let y=a.get(v.id);y&&n.mutateElement(y,{x:v.x+u,y:v.y+b},{informMutation:l,isDragging:!1})}if(dM(t)){let y=X9(i,t.id);y.forEach(E=>{let T=a.get(E.id);if(!T)return;let[I,S]=[E.x+E.width/2,E.y+E.height/2],[M,k]=Np(xr(E.x,E.y),xr(I,S),E.angle),_=Math.round(M+u),P=Math.round(k+b),[A,H]=Np(xr(_,P),xr(I+u,S+b),-E.angle);n.mutateElement(T,{x:A,y:H},{informMutation:l,isDragging:!1}),sM(T,n,r,{simultaneouslyUpdated:y})})}},il=(e,o)=>{let n=W9(o).map(r=>Y9(e,r).reduce((i,l)=>(i[l.id]=!0,i),{}));return e.filter(r=>!V9(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as tx,jsxs as J9}from"react/jsx-runtime";var q9=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:l,property:a,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=Ae(),u=he(),b=Bp(null),g=Bp(null),[x,v]=$9(n.toString()),y=Bp(null);y.current||(y.current={originalAppState:ex(c),originalElements:r,lastUpdatedValue:x,updatePending:!1}),pM(()=>{let I=n.toString();v(I),y.current.lastUpdatedValue=I},[n]);let E=(I,S,M)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let k=Number(I);if(isNaN(k)){v(n.toString());return}let _=Number(k.toFixed(2)),P=Number(n);(isNaN(P)||Math.abs(_-P)>=mM)&&(y.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:l,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:a,originalAppState:M,setInputValue:A=>v(String(A)),app:d,setAppState:u}),d.syncActionResult({captureUpdate:uM.IMMEDIATELY}))},T=Bp({});return T.current.handleInputValue=E,pM(()=>{let I=b.current,S=T.current;return()=>{let M=I?.value;M&&S.handleInputValue?.(M,y.current.originalElements,y.current.originalAppState),window.removeEventListener(al.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(al.POINTER_UP,S.onPointerUp,!1)}},[i]),i?J9("div",{className:K9("drag-input-container",!i&&"disabled"),"data-testid":e,children:[tx("div",{className:"drag-input-label",ref:g,onPointerDown:I=>{if(b.current&&i){document.body.classList.add("hellixitboard-cursor-resize");let S=Number(b.current.value);isNaN(S)&&(S=0);let M=null,k=d.scene.getNonDeletedElements().reduce((V,U)=>(V.set(U.id,j9(U)),V),new Map),_=r.map(V=>k.get(V.id)),P=ex(c),A=0,H=0,F=V=>{if(M&&k!==null&&_!==null){let U=V.clientX-M.x;U!==0&&(H+=U,Math.abs(H)>=m&&(H=Math.sign(H)*Math.floor(Math.abs(H)/m),A+=H,t({accumulatedChange:A,instantChange:H,originalElements:_,originalElementsMap:k,shouldKeepAspectRatio:l,shouldChangeByStepSize:V.shiftKey,property:a,scene:s,originalAppState:P,setInputValue:D=>v(String(D)),app:d,setAppState:u}),H=0))}M={x:V.clientX,y:V.clientY}},Y=()=>{window.removeEventListener(al.POINTER_MOVE,F,!1),d.syncActionResult({captureUpdate:uM.IMMEDIATELY}),p?.({app:d,setAppState:u,originalElements:_,originalAppState:P}),M=null,A=0,H=0,_=null,k=null,document.body.classList.remove("hellixitboard-cursor-resize"),window.removeEventListener(al.POINTER_UP,Y,!1)};T.current.onPointerMove=F,T.current.onPointerUp=Y,window.addEventListener(al.POINTER_MOVE,F,!1),window.addEventListener(al.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:o?tx($o,{icon:o}):e}),tx("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let S=I.target;S instanceof HTMLInputElement&&I.key===Z9.ENTER&&(E(S.value,r,c),d.focusContainer())}},ref:b,value:x,onChange:I=>{y.current.updatePending=!0,v(I.target.value)},onFocus:I=>{I.target.select(),y.current.originalElements=r,y.current.originalAppState=ex(c)},onBlur:I=>{x?i&&E(I.target.value,y.current.originalElements,y.current.originalAppState):v(n.toString())},disabled:!i})]}):null},dt=q9;import{jsx as nU}from"react/jsx-runtime";var eU=15,tU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let l=r.getNonDeletedElementsMap(),a=o[0];if(a&&!Q9(a)){let s=l.get(a.id);if(!s)return;if(n!==void 0){let b=hM(n);r.mutateElement(s,{angle:b}),bM(s,r,i.state);let g=gM(s,l);g&&!fM(s)&&r.mutateElement(g,{angle:b});return}let c=Math.round(xM(a.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=Oe(p,eU)),p=p<0?p+360:p;let d=hM(p);r.mutateElement(s,{angle:d}),bM(s,r,i.state);let u=gM(s,l);u&&!fM(s)&&r.mutateElement(u,{angle:d})}},oU=({element:e,scene:o,appState:t,property:n})=>nU(dt,{label:"A",icon:Xc,value:Math.round(xM(e.angle)%360*100)/100,elements:[e],dragInputCallback:tU,editable:zt(e,"angle"),scene:o,appState:t,property:n}),yM=oU;import{jsx as iU}from"react/jsx-runtime";var EM=5,rU=({property:e,scene:o,appState:t,setAppState:n})=>iU(dt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:l,setInputValue:a})=>{n(s=>{let c;return r?c=r:i&&(c=l?Oe(s.gridStep+EM*Math.sign(i),EM):s.gridStep+i),c?(c=Dy(c),a(c),{gridStep:c}):(a(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),vM=rU;import{clamp as Fp,round as ox}from"@hellixit/math";import{MIN_WIDTH_OR_HEIGHT as Op}from"@hellixit/common";import{MINIMAL_CROP_SIZE as TM,getUncroppedWidthAndHeight as SM}from"@hellixit/element";import{resizeSingleElement as IM}from"@hellixit/element";import{isImageElement as wM}from"@hellixit/element";import{isFrameLikeElement as nx}from"@hellixit/element";import{getElementsInResizingFrame as rx}from"@hellixit/element";import{replaceAllElementsInFrame as kM}from"@hellixit/element";import{jsx as dU}from"react/jsx-runtime";var CM=10,aU=e=>e.type==="image",lU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:l,originalAppState:a,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),u=o[0],b=d.get(u.id);if(u&&b){let g=n||aU(u),x=u.width/u.height;if(a.croppingElementId===u.id){let v=d.get(u.id);if(!v||!wM(v)||!v.crop)return;let y=v.crop,E={...y},T=v.scale[0]===-1,I=v.scale[1]===-1,{width:S,height:M}=SM(v),k=y.naturalWidth/S,_=y.naturalHeight/M,P=T?y.width+y.x:y.naturalWidth-y.x,A=I?y.height+y.y:y.naturalHeight-y.y,H=TM*k,F=TM*_;if(i!==void 0){if(l==="width"){let B=i*k,W=Fp(B,H,P);E={...E,width:W,x:T?y.x+y.width-W:y.x}}else if(l==="height"){let B=i*_,W=Fp(B,F,A);E={...E,height:W,y:I?y.y+y.height-W:y.y}}c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/S),height:E.height/(y.naturalHeight/M)});return}let Y=l==="width"?s:0,V=l==="height"?s:0,U=Fp(y.width+Y,H,P),D=Fp(y.height+V,H,A);E={...y,x:T?y.x+y.width-U:y.x,y:I?y.y+y.height-D:y.y,width:U,height:D},c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/S),height:E.height/(y.naturalHeight/M)});return}if(i!==void 0){let v=Math.max(l==="width"?i:g?i*x:u.width,Op),y=Math.max(l==="height"?i:g?i/x:u.height,Op);if(IM(v,y,b,u,t,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:g}),nx(b)){let E=rx(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap()),T=kM(c.getElementsIncludingDeleted(),E,b,m);c.replaceAllElements(T)}return}{let v=l==="width"?e:0,y=l==="height"?e:0,E=Math.max(0,u.width+v);l==="width"&&(r?E=Oe(E,CM):E=Math.round(E));let T=Math.max(0,u.height+y);if(l==="height"&&(r?T=Oe(T,CM):T=Math.round(T)),g&&(l==="width"?T=Math.round(E/x*100)/100:E=Math.round(T*x*100)/100),T=Math.max(Op,T),E=Math.max(Op,E),IM(E,T,b,u,t,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:g}),nx(b)){let I=rx(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},sU=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],l=i&&r.get(i.id);if(l&&nx(l)){let a=rx(o.scene.getElementsIncludingDeleted(),l,n,o.scene.getNonDeletedElementsMap()),s=kM(o.scene.getElementsIncludingDeleted(),a,l,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},cU=({property:e,element:o,scene:t,appState:n})=>{let r=ox(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&wM(o)&&o.crop){let{width:i,height:l}=SM(o);if(e==="width"){let a=i/o.crop.naturalWidth;r=ox(o.crop.width*a,2)}if(e==="height"){let a=l/o.crop.naturalHeight;r=ox(o.crop.height*a,2)}}return dU(dt,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:lU,value:r,editable:zt(o,e),scene:t,appState:n,property:e,dragFinishedCallback:sU})},ix=cU;import{getBoundTextElement as mU,redrawTextBoundingBox as pU}from"@hellixit/element";import{hasBoundTextElement as uU,isTextElement as PM}from"@hellixit/element";import{jsx as bU}from"react/jsx-runtime";var MM=4,hU=4,gU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),l=o[0];if(l){let a=i.get(l.id);if(!a||!PM(a))return;let s;if(n!==void 0)s=Math.max(Math.round(n),MM);else if(l.type==="text"){let c=Math.round(l.fontSize),m=Math.round(e);s=Math.max(c+m,MM),t&&(s=Oe(s,hU))}s&&(r.mutateElement(a,{fontSize:s}),pU(a,r.getContainerElement(a),r))}},fU=({element:e,scene:o,appState:t,property:n})=>{let r=PM(e)?e:uU(e)?mU(e,o.getNonDeletedElementsMap()):null;return r?bU(dt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:gU,icon:Br,appState:t,scene:o,property:n}):null},AM=fU;import{degreesToRadians as LM,radiansToDegrees as HM}from"@hellixit/math";import{getBoundTextElement as _M}from"@hellixit/element";import{isArrowElement as DM}from"@hellixit/element";import{isInGroup as ax}from"@hellixit/element";import{jsx as vU}from"react/jsx-runtime";var xU=15,yU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let l=i.getNonDeletedElementsMap(),a=o.map(c=>l.get(c.id)).filter(c=>c&&!ax(c)&&zt(c,r)),s=o.filter(c=>!ax(c)&&zt(c,r));if(n!==void 0){let c=LM(n);for(let m of a){if(!m)continue;i.mutateElement(m,{angle:c});let p=_M(m,l);p&&!DM(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<a.length;c++){let m=a[c];if(!m)continue;let p=s[c],d=Math.round(HM(p.angle)*100)/100,u=Math.round(e),b=(d+u)%360;t&&(b=Oe(b,xU)),b=b<0?b+360:b;let g=LM(b);i.mutateElement(m,{angle:g});let x=_M(m,l);x&&!DM(m)&&i.mutateElement(x,{angle:g})}i.triggerUpdate()},EU=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!ax(s)&&zt(s,"angle")),i=r.map(s=>Math.round(HM(s.angle)%360*100)/100),l=new Set(i).size===1?i[0]:"Mixed",a=r.some(s=>zt(s,"angle"));return vU(dt,{label:"A",icon:Xc,value:l,elements:e,dragInputCallback:yU,editable:a,appState:t,scene:o,property:n})},RM=EU;import{pointFrom as NM}from"@hellixit/math";import{useMemo as TU}from"react";import{MIN_WIDTH_OR_HEIGHT as yr}from"@hellixit/common";import{getElementsInResizingFrame as lx,isFrameLikeElement as sx,replaceAllElementsInFrame as OM,updateBoundElements as IU}from"@hellixit/element";import{rescalePointsInElement as CU,resizeSingleElement as BM}from"@hellixit/element";import{getBoundTextElement as SU,handleBindTextResize as wU}from"@hellixit/element";import{isTextElement as zM}from"@hellixit/element";import{jsx as _U}from"react/jsx-runtime";var ll=10,kU=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,l=n.width*t,a=n.height*t,s=e+r*t,c=o+i*t;return{width:l,height:a,x:s,y:c,...CU(n,l,a,!1),...zM(n)?{fontSize:n.fontSize*t}:{}}},MU=(e,o,t,n,r,i,l,a)=>{let s=a.getNonDeletedElementsMap(),c=kU(e,o,n,i);a.mutateElement(r,c);let m=SU(i,l);if(m){let p=m.fontSize*n;IU(r,a);let d=s.get(m.id);d&&zM(d)&&(a.mutateElement(d,{fontSize:p}),wU(r,a,t==="width"?"e":"s",!0))}},FM=(e,o,t,n,r,i,l,a,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<a.length;p++){let d=a[p],u=l[p];MU(r[0],r[1],i,m,u,d,s,c)}},PU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:l,property:a,setAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=il(o,n);if(i!==void 0){for(let g of p){let x=rl(g,m,t);if(x.length>1){let v=x.map(H=>H.latest),y=x.map(H=>H.original),[E,T,I,S]=kp(y),M=I-E,k=S-T,_=M/k,P=Math.max(yr,a==="width"?Math.max(0,i):M),A=Math.max(yr,a==="height"?Math.max(0,i):k);FM(P,A,k,_,NM(E,T),a,v,y,t,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&zt(y,a)){let T=a==="width"?Math.max(0,i):y.width;a==="width"&&(r?T=Oe(T,ll):T=Math.round(T));let I=a==="height"?Math.max(0,i):y.height;if(a==="height"&&(r?I=Oe(I,ll):I=Math.round(I)),T=Math.max(yr,T),I=Math.max(yr,I),BM(T,I,y,E,t,l,a==="width"?"e":"s",{shouldInformMutation:!1}),sx(y)){let S=lx(l.getElementsIncludingDeleted(),y,n,l.getNonDeletedElementsMap()),M=OM(l.getElementsIncludingDeleted(),S,y,c);l.replaceAllElements(M)}}}}l.triggerUpdate();return}let d=a==="width"?e:0,u=a==="height"?e:0,b=[];for(let g of p){let x=rl(g,m,t);if(x.length>1){let v=x.map(H=>H.latest),y=x.map(H=>H.original),[E,T,I,S]=kp(y),M=I-E,k=S-T,_=M/k,P=Math.max(0,M+d);a==="width"&&(r?P=Oe(P,ll):P=Math.round(P));let A=Math.max(0,k+u);a==="height"&&(r?A=Oe(A,ll):A=Math.round(A)),P=Math.max(yr,P),A=Math.max(yr,A),FM(P,A,k,_,NM(E,T),a,v,y,t,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&zt(y,a)){let T=Math.max(0,E.width+d);a==="width"&&(r?T=Oe(T,ll):T=Math.round(T));let I=Math.max(0,E.height+u);if(a==="height"&&(r?I=Oe(I,ll):I=Math.round(I)),T=Math.max(yr,T),I=Math.max(yr,I),BM(T,I,y,E,t,l,a==="width"?"e":"s",{shouldInformMutation:!1}),sx(y)){let S=lx(l.getElementsIncludingDeleted(),y,n,l.getNonDeletedElementsMap());b.push(...S)}}}}s({elementsToHighlight:b}),l.triggerUpdate()},AU=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],l=i&&r.get(i.id);if(l&&sx(l)){let a=lx(o.scene.getElementsIncludingDeleted(),l,n,o.scene.getNonDeletedElementsMap()),s=OM(o.scene.getElementsIncludingDeleted(),a,l,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},LU=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let l=TU(()=>n.map(c=>{let m=rl(c,t);if(m.length>1){let[d,u,b,g]=kp(m.map(x=>x.latest));return Math.round((e==="width"?b-d:g-u)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,n,e]),a=new Set(l).size===1?Math.round(l[0]*100)/100:"Mixed",s=l.length>0;return _U(dt,{label:e==="width"?"W":"H",elements:o,dragInputCallback:PU,value:a,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:AU})},cx=LU;import{getBoundTextElement as DU,redrawTextBoundingBox as GM}from"@hellixit/element";import{hasBoundTextElement as HU,isTextElement as RU}from"@hellixit/element";import{isInGroup as NU}from"@hellixit/element";import{jsx as GU}from"react/jsx-runtime";var UM=4,BU=4,FU=(e,o)=>e.reduce((t,n)=>{if(!n||NU(n))return t;if(RU(n))return t.push(n),t;if(HU(n)){let r=DU(n,o);if(r)return t.push(r),t}return t},[]),OU=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),l=o.map(s=>i.get(s.id)),a;if(n){a=Math.max(Math.round(n),UM);for(let s of l)r.mutateElement(s,{fontSize:a}),GM(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<l.length;c++){let m=l[c],p=s[c],d=Math.round(p.fontSize),u=Math.round(e),b=Math.max(d+u,UM);t&&(b=Oe(b,BU)),r.mutateElement(m,{fontSize:b}),GM(m,r.getContainerElement(m),r)}r.triggerUpdate()}},zU=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=FU(e,r);if(!i.length)return null;let l=i.map(c=>Math.round(c.fontSize*10)/10),a=new Set(l).size===1?l[0]:"Mixed",s=l.length>0;return GU(dt,{label:"F",icon:Br,elements:i,dragInputCallback:OU,value:a,editable:s,scene:o,property:n,appState:t})},WM=zU;import{pointFrom as Er,pointRotateRads as zp}from"@hellixit/math";import{useMemo as UU}from"react";import{isTextElement as WU}from"@hellixit/element";import{getCommonBounds as dx}from"@hellixit/element";import{jsx as $U}from"react/jsx-runtime";var YU=(e,o,t,n,r,i,l)=>{for(let a=0;a<n.length;a++){let s=n[a],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=zp(Er(s.x,s.y),Er(c,m),s.angle),u=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(d+t):d;pi(u,b,s,i,l,r,!1)}},VU=(e,o,t,n,r,i)=>{let l=r.getNonDeletedElementsMap(),[a,s,,]=dx(t),c=e-a,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],u=l.get(d.id);if(u&&(!WU(u)||!u.containerId)){let[b,g]=[u.x+u.width/2,u.y+u.height/2],[x,v]=zp(Er(u.x,u.y),Er(b,g),u.angle);pi(x+c,v+m,d,r,i,n,!1)}}},XU=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:l,originalAppState:a,app:s})=>{let c=l.getNonDeletedElementsMap();if(r!==void 0){for(let u of il(o,a)){let b=rl(u,c,t);if(b.length>1){let[g,x,,]=dx(b.map(E=>E.latest));VU(i==="x"?r:g,i==="y"?r:x,b.map(E=>E.original),t,l,s.state)}else{let g=b[0]?.original,x=b[0]?.latest;if(g&&x&&zt(x,i)){let[v,y]=[g.x+g.width/2,g.y+g.height/2],[E,T]=zp(Er(g.x,g.y),Er(v,y),g.angle);pi(i==="x"?r:E,i==="y"?r:T,g,l,s.state,t,!1)}}}l.triggerUpdate();return}let m=n?Oe(e,tc):e;YU(i,i==="x"?m:0,i==="y"?m:0,o,t,l,s.state),l.triggerUpdate()},KU=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let l=UU(()=>n.map(s=>{let c=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,x]=dx(c);return Math.round((e==="x"?g:x)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[u,b]=zp(Er(m.x,m.y),Er(p,d),m.angle);return Math.round((e==="x"?u:b)*100)/100}),[n,t,e]),a=new Set(l).size===1?l[0]:"Mixed";return $U(dt,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:XU,value:a,property:e,scene:r,appState:i})},mx=KU;import{clamp as oc,pointFrom as Gp,pointRotateRads as VM,round as YM}from"@hellixit/math";import{getFlipAdjustedCropPosition as ZU,getUncroppedWidthAndHeight as jU}from"@hellixit/element";import{isImageElement as XM}from"@hellixit/element";import{jsx as QU}from"react/jsx-runtime";var qU=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:l,scene:a,originalAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=t[0],[d,u]=[p.x+p.width/2,p.y+p.height/2],[b,g]=VM(Gp(p.x,p.y),Gp(d,u),p.angle);if(s.croppingElementId===p.id){let T=m.get(p.id);if(!T||!XM(T)||!T.crop)return;let I=T.crop,S=I,M=T.scale[0]===-1,k=T.scale[1]===-1,{width:_,height:P}=jU(T);if(i!==void 0){if(l==="x"){let F=i*(I.naturalWidth/_);M?S={...I,x:oc(I.naturalWidth-F-I.width,0,I.naturalWidth-I.width)}:S={...I,x:oc(i*(I.naturalWidth/_),0,I.naturalWidth-I.width)}}l==="y"&&(S={...I,y:oc(i*(I.naturalHeight/P),0,I.naturalHeight-I.height)}),a.mutateElement(T,{crop:S});return}let A=(l==="x"?o:0)*(M?-1:1),H=(l==="y"?o:0)*(k?-1:1);S={...I,x:oc(I.x+A,0,I.naturalWidth-I.width),y:oc(I.y+H,0,I.naturalHeight-I.height)},a.mutateElement(T,{crop:S});return}if(i!==void 0){pi(l==="x"?i:b,l==="y"?i:g,p,a,c.state,n);return}let x=l==="x"?e:0,v=l==="y"?e:0,y=l==="x"?Math.round(r?Oe(p.x+x,tc):b+x):b,E=l==="y"?Math.round(r?Oe(p.y+v,tc):g+v):g;pi(y,E,p,a,c.state,n)},JU=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,l]=VM(Gp(o.x,o.y),Gp(o.x+o.width/2,o.y+o.height/2),o.angle),a=YM(e==="x"?i:l,2);if(r.croppingElementId===o.id&&XM(o)&&o.crop){let s=ZU(o);s&&(a=YM(e==="x"?s.x:s.y,2))}return QU(dt,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:qU,scene:n,value:a,property:e,appState:r})},px=JU;import{Fragment as gx,jsx as ne,jsxs as Gt}from"react/jsx-runtime";var sW=50,nc=e=>{let o=Xo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=cr(e.app);return ne(cW,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Re=({children:e,columns:o=1,heading:t,style:n,...r})=>ne("div",{className:eW("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Re.displayName="StatsRow";var Wp=({children:e,order:o,style:t,...n})=>ne("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});Wp.displayName="StatsRows";nc.StatsRow=Re;nc.StatsRows=Wp;var cW=nW(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:l})=>{let a=e.scene,s=a.getNonDeletedElements(),c=a.getNonDeletedElementsMap(),m=he(),p=n.length===1?n[0]:null,d=n.length>1?n:null,u=r.croppingElementId&&hx(p),b=u?iW(p):null,[g,x]=oW({width:0,height:0}),v=ux(()=>tW(T=>{let I=rW(T);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},sW),[]);$M(()=>{v(s)},[i,s,v]),$M(()=>()=>v.cancel(),[v]);let y=ux(()=>il(n,r),[n,r]),E=ux(()=>aW(n),[n]);return ne("div",{className:"exc-stats",children:Gt(Xe,{padding:3,children:[Gt("div",{className:"title",children:[ne("h2",{children:h("stats.title")}),ne("div",{className:"close",onClick:o,children:Qt})]}),Gt(Jl,{label:ne("h3",{children:h("stats.generalStats")}),open:!!(r.stats.panels&Up.generalStats),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Up.generalStats}})),children:[Gt(Wp,{children:[ne(Re,{heading:!0,children:h("stats.scene")}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.shapes")}),ne("div",{children:s.length})]}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.width")}),ne("div",{children:g.width})]}),Gt(Re,{columns:2,children:[ne("div",{children:h("stats.height")}),ne("div",{children:g.height})]}),l&&Gt(gx,{children:[ne(Re,{heading:!0,children:"Canvas"}),ne(Re,{children:ne(vM,{property:"gridStep",scene:a,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!E&&n.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Jl,{label:ne("h3",{children:h("stats.elementProperties")}),open:!!(r.stats.panels&Up.elementProperties),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Up.elementProperties}})),children:Gt(Wp,{children:[p&&Gt(gx,{children:[u&&ne(Re,{heading:!0,children:h("labels.unCroppedDimension")}),r.croppingElementId&&hx(p)&&b&&Gt(Re,{columns:2,children:[ne("div",{children:h("stats.width")}),ne("div",{children:KM(b.width,2)})]}),r.croppingElementId&&hx(p)&&b&&Gt(Re,{columns:2,children:[ne("div",{children:h("stats.height")}),ne("div",{children:KM(b.height,2)})]}),ne(Re,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?h("labels.imageCropping"):h(`element.${p.type}`)}),ne(Re,{children:ne(px,{element:p,property:"x",elementsMap:c,scene:a,appState:r})}),ne(Re,{children:ne(px,{element:p,property:"y",elementsMap:c,scene:a,appState:r})}),ne(Re,{children:ne(ix,{property:"width",element:p,scene:a,appState:r})}),ne(Re,{children:ne(ix,{property:"height",element:p,scene:a,appState:r})}),ne(Re,{children:ne(yM,{property:"angle",element:p,scene:a,appState:r})}),ne(Re,{children:ne(AM,{property:"fontSize",element:p,scene:a,appState:r})})]}),d&&Gt(gx,{children:[lW(d)&&ne(Re,{heading:!0,children:h("element.group")}),Gt(Re,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:h("stats.shapes")}),ne("div",{children:n.length})]}),ne(Re,{children:ne(mx,{property:"x",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(mx,{property:"y",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(cx,{property:"width",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(cx,{property:"height",elements:d,elementsMap:c,atomicUnits:y,scene:a,appState:r})}),ne(Re,{children:ne(RM,{property:"angle",elements:d,scene:a,appState:r})}),ne(Re,{children:ne(WM,{property:"fontSize",elements:d,scene:a,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as dW,useEffect as ZM,useState as jM}from"react";import{normalizeLink as mW,KEYS as fx}from"@hellixit/common";import{defaultGetElementLinkFromSelection as pW,getLinkIdAndTypeFromSelection as uW}from"@hellixit/element";import{jsx as sl,jsxs as Yp}from"react/jsx-runtime";var hW=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=pW})=>{let i=n.getNonDeletedElementsMap(),l=i.get(e)?.link??null,[a,s]=jM(l),[c,m]=jM(!1);ZM(()=>{let d=oe(i,t),u=l;if(d.length>0&&r){let b=uW(d,t);b&&(u=mW(r(b.id,b.type)))}s(u)},[i,t,t.selectedElementIds,l,r]);let p=dW(()=>{if(a&&a!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:a})}if(!a&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,a,i,c,n,o]);return ZM(()=>{let d=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===fx.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===fx.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),Yp("div",{className:"ElementLinkDialog",children:[Yp("div",{className:"ElementLinkDialog__header",children:[sl("h2",{children:h("elementLink.title")}),sl("p",{children:h("elementLink.desc")})]}),Yp("div",{className:"ElementLinkDialog__input",children:[sl(ar,{value:a??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===fx.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),l&&a&&sl(J,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:pt})]}),Yp("div",{className:"ElementLinkDialog__actions",children:[sl(kn,{label:h("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),sl(kn,{label:h("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},qM=hW;import gW,{useState as fW}from"react";import{Fragment as bW,jsx as bx}from"react/jsx-runtime";var JM=({children:e,onClose:o})=>{let[t,n]=fW(!!e),{container:r}=_e(),i=gW.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return bx(bW,{children:t&&bx(je,{size:"small",onCloseRequest:i,title:h("errorDialog.title"),children:bx("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import xW from"react";import{isDarwin as QM,isFirefox as eP,isWindows as yW}from"@hellixit/common";import{KEYS as Ye}from"@hellixit/common";import{Fragment as oP,jsx as G,jsxs as Ut}from"react/jsx-runtime";var EW=({onReportIssue:e})=>Ut("div",{className:"HelpDialog__header",children:[Ut("a",{className:"HelpDialog__btn",href:"#",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),h("helpDialog.documentation")]}),Ut("a",{className:"HelpDialog__btn",href:"#",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),h("helpDialog.blog")]}),Ut("a",{className:"HelpDialog__btn",href:"https://www.hellixit.cloud",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:zc}),"Website"]}),e&&Ut("button",{className:"HelpDialog__btn",onClick:e,style:{cursor:"pointer"},type:"button",children:[G("div",{className:"HelpDialog__link-icon",children:Ut("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[G("circle",{cx:"12",cy:"12",r:"10"}),G("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),G("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),"Found an issue? Submit"]})]}),vW=e=>Ut(oP,{children:[G("h3",{children:e.title}),G("div",{className:"HelpDialog__islands-container",children:e.children})]}),Vp=e=>Ut("div",{className:`HelpDialog__island ${e.className}`,children:[G("h4",{className:"HelpDialog__island-title",children:e.caption}),G("div",{className:"HelpDialog__island-content",children:e.children})]});function*TW(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var IW=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(l=>G(CW,{children:IW(l)},l)));return Ut("div",{className:"HelpDialog__shortcut",children:[G("div",{children:e}),G("div",{className:"HelpDialog__key-container",children:[...TW(n,t?h("helpDialog.or"):null)]})]})},CW=e=>G("kbd",{className:"HelpDialog__key",...e}),tP=({onClose:e,onReportIssue:o})=>{let t=xW.useCallback(()=>{e&&e()},[e]);return G(oP,{children:Ut(je,{onCloseRequest:t,title:h("helpDialog.title"),className:"HelpDialog",children:[G(EW,{onReportIssue:o}),Ut(vW,{title:h("helpDialog.shortcuts"),children:[Ut(Vp,{className:"HelpDialog__island--tools",caption:h("helpDialog.tools"),children:[G($,{label:h("toolBar.hand"),shortcuts:[Ye.H]}),G($,{label:h("toolBar.selection"),shortcuts:[Ye.V,Ye[1]]}),G($,{label:h("toolBar.rectangle"),shortcuts:[Ye.R,Ye[2]]}),G($,{label:h("toolBar.diamond"),shortcuts:[Ye.D,Ye[3]]}),G($,{label:h("toolBar.ellipse"),shortcuts:[Ye.O,Ye[4]]}),G($,{label:h("toolBar.arrow"),shortcuts:[Ye.A,Ye[5]]}),G($,{label:h("toolBar.line"),shortcuts:[Ye.L,Ye[6]]}),G($,{label:h("toolBar.freedraw"),shortcuts:[Ye.P,Ye[7]]}),G($,{label:h("toolBar.text"),shortcuts:[Ye.T,Ye[8]]}),G($,{label:h("toolBar.image"),shortcuts:[Ye[9]]}),G($,{label:h("toolBar.eraser"),shortcuts:[Ye.E,Ye[0]]}),G($,{label:h("toolBar.frame"),shortcuts:[Ye.F]}),G($,{label:h("toolBar.laser"),shortcuts:[Ye.K]}),G($,{label:h("labels.eyeDropper"),shortcuts:[Ye.I,"Shift+S","Shift+G"]}),G($,{label:h("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),G($,{label:h("helpDialog.editText"),shortcuts:[N("Enter")]}),G($,{label:h("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),G($,{label:h("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),G($,{label:h("helpDialog.curvedArrow"),shortcuts:["A",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),G($,{label:h("helpDialog.curvedLine"),shortcuts:["L",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),G($,{label:h("helpDialog.cropStart"),shortcuts:[h("helpDialog.doubleClick"),N("Enter")],isOr:!0}),G($,{label:h("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),G($,{label:h("toolBar.lock"),shortcuts:[Ye.Q]}),G($,{label:h("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),G($,{label:h("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),G($,{label:h("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ut(Vp,{className:"HelpDialog__island--view",caption:h("helpDialog.view"),children:[G($,{label:h("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),G($,{label:h("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),G($,{label:h("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),G($,{label:h("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),G($,{label:h("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),G($,{label:h("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),G($,{label:h("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),G($,{label:h("buttons.zenMode"),shortcuts:[N("Alt+Z")]}),G($,{label:h("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),G($,{label:h("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),G($,{label:h("labels.viewMode"),shortcuts:[N("Alt+R")]}),G($,{label:h("labels.toggleTheme"),shortcuts:[N("Alt+Shift+D")]}),G($,{label:h("stats.fullTitle"),shortcuts:[N("Alt+/")]}),G($,{label:h("search.title"),shortcuts:[Le("searchMenu")]}),G($,{label:"Search canvas globally",shortcuts:[N("CtrlOrCmd+Shift+F")]}),G($,{label:"Open workspaces",shortcuts:["Shift+W"]}),G($,{label:h("commandPalette.title"),shortcuts:eP?[Le("commandPalette")]:[Le("commandPalette"),Le("commandPalette",1)]})]}),Ut(Vp,{className:"HelpDialog__island--editor",caption:h("helpDialog.editor"),children:[G($,{label:h("helpDialog.createFlowchart"),shortcuts:[N("CtrlOrCmd+Arrow Key")],isOr:!0}),G($,{label:h("helpDialog.navigateFlowchart"),shortcuts:[N("Alt+Arrow Key")],isOr:!0}),G($,{label:h("labels.moveCanvas"),shortcuts:[N(`Space+${h("helpDialog.drag")}`),N(`Wheel+${h("helpDialog.drag")}`)],isOr:!0}),G($,{label:h("buttons.clearReset"),shortcuts:[N("CtrlOrCmd+Delete")]}),G($,{label:h("labels.delete"),shortcuts:[N("Delete")]}),G($,{label:h("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),G($,{label:h("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),G($,{label:h("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),G($,{label:h("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),G($,{label:h("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),G($,{label:h("labels.multiSelect"),shortcuts:[N(`Shift+${h("helpDialog.click")}`)]}),G($,{label:h("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${h("helpDialog.click")}`)]}),G($,{label:h("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${h("helpDialog.drag")}`)]}),(oa||eP)&&G($,{label:h("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),G($,{label:h("labels.copyStyles"),shortcuts:[N("CtrlOrCmd+Alt+C")]}),G($,{label:h("labels.pasteStyles"),shortcuts:[N("CtrlOrCmd+Alt+V")]}),G($,{label:h("labels.sendToBack"),shortcuts:[QM?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),G($,{label:h("labels.bringToFront"),shortcuts:[QM?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),G($,{label:h("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),G($,{label:h("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),G($,{label:h("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),G($,{label:h("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),G($,{label:h("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),G($,{label:h("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),G($,{label:h("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${h("helpDialog.drag")}`)]}),G($,{label:h("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),G($,{label:h("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),G($,{label:h("buttons.redo"),shortcuts:yW?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),G($,{label:h("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),G($,{label:h("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),G($,{label:h("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),G($,{label:h("labels.flipVertical"),shortcuts:[N("Shift+V")]}),G($,{label:h("labels.showStroke"),shortcuts:[N("S")]}),G($,{label:h("labels.showBackground"),shortcuts:[N("G")]}),G($,{label:h("labels.showFonts"),shortcuts:[N("Shift+F")]}),G($,{label:h("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),G($,{label:h("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]}),G(Vp,{className:"HelpDialog__island--collab",caption:h("helpDialog.collaboration"),children:G($,{label:h("helpDialog.cursorChat"),shortcuts:["/"]})})]})]})})};import{CANVAS_SEARCH_TAB as SW,DEFAULT_SIDEBAR as wW}from"@hellixit/common";import{isFlowchartNodeElement as kW,isImageElement as nP,isLinearElement as rP,isLineElement as MW,isTextBindableContainer as PW,isTextElement as AW}from"@hellixit/element";import{isNodeInFlowchart as LW}from"@hellixit/element";import{jsx as xx}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,_W=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:l,lastPointerDownWith:a}=e,s=e.multiElement!==null;if(e.openSidebar?.name===wW.name&&e.openSidebar.tab===SW&&e.searchMatches?.matches.length)return h("hints.dismissSearch",{shortcut:Se("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Ht(e))return h("hints.eraserRevert",{shortcut:Se("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return h("hints.arrowBindModifiers",{shortcut_1:Se("Ctrl"),shortcut_2:Se("Alt")});if(r.type==="arrow"||r.type==="line")return s?h("hints.linearElementMulti",{shortcut_1:Se("Escape"),shortcut_2:Se("Enter")}):r.type==="arrow"?h("hints.arrowTool",{shortcut:Se("A")}):h("hints.linearElement");if(r.type==="freedraw")return h("hints.freeDraw");if(r.type==="text")return h("hints.text");if(r.type==="embeddable")return h("hints.embeddable");if(i&&a==="mouse"&&c.length===1){let m=c[0];return rP(m)&&m.points.length===2?h("hints.lockAngle",{shortcut:Se("Shift")}):nP(m)?h("hints.resizeImage",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):h("hints.resize",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")})}if(l&&a==="mouse")return h("hints.rotate",{shortcut:Se("Shift")});if(c.length===1&&AW(c[0]))return h("hints.text_selected",{shortcut:Se("Enter")});if(e.editingTextElement)return h("hints.text_editing",{shortcut_1:Se("Escape"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return h("hints.leaveCropEditor",{shortcut_1:Se("Enter"),shortcut_2:Se("Escape")});if(c.length===1&&nP(c[0]))return h("hints.enterCropEditor",{shortcut:Se("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return h("hints.deepBoxSelect",{shortcut:Se("CtrlOrCmd")});if(cr(n)&&e.selectedElementsAreBeingDragged)return h("hints.disableSnapping",{shortcut:Se("CtrlOrCmd")});if(!c.length&&!o)return h("hints.canvasPanning",{shortcut_1:Se(h("keys.mmb")),shortcut_2:Se("Space")});if(c.length===1){if(rP(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?h("hints.lineEditor_pointSelected",{shortcut_1:Se("Delete"),shortcut_2:Se(["CtrlOrCmd","D"])}):h("hints.lineEditor_nothingSelected",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):MW(c[0])?h("hints.lineEditor_line_info",{shortcut:Se("Enter")}):h("hints.lineEditor_info",{shortcut_1:Se("CtrlOrCmd"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&PW(c[0])){let m=h("hints.bindTextToElement",{shortcut:Se("Enter")}),p=h("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return kW(c[0])?LW(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},iP=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=_W({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let l=(Array.isArray(r)?r.map(a=>a.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((a,s)=>{if(s%2===1){let c=a[0]==="<"&&a.match(/^<kbd>([^<]+)<\/kbd>$/);return xx("kbd",{children:c?c[1]:a},s)}return a});return xx("div",{className:"HintViewer",children:xx("span",{children:l})})};import{useEffect as sP,useRef as cP,useState as ui}from"react";import{DEFAULT_EXPORT_PADDING as FW,EXPORT_IMAGE_TYPES as yx,isFirefox as OW,EXPORT_SCALES as zW,cloneJSON as dP}from"@hellixit/common";import{useCallback as DW,useRef as HW,useState as RW}from"react";var NW=2e3,aP=()=>{let[e,o]=RW(null),t=HW(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},NW)},r=DW(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import BW from"clsx";import{jsx as lP}from"react/jsx-runtime";var rc=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>lP("div",{className:BW("Switch",{toggled:t,disabled:r}),children:lP("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Ne,jsxs as vr}from"react/jsx-runtime";var GW=()=>vr("div",{children:[Ne("h3",{children:h("canvasError.cannotShowPreview")}),Ne("p",{children:Ne("span",{children:h("canvasError.canvasTooBig")})}),vr("em",{children:["(",h("canvasError.canvasTooBigTip"),")"]})]}),UW=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i,exportWithDarkMode:l})=>{let a=Me(o,e),[s,c]=ui(i),[m,p]=ui(a),[d,u]=ui(e.exportBackground),[b,g]=ui(e.exportEmbedScene),[x,v]=ui(e.exportScale),y=cP(null),E=cP(0),[T,I]=ui(null),{onCopy:S,copyStatus:M,resetCopyStatus:k}=aP();sP(()=>{k()},[s,d,l,x,b,k]);let{exportedElements:_,exportingFrame:P}=Ur(o,e,m);return sP(()=>{let A=y.current;if(!A)return;let H=A.offsetWidth,F=A.offsetHeight;if(!H)return;let Y=++E.current,V=()=>Y!==E.current;return nr({elements:_,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:l,exportScale:x,exportEmbedScene:b},files:t,exportPadding:FW,maxWidthOrHeight:Math.max(H,F),exportingFrame:P}).then(async U=>{if(!V()){try{await Dr(U)}catch(D){throw D.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):D}V()||(I(null),A.replaceChildren(U))}}).catch(U=>{V()||(console.error(U),I(U))}),()=>{E.current+=1}},[e,t,_,P,s,d,l,x,b]),vr("div",{className:"ImageExportModal",children:[Ne("h3",{children:h("imageExportDialog.header")}),vr("div",{className:"ImageExportModal__preview",children:[Ne("div",{className:"ImageExportModal__preview__canvas",ref:y,children:T&&Ne(GW,{})}),Ne("div",{className:"ImageExportModal__preview__filename",children:!vi&&Ne("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:A=>{c(A.target.value),n.executeAction(Vh,"ui",A.target.value)}})})]}),vr("div",{className:"ImageExportModal__settings",children:[Ne("h3",{children:h("imageExportDialog.header")}),a&&Ne(ic,{label:h("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ne(rc,{name:"exportOnlySelected",checked:m,onChange:A=>{p(A)}})}),Ne(ic,{label:h("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ne(rc,{name:"exportBackgroundSwitch",checked:d,onChange:A=>{u(A),n.executeAction(Xh,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ne(rc,{name:"exportDarkModeSwitch",checked:l,onChange:A=>{n.executeAction(Fv,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.embedScene"),tooltip:h("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ne(rc,{name:"exportEmbedSwitch",checked:b,onChange:A=>{g(A),n.executeAction(Bd,"ui",A)}})}),Ne(ic,{label:h("imageExportDialog.label.scale"),name:"exportScale",children:Ne(gp,{name:"exportScale",value:x,onChange:A=>{v(A),n.executeAction(Nv,"ui",A)},choices:zW.map(A=>({value:A,label:`${A}\xD7`}))})}),vr("div",{className:"ImageExportModal__settings__buttons",children:[Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToPng"),onClick:()=>r(yx.png,_,{exportingFrame:P}),icon:Yu,children:h("imageExportDialog.button.exportToPng")}),Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToSvg"),onClick:()=>r(yx.svg,_,{exportingFrame:P}),icon:Yu,children:h("imageExportDialog.button.exportToSvg")}),(oa||OW)&&Ne(sn,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.copyPngToClipboard"),status:M,onClick:async()=>{await r(yx.clipboard,_,{exportingFrame:P}),S()},icon:Bi,children:h("imageExportDialog.button.copyPngToClipboard")})]})]})]})},ic=({label:e,children:o,tooltip:t,name:n})=>vr("div",{className:"ImageExportModal__settings__setting",title:e,children:[vr("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ne($t,{label:t,long:!0,children:yE})]}),Ne("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),mP=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:l})=>{let[{appStateSnapshot:a,elementsSnapshot:s}]=ui(()=>({appStateSnapshot:dP(o),elementsSnapshot:dP(e)}));return Ne(je,{onCloseRequest:i,size:"wide",title:!1,children:Ne(UW,{elementsSnapshot:s,appStateSnapshot:a,files:t,actionManager:n,onExportImage:r,name:l,exportWithDarkMode:o.exportWithDarkMode})})};import YW from"react";import{getFrame as VW}from"@hellixit/common";import{jsx as WW}from"react/jsx-runtime";var Ex={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},vx=({children:e,color:o})=>WW("div",{className:"Card",style:{"--card-color":Ex[o].base,"--card-color-darker":Ex[o].darker,"--card-color-darkest":Ex[o].darkest},children:e});import{Fragment as KW,jsx as Do,jsxs as Xp}from"react/jsx-runtime";var XW=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:l,onCloseRequest:a})=>{let{onExportToBackend:s}=i;return Do("div",{className:"ExportDialog ExportDialog--json",children:Xp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Xp(vx,{color:"lime",children:[Do("div",{className:"Card-icon",children:I0}),Do("h2",{children:h("exportDialog.disk_title")}),Xp("div",{className:"Card-details",children:[h("exportDialog.disk_details"),!vi&&r.renderAction("changeProjectName")]}),Do(J,{className:"Card-button",type:"button",title:h("exportDialog.disk_button"),"aria-label":h("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ls,"ui")}})]}),s&&Xp(vx,{color:"pink",children:[Do("div",{className:"Card-icon",children:Rl}),Do("h2",{children:h("exportDialog.link_title")}),Do("div",{className:"Card-details",children:h("exportDialog.link_details")}),Do(J,{className:"Card-button",type:"button",title:h("exportDialog.link_button"),"aria-label":h("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ce("export","link",`ui (${VW()})`),await s(e,o,n),a()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,l)]})})},pP=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:l})=>{let a=YW.useCallback(()=>{l({openDialog:null})},[l]);return Do(KW,{children:o.openDialog?.name==="jsonExport"&&Do(je,{onCloseRequest:a,title:h("buttons.export"),children:Do(XW,{elements:e,appState:o,setAppState:l,files:t,actionManager:n,onCloseRequest:a,exportOpts:r,canvas:i})})})};import $W from"clsx";import{jsx as uP,jsxs as jW}from"react/jsx-runtime";var ZW="small",hP=e=>jW("label",{className:$W("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${ZW}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[uP("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),uP("div",{className:"ToolIcon__icon",children:Yo})]});import{Fragment as bP,jsx as ee,jsxs as Wt}from"react/jsx-runtime";var rY=({UIOptions:e})=>Wt(vt,{__fallback:!0,children:[ee(vt.DefaultItems.LoadScene,{}),ee(vt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(vt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(vt.DefaultItems.SaveAsImage,{}),ee(vt.DefaultItems.SearchMenu,{}),ee(vt.DefaultItems.Help,{}),ee(vt.DefaultItems.ClearCanvas,{}),ee(vt.Separator,{}),ee(vt.Group,{title:"Hellix IT links",children:ee(vt.DefaultItems.Socials,{})}),ee(vt.Separator,{}),ee(vt.DefaultItems.ToggleTheme,{}),ee(vt.DefaultItems.ChangeCanvasBackground,{})]}),iY=()=>Wt(yp,{__fallback:!0,children:[ee(yp.Actions.SaveToDisk,{}),ee(yp.Actions.ExportToImage,{})]}),aY=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:l,onHandToolToggle:a,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:u,onExportImage:b,renderWelcomeScreen:g,children:x,app:v,isCollaborating:y,generateLinkForSelection:E,onReportIssue:T})=>{let I=fe(),M=at()==="compact",k=sI(),_=M?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},P=k.tunnelsJotai.Provider,[A,H]=Q(Xn),F=()=>u.canvasActions.export?ee(pP,{elements:r,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,Y=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:ee(mP,{elements:r,appState:o,files:t,actionManager:e,onExportImage:b,onCloseRequest:()=>n({openDialog:null}),name:v.getName()}),V=()=>Wt("div",{style:{position:"relative"},children:[ee(k.MainMenuTunnel.Out,{}),g&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),U=()=>{let X=M;return ee(Ys,{heading:"selectedShapeActions",className:hi("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:X?ee(Xe,{className:hi("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:ee(wI,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v,setAppState:n})}):ee(Xe,{className:JW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:ee(EI,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v})})})},D=()=>{let X=oY(o,r),le=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return ee(ap,{side:"top",children:Wt("div",{className:"App-menu App-menu_top",children:[Wt(Et.Col,{gap:_.menuTopGap,className:hi("App-menu_top__left"),children:[V(),ee("div",{className:hi("selected-shape-actions-container",{"selected-shape-actions-container--compact":M}),children:X&&U()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&ee(Ys,{heading:"shapes",className:"shapes-section",children:pe=>Wt("div",{style:{position:"relative"},children:[g&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Et.Col,{gap:_.toolbarColGap,align:"start",children:Wt(Et.Row,{gap:_.toolbarRowGap,className:hi("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Wt(Xe,{padding:_.islandPadding,className:hi("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":M}),children:[ee(iP,{appState:o,isMobile:I.formFactor==="phone",editorInterface:I,app:v}),pe,Wt(Et.Row,{gap:_.toolbarInnerRowGap,children:[ee(lp,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:h("toolBar.penMode"),penDetected:o.penDetected}),ee(iw,{checked:o.activeTool.locked,onChange:l,title:h("toolBar.lock")}),ee("div",{className:"App-toolbar__divider"}),ee(MI,{setAppState:n,activeTool:o.activeTool,UIOptions:u,app:v})]})]}),y&&ee(Xe,{style:{marginLeft:_.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(hP,{title:h("toolBar.laser"),checked:o.activeTool.type===gP.laser,onChange:()=>v.setActiveTool({type:gP.laser}),isMobile:!0})})]})})]})}),Wt("div",{className:hi("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":M}),children:[o.collaborators.size>0&&ee(pp,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(I.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!W||o.openSidebar?.name!==Tx.name)&&ee(k.DefaultSidebarTriggerTunnel.Out,{}),le&&ee(nc,{app:v,onClose:()=>{e.executeAction(or)},renderCustomStats:d})]})]})})},B=()=>ee(Tp,{__fallback:!0,onDock:X=>{ce("sidebar",`toggleDock (${X?"dock":"undock"})`,`(${I.formFactor==="phone"?"mobile":"desktop"})`)}}),W=Ii(Vs),te=Wt(bP,{children:[x,ee(rY,{UIOptions:u}),ee(Tp.Trigger,{__fallback:!0,icon:$E,title:eY(h("toolBar.library")),onToggle:X=>{X&&ce("sidebar",`${Tx.name} (open)`,`button (${I.formFactor==="phone"?"mobile":"desktop"})`)},tab:Tx.defaultTab}),ee(iY,{}),o.openDialog?.name==="ttd"&&ee(Rp,{__fallback:!0}),o.isLoading&&ee(np,{delay:250}),o.errorMessage&&ee(JM,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),A&&I.formFactor!=="phone"&&ee(p1,{colorPickerType:A.colorPickerType,onCancel:()=>{H(null)},onChange:(X,le,pe,{altKey:de})=>{if(!(X!=="elementBackground"&&X!=="elementStroke"))if(pe.length){for(let Ee of pe)tY(Ee,QW(r),{[de&&A.swapPreviewOnAlt?X==="elementBackground"?"strokeColor":"backgroundColor":X==="elementBackground"?"backgroundColor":"strokeColor"]:le}),nY.delete(Ee);v.scene.triggerUpdate()}else n(X==="elementBackground"?{currentItemBackgroundColor:le}:{currentItemStrokeColor:le})},onSelect:(X,le)=>{H(pe=>pe?.keepOpenOnAlt&&le.altKey?pe:null),A?.onSelect?.(X,le)}}),o.openDialog?.name==="help"&&ee(tP,{onClose:()=>{n({openDialog:null})},onReportIssue:T}),ee(DI,{}),o.openDialog?.name==="elementLinkSelector"&&ee(qM,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:v.scene,appState:o,generateLinkForSelection:E}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),Y(),F(),o.openDialog?.name==="charts"&&ee(Ew,{data:o.openDialog.data,rawText:o.openDialog.rawText,onClose:()=>n({openDialog:null})}),I.formFactor==="phone"&&ee(hw,{app:v,appState:o,elements:r,actionManager:e,renderJSONExportDialog:F,renderImageExportDialog:Y,setAppState:n,onHandToolToggle:a,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:B,renderWelcomeScreen:g,UIOptions:u}),I.formFactor!=="phone"&&Wt(bP,{children:[Wt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&W&&I.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&ee(k.WelcomeScreenCenterTunnel.Out,{}),D(),ee(Sw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),(o.toast||o.scrolledOutside)&&Wt("div",{className:"floating-status-stack",children:[o.toast&&ee(Ld,{message:o.toast.message,onClose:()=>n({toast:null}),duration:o.toast.duration,closable:o.toast.closable}),!o.toast&&o.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(X=>({...Pr(r,X)}))},children:h("buttons.scrollBackToContent")})]})]}),B()]})]});return ee(ih.Provider,{value:o,children:ee(P,{children:ee(af.Provider,{value:k,children:te})})})},fP=e=>{let{startBoundElement:o,cursorButton:t,scrollX:n,scrollY:r,...i}=e;return i},lY=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:l,...a}=o;return Kp(fP(n),fP(l),{selectedElementIds:Kp,selectedGroupIds:Kp})&&Kp(r,a)},xP=qW.memo(aY,lY);import sY from"clsx";import{jsx as yP,jsxs as dY}from"react/jsx-runtime";var cY="small",$p=e=>dY("label",{className:sY("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${cY}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[yP("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),yP("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as mY,useRef as pY}from"react";import{jsx as EP}from"react/jsx-runtime";var vP=({trails:e})=>{let o=pY(null);return mY(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),EP("div",{className:"SVGLayer",children:EP("svg",{ref:o})})};import jY,{useEffect as qY,useRef as FP}from"react";import{CURSOR_TYPE as OP,isShallowEqual as JY,sceneCoordsToViewportCoords as QY}from"@hellixit/common";import{clamp as wx,pointFrom as cl,pointsEqual as yY,bezierEquation as DP,pointRotateRads as Zp,pointDistance as EY}from"@hellixit/math";import{arrayToMap as vY,BIND_MODE_TIMEOUT as ac,DEFAULT_TRANSFORM_HANDLE_SPACING as Ax,FRAME_STYLE as uo,getFeatureFlag as TY,invariant as wP,THEME as Tr}from"@hellixit/common";import{deconstructDiamondElement as kx,deconstructRectanguloidElement as HP,elementCenterPoint as dl,getDiamondBaseCorners as IY,FOCUS_POINT_SIZE as CY,getOmitSidesForEditorInterface as Ix,getTransformHandles as SY,getTransformHandlesFromCoords as wY,hasBoundingBox as kY,hitElementItself as MY,isArrowElement as PY,isBindableElement as RP,isElbowArrow as ml,isFrameLikeElement as pl,isImageElement as kP,isLinearElement as AY,isLineElement as LY,maxBindingDistance_simple as _Y,isTextElement as MP,LinearElementEditor as mn}from"@hellixit/element";import{renderSelectionElement as DY}from"@hellixit/element";import{getElementsInGroup as Mx,getSelectedGroupIds as HY,isSelectedViaGroup as RY,selectGroupsFromGivenElements as NY}from"@hellixit/element";import{getCommonBounds as Px,getElementAbsoluteCoords as jp}from"@hellixit/element";import{getGlobalFixedPointForBindableElement as PP,isFocusPointVisible as BY}from"@hellixit/element";import{pointFrom as Tt}from"@hellixit/math";import{THEME as uY}from"@hellixit/common";var hY="#ff6b6b",gY="#ff0000",TP=1,IP=2,CP=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===uY.LIGHT||o.zenModeEnabled?hY:gY,n=(o.zenModeEnabled?TP*1.5:TP)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,bY(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,xY(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,fY(r,e,o));e.restore()},fY=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];po(n,r,o)}for(let n of e.points)SP(n,t,o)},bY=(e,o,t)=>{SP(e.points[0],t,o),t.zenModeEnabled||po(e.points[0],e.points[1],o)},SP=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?IP*1.5:IP)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},po=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},xY=(e,o,t,n,r)=>{let i=8/n.zoom.value,l=i/2,a=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||po(Tt(e[0],e[1]-i),Tt(e[0],e[1]+i),r),po(Tt(s[0]-a,s[1]-l),Tt(s[0]-a,s[1]+l),r),po(Tt(s[0]+a,s[1]-l),Tt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(po(Tt(o[0],o[1]-i),Tt(o[0],o[1]+i),r),po(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||po(Tt(e[0]-i,e[1]),Tt(e[0]+i,e[1]),r),po(Tt(s[0]-l,s[1]-a),Tt(s[0]+l,s[1]-a),r),po(Tt(s[0]-l,s[1]+a),Tt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(po(Tt(o[0]-i,o[1]),Tt(o[0]+i,o[1]),r),po(e,o,r))}};var FY=(e,o)=>{wP(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;wP(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Lx(t,e,o),e.restore()},OY=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r)||o.selectedLinearElement?.isDragging)return;let i=mn.getElement(n,t);if(!i)return;let l=mn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Lx(l,e,o),e.restore()},Lx=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Ml(o,e[0],e[1],mn.POINT_HANDLE_SIZE/t.zoom.value,!1)},zY=(e,o,t)=>{e.save(),e.translate(o.scrollX,o.scrollY),Lx(t,e,o),e.restore()},Cx=(e,o,t,n,r,i,l)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Ml(e,t[0],t[1],(l?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!l||r)},GY=(e,o,t,n,r)=>{let i=o.element.frameId&&t.get(o.element.frameId);switch(i&&pl(i)&&(e.translate(i.x,i.y),e.beginPath(),uo.radius&&e.roundRect?e.roundRect(-1,-1,i.width+1,i.height+1,uo.radius/n.zoom.value):e.rect(-1,-1,i.width+1,i.height+1),e.clip(),e.translate(-i.x,-i.y)),o.element.type){case"magicframe":case"frame":e.save(),e.translate(o.element.x,o.element.y),e.lineWidth=uo.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",uo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.element.width,o.element.height,uo.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.element.width,o.element.height),e.restore();break;default:e.save();let l=dl(o.element,t);switch(e.translate(l[0],l[1]),e.rotate(o.element.angle),e.translate(-l[0],-l[1]),e.translate(o.element.x,o.element.y),e.lineWidth=wx(1.75,o.element.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.element.type){case"ellipse":e.beginPath(),e.ellipse(o.element.width/2,o.element.height/2,o.element.width/2,o.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[a,s]=kx(o.element);a.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break;default:{let[a,s]=HP(o.element);a.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),s.forEach(c=>{let[m,p,d,u]=c;e.beginPath(),e.moveTo(m[0]-o.element.x,m[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,d[0]-o.element.x,d[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break}e.restore();break}if(n.isMidpointSnappingEnabled&&(pl(o.element)||RP(o.element))){let l=n.selectedLinearElement,a=l?.elementId&&mn.getElement(l?.elementId,t),s=r&&MY({point:r,element:o.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=a&&ml(a)||n.activeTool.type==="arrow"&&n.currentItemArrowType==="elbow";if(!s||c){e.save();let m=dl(o.element,t),p;if(o.element.type==="diamond"){let g=dl(o.element,t);p=IY(o.element).map(x=>{let v=DP(x,.5),y=Zp(v,g,o.element.angle);return cl(y[0],y[1])})}else p=[{x:o.element.width,y:o.element.height/2},{x:o.element.width/2,y:o.element.height},{x:0,y:o.element.height/2},{x:o.element.width/2,y:0}].map(x=>{let v=cl(x.x+o.element.x,x.y+o.element.y),y=Zp(v,m,o.element.angle);return cl(y[0],y[1])});let d=r&&p.reduce((g,x,v)=>{let y=EY(x,r);return v===-1||y<g.distance?{idx:v,distance:y}:g},{idx:-1,distance:1/0}),u=4/n.zoom.value,b=_Y(n.zoom)+o.element.strokeWidth/2;p.forEach((g,x)=>{let v=(!s||c)&&d?.idx===x&&d.distance<=b,y=!v&&(c||x===d?.idx&&d.distance<=b*2);v?(e.fillStyle=n.theme===Tr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill()):y&&(e.fillStyle=n.theme===Tr.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(g[0],g[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},UY=(e,o,t,n,r,i,l)=>{let a=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=ac-(l?.runtime??(a?0:ac)),c=wx(1/ac*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&pl(p)&&(o.translate(p.x,p.y),o.beginPath(),uo.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,uo.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=uo.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,uo.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,uo.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let u=dl(t,n),b=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(o.translate(b,g),o.rotate(t.angle),o.translate(-b,-g),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=wx(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[x,v]=kx(t,m);x.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),v.forEach(y=>{let[E,T,I,S]=y;o.beginPath(),o.moveTo(E[0]-t.x+m,E[1]-t.y+m),o.bezierCurveTo(T[0]-t.x+m,T[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,S[0]-t.x+m,S[1]-t.y+m),o.stroke()})}break;default:{let[x,v]=HP(t,m);x.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),v.forEach(y=>{let[E,T,I,S]=y;o.beginPath(),o.moveTo(E[0]-t.x+m,E[1]-t.y+m),o.bezierCurveTo(T[0]-t.x+m,T[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,S[0]-t.x+m,S[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!a||(l?.runtime??0)>ac)return;let d=.5*(Math.min(t.width,t.height)/2);if(!pl(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/ac*s;if(o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-u*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore(),r.isMidpointSnappingEnabled){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let b=5/r.zoom.value,g=5/r.zoom.value,x=b+g,v;if(t.type==="diamond"){let[,y]=kx(t),E=dl(t,n);v=y.map(T=>{let I=DP(T,.5),S=Zp(I,E,t.angle);return{x:S[0]-t.x,y:S[1]-t.y}})}else{let y=dl(t,n);v=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(T=>{let I=cl(T.x+t.x,T.y+t.y),S=Zp(I,y,t.angle);return{x:S[0]-t.x,y:S[1]-t.y}})}v.forEach(y=>{o.clearRect(y.x-x,y.y-x,x*2,x*2)}),o.fillStyle=r.theme===Tr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,v.forEach(y=>{o.beginPath(),o.arc(y.x,y.y,b,0,2*Math.PI),o.fill()}),o.restore()}}return{runtime:(l?.runtime??0)+i}},WY=(e,o,t,n,r,i,l)=>{if(t===null)return;if(TY("COMPLEX_BINDINGS"))return UY(e,o,t.element,n,r,i,l);o.save(),o.translate(r.scrollX,r.scrollY);let a=e.lastPointerMoveCoords?cl(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null;GY(o,t,n,r,a),o.restore()},NP=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:l,y2:a,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,u=l-r,b=a-i,x=(t.padding??Ax*2)/o.zoom.value,v=8/o.zoom.value,y=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let E=s.length;for(let T=0;T<E;++T)e.strokeStyle=s[T],p&&e.setLineDash([v,y+(v+y)*(E-1)]),e.lineDashOffset=(v+y)*T,Pl(e,r-x,i-x,u+x*2,b+x*2,c,m,n);e.restore()},YY=(e,o,t,n)=>{let[r,i,l,a]=jp(t,n),s=l-r,c=a-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=uo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Pl(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,uo.radius/o.zoom.value),e.restore()},AP=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},l=t.filter(m=>m.groupIds.length===0),a=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,u,b]=Px(m);return{angle:0,x1:p,x2:u,y1:d,y2:b,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:d+(b-d)/2,activeEmbeddable:!1}},c=m=>{let p=Mx(t,m);return s(p)};Object.entries(NY(a,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(l.map(m=>s([m]))).forEach(m=>NP(e,o,m))},Sx=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=mn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=mn,l=o.selectedLinearElement?.isEditing?i:i/2,a=ml(t),s=LY(t);if(r.forEach((c,m)=>{if(a&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&yY(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),Cx(e,o,c,l,d,!1,p)}),ml(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{mn.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom)||Cx(e,o,cl((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else mn.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(ml(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&Cx(e,o,m,i/2,!1,!0,!1)});e.restore()},VY=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},XY=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ml(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},LP=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,l=i?.elementId&&r.get(i.elementId);if(!l||!RP(l)||l.isDeleted)return;let a=PP(i.fixedPoint,l,r);if(!BY(a,e,l,r,o,t))return;let s=o.selectedLinearElement,c=!!s?.isDragging,m=t==="start"?0:e.points.length-1,p=!!s?.selectedPointsIndices?.includes(m);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&zY(n,o,a),!(p&&c)){let d=PP(i.fixedPoint,l,r),u=s?.hoveredFocusPointBinding===t,b=mn.getPointAtIndexGlobalCoordinates(e,m,r);VY(n,o,b,d),XY(n,o,d,CY/1.5,u)}},_P=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let l=n[i];if(l!==void 0){let[a,s,c,m]=l;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Ml(e,a+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(a,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):Pl(e,a,s,c,m,a+c/2,s+m/2,r,!0),e.restore()}})},KY=(e,o,t,n,r)=>{let[i,l,,,a,s]=jp(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,u=a-i+p,b=s-l+p,g=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,b);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-b],[0,d],[g,d],[d,0],[d,x]],[[u-d,-b],[d,d],[-g+d,d],[0,0],[0,x]],[[-u,b],[0,-d],[g,-d],[d,0],[d,-x]],[[u-d,b],[d,-d],[-g+d,-d],[0,0],[0,-x]]].forEach(y=>{let[[E,T],[I,S],[M,k],[_,P],[A,H]]=y;e.save(),e.translate(a,s),e.rotate(n.angle),e.beginPath(),e.moveTo(E+I,T+S),e.lineTo(E+M,T+k),e.stroke(),e.beginPath(),e.moveTo(E+_,T+P),e.lineTo(E+A,T+H),e.stroke(),e.restore()}),e.restore()},$Y=(e,o,t,n)=>{o.save();let r=Ax*2/t.zoom.value,i=e.width+r*2,l=e.height+r*2,a=e.x+i/2,s=e.y+l/2,c=-(i/2+r),m=-(l/2+r);o.translate(a+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(c,m,i,l),o.restore()},ZY=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:l,appState:a,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,u]=Mc(o,l),b=m,g=Pc({canvas:o,scale:l,normalizedWidth:d,normalizedHeight:u});g.save(),g.scale(a.zoom.value,a.zoom.value);let x;if(n.forEach(I=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===I.id&&I&&(x=I)}),x&&Sx(g,a,x,t),a.selectionElement&&!a.isCropping)try{DY(a.selectionElement,g,a,s.selectionColor)}catch(I){console.error(I)}if(a.editingTextElement&&MP(a.editingTextElement)){let I=i.get(a.editingTextElement.id);I&&!I.autoResize&&$Y(I,g,a,s.selectionColor)}if(a.isBindingEnabled&&a.suggestedBinding?b={...m,bindingHighlight:WY(e,g,a.suggestedBinding,i,a,p,m?.bindingHighlight)}:b={...m,bindingHighlight:void 0},a.frameToHighlight&&YY(g,a,a.frameToHighlight,t),a.elementsToHighlight&&AP(g,a,a.elementsToHighlight),a.activeLockedId){let I=i.get(a.activeLockedId),S=I?[I]:Mx(i,a.activeLockedId);AP(g,a,S,{colors:["#ced4da"],dashed:!0})}let v=r.some(I=>pl(I));r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Sx(g,a,r[0],t);let y=a.selectedLinearElement,E=y&&mn.getElement(y.elementId,i);if(E&&(a.selectedLinearElement.isDragging||(y.segmentMidPointHoveredCoords?FY(g,a):(ml(E)?y.hoverPointIndex===0||y.hoverPointIndex===E.points.length-1:y.hoverPointIndex>=0)&&OY(g,a,t)),PY(E)&&(LP({arrow:E,elementsMap:i,appState:a,context:g,type:"start"}),LP({arrow:E,elementsMap:i,appState:a,context:g,type:"end"}))),!a.multiElement&&!a.newElement&&!a.selectedLinearElement?.isEditing){let I=kY(r,a,c),S=r.length===1&&AY(r[0]);S&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Sx(g,a,r[0],t);let M=s.selectionColor||"#000";if(I){let k=vY(r),_=[];for(let A of t.values()){let H=[],F=s.remoteSelectedElementIds.get(A.id);if(S&&ml(A)&&(A.startBinding||A.endBinding)||(k.has(A.id)&&!RY(a,A)&&H.push(M),F&&H.push(...F.map(Y=>Xr(Y,a.collaborators.get(Y))))),H.length){let[Y,V,U,D,B,W]=jp(A,t,!0);_.push({angle:A.angle,x1:Y,y1:V,x2:U,y2:D,selectionColors:A.locked?["#ced4da"]:H,dashed:!!F||A.locked,cx:B,cy:W,activeEmbeddable:a.activeEmbeddable?.element===A&&a.activeEmbeddable.state==="active",padding:A.id===a.croppingElementId||kP(A)?0:void 0})}}let P=A=>{let H=Mx(t,A),[F,Y,V,U]=Px(H);_.push({angle:0,x1:F,x2:V,y1:Y,y2:U,selectionColors:H.some(D=>D.locked)?["#ced4da"]:["#000"],dashed:!0,cx:F+(V-F)/2,cy:Y+(U-Y)/2,activeEmbeddable:!1})};for(let A of HY(a))P(A);a.editingGroupId&&P(a.editingGroupId),_.forEach(A=>NP(g,a,A))}if(g.save(),g.translate(a.scrollX,a.scrollY),r.length===1){g.fillStyle="#fff";let k=SY(r[0],a.zoom,t,"mouse",Ix(c));if(!a.viewModeEnabled&&I&&!MP(a.editingTextElement)&&!a.croppingElementId&&_P(g,s,a,k,r[0].angle),a.croppingElementId&&!a.isCropping){let _=t.get(a.croppingElementId);_&&kP(_)&&KY(g,s,a,_,t)}}else if(r.length>1&&!a.isRotating&&!r.some(k=>k.locked)){let k=Ax*2/a.zoom.value;g.fillStyle="#fff";let[_,P,A,H]=Px(r,t),F=g.getLineDash();g.setLineDash([2/a.zoom.value]);let Y=g.lineWidth;g.lineWidth=1/a.zoom.value,g.strokeStyle=M,Pl(g,_-k,P-k,A-_+k*2,H-P+k*2,(_+A)/2,(P+H)/2,0),g.lineWidth=Y,g.setLineDash(F);let V=wY([_,P,A,H,(_+A)/2,(P+H)/2],0,a.zoom,"mouse",v?{...Ix(c),rotation:!0}:Ix(c));r.some(U=>!U.locked)&&_P(g,s,a,V,0)}g.restore()}a.searchMatches?.matches.forEach(({id:I,focus:S,matchedLines:M})=>{let k=t.get(I);if(k){let[_,P,,,A,H]=jp(k,t,!0);g.save(),a.theme===Tr.LIGHT?S?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":S?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let F=pl(k)?a.zoom.value:1;g.translate(a.scrollX,a.scrollY),g.translate(A,H),g.rotate(k.angle),M.forEach(Y=>{(Y.showOnCanvas||S)&&g.fillRect(_+Y.offsetX/F-A,P+Y.offsetY/F-H,Y.width/F,Y.height/F)}),g.restore()}}),CP(g,a),g.restore(),jv({context:g,renderConfig:s,appState:a,normalizedWidth:d,normalizedHeight:u});let T;return s.renderScrollbars&&(T=nS(t,d,u,a),g.save(),g.fillStyle=oS,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(I=>{I&&Ud(g,I.x,I.y,I.width,I.height,ao/2)}),g.restore()),{scrollBars:T,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:b}},BP=e=>{let o=ZY(e);return e.callback(o),o};var mt=class mt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(mt.animations.set(o,{animation:t,lastTime:0,state:n}),mt.isRunning||(mt.isRunning=!0,ri()?requestAnimationFrame(mt.tick):setTimeout(mt.tick,0)))}static tick(){if(mt.animations.size>0){for(let[o,t]of mt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(mt.animations.delete(o),mt.animations.size===0){mt.isRunning=!1;return}}ri()?requestAnimationFrame(mt.tick):setTimeout(mt.tick,0)}}static running(o){return mt.animations.has(o)}static cancel(o){mt.animations.delete(o)}};w(mt,"isRunning",!1),w(mt,"animations",new Map);var lc=mt;import{jsx as oV}from"react/jsx-runtime";var zP="animateInteractiveScene",eV=e=>{let o=FP(!1),t=FP(null);return qY(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,l=new Map,a=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&l.set(m,c.username),c.userState&&a.set(m,c.userState),r.set(m,QY({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:l,remotePointerUserStates:a,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},lc.running(zP)||lc.start(zP,({deltaTime:c,state:m})=>{let p=BP({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),oV("canvas",{className:"hellixitboard__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?OP.GRAB:OP.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:h("labels.drawingCanvas")})},GP=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),tV=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:JY(GP(e.appState),GP(o.appState)),_x=jY.memo(eV,tV);import nV,{useEffect as UP,useRef as WP}from"react";import{isShallowEqual as YP}from"@hellixit/common";import{jsx as aV}from"react/jsx-runtime";var rV=e=>{let o=WP(null),t=WP(!1);return UP(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),UP(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("hellixitboard__canvas","static")),zy({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},ri())}),aV("div",{className:"hellixitboard__canvas-wrapper",ref:o})},VP=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),iV=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:YP(VP(e.appState),VP(o.appState))&&YP(e.renderConfig,o.renderConfig),Dx=nV.memo(rV,iV);import{useEffect as uV,useRef as hV}from"react";import{throttleRAF as lV}from"@hellixit/common";import{getTargetFrame as sV,isInvisiblySmallElement as cV,renderElement as dV,shouldApplyFrameClip as mV}from"@hellixit/element";var XP=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:l,renderConfig:a})=>{if(e){let[s,c]=Mc(e,i),m=Pc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(l.zoom.value,l.zoom.value),t&&t.type!=="selection"){if(cV(t))return;if((t.frameId||l.frameToHighlight?.id)&&l.frameRendering.enabled&&l.frameRendering.clip){let d=sV(t,n,l);d&&mV(t,d,l,n)&&Fy(d,m,a,l)}dV(t,n,r,o,m,a,l)}else m.clearRect(0,0,s,c);m.restore()}},pV=lV(e=>{XP(e)}),KP=(e,o)=>{if(o){pV(e);return}XP(e)};import{jsx as fV}from"react/jsx-runtime";var gV=e=>{let o=hV(null);return uV(()=>{o.current&&KP({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ri())}),fV("canvas",{className:"hellixitboard__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},$P=gV;var qp=class{constructor(o){this.getState=o;w(this,"listeners",[]);w(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:l,once:a,matchesImmediately:s}=this.normalize(o,t,n);return l?s&&(queueMicrotask(()=>{let c=this.getState();l(i(c),c)}),a)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:l,once:a}):s?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:m=>c(m),once:!0})})})}isStateChangePredicateOptions(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,l=t,a=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:m,once:p}=o;r=c,i=d=>d,l=m?(d,u)=>m(u):void 0,a=p??!1,s=c(this.getState())}else if(typeof o=="function"){let c=o;r=(m,p)=>c(m)!==c(p),i=m=>c(m)}else if(Array.isArray(o)){let c=o;r=(m,p)=>c.some(d=>m[d]!==p[d]),i=m=>m}else{let c=o;r=(m,p)=>m[c]!==p[c],i=m=>m[c]}return{predicate:r,getValue:i,callback:l,once:a,matchesImmediately:s}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as bV,getElementsInGroup as xV,selectGroupsFromGivenElements as yV}from"@hellixit/element";import{sceneCoordsToViewportCoords as EV}from"@hellixit/common";import{flushSync as vV}from"react-dom";import{jsx as IV}from"react/jsx-runtime";var TV=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:xV(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=bV(n),{x:l,y:a}=EV({sceneX:r,sceneY:i},e.state);return IV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-a+e.state.offsetTop}px`,left:`${l-e.state.offsetLeft}px`},onClick:()=>{vV(()=>{let s=yV(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(gs)},title:h("labels.elementLock.unlock"),children:s0})},ZP=TV;import{Fragment as CK,jsx as Te,jsxs as su}from"react/jsx-runtime";var eL=go.createContext(null),tL=go.createContext(null),dy={formFactor:"desktop",desktopUIMode:"full",userAgent:JA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},py=go.createContext(dy);py.displayName="EditorInterfaceContext";var TK={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},uy=go.createContext({container:null,id:null});uy.displayName="HellixitboardContainerContext";var hy=go.createContext([]);hy.displayName="HellixitboardElementsContext";var gy=go.createContext({...Oo(),width:0,height:0,offsetLeft:0,offsetTop:0});gy.displayName="HellixitboardAppStateContext";var fy=go.createContext(()=>{console.warn("Uninitialized HellixitboardSetAppStateContext context!")});fy.displayName="HellixitboardSetAppStateContext";var by=go.createContext(null);by.displayName="HellixitboardActionManagerContext";var yl=go.createContext(null);yl.displayName="HellixitboardAPIContext";var du=go.createContext(null);du.displayName="HellixitboardAPISetContext";var Ae=()=>On(eL),Ko=()=>On(tL),fe=()=>On(py),at=()=>cu(fe()),_e=()=>On(uy),Kn=()=>On(hy),Xo=()=>On(gy),he=()=>On(fy),De=()=>On(by),mu=()=>On(yl),gc=!1,ay=0,fc=null,kr=!1,bc=!1,ly=!1,xc={horizontal:null,vertical:null},Mr=0,yc=!1,sy=new Map,cy=!1,$A=0,ZA=!1,Ec=null,ve={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},my=class e extends go.Component{constructor(t){super(t);w(this,"canvas");w(this,"interactiveCanvas",null);w(this,"sessionExportThemeOverride");w(this,"rc");w(this,"unmounted",!1);w(this,"actionManager");w(this,"editorInterface",dy);w(this,"stylesPanelMode",cu(dy));w(this,"hellixitboardContainerRef",go.createRef());w(this,"_contextMenuPos",null);w(this,"scene");w(this,"fonts");w(this,"renderer");w(this,"visibleElements");w(this,"resizeObserver");w(this,"library");w(this,"libraryItemsFromStorage");w(this,"id");w(this,"store");w(this,"history");w(this,"hellixitboardContainerValue");w(this,"files",{});w(this,"imageCache",new Map);w(this,"iFrameRefs",new Map);w(this,"embedsValidationStatus",new Map);w(this,"initializedEmbeds",new Set);w(this,"elementsPendingErasure",new Set);w(this,"_initialized",!1);w(this,"editorLifecycleEvents",new eX(TK));w(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));w(this,"appStateObserver",new qp(()=>this.state));w(this,"onStateChange",this.appStateObserver.onStateChange);w(this,"flowChartCreator",new WX);w(this,"flowChartNavigator",new YX);w(this,"bindModeHandler",null);w(this,"hitLinkElement");w(this,"lastPointerDownEvent",null);w(this,"lastPointerUpEvent",null);w(this,"lastPointerMoveEvent",null);w(this,"lastPointerMoveCoords",null);w(this,"previousPointerMoveCoords",null);w(this,"lastViewportPosition",{x:0,y:0});w(this,"animationFrameHandler",new zm);w(this,"laserTrails",new Ym(this.animationFrameHandler,this));w(this,"eraserTrail",new Zm(this.animationFrameHandler,this));w(this,"lassoTrail",new $m(this.animationFrameHandler,this));w(this,"onChangeEmitter",new gi);w(this,"onPointerDownEmitter",new gi);w(this,"onPointerUpEmitter",new gi);w(this,"onUserFollowEmitter",new gi);w(this,"onScrollChangeEmitter",new gi);w(this,"missingPointerEventCleanupEmitter",new gi);w(this,"onRemoveEventListenersEmitter",new gi);w(this,"api");w(this,"updateEditorAtom",(t,...n)=>{let r=Qe.set(t,...n);return this.triggerRender(),r});w(this,"previousHoveredBindableElement",null);w(this,"getEffectiveGridSize",()=>cr(this)?this.state.gridSize:null);w(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&Yx(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(Ce(this.interactiveCanvas,ze.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));w(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),hc.delete(t)});w(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Fn(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=$x(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else xl(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});w(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);w(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),l=Be({clientX:i.x,clientY:i.y},this.state),a=Be({clientX:i.right,clientY:i.bottom},this.state);return n={x:l.x,y:l.y,width:a.x-l.x,height:a.y-l.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});w(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});w(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ul.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!CA(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:l,y:a}=tu({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=BX(i);if(i.id===this.state.editingFrame){let p=m;c=Te("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===j.ESCAPE||d.key===j.ENTER)&&this.resetEditingFrame(i)},style:{background:t?QV(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${pn.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?pn.nameColorDarkTheme:pn.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-l-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return Te("div",{id:this.getFrameNameDOMId(i),className:Gx.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+pn.nameOffsetY-a+this.state.offsetTop}px`,left:`${l-this.state.offsetLeft}px`,zIndex:2,fontSize:pn.nameFontSize,color:t?pn.nameColorDarkTheme:pn.nameColorLightTheme,lineHeight:pn.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:ze.MOVE,pointerEvents:this.state.viewModeEnabled?hl.disabled:hl.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});w(this,"focusContainer",()=>{this.hellixitboardContainerRef.current?.focus()});w(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());w(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());w(this,"getSceneElements",()=>this.scene.getNonDeletedElements());w(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});w(this,"onExportImage",async(t,n,r)=>{ce("export",t,"ui");let i=await Wr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(jV).catch(l=>{console.error(l),this.setState({errorMessage:l.message})});this.state.exportEmbedScene&&i&&Lc(i)&&this.setState({fileHandle:i})});w(this,"magicGenerations",new Map);w(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});w(this,"plugins",{});w(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:hn.magicframe}),ce("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Vx(t[0])&&t[0];if(!n&&t.some(i=>Vt(i)||i.frameId)){this.setActiveTool({type:hn.magicframe});return}ce("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,l,a,s]=fl(t),c=50;r=yA({...pn,x:i-c,y:l-c,width:a-i+c*2,height:s-l+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});w(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Xn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Dt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Dt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?wr(a,{[i?"strokeColor":"backgroundColor"]:n}):a),captureUpdate:Dt.IMMEDIATELY})},keepOpenOnAlt:!1})});w(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});w(this,"syncActionResult",We(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,l=t?.appState?.zenModeEnabled||!1,a=t?.appState?.theme||this.props.theme||ul.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(l=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&GA(m)&&Ro(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:l,theme:a,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));w(this,"onBlur",We(()=>{kr=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));w(this,"onUnload",()=>{this.onBlur()});w(this,"disableEvent",t=>{t.preventDefault()});w(this,"resetHistory",()=>{this.history.clear()});w(this,"resetStore",()=>{this.store.clear()});w(this,"resetScene",We(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Oo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));w(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let a=l.files[0],s=await a.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),a)}),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(l=>{console.error(l)})}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let n=Lr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ti(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...Pr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:Dt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),ty(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});w(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??iX(t,n));w(this,"refreshEditorInterface",()=>{let t=this.hellixitboardContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=cX(),l=JA(typeof navigator<"u"?navigator.userAgent:""),a=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:DV,s=zx(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:l,canFitSidebar:n>a,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});w(this,"reconcileStylesPanelMode",t=>{let n=cu(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});w(this,"setDesktopUIMode",t=>{let n=dX(t);this.editorInterface=zx(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});w(this,"onResize",We(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>hc.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));w(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});w(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(xc=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});w(this,"onScroll",mA(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},HV));w(this,"onCut",We(t=>{!this.hellixitboardContainerRef.current?.contains(document.activeElement)||cc(t.target)||(this.actionManager.executeAction(Vd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));w(this,"onCopy",We(t=>{!this.hellixitboardContainerRef.current?.contains(document.activeElement)||cc(t.target)||(this.actionManager.executeAction(pa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));w(this,"onTouchStart",t=>{if(aX&&t.preventDefault(),!gc){gc=!0,t.touches.length===1&&(fc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(ay),ay=window.setTimeout(e.resetTapTwice,RV);return}if(gc&&t.touches.length===1&&fc){let n=t.touches[0];Ir(re(n.clientX,n.clientY),re(fc.x,fc.y))<=nX&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),gc=!1,clearTimeout(ay)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})});w(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):ve.pointers.clear()});w(this,"pasteFromClipboard",We(async t=>{let n=!!cy,r=document.activeElement,i=this.hellixitboardContainerRef.current?.contains(r);if(t&&!i)return;let l=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(l instanceof HTMLCanvasElement)||cc(r)))return;let a=await na(t),s=a.getFiles(),c=await Rd(a,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));w(this,"addElementsFromPasteOrLibrary",t=>{let n=Lr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,l,a]=fl(n),s=gl(r,l)/2,c=gl(i,a)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:u}=Be({clientX:m,clientY:p},this.state),b=d-s,g=u-c,[x,v]=It(b,g,this.getEffectiveGridSize()),{duplicatedElements:y}=Ux({type:"everything",elements:n.map(k=>wr(k,{x:k.x+x-r,y:k.y+v-i})),randomizeSeed:!t.retainSeed}),E=this.scene.getElementsIncludingDeleted(),T=[...E,...y];T=this.props.onDuplicate?.(T,E)||T,NA(T,ou(y));let S=this.getTopLayerFrameAtSceneCoords({x:d,y:u});if(S){let k=OX(y,S);Jx(T,k,S,this.state)}this.scene.replaceAllElements(T),y.forEach(k=>{if(Ro(k)&&Wx(k)){let _=PA(k,this.scene.getElementsMapIncludingDeleted());LX(k,_,this.scene)}}),sX&&Gn.loadElementsFonts(y).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let M=iK(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Qe.get(Vs)?this.state.openSidebar:null,...ho({editingGroupId:null,selectedElementIds:M.reduce((k,_)=>(Wx(_)||(k[_.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(y,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});w(this,"setAppState",(t,n)=>{this.setState(t,n)});w(this,"removePointer",t=>{Mr&&this.resetContextMenuTimer(),ve.pointers.delete(t.pointerId)});w(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ce("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...gn(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});w(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});w(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});w(this,"onHandToolToggle",()=>{this.actionManager.executeAction(uv)});w(this,"zoomCanvas",t=>{this.setState({...In({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:No(t)},this.state)})});w(this,"cancelInProgressAnimation",null);w(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(ty(t)?s=KX(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):ty(t)&&this.setState({toast:{message:h("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,l=this.state.scrollX,a=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=ts({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,l=s.scrollX,a=s.scrollY}else{let s=Pr(r,this.state);l=s.scrollX,a=s.scrollY}if(n?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,p=ZV({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:l,scrollY:a,zoom:i.value},interpolateValue:(d,u,b,g)=>{if(g==="zoom")return d*Math.pow(u/d,qV(b))},onStep:({scrollX:d,scrollY:u,zoom:b})=>{this.setState({scrollX:d,scrollY:u,zoom:{value:b}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{p(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:l,scrollY:a,zoom:i})});w(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});w(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});w(this,"setToast",t=>{this.setState({toast:t})});w(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,MV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});w(this,"addFiles",We(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));w(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},l=Array.isArray(t)?t:Object.values(t);for(let a of l)if(!r[a.id]&&(i[a.id]=a,r[a.id]=a,a.mimeType===un.svg))try{let s=$y(MA(Zy(a.dataURL)),un.svg);a.dataURL!==s&&(a.version=(a.version??1)+1,a.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});w(this,"updateScene",We(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:l}=t;if(l){let a=n||void 0,s=r?mX({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:l,elements:a,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));w(this,"applyDeltas",(t,n)=>{let r=WA.squash(...t),i={...this.state},l=new Map(this.scene.getElementsMapIncludingDeleted());return WA.applyTo(r,l,i,n)});w(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));w(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});w(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let l=i?{name:i}:null;return l&&n&&(l.tab=n),this.setState({openSidebar:l}),!!i});w(this,"updateCurrentCursorPosition",We(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));w(this,"getEditorUIOffsets",()=>{let t=this.hellixitboardContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.hellixitboardContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.hellixitboardContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return En().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});w(this,"onKeyDown",We(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,s){let c=a[s];return typeof c=="function"?c.bind(a):s==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():c}})),!pA(t.target)){if((t.key===j.ESCAPE||t.key===j.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=oe(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&fi(a[0])&&t.key===j.ENTER){this.startImageCropping(a[0]);return}if(t.key===j.ESCAPE)this.updateEditorAtom(Io,null);else if(t.key===j.TAB&&(document.activeElement===this.hellixitboardContainerRef?.current||document.activeElement?.classList.contains(Gx.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=xa(a);Qe.get(Io)?.type==="panel"&&Lg(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(Io,{type:"panel"})}if(t.key===j.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let s=Jp(t.key);if(t[j.CTRL_OR_CMD]&&s&&!t.shiftKey){t.preventDefault();let c=oe(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&CX(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,DA(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Kx(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let c=oe(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&s){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),DA(t.key));if(m){this.setState(d=>({selectedElementIds:ke({[m]:!0},d)}));let p=this.scene.getNonDeletedElementsMap().get(m);p&&!Kx([p],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[j.CTRL_OR_CMD]&&t.key===j.P&&!t.shiftKey&&!t.altKey){this.setToast({message:h("commandPalette.shortcutHint",{shortcut:Le("commandPalette")})}),t.preventDefault();return}if(t[j.CTRL_OR_CMD]&&t.key.toLowerCase()===j.V&&(cy=t.shiftKey,clearTimeout($A),$A=window.setTimeout(()=>{cy=!1},100)),t[j.CTRL_OR_CMD]&&cc(t.target)&&(t.code===oA.MINUS||t.code===oA.EQUAL)){t.preventDefault();return}if(cc(t.target)&&t.key!==j.ESCAPE||Jp(t.key)&&pA(t.target))return;if(t.key===j.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===j.E&&t.shiftKey&&t[j.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===j.PAGE_UP||t.key===j.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===j.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(s=>({scrollX:s.scrollX+a})):this.translateCanvas(s=>({scrollY:s.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===j.ALT&&(Bn("COMPLEX_BINDINGS")?this.handleSkipBindMode():lu({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===j.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=lI(t.key,this);if(this.state.viewModeEnabled&&!gA(a,["laser","hand"]))return;if(a){this.state.activeTool.type!==a&&ce("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(s=>({currentItemArrowType:s.currentItemArrowType===Sr.sharp?Sr.round:s.currentItemArrowType===Sr.round?Sr.elbow:Sr.sharp})),a==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:a}),t.stopPropagation();return}else if(t.key===j.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[j.CTRL_OR_CMD]&&!t.repeat&&(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),lu({app:this,event:t})),Jp(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),s=new Set;a.filter(d=>bn(d)).filter(d=>{let u=d.startBinding&&!a.some(g=>g.id===d.startBinding?.elementId),b=d.endBinding&&!a.some(g=>g.id===d.endBinding?.elementId);return u||b}).forEach(d=>s.add(d.id)),a=a.filter(d=>!s.has(d.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?lA:this.getEffectiveGridSize())||(t.shiftKey?AV:lA),m=0,p=0;t.key===j.ARROW_LEFT?m=-c:t.key===j.ARROW_RIGHT?m=c:t.key===j.ARROW_UP?p=-c:t.key===j.ARROW_DOWN&&(p=c),a.forEach(d=>{this.scene.mutateElement(d,{x:d.x+m,y:d.y+p},{informMutation:!1,isDragging:!1}),ru(d,this.scene,{simultaneouslyUpdated:a})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===j.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let s=a[0];if(t[j.CTRL_OR_CMD]||oy(s))_t(s)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)&&(this.store.scheduleCapture(),Xt(s)||this.actionManager.executeAction(Ha));else if(Ro(s)||AX(s)){let c;Ro(s)||(c=s);let m=jx(s,this.state,this.scene.getNonDeletedElementsMap()),p=m.x,d=m.y;this.startTextEditing({sceneX:p,sceneY:d,container:c}),t.preventDefault();return}else Vt(s)&&this.setState({editingFrame:s.id})}}if(t.key===j.SPACE&&ve.pointers.size===0&&(kr=!0,Ce(this.interactiveCanvas,ze.GRAB),t.preventDefault()),(t.key===j.G||t.key===j.S)&&!t.altKey&&!t[j.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===j.G&&(Bo(this.state.activeTool.type)||a.some(s=>Bo(s.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===j.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[j.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===j.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(s=>Ro(s)||Zx(s,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}t[j.CTRL_OR_CMD]&&(t.key===j.BACKSPACE||t.key===j.DELETE)&&this.updateEditorAtom(jr,"clearCanvas");let r=t.key.toLocaleLowerCase(),i=r===j.S&&t.shiftKey&&!t[j.CTRL_OR_CMD],l=t.key===j.I||r===j.G&&t.shiftKey;(i||l)&&this.openEyeDropper({type:i?"stroke":"background"})}));w(this,"onKeyUp",We(t=>{if(t.key===j.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?Ce(this.interactiveCanvas,ze.GRAB):nu(this.state.activeTool.type)?Zt(this.interactiveCanvas):(jt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),kr=!1),t.key===j.ALT&&lu({app:this,event:t}),(t.key===j.ALT&&this.state.bindMode==="skip"||!t[j.CTRL_OR_CMD]&&!mc(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Bn("COMPLEX_BINDINGS"))){let n=Be({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ho(re(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=xe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());bn(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[j.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&Yt(()=>{this.setState({isBindingEnabled:n})}),lu({app:this,event:t})}if(Jp(t.key)){bA(this.scene.getSelectedElements(this.state).filter(bl),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(ny).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...VA(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...VA(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Dt.IMMEDIATELY})),!t[j.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ke({[n.id]:!0},r)})),Kx([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(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Dt.IMMEDIATELY})}}));w(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);w(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=gn(this.state,t);r.type==="hand"?Ce(this.interactiveCanvas,ze.GRAB):kr||jt(this.interactiveCanvas,{...this.state,activeTool:r}),XV(document.activeElement)&&this.focusContainer(),TX(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let l={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:nu(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...l,activeTool:r,...n?{}:{selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...l,activeTool:r,selectedElementIds:ke({},i),selectedGroupIds:ke({},i),editingGroupId:null,multiElement:null}:{...i,...l,activeTool:r}})});w(this,"setOpenDialog",t=>{this.setState({openDialog:t})});w(this,"setCursor",t=>{Ce(this.interactiveCanvas,t)});w(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});w(this,"isTouchScreenMultiTouchGesture",()=>ve.pointers.size>=2);w(this,"getName",()=>this.state.name||this.props.name||`${h("labels.untitled")}-${uA()}`);w(this,"onGestureStart",We(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),ve.initialScale=this.state.zoom.value}));w(this,"onGestureChange",We(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ve.initialScale;n&&this.setState(r=>({...In({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:No(n*t.scale)},r)}))}));w(this,"onGestureEnd",We(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),ve.initialScale=null}));w(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:l=!0})=>{let a=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(Zx(i,this.scene.getNonDeletedElementsMap())||(a=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Ro(m[0])?c=m[0]:i?c=Zx(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,n):c=this.getTextElementAtPosition(t,n);let p=c?.fontFamily||this.state.currentItemFontFamily,d=c?.lineHeight||dA(p),u=this.state.currentItemFontSize;if(!c&&a&&i&&!bl(i)){let v=qX(Fx({fontSize:u,fontFamily:p}),d),y=JX(u,d),E=Math.max(i.height,y),T=Math.max(i.width,v);this.scene.mutateElement(i,{height:E,width:T}),t=i.x+T/2,n=i.y+E/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let b=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),g=c||EA({x:s?s.elementCenterX:t,y:s?s.elementCenterY: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,text:"",fontSize:u,fontFamily:p,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?FV.MIDDLE:iA,containerId:a?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?bl(i)?0:i.angle:0,frameId:b?b.id:null});if(!c&&a&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:g.id})}),this.setState({editingTextElement:g}),!c)if(i&&a){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(g,x+1)}else this.scene.insertElement(g);l||c||i?this.handleTextWysiwyg(g,{isExistingElement:!!c}):this.setState({newElement:g,multiElement:null})});w(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});w(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});w(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Be(t,this.state);if(n.length===1&&_t(n[0])){let a=n[0];if((t[j.CTRL_OR_CMD]&&ny(a)||oy(a))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==a.id)){this.actionManager.executeAction(Ha);return}else if(this.state.selectedLinearElement&&Xt(n[0])){let s=xe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),xe.deleteFixedSegment(n[0],this.scene,c);let m=xe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===a.id&&oy(a))return}if(n.length===1&&fi(n[0])){this.startImageCropping(n[0]);return}if(Zt(this.interactiveCanvas),nK(this.state).length>0){let a=this.getElementAtPosition(r,i),s=a&&oK(a,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ho({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Zt(this.interactiveCanvas),!t[j.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let a=this.getElementAtPosition(r,i);if(Yx(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(TA(s)||!$V(s.backgroundColor)||uc({point:re(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=jx(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});w(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let l=r.length-1;l>=0;l--){let a=r[l];if(n&&a.id===n.id&&(i=l),a.link&&l>=i&&kc(a,this.scene.getNonDeletedElementsMap(),this.state,re(t.x,t.y),this.editorInterface.formFactor==="phone"))return a}});w(this,"handleElementLinkClick",t=>{let n=Ir(re(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),re(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>aA)return;let r=Be(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),l=kc(this.hitLinkElement,i,this.state,re(r.x,r.y),this.editorInterface.formFactor==="phone"),a=Be(this.lastPointerUpEvent,this.state),s=kc(this.hitLinkElement,i,this.state,re(a.x,a.y),this.editorInterface.formFactor==="phone");if(l&&s){xg();let c=this.hitLinkElement.link;if(c){c=Bx(c);let m;if(this.props.onLinkOpen&&(m=KV(ae.HELLIXITBOARD_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},m)),!m?.defaultPrevented){let p=WV(c)?"_self":"_blank",d=window.open(void 0,p);d&&(d.opener=null,d.location=c)}}}});w(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&AA(t,i,n));return r.length?r[r.length-1]:null});w(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},ve.pointers.has(t.pointerId)&&ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let l=ve.initialScale;if(ve.pointers.size===2&&ve.lastCenter&&l&&ve.initialDistance){let g=Bf(ve.pointers),x=g.x-ve.lastCenter.x,v=g.y-ve.lastCenter.y;ve.lastCenter=g;let y=Ff(Array.from(ve.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/ve.initialDistance,T=E?No(l*E):this.state.zoom.value;this.setState(I=>{let S=In({viewportX:g.x,viewportY:g.y,nextZoom:T},I);return this.translateCanvas({zoom:S.zoom,scrollX:S.scrollX+2*(x/T),scrollY:S.scrollY+2*(v/T),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else ve.lastCenter=ve.initialDistance=ve.initialScale=null;if(kr||bc||ly||yn(this.state))return;let s=$f(xc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?Zt(this.interactiveCanvas):jt(this.interactiveCanvas,this.state)),!this.state.newElement&&UC(this.state.activeTool.type)){let{originOffset:g,snapLines:x}=GC(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(v=>{let y=dc(v.snapLines,x),E=v.originSnapOffset?dc(v.originSnapOffset,g):g;return v.snapLines===y&&v.originSnapOffset===E?null:{snapLines:y,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:xe.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Yt(()=>{this.setState({selectedLinearElement:g})})}if(vX(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&mc(this.state)){let x=re(r,i),v=this.scene.getNonDeletedElementsMap(),y=Ho(x,this.scene.getNonDeletedElements(),v,ry(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:iy(x,y,v,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:x}=this.state,{x:v,y,points:E}=g,T=E[E.length-1],{lastCommittedPoint:I}=x;if(jt(this.interactiveCanvas,this.state),T===I)bl(this.state.newElement)&&mc(this.state)&&Ho(re(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ry(this.state.zoom))?(this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Zt(this.interactiveCanvas),this.setState(M=>({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...M.selectedElementIds,[g.id]:!0},M),selectedLinearElement:new xe(g,this.scene.getNonDeletedElementsMap())})))):Ir(re(r-v,i-y),T)>=Nx?(this.scene.mutateElement(g,{points:[...E,re(r-v,i-y)]},{informMutation:!1,isDragging:!1}),fn(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:E[E.length-1],selectedPointsIndices:[g.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length-1}}})):Ce(this.interactiveCanvas,ze.POINTER);else if(E.length>2&&I&&Ir(re(r-v,i-y),I)<Nx)Ce(this.interactiveCanvas,ze.POINTER),this.scene.mutateElement(g,{points:E.slice(0,-1)},{informMutation:!1,isDragging:!1}),this.setState({selectedLinearElement:{...x,selectedPointsIndices:x.selectedPointsIndices?.includes(g.points.length)?[...x.selectedPointsIndices.filter(S=>S!==g.points.length&&S!==g.points.length-1),g.points.length-1]:x.selectedPointsIndices,lastCommittedPoint:g.points[g.points.length-1],initialState:{...x.initialState,lastClickedPoint:g.points.length-1}}});else{wA(E,this.state.zoom.value)&&Ce(this.interactiveCanvas,ze.POINTER);let S=this.scene.getNonDeletedElementsMap();if(ny(g)){let k=Ho(re(r,i),this.scene.getNonDeletedElements(),S);Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,k)}fn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let M=xe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);M&&this.setState(M)}return}if(this.state.activeTool.type==="arrow"){let g=Ho(re(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ry(this.state.zoom)),x=re(r,i),v=this.scene.getNonDeletedElementsMap();g&&!fK(x,g,v)&&this.setState({suggestedBinding:{element:g,midPoint:iy(x,g,v,this.state.zoom)}})}let c=!!t.buttons,m=this.state.activeTool.type==="laser";if(c||!m&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let p=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&Xt(d[0]))&&!(_t(d[0])&&(this.editorInterface.userAgent.isMobileDevice||d[0].points.length===2))){let g=FA(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){Ce(this.interactiveCanvas,BA(g));return}}}else if(d.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=OA(fl(d),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){Ce(this.interactiveCanvas,BA({transformHandleType:g}));return}}if(Ht(this.state))return;let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),b=null;if(u&&u.locked?b=null:b=u,this.handleIframeLikeElementHover({hitElement:b,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])Ce(this.interactiveCanvas,ze.POINTER),_2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(xg(),m)return;b&&(b.link||Fn(b))&&this.state.selectedElementIds[b.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Ce(this.interactiveCanvas,Ro(b)?ze.TEXT:ze.CROSSHAIR):this.state.viewModeEnabled?Ce(this.interactiveCanvas,ze.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Ce(this.interactiveCanvas,ze.AUTO):s?Ce(this.interactiveCanvas,ze.AUTO):t[j.CTRL_OR_CMD]?Ce(this.interactiveCanvas,ze.AUTO):(b||this.isHittingCommonBoundingBoxOfSelectedElements(n,d))&&!b?.locked&&(!b||!Xt(b)||!(b.startBinding||b.endBinding))&&(this.state.activeTool.type!=="lasso"||d.length>0)&&Ce(this.interactiveCanvas,ze.MOVE),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&b?this.setState(g=>({hoveredElementIds:dc(g.hoveredElementIds,ho({editingGroupId:g.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!b&&this.setState(g=>({hoveredElementIds:dc(g.hoveredElementIds,{})}))});w(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});w(this,"handleTouchMove",t=>{yc=!0});w(this,"handleCanvasPointerDown",t=>{if(!t.ctrlKey){let b=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==b&&this.setState({isBindingEnabled:b})}let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(b=>({searchMatches:b.searchMatches&&{focusedId:null,matches:b.searchMatches.matches.map(g=>({...g,focus:!1}))}})),this.updateEditorAtom(Rb,null)),Qe.get(Io)&&this.updateEditorAtom(Io,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let b=this.state.newElement;this.updateScene({...b.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(g=>g.id!==b.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:ke(Object.keys(this.state.selectedElementIds).filter(g=>g!==b.id).reduce((g,x)=>(g[x]=this.state.selectedElementIds[x],g),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Dt.EVENTUALLY:Dt.NEVER});return}let a=document.getSelection();if(a?.anchorNode&&a.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(b=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=zx(this.editorInterface,{isTouchScreen:!0})),bc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Cr.ERASER&&this.state.activeTool.type!==hn.eraser){this.setState({activeTool:gn(this.state,{type:hn.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let b=()=>{g(),x?.(),Ht(this.state)&&this.setState({activeTool:gn(this.state,{...this.state.activeTool.lastActiveTool||{type:hn.selection},lastActiveToolBeforeEraser:null})})},g=$e(window,ae.POINTER_UP,b,{once:!0}),x;requestAnimationFrame(()=>{x=this.missingPointerEventCleanupEmitter.once(b)})});return}if(t.button!==Cr.MAIN&&t.button!==Cr.TOUCH&&t.button!==Cr.ERASER||ve.pointers.size>1)return;let s=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,s)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,s))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let b=s.hit.element&&this.isASelectedElement(s.hit.element);!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!b&&(this.lassoTrail.startPath(s.origin.x,s.origin.y,t.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&s.hit.element&&!b&&(this.setState(g=>{let x={...g.selectedElementIds,[s.hit.element.id]:!0},v=[];Object.keys(g.selectedElementIds).forEach(E=>{let T=this.scene.getElement(E);T&&v.push(T)});let y=s.hit.element;if(Vt(y))qx(v,y.id).forEach(E=>{delete x[E.id]});else if(y.frameId)x[y.frameId]&&delete x[y.id];else{let E=y.groupIds,T=new Set(E.flatMap(I=>bi(this.scene.getNonDeletedElements(),I)).filter(I=>Vt(I)).map(I=>I.id));T.size>0&&v.forEach(I=>{I.frameId&&T.has(I.frameId)&&(delete x[I.id],I.groupIds.flatMap(S=>bi(this.scene.getNonDeletedElements(),S)).forEach(S=>{delete x[S.id]}))})}return{...ho({editingGroupId:g.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),g,this),showHyperlinkPopup:y.link||Fn(y)?"info":!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,s):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="custom"?jt(this.interactiveCanvas,this.state):this.state.activeTool.type===hn.frame||this.state.activeTool.type===hn.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(s),p=this.onPointerUpFromPointerDownHandler(s),d=this.onKeyDownFromPointerDownHandler(s),u=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(b=>p(b||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ae.POINTER_MOVE,m),window.addEventListener(ae.POINTER_UP,p),window.addEventListener(ae.KEYDOWN,d),window.addEventListener(ae.KEYUP,u),s.eventListeners.onMove=m,s.eventListeners.onUp=p,s.eventListeners.onKeyUp=u,s.eventListeners.onKeyDown=d)});w(this,"handleCanvasPointerUp",t=>{if(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpEvent=t,!t.ctrlKey){let l=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==l&&this.setState({isBindingEnabled:l})}let n=Be({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let l=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,l)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});w(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(yc=!1,Mr?yc=!0:Mr=window.setTimeout(()=>{Mr=0,yc||this.handleCanvasContextMenu(t)},BV))});w(this,"resetContextMenuTimer",()=>{clearTimeout(Mr),Mr=0,yc=!1});w(this,"maybeCleanupAfterMissingPointerUp",t=>{Ec?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});w(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ve.pointers.size<=1&&(t.button===Cr.WHEEL||t.button===Cr.MAIN&&kr||yn(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;bc=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Ce(this.interactiveCanvas,ze.GRABBING);let{clientX:i,clientY:l}=t,a=Vm(c=>{let m=i-c.clientX,p=l-c.clientY;if(i=c.clientX,l=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=b=>{document.body.removeEventListener(ae.PASTE,d),b.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ae.PASTE,d),window.removeEventListener(ae.POINTER_UP,u)},100)};document.body.addEventListener(ae.PASTE,d),window.addEventListener(ae.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=We(Ec=()=>{Ec=null,bc=!1,kr||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?Ce(this.interactiveCanvas,ze.GRAB):jt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ae.POINTER_MOVE,a),window.removeEventListener(ae.POINTER_UP,s),window.removeEventListener(ae.BLUR,s),a.flush()});return window.addEventListener(ae.BLUR,s),window.addEventListener(ae.POINTER_MOVE,a,{passive:!0}),window.addEventListener(ae.POINTER_UP,s),!0});w(this,"clearSelectionIfNotUsingSelection",()=>{nu(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});w(this,"handleSelectionOnPointerDown",(t,n)=>{if(nu(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),l=this.scene.getSelectedElements(this.state);if(l.length===1&&!this.state.selectedLinearElement?.isEditing&&!Xt(l[0])&&!(_t(l[0])&&(this.editorInterface.userAgent.isMobileDevice||l[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=FA(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);a!=null&&(a.transformHandleType==="rotation"?(this.setState({resizingElement:a.element}),n.resize.handleType=a.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:a.element}),n.resize.handleType=a.transformHandleType))}else l.length>1&&(n.resize.handleType=OA(fl(l),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=Ox(lK(n.resize.handleType,l,i,n.origin.x,n.origin.y)),l.length===1&&_t(l[0])&&l[0].points.length===2&&(n.resize.arrowDirection=sK(n.resize.handleType,l[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,u=xe.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let b=this.scene.getNonDeletedElementsMap(),g=xe.getElement(d.elementId,b);if(g&&bn(g)){let{hitFocusPoint:x,pointerOffset:v}=yK(g,n,b,this.state);if(x)return this.setState({selectedLinearElement:{...d,hoveredFocusPointBinding:x,draggedFocusPointBinding:x,pointerOffset:v}}),!1}}let a=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=a.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:a});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?ke({[d.selectedLinearElement.elementId]:!0},this.state):ke({},d)}));else if(m!=null){if(t[j.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...tK(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!RA(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let u={...d.selectedElementIds,[m.id]:!0},b=[];if(Object.keys(d.selectedElementIds).forEach(g=>{let x=this.scene.getElement(g);x&&b.push(x)}),Vt(m))qx(b,m.id).forEach(g=>{delete u[g.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let g=m.groupIds,x=new Set(g.flatMap(v=>bi(this.scene.getNonDeletedElements(),v)).filter(v=>Vt(v)).map(v=>v.id));x.size>0&&b.forEach(v=>{v.frameId&&x.has(v.frameId)&&(delete u[v.id],v.groupIds.flatMap(y=>bi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(g=>d.selectedGroupIds[g])||(u={[m.id]:!0})),{...ho({editingGroupId:d.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||Fn(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});w(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,l=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(r,i);TA(l)&&(a=l,r=l.x+l.width/2,i=l.y+l.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:a,autoEdit:!1}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})})});w(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,l]=It(r.origin.x,r.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),s=t.pressure===.5,c=hX({type:n,x:i,y:l,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:a?a.id:null,points:[re(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let d={...p.selectedElementIds};return delete d[c.id],{selectedElementIds:ke(d,p)}});let m=Ho(re(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:m,suggestedBinding:null})});w(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[l,a]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=gX({type:"iframe",x:l,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:r,height:i});return this.scene.insertElement(s),s});w(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,l]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=iu(r);if(!a)return;a.error instanceof URIError&&this.setToast({message:h("toast.unrecognizedLinkFormat"),closable:!0});let s=xA({type:"embeddable",x:i,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});w(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,l]=It(t,n,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=r?this.getTopLayerFrameAtSceneCoords({x:i,y:l}):null,s=100/this.state.zoom.value;return xX({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null,x:i-s/2,y:l-s/2,width:s,height:s})});w(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:l}=this.state;if(fn(l,"selectedLinearElement is expected to be set"),i.type==="line"&&wA(i.points,this.state.zoom.value)){Yt(()=>{this.setState({selectedLinearElement:{...l,lastCommittedPoint:i.points[i.points.length-1],initialState:{...l.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(kt);return}if(Xt(i)&&i.points.length>1){this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:a,y:s}=i,{lastCommittedPoint:c}=l,m=mc(this.state)&&Ho(re(this.lastPointerMoveCoords?.x??a+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(bn(i)&&m||i.points.length>1&&c&&Ir(re(r.origin.x-a,r.origin.y-s),c)<Nx){this.actionManager.executeAction(kt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:ke({...p.selectedElementIds,[i.id]:!0},p)})),Ce(this.interactiveCanvas,ze.POINTER)}else{let[i,l]=It(r.origin.x,r.origin.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?fX({type:n,x:i,y:l,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===Sr.round?{type:Qp.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Sr.elbow,fixedSegments:this.state.currentItemArrowType===Sr.elbow?[]:null}):yX({type:n,x:i,y:l,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:Qp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),u=re(r.origin.x,r.origin.y),b=this.scene.getNonDeletedElementsMap(),g=mc(this.state)?Ho(u,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(d,{points:[re(0,0),re(0,0)]}),this.scene.insertElement(d),bn(d)&&hK(d,new Map([[0,{point:re(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:rA(t.nativeEvent)}),Yt(()=>{this.setState(x=>{let v=null,y=x.selectedElementIds;if(_t(d)){v=new xe(d,this.scene.getNonDeletedElementsMap());let E=d.points.length-1;v={...v,selectedPointsIndices:[E],initialState:{...v.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:E,origin:re(r.origin.x,r.origin.y)}}}return y=this.state.activeTool.locked?x.selectedElementIds:ke({[d.id]:!0},x),{...x,bindMode:"orbit",newElement:d,startBoundElement:g,suggestedBinding:g&&bn(d)?{element:g,midPoint:iy(u,g,b,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:v}})}),bn(d)&&Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,g)}});w(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=It(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:l?l.id:null},s;t==="embeddable"?s=xA({type:"embeddable",...a}):s=bX({type:t,...a}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});w(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=It(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...pn},a=n===hn.magicframe?yA(l):uX(l);this.scene.insertElement(a),this.setState({multiElement:null,newElement:a})});w(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});w(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(bn(i)){if(i.startBinding){let l=this.scene.getElement(i.startBinding.elementId);au(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}if(i.endBinding){let l=this.scene.getElement(i.endBinding.elementId);au(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}}else Xx(i)&&i.boundElements?.forEach(l=>{if(l.type==="arrow"){let a=this.scene.getElement(l.id);a?.startBinding?.elementId===i.id&&au(a,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),a?.endBinding?.elementId===i.id&&au(a,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Wx(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,wr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});w(this,"initializeImage",async(t,n)=>{if(!_r(n))throw new Error(h("errors.unsupportedFileType"));let r=n.type;if(Ce(this.interactiveCanvas,"wait"),r===un.svg)try{n=Cu(MA(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(h("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||Ky(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(h("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await Dc(n,{maxWidthOrHeight:PV})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>sA)throw new Error(h("errors.fileTooBig",{maxSize:`${Math.trunc(sA/1024/1024)}MB`}))}let a=this.files[i]?.dataURL||await Iu(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:a,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(i)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(h("errors.imageInsertError")))}})});w(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return wr(r,{fileId:n})});w(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Be({clientX:t,clientY:n},this.state),l=await Sc({description:"Image",extensions:Object.keys(LV),multiple:!0});this.insertImages(l,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(kt)})}});w(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,i),a=l*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-a/2,c=t.y+t.height/2-l/2;return{x:s,y:c,width:a,height:l,crop:null}});w(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await PX({imageCache:this.imageCache,fileIds:t.map(l=>l.fileId),files:n});return i.size&&(this.store.scheduleAction(Dt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(l=>pc(l)&&i.has(l.fileId)?wr(l,{status:"error"}):l))),{updatedFiles:r,erroredFiles:i}});w(this,"addNewImagesToImageCache",async(t=MX(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let l of r)i.has(l.fileId)&&hc.delete(l);i.size&&this.scene.triggerUpdate()}});w(this,"scheduleImageRefresh",CV(()=>{this.addNewImagesToImageCache()},_V));w(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ae.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ae.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ae.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ae.TOUCH_END,this.onTouchEnd))});w(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,l=YA(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);l.forEach(d=>this.scene.insertElement(d));let a=await Promise.all(l.map(async(d,u)=>{try{return await this.initializeImage(d,await Ll(t[u]))}catch(b){return this.setState({errorMessage:b.message||h("errors.imageInsertError")}),wr(d,{isDeleted:!0})}})),s=ou(a),c=YA(a.filter(d=>!d.isDeleted),n,r,i),m=ou(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:Dt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(kt)})});w(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Be(t,this.state),i=await na(t),l=i.getFiles();if(l.length===1){let{file:p,fileHandle:d}=l[0];if(p&&(p.type===un.png||p.type===un.svg))try{let u=await _c(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Dt.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(h("alerts.couldNotLoadInvalidFile"))}}let a=l.map(p=>p.file).filter(p=>_r(p));if(a.length>0&&this.isToolSupported("image"))return this.insertImages(a,n,r);let s=i.getData(un.hellixitboardlibIds),c=i.getData(un.hellixitboardlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(b=>d.includes(b.id))}else c&&(p=Xy(c));p?.length&&(p=p.map(d=>({...d,elements:Ux({type:"everything",elements:d.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Ta(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(l.length>0){let{file:p,fileHandle:d}=l[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(un.text);if(m){let p=m.value;if(p&&$x(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||iu(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:Bx(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});w(this,"loadFileToCanvas",async(t,n)=>{t=await Ll(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await vu(t,this.state,r,n)}catch(l){let a=l instanceof Ry;if(a&&l.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:h("errors.imageToolNotSupported")});return}let s=a?h("alerts.cannotRestoreFromImage"):h("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===un.hellixitboard?(QA(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Dt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Dt.IMMEDIATELY})):i.type===un.hellixitboardlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(l=>{console.error(l),this.setState({errorMessage:h("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});w(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Cr.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=Be(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),l=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},l),s=i||a?"element":"canvas";this._contextMenuPos={sceneX:n,sceneY:r,elementId:i?.id??null};let c=this.hellixitboardContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,u=t.clientY-m;ce("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ho({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:_t(i)?new xe(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:d,items:this.getContextMenuItems(s)}})})});w(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,l=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){zA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:l.x,y:l.y,width:gl(t.origin.x,l.x),height:gl(t.origin.y,l.y),shouldMaintainAspectRatio:sc(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a)return;let[s,c]=It(l.x,l.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=pc(a)&&this.imageCache.get(a.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[a]);let{snapOffset:d,snapLines:u}=zC(a,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:u}),bn(a)||zA({newElement:a,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:gl(t.originInGrid.x,s),height:gl(t.originInGrid.y,c),shouldMaintainAspectRatio:fi(a)?!sc(n):sc(n),shouldResizeFromCenter:nA(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:a}),(this.state.activeTool.type===hn.frame||this.state.activeTool.type===hn.magicframe)&&this.setState({elementsToHighlight:Qx(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})});w(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[l,a]=It(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&fi(s)){let c=t.originalElements.get(s.id),m=pc(s)&&this.imageCache.get(s.fileId)?.image;if(c&&fi(c)&&m&&!(m instanceof Promise)){let[p,d]=It(i.x,i.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:b,snapLines:g}=Uf([s],[c],this,n,u,r);this.scene.mutateElement(s,VX(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,l+b.x,a+b.y,n.shiftKey?c.width/c.height:void 0)),ru(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});w(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Vt(p)),l=t.resize.handleType;if(i.length>0&&l==="rotation"||r.length===1&&Xt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:l&&l!=="rotation",isRotating:l==="rotation",activeEmbeddable:null});let a=t.lastCoords,[s,c]=It(a.x-t.resize.offset.x,a.y-t.resize.offset.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{qx(this.scene.getNonDeletedElements(),p.id).forEach(u=>{m.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=It(a.x,a.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:d-t.originInGrid.y},b=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:g,snapLines:x}=Uf(r,oe(b,this.state),this,n,u,l);s+=g.x,c+=g.y,this.setState({snapLines:x})}if(cK(t.originalElements,l,r,this.scene,rA(n),nA(n),r.some(p=>fi(p))?!sc(n):sc(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{Qx(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>p.add(u))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});w(this,"getContextMenuItems",t=>{let n=[];n.push(Kd,Xd);let r=this._contextMenuPos,i=this.props.onAddComment,l=i&&r?{name:"addComment",label:"labels.addComment",trackEvent:!1,perform:()=>(i(r.elementId,r.sceneX,r.sceneY),!1)}:null,a=this.props.onToggleComments,s=a?{name:"toggleComments",label:this.props.commentsVisible?"labels.hideComments":"labels.showComments",trackEvent:!1,perform:()=>(a(),!1)}:null;if(t==="canvas")return this.state.viewModeEnabled?[...n,ua,tr,Zr,or]:[ig,qe,Kd,Xd,$d,qe,oh,F2,qe,ua,cs,ds,ms,tr,Zr,or,l&&qe,l,s];if(n.push($d),this.state.viewModeEnabled)return[pa,...n];let c=this.editorInterface.formFactor==="desktop"?[qe,Ju,Qu,eh,th]:[];return[qe,Vd,pa,ig,qe,bC,xC,yC,qe,_f,qe,...n,qe,Zh,jh,qe,Jh,kC,sg,cg,I2,Qh,qe,og,...c,qe,ng,rg,qe,Ha,qe,hs,em,qe,nh,gs,qe,Gl,l&&qe,l,s]});w(this,"handleWheel",We(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(Gx.FRAME_NAME))){t[j.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),bc)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),l=OV*100,a=Math.abs(r),s=r;a>l&&(s=l*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,a/20),this.translateCanvas(m=>({...In({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:No(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:l})=>({scrollX:l-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:l,scrollY:a})=>({scrollX:l-n/i.value,scrollY:a-r/i.value}))}));w(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:l}=Be({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(l);let a={x:i,y:l,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:r,pointersMap:ve.pointers})});w(this,"resetShouldCacheIgnoreZoomDebounced",mA(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));w(this,"updateDOMRect",t=>{if(this.hellixitboardContainerRef?.current){let n=this.hellixitboardContainerRef.current,{width:r,height:i,left:l,top:a}=n.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&l===p&&a===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:l,offsetTop:a},()=>{t&&t()})}});w(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});w(this,"watchState",()=>{});let n=Oo(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:a=!1,theme:s=n.theme,name:c=`${h("labels.untitled")}-${uA()}`}=t;this.state={...n,theme:s,exportWithDarkMode:s===ul.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:a,gridModeEnabled:l??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=cu(this.editorInterface),this.id=wV(),this.library=new cT(this),this.actionManager=new Om(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new UA,this.canvas=document.createElement("canvas"),this.rc=SV.canvas(this.canvas),this.renderer=new Os(this.scene),this.visibleElements=[],this.store=new pK(this),this.history=new Ns(this.store),this.hellixitboardContainerValue={container:this.hellixitboardContainerRef.current,id:this.id},this.fonts=new Gn(this.scene),this.history=new Ns(this.store),this.actionManager.registerAll(qc),this.actionManager.registerAction(IC(this.history)),this.actionManager.registerAction(CC(this.history)),this.api=this.createHellixitboardAPI()}createHellixitboardAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.hellixitboard__embeddable");if(!i)break;for(let l of i)l.contentWindow===t.source&&(r=l.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(eu).includes(i)&&sy.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){fn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=Ho(re(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=xe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Yt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;fn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,l=n-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?xe.handlePointerMove(r,this,i,l,this.state.selectedLinearElement):xe.handlePointDragging(r,this,i,l,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||Xt(t))return;let r=()=>{if(this.bindModeHandler=null,fn(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!b&&!g||b&&g)return}let{x:p,y:d}=this.lastPointerMoveCoords,u=Ho(re(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){fn(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Yt(()=>{fn(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;fn(g,"Last event must exist");let x=p-this.state.selectedLinearElement.pointerOffset.x,v=d-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?xe.handlePointerMove(g,this,x,v,this.state.selectedLinearElement):xe.handlePointDragging(g,this,x,v,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),b=d?n:t.startBinding&&p.get(t.startBinding.elementId),g=u?n:t.endBinding&&p.get(t.endBinding.elementId),x=b&&XA(b,p),v=g&&XA(g,p);i=!!(x&&v&&b.id!==g.id&&gK(x,v))}let l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=l?"startBinding":a?"endBinding":null,c=l?"endBinding":a?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Yt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,rX)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Cr.MAIN||kr||!gA(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=re(Be({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=re(Be({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Ir(t,n)>aA)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ve.pointers.size<2&&Yx(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[1]))))return!1;let a=i;if(this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:a,state:"active"},selectedElementIds:{[a.id]:!0},newElement:null,selectionElement:null})},100),xl(a)))return!0;let s=this.getHTMLIFrameElement(a);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let c=sy.get(a.id);switch(c||(sy.set(a.id,eu.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:a.id}),"*")),c){case eu.PLAYING:case eu.BUFFERING:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return s.src.includes("player.vimeo.com")&&s.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(l=>Fn(l)&&this.embedsValidationStatus.get(l.id)===!0||xl(l));return Te(CK,{children:i.map(l=>{let{x:a,y:s}=tu({sceneX:l.x,sceneY:l.y},this.state),c=CA(l,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(l.id);if(c&&!m&&this.initializedEmbeds.add(l.id),!(c||m))return null;let d;if(xl(l)){d=null;let g=(l.customData?.generationData??this.magicGenerations.get(l.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(g.status==="done"){let x=g.html;d={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>x}}else if(g.status==="pending")d={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>kA(`
40
40
  <style>
41
41
  html, body {
42
42
  width: 100%;
@@ -127,8 +127,8 @@ Please fix the Mermaid syntax and regenerate a valid diagram.`;await v({prompt:t
127
127
  </style>
128
128
  <h1>Error!</h1>
129
129
  <h3>${x}</h3>
130
- `)}}}else d=iu(YV(l.link||""));let u=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active",b=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="hover";return Te("div",{className:jP("hellixitboard__embeddable-container",{"is-hovered":b}),style:{transform:c?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:eK(l,ey(l,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?UV:1),"--embeddable-radius":`${SX(Math.min(l.width,l.height),l)}px`},children:su("div",{className:"hellixitboard__embeddable-container__inner",style:{width:c?`${l.width}px`:0,height:c?`${l.height}px`:0,transform:c?`rotate(${l.angle}rad)`:"none",pointerEvents:u?hl.enabled:hl.disabled},children:[b&&Te("div",{className:"hellixitboard__embeddable-hint",children:h("buttons.embeddableInteractionButton")}),Te("div",{className:"hellixitboard__embeddable__outer",style:{padding:`${l.strokeWidth}px`},children:(Fn(l)?this.props.renderEmbeddable?.(l,this.state):null)??Te("iframe",{ref:g=>this.cacheEmbeddableRef(l,g),className:"hellixitboard__embeddable",srcDoc:d?.type==="document"?d.srcdoc(this.state.theme):void 0,src:d?.type!=="document"?d?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Hellix IT Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${d?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},l.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderTopLeftUI:r,renderCustomStats:i}=this.props,l=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:l,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let c=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],d=Qe.get(Io)?.type==="panel";return Te("div",{translate:"no",className:jP("hellixitboard hellixitboard-container notranslate",{"hellixitboard--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","hellixitboard--mobile":this.editorInterface.formFactor==="phone"}),style:{"--ui-pointerEvents":m?hl.disabled:hl.enabled,"--right-sidebar-width":"302px"},ref:this.hellixitboardContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Te(yl.Provider,{value:this.api,children:Te(eL.Provider,{value:this,children:Te(tL.Provider,{value:this.props,children:Te(uy.Provider,{value:this.hellixitboardContainerValue,children:Te(py.Provider,{value:this.editorInterface,children:Te(fy.Provider,{value:this.setAppState,children:Te(gy.Provider,{value:this.state,children:su(hy.Provider,{value:this.scene.getNonDeletedElements(),children:[su(by.Provider,{value:this.actionManager,children:[Te(xP,{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:En().code,renderTopLeftUI:r,renderTopRightUI:n,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,onReportIssue:this.props.onReportIssue,children:this.props.children}),Te("div",{className:"hellixitboard-textEditorContainer"}),Te("div",{className:"hellixitboard-contextMenuContainer"}),Te("div",{className:"hellixitboard-eye-dropper-container"}),Te(vP,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Te(A2,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.props.aiEnabled!==!1&&t.length===1&&Vx(p)&&Te(Wf,{element:p,elementsMap:a,children:Te($p,{title:h("labels.convertToCode"),icon:Fr,checked:!1,onChange:()=>this.onMagicFrameGenerate(p,"button")})}),t.length===1&&xl(p)&&p.customData?.generationData?.status==="done"&&su(Wf,{element:p,elementsMap:a,children:[Te($p,{title:h("labels.copySource"),icon:Bi,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),Te($p,{title:"Enter fullscreen",icon:wE,checked:!1,onChange:()=>{let u=this.getHTMLIFrameElement(p);if(u)try{u.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(b){console.warn(b),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.contextMenu&&Te(eS,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:u=>{this.setState({contextMenu:null},()=>{this.focusContainer(),u?.()})}}),Te(Dx,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:c,visibleElements:s,sceneNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:cr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes,theme:this.state.theme}}),this.state.newElement&&Te($P,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Te(_x,{app:this,containerRef:this.hellixitboardContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:c,selectedElements:t,sceneNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Te(oS,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&Te(ZP,{app:this,activeLockedId:this.state.activeLockedId}),d&&Te(K2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=FX(this.scene.getNonDeletedElements(),t).filter(a=>!Vx(a));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ce("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let l=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(l){this.updateMagicGeneration({frameElement:l,data:{status:"pending"}}),this.setState({selectedElementIds:{[l.id]:!0}}),ce("ai","generate (start)","d2c");try{let{html:a}=await r({frame:t,children:i});if(ce("ai","generate (success)","d2c"),!a.trim()){this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=a.includes("<!DOCTYPE html>")&&a.includes("</html>")?a.slice(a.indexOf("<!DOCTYPE html>"),a.indexOf("</html>")+7):a;this.updateMagicGeneration({frameElement:l,data:{status:"done",html:s}})}catch(a){ce("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:a.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(vo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{pc(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),hc.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createHellixitboardAPI(),this.hellixitboardContainerValue.container=this.hellixitboardContainerRef.current,jA()||qA()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.hellixitboardContainerRef.current&&this.focusContainer(),zV&&this.hellixitboardContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.hellixitboardContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),lX()&&!$X()&&this.setState({errorMessage:Te(jC,{})});let n={hellixitboardAPI:this.api,container:this.hellixitboardContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",n),this.props.onMount?.(n),this.props.onHellixitboardAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("HellixitboardAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `HellixitboardAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onHellixitboardAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new UA,this.fonts=new Gn(this.scene),this.renderer=new Os(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),hc.destroy(),io.destroy(),clearTimeout(Mr),Me.clearCache(),ho.clearCache(),Mr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once($e(document,ae.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once($e(this.hellixitboardContainerRef.current,ae.WHEEL,this.handleWheel,{passive:!1}),$e(window,ae.MESSAGE,this.onWindowMessage,!1),$e(document,ae.POINTER_UP,this.removePointer,{passive:!1}),$e(document,ae.COPY,this.onCopy,{passive:!1}),$e(document,ae.KEYUP,this.onKeyUp,{passive:!0}),$e(document,ae.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),$e(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),$e(document,ae.GESTURE_START,this.onGestureStart,!1),$e(document,ae.GESTURE_CHANGE,this.onGestureChange,!1),$e(document,ae.GESTURE_END,this.onGestureEnd,!1),$e(window,ae.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once($e(document,ae.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),$e(document,ae.PASTE,this.pasteFromClipboard,{passive:!1}),$e(document,ae.CUT,this.onCut,{passive:!1}),$e(window,ae.RESIZE,this.onResize,!1),$e(window,ae.UNLOAD,this.onUnload,!1),$e(window,ae.BLUR,this.onBlur,!1),$e(this.hellixitboardContainerRef.current,ae.WHEEL,this.handleWheel,{passive:!1}),$e(this.hellixitboardContainerRef.current,ae.DRAG_OVER,this.disableEvent,!1),$e(this.hellixitboardContainerRef.current,ae.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once($e(VV(this.hellixitboardContainerRef.current),ae.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.appStateObserver.flush(n),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),l=(this.sessionExportThemeOverride??this.state.theme)===ul.DARK;this.state.exportWithDarkMode!==l&&this.setState({exportWithDarkMode:l}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.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)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Ht(this.state)&&this.setState({activeTool:gn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&Fh(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Ht(n)&&!Ht(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.hellixitboardContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ul.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(kt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){gc=!1,fc=null}async insertClipboardContent(t,n,r){let{x:i,y:l}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:l});return}if(!r&&t.text){let m=op(t.text);if(m.ok){this.setState({openDialog:{name:"charts",data:m.data,rawText:t.text}});return}}let a=n.map(m=>m.file);if(a.length===0&&t.text&&!r){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&a.push(wu(m))}if(a.length>0){this.isToolSupported("image")?await this.insertImages(a,i,l):this.setState({errorMessage:h("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?KA(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r});return}if(!t.text)return;if(!r&&rC(t.text)){let m=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:p,files:d={}}=await m.parseMermaidToExcalidraw(t.text),u=KA(p,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:d,position:this.editorInterface.formFactor==="desktop"?"cursor":"center"});return}catch(p){console.warn(`parsing pasted text as mermaid definition failed: ${p.message}`)}}let s=JV(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),c=s.map(m=>kX(m)).filter(m=>$x(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||iu(m)?.type==="video"));if(!r&&c.length>0&&c.length===s.length){let m=[];for(let p of c){let d=m[m.length-1],u=this.insertEmbeddableElement({sceneX:d?d.x+d.width+20:i,sceneY:l,link:Bx(p)});u&&m.push(u)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(l=>l.type==="imageUrl")&&this.isToolSupported("image")){let l=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(l.map(async m=>{try{return{file:await jy(m)}}catch(p){let d=p.message;return p.cause==="FETCH_ERROR"?d=h("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(d=h("errors.unsupportedFileType")),{errorMessage:d}}})),s=a.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let c=a.find(m=>!!m.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let l=t.filter(a=>a.type==="text");l.length&&this.addTextFromPaste(l.map(a=>a.value).join(`
130
+ `)}}}else d=iu(YV(l.link||""));let u=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active",b=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="hover";return Te("div",{className:jP("hellixitboard__embeddable-container",{"is-hovered":b}),style:{transform:c?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:eK(l,ey(l,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?UV:1),"--embeddable-radius":`${wX(Math.min(l.width,l.height),l)}px`},children:su("div",{className:"hellixitboard__embeddable-container__inner",style:{width:c?`${l.width}px`:0,height:c?`${l.height}px`:0,transform:c?`rotate(${l.angle}rad)`:"none",pointerEvents:u?hl.enabled:hl.disabled},children:[b&&Te("div",{className:"hellixitboard__embeddable-hint",children:h("buttons.embeddableInteractionButton")}),Te("div",{className:"hellixitboard__embeddable__outer",style:{padding:`${l.strokeWidth}px`},children:(Fn(l)?this.props.renderEmbeddable?.(l,this.state):null)??Te("iframe",{ref:g=>this.cacheEmbeddableRef(l,g),className:"hellixitboard__embeddable",srcDoc:d?.type==="document"?d.srcdoc(this.state.theme):void 0,src:d?.type!=="document"?d?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Hellix IT Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${d?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},l.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderTopLeftUI:r,renderCustomStats:i}=this.props,l=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:l,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let c=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],d=Qe.get(Io)?.type==="panel";return Te("div",{translate:"no",className:jP("hellixitboard hellixitboard-container notranslate",{"hellixitboard--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","hellixitboard--mobile":this.editorInterface.formFactor==="phone"}),style:{"--ui-pointerEvents":m?hl.disabled:hl.enabled,"--right-sidebar-width":"302px"},ref:this.hellixitboardContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Te(yl.Provider,{value:this.api,children:Te(eL.Provider,{value:this,children:Te(tL.Provider,{value:this.props,children:Te(uy.Provider,{value:this.hellixitboardContainerValue,children:Te(py.Provider,{value:this.editorInterface,children:Te(fy.Provider,{value:this.setAppState,children:Te(gy.Provider,{value:this.state,children:su(hy.Provider,{value:this.scene.getNonDeletedElements(),children:[su(by.Provider,{value:this.actionManager,children:[Te(xP,{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:En().code,renderTopLeftUI:r,renderTopRightUI:n,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,onReportIssue:this.props.onReportIssue,children:this.props.children}),Te("div",{className:"hellixitboard-textEditorContainer"}),Te("div",{className:"hellixitboard-contextMenuContainer"}),Te("div",{className:"hellixitboard-eye-dropper-container"}),Te(vP,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Te(A2,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.props.aiEnabled!==!1&&t.length===1&&Vx(p)&&Te(Wf,{element:p,elementsMap:a,children:Te($p,{title:h("labels.convertToCode"),icon:Fr,checked:!1,onChange:()=>this.onMagicFrameGenerate(p,"button")})}),t.length===1&&xl(p)&&p.customData?.generationData?.status==="done"&&su(Wf,{element:p,elementsMap:a,children:[Te($p,{title:h("labels.copySource"),icon:Bi,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),Te($p,{title:"Enter fullscreen",icon:CE,checked:!1,onChange:()=>{let u=this.getHTMLIFrameElement(p);if(u)try{u.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(b){console.warn(b),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.contextMenu&&Te(ew,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:u=>{this.setState({contextMenu:null},()=>{this.focusContainer(),u?.()})}}),Te(Dx,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:c,visibleElements:s,sceneNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:cr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes,theme:this.state.theme}}),this.state.newElement&&Te($P,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Te(_x,{app:this,containerRef:this.hellixitboardContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:c,selectedElements:t,sceneNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Te(ow,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&Te(ZP,{app:this,activeLockedId:this.state.activeLockedId}),d&&Te(K2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=FX(this.scene.getNonDeletedElements(),t).filter(a=>!Vx(a));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ce("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let l=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(l){this.updateMagicGeneration({frameElement:l,data:{status:"pending"}}),this.setState({selectedElementIds:{[l.id]:!0}}),ce("ai","generate (start)","d2c");try{let{html:a}=await r({frame:t,children:i});if(ce("ai","generate (success)","d2c"),!a.trim()){this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=a.includes("<!DOCTYPE html>")&&a.includes("</html>")?a.slice(a.indexOf("<!DOCTYPE html>"),a.indexOf("</html>")+7):a;this.updateMagicGeneration({frameElement:l,data:{status:"done",html:s}})}catch(a){ce("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:a.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(vo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{pc(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),hc.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createHellixitboardAPI(),this.hellixitboardContainerValue.container=this.hellixitboardContainerRef.current,jA()||qA()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.hellixitboardContainerRef.current&&this.focusContainer(),zV&&this.hellixitboardContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.hellixitboardContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),lX()&&!$X()&&this.setState({errorMessage:Te(jS,{})});let n={hellixitboardAPI:this.api,container:this.hellixitboardContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",n),this.props.onMount?.(n),this.props.onHellixitboardAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("HellixitboardAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `HellixitboardAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onHellixitboardAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new UA,this.fonts=new Gn(this.scene),this.renderer=new Os(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),hc.destroy(),io.destroy(),clearTimeout(Mr),Me.clearCache(),ho.clearCache(),Mr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once($e(document,ae.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once($e(this.hellixitboardContainerRef.current,ae.WHEEL,this.handleWheel,{passive:!1}),$e(window,ae.MESSAGE,this.onWindowMessage,!1),$e(document,ae.POINTER_UP,this.removePointer,{passive:!1}),$e(document,ae.COPY,this.onCopy,{passive:!1}),$e(document,ae.KEYUP,this.onKeyUp,{passive:!0}),$e(document,ae.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),$e(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),$e(document,ae.GESTURE_START,this.onGestureStart,!1),$e(document,ae.GESTURE_CHANGE,this.onGestureChange,!1),$e(document,ae.GESTURE_END,this.onGestureEnd,!1),$e(window,ae.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once($e(document,ae.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),$e(document,ae.PASTE,this.pasteFromClipboard,{passive:!1}),$e(document,ae.CUT,this.onCut,{passive:!1}),$e(window,ae.RESIZE,this.onResize,!1),$e(window,ae.UNLOAD,this.onUnload,!1),$e(window,ae.BLUR,this.onBlur,!1),$e(this.hellixitboardContainerRef.current,ae.WHEEL,this.handleWheel,{passive:!1}),$e(this.hellixitboardContainerRef.current,ae.DRAG_OVER,this.disableEvent,!1),$e(this.hellixitboardContainerRef.current,ae.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once($e(VV(this.hellixitboardContainerRef.current),ae.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.appStateObserver.flush(n),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),l=(this.sessionExportThemeOverride??this.state.theme)===ul.DARK;this.state.exportWithDarkMode!==l&&this.setState({exportWithDarkMode:l}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.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)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Ht(this.state)&&this.setState({activeTool:gn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&Fh(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),Ht(n)&&!Ht(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.hellixitboardContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ul.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(kt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){gc=!1,fc=null}async insertClipboardContent(t,n,r){let{x:i,y:l}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:l});return}if(!r&&t.text){let m=op(t.text);if(m.ok){this.setState({openDialog:{name:"charts",data:m.data,rawText:t.text}});return}}let a=n.map(m=>m.file);if(a.length===0&&t.text&&!r){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&a.push(Cu(m))}if(a.length>0){this.isToolSupported("image")?await this.insertImages(a,i,l):this.setState({errorMessage:h("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?KA(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r});return}if(!t.text)return;if(!r&&rS(t.text)){let m=await import("@hellixit/mermaid-to-hellixitboard");try{let{elements:p,files:d={}}=await m.parseMermaidToExcalidraw(t.text),u=KA(p,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:d,position:this.editorInterface.formFactor==="desktop"?"cursor":"center"});return}catch(p){console.warn(`parsing pasted text as mermaid definition failed: ${p.message}`)}}let s=JV(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),c=s.map(m=>kX(m)).filter(m=>$x(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||iu(m)?.type==="video"));if(!r&&c.length>0&&c.length===s.length){let m=[];for(let p of c){let d=m[m.length-1],u=this.insertEmbeddableElement({sceneX:d?d.x+d.width+20:i,sceneY:l,link:Bx(p)});u&&m.push(u)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(l=>l.type==="imageUrl")&&this.isToolSupported("image")){let l=t.filter(m=>m.type==="imageUrl").map(m=>m.value),a=await Promise.all(l.map(async m=>{try{return{file:await jy(m)}}catch(p){let d=p.message;return p.cause==="FETCH_ERROR"?d=h("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(d=h("errors.unsupportedFileType")),{errorMessage:d}}})),s=a.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let c=a.find(m=>!!m.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let l=t.filter(a=>a.type==="text");l.length&&this.addTextFromPaste(l.map(a=>a.value).join(`
131
131
 
132
132
  `),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:GV,verticalAlign:iA,locked:!1},a=Fx({fontSize:l.fontSize,fontFamily:l.fontFamily}),s=dA(l.fontFamily),[c,,m]=UX(this.state),p=Math.max(Math.min((m-c)*.5,800),200),d=10,u=i,b=n?[t]:t.split(`
133
- `),g=b.reduce((x,v,y)=>{let E=ZX(v).trim();if(E.length){let T=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),I=HA(E,a,s),C=I.width>p,M=C?XX(E,a,p):E;I=C?HA(M,a,s):I;let k=r-I.width/2,_=u-I.height/2,P=EA({...l,x:k,y:_,text:M,originalText:E,lineHeight:s,autoResize:!C,frameId:T?T.id:null});x.push(P),u+=P.height+d}else b[y-1]?.trim()&&(u+=jX(l.fontSize,s)+d);return x},[]);g.length!==0&&(this.scene.insertElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(x=>[x.id,!0])),this.state)}),!n&&g.length>1&&ZA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:h("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),ZA=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(l,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Ro(s)?Sr(s,{originalText:l,isDeleted:a??s.isDeleted,...EX(s,PA(s,r),r,l)}):s)])};tC({id:t.id,canvas:this.canvas,getViewportCoords:(l,a)=>{let{x:s,y:c}=tu({sceneX:l,sceneY:a},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:We(l=>{i(l,!1),GA(t)&&ru(t,this.scene)}),onSubmit:We(({viaKeyboard:l,nextOriginalText:a})=>{let s=!a.trim();if(i(a,s),!s&&l){let c=t.containerId?t.containerId:t.id;Yt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[c]:!0},m)}))})}s&&pX(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Yt(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&jt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,hellixitboardContainer:this.hellixitboardContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&Ro(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let a=i.length-1;a>-1;a--)if(this.state.selectedElementIds[i[a].id])return i[a]}let l=i[i.length-1];return uc({point:re(t,n),element:l,threshold:this.getElementHitThreshold(l)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Vt(l)?this.frameNameBoundsCache.get(l):null})?l:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],l=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(Ro(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let c=ey(s,l);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?AA({x:t,y:n},c,l):!0}).filter(s=>xl(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(cA/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&_X([r],this.state,this.editorInterface)&&uK(re(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||zX(re(t,n),r,this.scene.getNonDeletedElementsMap())?!0:uc({point:re(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Vt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return IA(i[0],!1)?i[0]:null;let l=null;for(let a=r.length-1;a>=0;--a){if(r[a].isDeleted)continue;let[s,c,m,p]=fA(r[a],this.scene.getNonDeletedElementsMap());if(bl(r[a])&&uc({point:re(t,n),element:r[a],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[a])})){l=r[a];break}else if(s<t&&t<m&&c<n&&n<p){l=r[a];break}}return IA(l,!1)?l:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),l=xe.getElement(t.elementId,i);if(l)if(this.state.selectedLinearElement){let a=-1,s=null;uc({point:re(n,r),element:l,elementsMap:i,threshold:this.getElementHitThreshold(l)})?(a=xe.getPointIndexUnderCursor(l,i,this.state.zoom,n,r),s=xe.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Xt(l)?a===0||a===l.points.length-1:a>=0)||s?we(this.interactiveCanvas,ze.POINTER):this.hitElement(n,r,l)&&(!Xt(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&we(this.interactiveCanvas,ze.MOVE)):this.hitElement(n,r,l)&&(!Xt(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&we(this.interactiveCanvas,ze.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),xe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let c=null,m=l;(m.startBinding||m.endBinding)&&(c=xK(l,n,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&we(this.interactiveCanvas,ze.POINTER)}else we(this.interactiveCanvas,ze.AUTO)}updateGestureOnPointerDown(t){ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ve.pointers.size===2&&(ve.lastCenter=Bf(ve.pointers),ve.initialScale=this.state.zoom.value,ve.initialDistance=Ff(Array.from(ve.pointers.values())))}initialPointerDownState(t){let n=Be(t,this.state),r=this.scene.getSelectedElements(this.state),[i,l,a,s]=fl(r),c=r.findIndex(Xt)===0;return{origin:n,withCmdOrCtrl:t[j.CTRL_OR_CMD],originInGrid:Ox(It(n.x,n.y,t[j.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:$f(xc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,p)=>(m.set(p.id,vA(p)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+i)/2,y:(s+l)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;ly=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=Vm(l=>{l.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(l,n)}),i=We(()=>{Ec=null,ly=!1,jt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ae.POINTER_MOVE,r),window.removeEventListener(ae.POINTER_UP,i),r.flush()});return Ec=i,window.addEventListener(ae.POINTER_MOVE,r),window.addEventListener(ae.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(cA/this.state.zoom.value,1),[i,l,a,s]=fl(n);return t.x>i-r&&t.x<a+r&&t.y>l-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:IX(t)?Qp.ADAPTIVE_RADIUS:Qp.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){An({event:t,app:this,selectedElements:n})&&(r||!io.getReferenceSnapPoints())&&io.setReferenceSnapPoints(Fw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){An({event:t,app:this,selectedElements:n})&&(r||!io.getVisibleGaps())&&io.setVisibleGaps(Bw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return We(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return We(n=>{n.key===j.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return Vm(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Be(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[d,u]=It(r.x,r.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),b=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(b<0){let x=xe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:d,y:u},this.state,this.scene.getNonDeletedElementsMap());b=x?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let g=xe.moveFixedSegment(this.state.selectedLinearElement,b,d,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=Ox(mK(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(Ht(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[a,s]=It(r.x,r.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement;if(d.draggedFocusPointBinding){bK(d,c,r,this.scene,this.state,this.getEffectiveGridSize(),n.altKey),this.setState({selectedLinearElement:{...d,isDragging:!1,selectedPointsIndices:[],initialState:{...d.initialState,lastClickedPoint:-1}}});return}if(xe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=xe.addMidpoint(this.state.selectedLinearElement,r,this,!n[j.CTRL_OR_CMD],this.scene);if(!u)return;Yt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else{if(d.initialState.segmentMidpoint.value!==null&&!d.initialState.segmentMidpoint.added)return;if(d.initialState.lastClickedPoint>-1){let u=xe.getElement(d.elementId,c);if(u?.isDeleted)return;if(bn(u)){let g=Ho(re(r.x,r.y),this.scene.getNonDeletedElements(),c);Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(n.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Bn("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),d.initialState.lastClickedPoint===-1)return;let b=xe.handlePointDragging(n,this,r.x,r.y,d);if(b){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(b.suggestedBinding!==this.state.suggestedBinding||!hA(b.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||b.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||b.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==b.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==b.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(b);return}}}}let m=t.hit.allHitElements.some(d=>this.isASelectedElement(d)),p=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let d=this.scene.getSelectedElements(this.state);if(d.length>0&&d.every(x=>x.locked))return;let u=d.find(x=>Vt(x)),b=this.getTopLayerFrameAtSceneCoords(r),g=b&&!u?b:null;if(this.state.frameToHighlight!==g&&Yt(()=>{this.setState({frameToHighlight:g})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&d.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),d.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},v=[...t.originalElements.values()],y=n.shiftKey;if(y){let I=Math.abs(x.x),C=Math.abs(x.y),M=y&&I<C,k=y&&I>C;M&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&fi(I)&&I.crop!==null&&t.hit.element===I){let C=I.crop,M=pc(I)&&this.imageCache.get(I.fileId)?.image;if(M&&!(M instanceof Promise)){let k=vK(I),_=JP(r.x-i.x,r.y-i.y);_[0]*=M.naturalWidth/k.width,_[1]*=M.naturalHeight/k.height;let[P,A,H,F,Y,V]=fA(I,c),U=Rx(Hx(re(P,A),re(Y,V),I.angle)),D=Rx(Hx(re(H,A),re(Y,V),I.angle)),B=Rx(Hx(re(P,F),re(Y,V),I.angle)),W=tA(QP(D,U)),te=tA(QP(B,U)),X=JP(eA(_,W),eA(_,te)),le={...C,x:qP(C.x-X[0]*Math.sign(I.scale[0]),0,M.naturalWidth-C.width),y:qP(C.y-X[1]*Math.sign(I.scale[1]),0,M.naturalHeight-C.height)};this.scene.mutateElement(I,{crop:le});return}}}this.maybeCacheVisibleGaps(n,d),this.maybeCacheReferenceSnapPoints(n,d);let{snapOffset:E,snapLines:T}=Ow(v,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:T}),this.state.editingFrame||dK(t,d,x,this.scene,E,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),C=t.hit.element,M=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});C&&t.hit.wasAddedToSelection&&!M.find(U=>U.id===C.id)&&M.push(C);let k=new Map(M.map(U=>[U.id,U])),{duplicatedElements:_,duplicateElementsMap:P,elementsWithDuplicates:A,origIdToDuplicateId:H}=Ux({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:U,origElement:D})=>({frameId:U.frameId??D.frameId,seed:tX()})});_.forEach(U=>{t.originalElements.set(U.id,vA(U))});let F=A.map(U=>{if(k.has(U.id)){let D=t.originalElements.get(U.id);if(D)return Sr(U,{x:D.x,y:D.y})}return U}),Y=this.props.onDuplicate?.(F,I),V=NA(Y||F,ou(_));Yt(()=>{if(t.hit.element){let U=H.get(t.hit.element.id),D=U&&P.get(U);t.hit.element=D||null}t.hit.allHitElements=t.hit.allHitElements.reduce((U,D)=>{let B=H.get(D.id),W=B&&P.get(B);return W&&U.push(W),U},[]),t.drag.origin=Be(n,this.state),this.setState(U=>({...aK(_,this.scene.getNonDeletedElements(),U)})),this.scene.replaceAllElements(V),M.forEach(U=>{Xx(U)&&U.boundElements?.some(D=>D.type==="arrow")&&ru(U,this.scene)}),this.maybeCacheVisibleGaps(n,M,!0),this.maybeCacheReferenceSnapPoints(n,M,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let d=this.state.newElement;if(!d)return;if(d.type==="freedraw"){let u=d.points,b=r.x-d.x,g=r.y-d.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===b&&x[1]===g)){let y=d.simulatePressure?d.pressures:[...d.pressures,n.pressure];this.scene.mutateElement(d,{points:[...u,re(b,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:d})}}else if(_t(d)&&!d.isDeleted){t.drag.hasOccurred=!0;let u=d.points;fn(u.length>1,"Do not create linear elements with less than 2 points");let b=this.state.selectedLinearElement;b||(b=new xe(d,this.scene.getNonDeletedElementsMap()),b={...b,selectedPointsIndices:[1],initialState:{...b.initialState,lastClickedPoint:1}}),this.setState({newElement:d,...xe.handlePointDragging(n,this,a,s,b)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let d=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)xe.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&Me(d,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>ho({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let b=this.state.selectionElement?Hy(d,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(g=>{let x={...u&&g.selectedElementIds,...b.reduce((v,y)=>(v[y.id]=!0,v),{})};return t.hit.element&&(b.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...ho({editingGroupId:g.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:b.length===1&&_t(b[0])?new xe(b[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:b.length===1&&(b[0].link||Fn(b[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(xc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(xc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return We(n=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:i,resizingElement:l,croppingElementId:a,multiElement:s,activeTool:c,isResizing:m,isRotating:p,isCropping:d}=this.state;this.setState(y=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:dc(y.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,io.setReferenceSnapPoints(null),io.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let u=t.hit.allHitElements,b=Be({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(y=>this.state.selectedElementIds[y.id])){let y=this.getElementAtPosition(b.x,b.y,{includeLockedElements:!0});this.store.scheduleCapture(),y?.locked?this.setState({activeLockedId:y.groupIds.length>0?y.groupIds.at(-1)||"":y.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let y=r.get(t.hit.element.id);Xx(y)&&y.boundElements?.filter(E=>E.type==="arrow").map(E=>r.get(E.id)).filter(E=>Xt(E)).forEach(E=>{E&&this.scene.mutateElement(E,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(kt);else{let y=xe.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b}),y!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:y,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let y=xe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());y&&this.scene.mutateElement(y,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(EK(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b})),this.state.newElement&&this.state.multiElement&&_t(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:y}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y.points[y.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ae.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ae.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ae.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ae.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),i?.type==="freedraw"){let y=Be(n,this.state),E=i.points,T=y.x-i.x,I=y.y-i.y;T===E[0][0]&&I===E[0][1]&&(I+=1e-4,T+=1e-4);let C=i.simulatePressure?[]:[...i.pressures,n.pressure];this.scene.mutateElement(i,{points:[...E,re(T,I)],pressures:C}),this.actionManager.executeAction(kt);return}if(_t(i)){i.points.length>1&&i.points[1][0]!==0&&i.points[1][1]!==0&&this.store.scheduleCapture();let y=Be(n,this.state),E=Ir(re(y.x,y.y),re(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||E<oX)&&i&&!s)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[re(0,0),re(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(kt)}else{let T=y.x-i.x,I=y.y-i.y;this.scene.mutateElement(i,{points:[i.points[0],re(T,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:i,newElement:i})}else t.drag.hasOccurred&&!s&&(_t(i)&&this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b}),this.setState({suggestedBinding:null,startBoundElement:null}),c.locked?this.setState(T=>({newElement:null})):(Zt(this.interactiveCanvas),this.setState(T=>({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new xe(i,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(Ro(i)){let y=QX(Fx({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<y&&this.scene.mutateElement(i,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&CA(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==i.id),appState:{newElement:null},captureUpdate:Dt.NEVER});return}if(Vt(i)){let y=RX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Jx(this.scene.getElementsMapIncludingDeleted(),y,i,this.state))}if(i&&(this.scene.mutateElement(i,CX(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let y=Be(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let T=ey(E,r);T&&E&&(NX(E,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(E,{groupIds:[]}),HX([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(y),T=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),C=M=>{if(M.length>0){for(let k of M){let _=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}I.forEach(k=>{k.groupIds.length&&bi(I,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let M=T.filter(k=>k.frameId!==E.id&&_A(k,I,this.state));this.state.editingGroupId&&C(M),I=Jx(I,M,E,this.state)}else if(!E&&this.state.editingGroupId){let M=T.filter(k=>k.frameId&&!_A(k,I,this.state));C(M)}I=LA(I,this.state,this),this.scene.replaceAllElements(I)}}if(l&&this.store.scheduleCapture(),l&&CA(l)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==l.id),captureUpdate:Dt.NEVER}),t.resize.isResizing){let y=LA(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(T=>Vt(T));for(let T of E)y=DX(y,Qx(this.scene.getElementsIncludingDeleted(),T,this.state,r),T,this);this.scene.replaceAllElements(y)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&_t(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new xe(g,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!g&&!d||g&&g.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Ht(this.state)&&x&&v){if(this.eraserTrail.endPath(),Ir(re(x.clientX,x.clientY),re(v.clientX,v.clientY))===0){let E=Be({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?rK(this.state,g)?this.setState(y=>{let E={...y.selectedElementIds};for(let T of g.groupIds.flatMap(I=>bi(this.scene.getNonDeletedElements(),I)))delete E[T.id];return{selectedGroupIds:{...y.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,I)=>({...T,...I}),{})},selectedElementIds:ke(E,y)}}):this.state.selectedLinearElement?.isDragging||this.setState(y=>{let E={...y.selectedElementIds};delete E[g.id];let T=oe(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...ho({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:T.length===1&&_t(T[0])?new xe(T[0],this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(y=>{let E={...y.selectedElementIds,[g.id]:!0};return delete E[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>bi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete E[T.id]}),{...ho({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:g.link||Fn(g)?"info":!1}}):this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[g.id]:!0},y)})):this.setState(y=>({...ho({editingGroupId:y.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:_t(g)&&y.selectedLinearElement?.elementId!==g.id?new xe(g,this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Xt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&GX({point:re(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ha):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),we(this.interactiveCanvas,ze.AUTO);return}if(!c.locked&&c.type!=="freedraw"&&i&&this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y),showHyperlinkPopup:Fn(i)&&!i.link?"editor":y.showHyperlinkPopup})),(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!hA(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||p||d){let y=this.scene.getSelectedElements(this.state).filter(bl);bA(y,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}!c.locked&&c.type!=="freedraw"&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?(Zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBinding:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(n=>({selectedElementIds:ke({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&RA(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let l=i.x+i.width/2,a=i.y+i.height/2,s=jx(i,r,this.scene.getNonDeletedElementsMap());if(s&&(l=s.x,a=s.y),Math.hypot(t-l,n-a)<NV){let{x:p,y:d}=tu({sceneX:l,sceneY:a},r);return{viewportX:p,viewportY:d,elementCenterX:l,elementCenterY:a}}}}getCanvasOffsets(){if(this.hellixitboardContainerRef?.current){let t=this.hellixitboardContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Ci.find(n=>n.code===this.props.langCode)||Go;await Nc(t),this.setAppState({})}},IK=()=>{(jA()||qA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(QA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};IK();var oL=my;import{useEffect as CK,useState as SK}from"react";import{jsx as kK}from"react/jsx-runtime";var nL=e=>{let[o,t]=SK(!0);return CK(()=>{let n=async()=>{await Nc(r),t(!1)},r=Ci.find(i=>i.code===e.langCode)||Go;n()},[e.langCode]),o?kK(np,{theme:e.theme}):e.children};import MK from"clsx";import{jsx as rL}from"react/jsx-runtime";var iL=({children:e})=>{let{FooterCenterTunnel:o}=Pe(),t=se();return rL(o.In,{children:rL("div",{className:MK("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},PK=iL;iL.displayName="FooterCenter";import{jsx as LK}from"react/jsx-runtime";var aL=({children:e})=>{let{FooterRightSlotTunnel:o}=Pe();return LK(o.In,{children:e})},AK=aL;aL.displayName="FooterRightSlot";import _K from"clsx";import{MQ_MIN_WIDTH_DESKTOP as DK}from"@excalidraw/common";import{jsx as RK,jsxs as NK}from"react/jsx-runtime";var lL=({isCollaborating:e,onSelect:o,editorInterface:t,...n})=>{let r=se(),i=t?.formFactor!=="desktop"||r.width<DK;return NK(ut,{...n,className:_K("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:i?void 0:"auto"},title:h("labels.liveCollaboration"),children:[i?S0:h("labels.share"),r.collaborators.size>0&&RK("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},HK=lL;lL.displayName="LiveCollaborationTrigger";import{jsx as xy}from"react/jsx-runtime";var BK=()=>xy("img",{src:"/logo.svg",alt:"Hellix IT Whiteboard",className:"HellixitLogo-icon"}),sL=({style:e,size:o="small"})=>xy("div",{className:`HellixitboardLogo is-${o}`,style:e,children:xy(BK,{})});import{Fragment as mL,jsx as nt,jsxs as yy}from"react/jsx-runtime";var Ey=({icon:e,shortcut:o,children:t})=>{let n=fe();return yy(mL,{children:[nt("div",{className:"welcome-screen-menu-item__icon",children:e}),nt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&n.formFactor!=="phone"&&nt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Ey.displayName="WelcomeScreenMenuItemContent";var vc=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>nt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:nt(Ey,{icon:t,shortcut:n,children:o})});vc.displayName="WelcomeScreenMenuItem";var cL=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>nt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:nt(Ey,{icon:t,shortcut:n,children:e})});cL.displayName="WelcomeScreenMenuItemLink";var fo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Pe();return nt(o.In,{children:nt("div",{className:"welcome-screen-center",children:e||yy(mL,{children:[nt(vy,{}),nt(Ty,{children:h("welcomeScreen.defaults.center_heading")}),yy(Iy,{children:[nt(Cy,{}),nt(wy,{})]})]})})})};fo.displayName="Center";var vy=({children:e})=>nt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||nt(sL,{size:"large"})});vy.displayName="Logo";var Ty=({children:e})=>nt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ty.displayName="Heading";var Iy=({children:e})=>nt("div",{className:"welcome-screen-menu",children:e});Iy.displayName="Menu";var wy=()=>{let e=De();return nt(vc,{onSelect:()=>e.executeAction(Vr),shortcut:"?",icon:Di,children:h("helpDialog.title")})};wy.displayName="MenuItemHelp";var Cy=()=>{let e=se(),o=De();return e.viewModeEnabled?null:nt(vc,{onSelect:()=>o.executeAction(aa),shortcut:Le("loadScene"),icon:Hi,children:h("buttons.load")})};Cy.displayName="MenuItemLoadScene";var dL=({onSelect:e})=>{let{t:o}=Ie();return nt(vc,{shortcut:null,onSelect:e,icon:Wc,children:o("labels.liveCollaboration")})};dL.displayName="MenuItemLiveCollaborationTrigger";fo.Logo=vy;fo.Heading=Ty;fo.Menu=Iy;fo.MenuItem=vc;fo.MenuItemLink=cL;fo.MenuItemHelp=wy;fo.MenuItemLoadScene=Cy;fo.MenuItemLiveCollaborationTrigger=dL;import{jsx as El,jsxs as Sy}from"react/jsx-runtime";var pu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Pe();return El(o.In,{children:Sy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[c0,El("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.menuHint")})]})})};pu.displayName="MenuHint";var uu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Pe();return El(o.In,{children:Sy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[El("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.toolbarHint")}),m0]})})};uu.displayName="ToolbarHint";var hu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Pe();return El(o.In,{children:Sy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[El("div",{children:e||h("welcomeScreen.defaults.helpHint")}),d0]})})};hu.displayName="HelpHint";import{Fragment as pL,jsx as Tc,jsxs as OK}from"react/jsx-runtime";var gu=e=>Tc(pL,{children:e.children||OK(pL,{children:[Tc(fo,{}),Tc(pu,{}),Tc(uu,{}),Tc(hu,{})]})});gu.displayName="WelcomeScreen";gu.Center=fo;gu.Hints={MenuHint:pu,ToolbarHint:uu,HelpHint:hu};var FK=gu;import{useEffect as uL,useRef as hL,useState as zK}from"react";var GK=(e,o)=>typeof o=="function"?o(e):Array.isArray(o)?e:e[o],ky=(e,o,t)=>{if(e?.isDestroyed)return;let n=e?.getAppState();if(!n){if(!t)return;console.warn("useAppStateValue: hellixitboardAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Hellixitboard/> component tree?"),n=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Oo())}return GK(n,o)};function gL(e,o=!0){let t=mu(),[,n]=zK(0),r=hL(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:ky(t,e,o)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=ky(t,e,o)),uL(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,l=>{i.latestValue=l,n(a=>a+1)})},[t]),r.current.latestValue}function UK(e,o){let t=mu(),n=hL({selector:e,callback:o});n.current.selector=e,n.current.callback=o,uL(()=>{if(!(!t||t.isDestroyed))return n.current.callback(ky(t,n.current.selector,!0),t.getAppState()),t.onStateChange(n.current.selector,(r,i)=>{n.current.callback(r,i)})},[t])}var WK=()=>{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)})},fL=WK;import{getSceneVersion as hUe,hashElementsVersion as gUe,hashString as fUe,getNonDeletedElements as bUe}from"@excalidraw/element";import{getTextFromElements as yUe}from"@excalidraw/element";import{isInvisiblySmallElement as vUe}from"@excalidraw/element";import YK from"lodash.throttle";import{arrayToMap as VK,isDevEnv as bL,isTestEnv as xL}from"@excalidraw/common";import{orderByFractionalIndex as XK,syncInvalidIndices as yL,validateFractionalIndices as KK}from"@excalidraw/element";var $K=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<=t.versionNonce)),ZK=YK((e,o,t)=>{if(bL()||xL()||window?.DEBUG_FRACTIONAL_INDICES){let n=yL(e.map(r=>({...r})));KK(n,{shouldThrow:xL()||bL(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),jK=(e,o,t)=>{let n=VK(e),r=[],i=new Set;for(let a of o)if(!i.has(a.id)){let s=n.get(a.id),c=$K(t,s,a);s&&c?(r.push(s),i.add(s.id)):(r.push(a),i.add(a.id))}for(let a of e)i.has(a.id)||(r.push(a),i.add(a.id));let l=XK(r);return ZK(l,e,o),yL(l),l};import{isLinearElement as AUe}from"@excalidraw/element";import{FONT_FAMILY as _Ue,THEME as DUe,MIME_TYPES as HUe,ROUNDNESS as RUe,DEFAULT_LASER_COLOR as NUe,UserIdleState as BUe,normalizeLink as FUe,sceneCoordsToViewportCoords as OUe,viewportCoordsToSceneCoords as zUe,getFormFactor as GUe,throttleRAF as UUe}from"@excalidraw/common";import{mutateElement as YUe,newElementWith as VUe,bumpVersion as XUe}from"@excalidraw/element";import{CaptureUpdateAction as $Ue}from"@excalidraw/element";import{jsx as My}from"react/jsx-runtime";var EL=({children:e,icon:o})=>{let{t}=Ie(),{TTDDialogTriggerTunnel:n}=Pe(),r=he();return My(n.In,{children:My(ie.Item,{onSelect:()=>{ce("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??SE,badge:My(ie.Item.Badge,{children:"AI"}),children:e??t("labels.textToDiagram")})})};EL.displayName="TTDDialogTrigger";function qK(e){let o=e.get("X-Ratelimit-Limit"),t=e.get("X-Ratelimit-Remaining");return{rateLimit:o?parseInt(o,10):void 0,rateLimitRemaining:t?parseInt(t,10):void 0}}async function*JK(e){let o=new TextDecoder,t="";try{for(;;){let{done:n,value:r}=await e.read();if(n)break;t+=o.decode(r,{stream:!0});let i=t.split(`
134
- `);t=i.pop()||"";for(let l of i){let a=l.trim();a&&a.startsWith("data: ")&&(yield a.slice(6))}}}finally{e.releaseLock()}}async function QK(e){let{url:o,messages:t,onChunk:n,onStreamCreated:r,extractRateLimits:i=!0,signal:l}=e;try{let a="",s={},c=null,m=await fetch(o,{method:"POST",headers:{Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify({messages:t}),signal:l});if(i&&(s=qK(m.headers)),!m.ok){if(m.status===429)return{...s,error:new Fo({message:"Rate limit exceeded",status:429})};let d=await m.text();throw new Fo({message:d||"Generation failed...",status:m.status})}let p=m.body?.getReader();if(!p)throw new Fo({message:"Couldn't get reader from response body",status:500});r?.();try{for await(let d of JK(p)){if(d==="[DONE]")break;try{let u=JSON.parse(d);if(u===null)break;switch(u.type){case"content":{let b=u.delta;b&&(a+=b,n?.(b));break}case"error":c=new Fo({message:u.error.message,status:500});break;case"done":break}}catch(u){console.warn("Failed to parse SSE data:",d,u)}}}catch(d){d.name==="AbortError"?c=new Fo({message:"Request aborted",status:499}):c=new Fo({message:d.message||"Streaming error",status:500})}return c?{...s,error:c}:a?{generatedResponse:a,error:null,...s}:{...s,error:new Fo({message:"Generation failed...",status:m.status})}}catch(a){return a.name==="AbortError"?{error:new Fo({message:"Request aborted",status:499})}:{error:new Fo({message:a.message||"Request failed",status:500})}}}import{getCommonBounds as lWe,getVisibleSceneBounds as sWe,convertToHellixitboardElements as cWe}from"@excalidraw/element";import{useLayoutEffect as e$}from"react";var t$=e=>{let o=Ae();return e$(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as hWe}from"@excalidraw/element";import{setCustomTextMetricsProvider as fWe}from"@excalidraw/element";import{jsx as Ic}from"react/jsx-runtime";fL();var cUe=({children:e})=>{let[o,t]=l$(null);return Ic(yl.Provider,{value:o,children:Ic(du.Provider,{value:t,children:e})})},c$=e=>{let{onExport:o,onChange:t,onIncrement:n,initialData:r,onHellixitboardAPI:i,onMount:l,onUnmount:a,onInitialize:s,isCollaborating:c=!1,onPointerUpdate:m,renderTopLeftUI:p,renderTopRightUI:d,langCode:u=Go.code,viewModeEnabled:b,zenModeEnabled:g,gridModeEnabled:x,libraryReturnUrl:v,theme:y,name:E,renderCustomStats:T,onPaste:I,detectScroll:C=!0,handleKeyboardGlobally:M=!1,onLibraryChange:k,autoFocus:_=!1,generateIdForFile:P,onLinkOpen:A,generateLinkForSelection:H,onPointerDown:F,onPointerUp:Y,onScrollChange:V,onDuplicate:U,children:D,validateEmbeddable:B,renderEmbeddable:W,aiEnabled:te,showDeprecatedFonts:X,renderScrollbars:le,onFileUpload:pe,onClearCanvas:de,onReportIssue:Ee,onAddComment:Ve,onToggleComments:rt,commentsVisible:ft}=e,wt=e.UIOptions?.canvasActions,zn={...e.UIOptions,canvasActions:{...vL.canvasActions,...wt},tools:{image:e.UIOptions?.tools?.image??!0}};wt?.export&&(zn.canvasActions.export.saveFileToDisk=wt.export?.saveFileToDisk??vL.canvasActions.export.saveFileToDisk),zn.canvasActions.toggleTheme===null&&typeof y>"u"&&(zn.canvasActions.toggleTheme=!0);let wc=r$(du),vl=a$(i);vl.current=i;let fu=n$(xn=>{wc?.(xn),vl.current?.(xn)},[wc]);return i$(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let bo=Tl=>{typeof Tl.scale=="number"&&Tl.scale!==1&&Tl.preventDefault()};return document.addEventListener("touchmove",bo,{passive:!1}),()=>{document.removeEventListener("touchmove",bo)}},[]),Ic(e0,{store:Qe,children:Ic(nL,{langCode:u,theme:y,children:Ic(oL,{onExport:o,onChange:t,onIncrement:n,initialData:r,onHellixitboardAPI:fu,onMount:l,onUnmount:a,onInitialize:s,isCollaborating:c,onPointerUpdate:m,renderTopLeftUI:p,renderTopRightUI:d,langCode:u,viewModeEnabled:b,zenModeEnabled:g,gridModeEnabled:x,libraryReturnUrl:v,theme:y,name:E,renderCustomStats:T,UIOptions:zn,onPaste:I,detectScroll:C,handleKeyboardGlobally:M,onLibraryChange:k,autoFocus:_,generateIdForFile:P,onLinkOpen:A,generateLinkForSelection:H,onPointerDown:F,onPointerUp:Y,onScrollChange:V,onDuplicate:U,validateEmbeddable:B,renderEmbeddable:W,aiEnabled:te!==!1,showDeprecatedFonts:X,renderScrollbars:le,onFileUpload:pe,onClearCanvas:de,onReportIssue:Ee,onAddComment:Ve,onToggleComments:rt,commentsVisible:ft,children:D})})})},d$=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:l={},...a}=o,s=Object.keys(n),c=Object.keys(l);return s.length!==c.length?!1:s.every(p=>p==="getFormFactor"?!0:p==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&l?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===l.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===l?.canvasActions?.[u]):n[p]===l[p])&&s$(r,a)},m$=o$.memo(c$,d$);m$.displayName="Hellix IT";function dUe(e){return gL(e,!1)}export{ut as Button,$Ue as CaptureUpdateAction,eF as CommandPalette,NUe as DEFAULT_LASER_COLOR,Tp as DefaultSidebar,t$ as DiagramToCodePlugin,Zl as Ellipsify,_Ue as FONT_FAMILY,PK as Footer,AK as FooterRightSlot,m$ as Hellixitboard,yl as HellixitboardAPIContext,cUe as HellixitboardAPIProvider,HK as LiveCollaborationTrigger,HUe as MIME_TYPES,vt as MainMenu,RUe as ROUNDNESS,so as Sidebar,nc as Stats,DUe as THEME,Rp as TTDDialog,EL as TTDDialogTrigger,QK as TTDStreamFetch,BUe as UserIdleState,FK as WelcomeScreen,XUe as bumpVersion,cWe as convertToHellixitboardElements,Go as defaultLang,JI as elementPartiallyOverlapsWithOrContainsBBox,QI as elementsOverlappingBBox,J2 as exportToBlob,nr as exportToCanvas,g4 as exportToClipboard,ya as exportToSvg,lWe as getCommonBounds,Iu as getDataURL,GUe as getFormFactor,im as getLibraryItemsHash,bUe as getNonDeletedElements,hUe as getSceneVersion,yUe as getTextFromElements,sWe as getVisibleSceneBounds,gUe as hashElementsVersion,fUe as hashString,Cf as isElementInsideBBox,hWe as isElementLink,vUe as isInvisiblySmallElement,AUe as isLinearElement,Ga as isSpreadsheetValidForChartType,Ci as languages,_c as loadFromBlob,Tu as loadLibraryFromBlob,vu as loadSceneOrLibraryFromBlob,lT as mergeLibraryItems,YUe as mutateElement,VUe as newElementWith,FUe as normalizeLink,zg as parseLibraryTokensFromUrl,jK as reconcileElements,sb as renderSpreadsheet,Ti as restoreAppState,IL as restoreElement,Lr as restoreElements,Al as restoreLibraryItems,OUe as sceneCoordsToViewportCoords,kl as serializeAsJSON,TL as serializeLibraryAsJSON,fWe as setCustomTextMetricsProvider,UUe as throttleRAF,op as tryParseSpreadsheet,fe as useEditorInterface,L4 as useHandleLibrary,mu as useHellixitboardAPI,dUe as useHellixitboardStateValue,Ie as useI18n,UK as useOnHellixitboardStateChange,at as useStylesPanelMode,zUe as viewportCoordsToSceneCoords,pv as zoomToFitBounds};
133
+ `),g=b.reduce((x,v,y)=>{let E=ZX(v).trim();if(E.length){let T=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),I=HA(E,a,s),S=I.width>p,M=S?XX(E,a,p):E;I=S?HA(M,a,s):I;let k=r-I.width/2,_=u-I.height/2,P=EA({...l,x:k,y:_,text:M,originalText:E,lineHeight:s,autoResize:!S,frameId:T?T.id:null});x.push(P),u+=P.height+d}else b[y-1]?.trim()&&(u+=jX(l.fontSize,s)+d);return x},[]);g.length!==0&&(this.scene.insertElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(x=>[x.id,!0])),this.state)}),!n&&g.length>1&&ZA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:h("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),ZA=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(l,a)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Ro(s)?wr(s,{originalText:l,isDeleted:a??s.isDeleted,...EX(s,PA(s,r),r,l)}):s)])};tS({id:t.id,canvas:this.canvas,getViewportCoords:(l,a)=>{let{x:s,y:c}=tu({sceneX:l,sceneY:a},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:We(l=>{i(l,!1),GA(t)&&ru(t,this.scene)}),onSubmit:We(({viaKeyboard:l,nextOriginalText:a})=>{let s=!a.trim();if(i(a,s),!s&&l){let c=t.containerId?t.containerId:t.id;Yt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[c]:!0},m)}))})}s&&pX(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Yt(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&jt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,hellixitboardContainer:this.hellixitboardContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&Ro(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let a=i.length-1;a>-1;a--)if(this.state.selectedElementIds[i[a].id])return i[a]}let l=i[i.length-1];return uc({point:re(t,n),element:l,threshold:this.getElementHitThreshold(l)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Vt(l)?this.frameNameBoundsCache.get(l):null})?l:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],l=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(Ro(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let c=ey(s,l);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?AA({x:t,y:n},c,l):!0}).filter(s=>xl(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(cA/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&_X([r],this.state,this.editorInterface)&&uK(re(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||zX(re(t,n),r,this.scene.getNonDeletedElementsMap())?!0:uc({point:re(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Vt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return IA(i[0],!1)?i[0]:null;let l=null;for(let a=r.length-1;a>=0;--a){if(r[a].isDeleted)continue;let[s,c,m,p]=fA(r[a],this.scene.getNonDeletedElementsMap());if(bl(r[a])&&uc({point:re(t,n),element:r[a],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[a])})){l=r[a];break}else if(s<t&&t<m&&c<n&&n<p){l=r[a];break}}return IA(l,!1)?l:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),l=xe.getElement(t.elementId,i);if(l)if(this.state.selectedLinearElement){let a=-1,s=null;uc({point:re(n,r),element:l,elementsMap:i,threshold:this.getElementHitThreshold(l)})?(a=xe.getPointIndexUnderCursor(l,i,this.state.zoom,n,r),s=xe.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Xt(l)?a===0||a===l.points.length-1:a>=0)||s?Ce(this.interactiveCanvas,ze.POINTER):this.hitElement(n,r,l)&&(!Xt(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&Ce(this.interactiveCanvas,ze.MOVE)):this.hitElement(n,r,l)&&(!Xt(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&Ce(this.interactiveCanvas,ze.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),xe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let c=null,m=l;(m.startBinding||m.endBinding)&&(c=xK(l,n,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&Ce(this.interactiveCanvas,ze.POINTER)}else Ce(this.interactiveCanvas,ze.AUTO)}updateGestureOnPointerDown(t){ve.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ve.pointers.size===2&&(ve.lastCenter=Bf(ve.pointers),ve.initialScale=this.state.zoom.value,ve.initialDistance=Ff(Array.from(ve.pointers.values())))}initialPointerDownState(t){let n=Be(t,this.state),r=this.scene.getSelectedElements(this.state),[i,l,a,s]=fl(r),c=r.findIndex(Xt)===0;return{origin:n,withCmdOrCtrl:t[j.CTRL_OR_CMD],originInGrid:Ox(It(n.x,n.y,t[j.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:$f(xc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,p)=>(m.set(p.id,vA(p)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+i)/2,y:(s+l)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;ly=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=Vm(l=>{l.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(l,n)}),i=We(()=>{Ec=null,ly=!1,jt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ae.POINTER_MOVE,r),window.removeEventListener(ae.POINTER_UP,i),r.flush()});return Ec=i,window.addEventListener(ae.POINTER_MOVE,r),window.addEventListener(ae.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(cA/this.state.zoom.value,1),[i,l,a,s]=fl(n);return t.x>i-r&&t.x<a+r&&t.y>l-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:IX(t)?Qp.ADAPTIVE_RADIUS:Qp.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){An({event:t,app:this,selectedElements:n})&&(r||!io.getReferenceSnapPoints())&&io.setReferenceSnapPoints(FC(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){An({event:t,app:this,selectedElements:n})&&(r||!io.getVisibleGaps())&&io.setVisibleGaps(BC(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return We(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return We(n=>{n.key===j.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return Vm(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Be(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[d,u]=It(r.x,r.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),b=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(b<0){let x=xe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:d,y:u},this.state,this.scene.getNonDeletedElementsMap());b=x?xe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let g=xe.moveFixedSegment(this.state.selectedLinearElement,b,d,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=Ox(mK(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(Ht(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[a,s]=It(r.x,r.y,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement;if(d.draggedFocusPointBinding){bK(d,c,r,this.scene,this.state,this.getEffectiveGridSize(),n.altKey),this.setState({selectedLinearElement:{...d,isDragging:!1,selectedPointsIndices:[],initialState:{...d.initialState,lastClickedPoint:-1}}});return}if(xe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=xe.addMidpoint(this.state.selectedLinearElement,r,this,!n[j.CTRL_OR_CMD],this.scene);if(!u)return;Yt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else{if(d.initialState.segmentMidpoint.value!==null&&!d.initialState.segmentMidpoint.added)return;if(d.initialState.lastClickedPoint>-1){let u=xe.getElement(d.elementId,c);if(u?.isDeleted)return;if(bn(u)){let g=Ho(re(r.x,r.y),this.scene.getNonDeletedElements(),c);Bn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(n.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Bn("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),d.initialState.lastClickedPoint===-1)return;let b=xe.handlePointDragging(n,this,r.x,r.y,d);if(b){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(b.suggestedBinding!==this.state.suggestedBinding||!hA(b.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||b.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||b.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==b.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==b.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(b);return}}}}let m=t.hit.allHitElements.some(d=>this.isASelectedElement(d)),p=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let d=this.scene.getSelectedElements(this.state);if(d.length>0&&d.every(x=>x.locked))return;let u=d.find(x=>Vt(x)),b=this.getTopLayerFrameAtSceneCoords(r),g=b&&!u?b:null;if(this.state.frameToHighlight!==g&&Yt(()=>{this.setState({frameToHighlight:g})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&d.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),d.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},v=[...t.originalElements.values()],y=n.shiftKey;if(y){let I=Math.abs(x.x),S=Math.abs(x.y),M=y&&I<S,k=y&&I>S;M&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&fi(I)&&I.crop!==null&&t.hit.element===I){let S=I.crop,M=pc(I)&&this.imageCache.get(I.fileId)?.image;if(M&&!(M instanceof Promise)){let k=vK(I),_=JP(r.x-i.x,r.y-i.y);_[0]*=M.naturalWidth/k.width,_[1]*=M.naturalHeight/k.height;let[P,A,H,F,Y,V]=fA(I,c),U=Rx(Hx(re(P,A),re(Y,V),I.angle)),D=Rx(Hx(re(H,A),re(Y,V),I.angle)),B=Rx(Hx(re(P,F),re(Y,V),I.angle)),W=tA(QP(D,U)),te=tA(QP(B,U)),X=JP(eA(_,W),eA(_,te)),le={...S,x:qP(S.x-X[0]*Math.sign(I.scale[0]),0,M.naturalWidth-S.width),y:qP(S.y-X[1]*Math.sign(I.scale[1]),0,M.naturalHeight-S.height)};this.scene.mutateElement(I,{crop:le});return}}}this.maybeCacheVisibleGaps(n,d),this.maybeCacheReferenceSnapPoints(n,d);let{snapOffset:E,snapLines:T}=OC(v,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:T}),this.state.editingFrame||dK(t,d,x,this.scene,E,n[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),S=t.hit.element,M=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!M.find(U=>U.id===S.id)&&M.push(S);let k=new Map(M.map(U=>[U.id,U])),{duplicatedElements:_,duplicateElementsMap:P,elementsWithDuplicates:A,origIdToDuplicateId:H}=Ux({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:U,origElement:D})=>({frameId:U.frameId??D.frameId,seed:tX()})});_.forEach(U=>{t.originalElements.set(U.id,vA(U))});let F=A.map(U=>{if(k.has(U.id)){let D=t.originalElements.get(U.id);if(D)return wr(U,{x:D.x,y:D.y})}return U}),Y=this.props.onDuplicate?.(F,I),V=NA(Y||F,ou(_));Yt(()=>{if(t.hit.element){let U=H.get(t.hit.element.id),D=U&&P.get(U);t.hit.element=D||null}t.hit.allHitElements=t.hit.allHitElements.reduce((U,D)=>{let B=H.get(D.id),W=B&&P.get(B);return W&&U.push(W),U},[]),t.drag.origin=Be(n,this.state),this.setState(U=>({...aK(_,this.scene.getNonDeletedElements(),U)})),this.scene.replaceAllElements(V),M.forEach(U=>{Xx(U)&&U.boundElements?.some(D=>D.type==="arrow")&&ru(U,this.scene)}),this.maybeCacheVisibleGaps(n,M,!0),this.maybeCacheReferenceSnapPoints(n,M,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let d=this.state.newElement;if(!d)return;if(d.type==="freedraw"){let u=d.points,b=r.x-d.x,g=r.y-d.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===b&&x[1]===g)){let y=d.simulatePressure?d.pressures:[...d.pressures,n.pressure];this.scene.mutateElement(d,{points:[...u,re(b,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:d})}}else if(_t(d)&&!d.isDeleted){t.drag.hasOccurred=!0;let u=d.points;fn(u.length>1,"Do not create linear elements with less than 2 points");let b=this.state.selectedLinearElement;b||(b=new xe(d,this.scene.getNonDeletedElementsMap()),b={...b,selectedPointsIndices:[1],initialState:{...b.initialState,lastClickedPoint:1}}),this.setState({newElement:d,...xe.handlePointDragging(n,this,a,s,b)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let d=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)xe.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&Me(d,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>ho({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let b=this.state.selectionElement?Hy(d,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(g=>{let x={...u&&g.selectedElementIds,...b.reduce((v,y)=>(v[y.id]=!0,v),{})};return t.hit.element&&(b.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...ho({editingGroupId:g.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:b.length===1&&_t(b[0])?new xe(b[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:b.length===1&&(b[0].link||Fn(b[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(xc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(xc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return We(n=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:i,resizingElement:l,croppingElementId:a,multiElement:s,activeTool:c,isResizing:m,isRotating:p,isCropping:d}=this.state;this.setState(y=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:dc(y.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,io.setReferenceSnapPoints(null),io.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let u=t.hit.allHitElements,b=Be({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(y=>this.state.selectedElementIds[y.id])){let y=this.getElementAtPosition(b.x,b.y,{includeLockedElements:!0});this.store.scheduleCapture(),y?.locked?this.setState({activeLockedId:y.groupIds.length>0?y.groupIds.at(-1)||"":y.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Bn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let y=r.get(t.hit.element.id);Xx(y)&&y.boundElements?.filter(E=>E.type==="arrow").map(E=>r.get(E.id)).filter(E=>Xt(E)).forEach(E=>{E&&this.scene.mutateElement(E,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(kt);else{let y=xe.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b}),y!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:y,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let y=xe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());y&&this.scene.mutateElement(y,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(EK(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b})),this.state.newElement&&this.state.multiElement&&_t(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:y}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y.points[y.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ae.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ae.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ae.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ae.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),i?.type==="freedraw"){let y=Be(n,this.state),E=i.points,T=y.x-i.x,I=y.y-i.y;T===E[0][0]&&I===E[0][1]&&(I+=1e-4,T+=1e-4);let S=i.simulatePressure?[]:[...i.pressures,n.pressure];this.scene.mutateElement(i,{points:[...E,re(T,I)],pressures:S}),this.actionManager.executeAction(kt);return}if(_t(i)){i.points.length>1&&i.points[1][0]!==0&&i.points[1][1]!==0&&this.store.scheduleCapture();let y=Be(n,this.state),E=Ir(re(y.x,y.y),re(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||E<oX)&&i&&!s)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[re(0,0),re(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(kt)}else{let T=y.x-i.x,I=y.y-i.y;this.scene.mutateElement(i,{points:[i.points[0],re(T,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:i,newElement:i})}else t.drag.hasOccurred&&!s&&(_t(i)&&this.actionManager.executeAction(kt,"ui",{event:n,sceneCoords:b}),this.setState({suggestedBinding:null,startBoundElement:null}),c.locked?this.setState(T=>({newElement:null})):(Zt(this.interactiveCanvas),this.setState(T=>({newElement:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new xe(i,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(Ro(i)){let y=QX(Fx({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<y&&this.scene.mutateElement(i,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&SA(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==i.id),appState:{newElement:null},captureUpdate:Dt.NEVER});return}if(Vt(i)){let y=RX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Jx(this.scene.getElementsMapIncludingDeleted(),y,i,this.state))}if(i&&(this.scene.mutateElement(i,SX(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let y=Be(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let T=ey(E,r);T&&E&&(NX(E,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(E,{groupIds:[]}),HX([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(y),T=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),S=M=>{if(M.length>0){for(let k of M){let _=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}I.forEach(k=>{k.groupIds.length&&bi(I,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let M=T.filter(k=>k.frameId!==E.id&&_A(k,I,this.state));this.state.editingGroupId&&S(M),I=Jx(I,M,E,this.state)}else if(!E&&this.state.editingGroupId){let M=T.filter(k=>k.frameId&&!_A(k,I,this.state));S(M)}I=LA(I,this.state,this),this.scene.replaceAllElements(I)}}if(l&&this.store.scheduleCapture(),l&&SA(l)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==l.id),captureUpdate:Dt.NEVER}),t.resize.isResizing){let y=LA(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(T=>Vt(T));for(let T of E)y=DX(y,Qx(this.scene.getElementsIncludingDeleted(),T,this.state,r),T,this);this.scene.replaceAllElements(y)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&_t(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new xe(g,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!g&&!d||g&&g.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Ht(this.state)&&x&&v){if(this.eraserTrail.endPath(),Ir(re(x.clientX,x.clientY),re(v.clientX,v.clientY))===0){let E=Be({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?rK(this.state,g)?this.setState(y=>{let E={...y.selectedElementIds};for(let T of g.groupIds.flatMap(I=>bi(this.scene.getNonDeletedElements(),I)))delete E[T.id];return{selectedGroupIds:{...y.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,I)=>({...T,...I}),{})},selectedElementIds:ke(E,y)}}):this.state.selectedLinearElement?.isDragging||this.setState(y=>{let E={...y.selectedElementIds};delete E[g.id];let T=oe(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...ho({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:T.length===1&&_t(T[0])?new xe(T[0],this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(y=>{let E={...y.selectedElementIds,[g.id]:!0};return delete E[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>bi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete E[T.id]}),{...ho({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:g.link||Fn(g)?"info":!1}}):this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[g.id]:!0},y)})):this.setState(y=>({...ho({editingGroupId:y.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:_t(g)&&y.selectedLinearElement?.elementId!==g.id?new xe(g,this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Xt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&GX({point:re(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ha):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Ce(this.interactiveCanvas,ze.AUTO);return}if(!c.locked&&c.type!=="freedraw"&&i&&this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y),showHyperlinkPopup:Fn(i)&&!i.link?"editor":y.showHyperlinkPopup})),(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!hA(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||p||d){let y=this.scene.getSelectedElements(this.state).filter(bl);bA(y,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}!c.locked&&c.type!=="freedraw"&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?(Zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBinding:null,activeTool:gn(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(n=>({selectedElementIds:ke({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&RA(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let l=i.x+i.width/2,a=i.y+i.height/2,s=jx(i,r,this.scene.getNonDeletedElementsMap());if(s&&(l=s.x,a=s.y),Math.hypot(t-l,n-a)<NV){let{x:p,y:d}=tu({sceneX:l,sceneY:a},r);return{viewportX:p,viewportY:d,elementCenterX:l,elementCenterY:a}}}}getCanvasOffsets(){if(this.hellixitboardContainerRef?.current){let t=this.hellixitboardContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Si.find(n=>n.code===this.props.langCode)||Go;await Nc(t),this.setAppState({})}},IK=()=>{(jA()||qA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(QA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};IK();var oL=my;import{useEffect as SK,useState as wK}from"react";import{jsx as kK}from"react/jsx-runtime";var nL=e=>{let[o,t]=wK(!0);return SK(()=>{let n=async()=>{await Nc(r),t(!1)},r=Si.find(i=>i.code===e.langCode)||Go;n()},[e.langCode]),o?kK(np,{theme:e.theme}):e.children};import MK from"clsx";import{jsx as rL}from"react/jsx-runtime";var iL=({children:e})=>{let{FooterCenterTunnel:o}=Pe(),t=se();return rL(o.In,{children:rL("div",{className:MK("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},PK=iL;iL.displayName="FooterCenter";import{jsx as LK}from"react/jsx-runtime";var aL=({children:e})=>{let{FooterRightSlotTunnel:o}=Pe();return LK(o.In,{children:e})},AK=aL;aL.displayName="FooterRightSlot";import _K from"clsx";import{MQ_MIN_WIDTH_DESKTOP as DK}from"@hellixit/common";import{jsx as RK,jsxs as NK}from"react/jsx-runtime";var lL=({isCollaborating:e,onSelect:o,editorInterface:t,...n})=>{let r=se(),i=t?.formFactor!=="desktop"||r.width<DK;return NK(ut,{...n,className:_K("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:i?void 0:"auto"},title:h("labels.liveCollaboration"),children:[i?w0:h("labels.share"),r.collaborators.size>0&&RK("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},HK=lL;lL.displayName="LiveCollaborationTrigger";import{jsx as xy}from"react/jsx-runtime";var BK=()=>xy("img",{src:"/logo.svg",alt:"Hellix IT Whiteboard",className:"HellixitLogo-icon"}),sL=({style:e,size:o="small"})=>xy("div",{className:`HellixitboardLogo is-${o}`,style:e,children:xy(BK,{})});import{Fragment as mL,jsx as nt,jsxs as yy}from"react/jsx-runtime";var Ey=({icon:e,shortcut:o,children:t})=>{let n=fe();return yy(mL,{children:[nt("div",{className:"welcome-screen-menu-item__icon",children:e}),nt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&n.formFactor!=="phone"&&nt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Ey.displayName="WelcomeScreenMenuItemContent";var vc=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>nt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:nt(Ey,{icon:t,shortcut:n,children:o})});vc.displayName="WelcomeScreenMenuItem";var cL=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>nt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:nt(Ey,{icon:t,shortcut:n,children:e})});cL.displayName="WelcomeScreenMenuItemLink";var fo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Pe();return nt(o.In,{children:nt("div",{className:"welcome-screen-center",children:e||yy(mL,{children:[nt(vy,{}),nt(Ty,{children:h("welcomeScreen.defaults.center_heading")}),yy(Iy,{children:[nt(Sy,{}),nt(Cy,{})]})]})})})};fo.displayName="Center";var vy=({children:e})=>nt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||nt(sL,{size:"large"})});vy.displayName="Logo";var Ty=({children:e})=>nt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ty.displayName="Heading";var Iy=({children:e})=>nt("div",{className:"welcome-screen-menu",children:e});Iy.displayName="Menu";var Cy=()=>{let e=De();return nt(vc,{onSelect:()=>e.executeAction(Vr),shortcut:"?",icon:Di,children:h("helpDialog.title")})};Cy.displayName="MenuItemHelp";var Sy=()=>{let e=se(),o=De();return e.viewModeEnabled?null:nt(vc,{onSelect:()=>o.executeAction(aa),shortcut:Le("loadScene"),icon:Hi,children:h("buttons.load")})};Sy.displayName="MenuItemLoadScene";var dL=({onSelect:e})=>{let{t:o}=Ie();return nt(vc,{shortcut:null,onSelect:e,icon:Wc,children:o("labels.liveCollaboration")})};dL.displayName="MenuItemLiveCollaborationTrigger";fo.Logo=vy;fo.Heading=Ty;fo.Menu=Iy;fo.MenuItem=vc;fo.MenuItemLink=cL;fo.MenuItemHelp=Cy;fo.MenuItemLoadScene=Sy;fo.MenuItemLiveCollaborationTrigger=dL;import{jsx as El,jsxs as wy}from"react/jsx-runtime";var pu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Pe();return El(o.In,{children:wy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[c0,El("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.menuHint")})]})})};pu.displayName="MenuHint";var uu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Pe();return El(o.In,{children:wy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[El("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.toolbarHint")}),m0]})})};uu.displayName="ToolbarHint";var hu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Pe();return El(o.In,{children:wy("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[El("div",{children:e||h("welcomeScreen.defaults.helpHint")}),d0]})})};hu.displayName="HelpHint";import{Fragment as pL,jsx as Tc,jsxs as OK}from"react/jsx-runtime";var gu=e=>Tc(pL,{children:e.children||OK(pL,{children:[Tc(fo,{}),Tc(pu,{}),Tc(uu,{}),Tc(hu,{})]})});gu.displayName="WelcomeScreen";gu.Center=fo;gu.Hints={MenuHint:pu,ToolbarHint:uu,HelpHint:hu};var FK=gu;import{useEffect as uL,useRef as hL,useState as zK}from"react";var GK=(e,o)=>typeof o=="function"?o(e):Array.isArray(o)?e:e[o],ky=(e,o,t)=>{if(e?.isDestroyed)return;let n=e?.getAppState();if(!n){if(!t)return;console.warn("useAppStateValue: hellixitboardAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Hellixitboard/> component tree?"),n=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Oo())}return GK(n,o)};function gL(e,o=!0){let t=mu(),[,n]=zK(0),r=hL(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:ky(t,e,o)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=ky(t,e,o)),uL(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,l=>{i.latestValue=l,n(a=>a+1)})},[t]),r.current.latestValue}function UK(e,o){let t=mu(),n=hL({selector:e,callback:o});n.current.selector=e,n.current.callback=o,uL(()=>{if(!(!t||t.isDestroyed))return n.current.callback(ky(t,n.current.selector,!0),t.getAppState()),t.onStateChange(n.current.selector,(r,i)=>{n.current.callback(r,i)})},[t])}var WK=()=>{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)})},fL=WK;import{getSceneVersion as hUe,hashElementsVersion as gUe,hashString as fUe,getNonDeletedElements as bUe}from"@hellixit/element";import{getTextFromElements as yUe}from"@hellixit/element";import{isInvisiblySmallElement as vUe}from"@hellixit/element";import YK from"lodash.throttle";import{arrayToMap as VK,isDevEnv as bL,isTestEnv as xL}from"@hellixit/common";import{orderByFractionalIndex as XK,syncInvalidIndices as yL,validateFractionalIndices as KK}from"@hellixit/element";var $K=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<=t.versionNonce)),ZK=YK((e,o,t)=>{if(bL()||xL()||window?.DEBUG_FRACTIONAL_INDICES){let n=yL(e.map(r=>({...r})));KK(n,{shouldThrow:xL()||bL(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),jK=(e,o,t)=>{let n=VK(e),r=[],i=new Set;for(let a of o)if(!i.has(a.id)){let s=n.get(a.id),c=$K(t,s,a);s&&c?(r.push(s),i.add(s.id)):(r.push(a),i.add(a.id))}for(let a of e)i.has(a.id)||(r.push(a),i.add(a.id));let l=XK(r);return ZK(l,e,o),yL(l),l};import{isLinearElement as AUe}from"@hellixit/element";import{FONT_FAMILY as _Ue,THEME as DUe,MIME_TYPES as HUe,ROUNDNESS as RUe,DEFAULT_LASER_COLOR as NUe,UserIdleState as BUe,normalizeLink as FUe,sceneCoordsToViewportCoords as OUe,viewportCoordsToSceneCoords as zUe,getFormFactor as GUe,throttleRAF as UUe}from"@hellixit/common";import{mutateElement as YUe,newElementWith as VUe,bumpVersion as XUe}from"@hellixit/element";import{CaptureUpdateAction as $Ue}from"@hellixit/element";import{jsx as My}from"react/jsx-runtime";var EL=({children:e,icon:o})=>{let{t}=Ie(),{TTDDialogTriggerTunnel:n}=Pe(),r=he();return My(n.In,{children:My(ie.Item,{onSelect:()=>{ce("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??wE,badge:My(ie.Item.Badge,{children:"AI"}),children:e??t("labels.textToDiagram")})})};EL.displayName="TTDDialogTrigger";function qK(e){let o=e.get("X-Ratelimit-Limit"),t=e.get("X-Ratelimit-Remaining");return{rateLimit:o?parseInt(o,10):void 0,rateLimitRemaining:t?parseInt(t,10):void 0}}async function*JK(e){let o=new TextDecoder,t="";try{for(;;){let{done:n,value:r}=await e.read();if(n)break;t+=o.decode(r,{stream:!0});let i=t.split(`
134
+ `);t=i.pop()||"";for(let l of i){let a=l.trim();a&&a.startsWith("data: ")&&(yield a.slice(6))}}}finally{e.releaseLock()}}async function QK(e){let{url:o,messages:t,onChunk:n,onStreamCreated:r,extractRateLimits:i=!0,signal:l}=e;try{let a="",s={},c=null,m=await fetch(o,{method:"POST",headers:{Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify({messages:t}),signal:l});if(i&&(s=qK(m.headers)),!m.ok){if(m.status===429)return{...s,error:new Fo({message:"Rate limit exceeded",status:429})};let d=await m.text();throw new Fo({message:d||"Generation failed...",status:m.status})}let p=m.body?.getReader();if(!p)throw new Fo({message:"Couldn't get reader from response body",status:500});r?.();try{for await(let d of JK(p)){if(d==="[DONE]")break;try{let u=JSON.parse(d);if(u===null)break;switch(u.type){case"content":{let b=u.delta;b&&(a+=b,n?.(b));break}case"error":c=new Fo({message:u.error.message,status:500});break;case"done":break}}catch(u){console.warn("Failed to parse SSE data:",d,u)}}}catch(d){d.name==="AbortError"?c=new Fo({message:"Request aborted",status:499}):c=new Fo({message:d.message||"Streaming error",status:500})}return c?{...s,error:c}:a?{generatedResponse:a,error:null,...s}:{...s,error:new Fo({message:"Generation failed...",status:m.status})}}catch(a){return a.name==="AbortError"?{error:new Fo({message:"Request aborted",status:499})}:{error:new Fo({message:a.message||"Request failed",status:500})}}}import{getCommonBounds as lWe,getVisibleSceneBounds as sWe,convertToHellixitboardElements as cWe}from"@hellixit/element";import{useLayoutEffect as e$}from"react";var t$=e=>{let o=Ae();return e$(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as hWe}from"@hellixit/element";import{setCustomTextMetricsProvider as fWe}from"@hellixit/element";import{jsx as Ic}from"react/jsx-runtime";fL();var cUe=({children:e})=>{let[o,t]=l$(null);return Ic(yl.Provider,{value:o,children:Ic(du.Provider,{value:t,children:e})})},c$=e=>{let{onExport:o,onChange:t,onIncrement:n,initialData:r,onHellixitboardAPI:i,onMount:l,onUnmount:a,onInitialize:s,isCollaborating:c=!1,onPointerUpdate:m,renderTopLeftUI:p,renderTopRightUI:d,langCode:u=Go.code,viewModeEnabled:b,zenModeEnabled:g,gridModeEnabled:x,libraryReturnUrl:v,theme:y,name:E,renderCustomStats:T,onPaste:I,detectScroll:S=!0,handleKeyboardGlobally:M=!1,onLibraryChange:k,autoFocus:_=!1,generateIdForFile:P,onLinkOpen:A,generateLinkForSelection:H,onPointerDown:F,onPointerUp:Y,onScrollChange:V,onDuplicate:U,children:D,validateEmbeddable:B,renderEmbeddable:W,aiEnabled:te,showDeprecatedFonts:X,renderScrollbars:le,onFileUpload:pe,onClearCanvas:de,onReportIssue:Ee,onAddComment:Ve,onToggleComments:rt,commentsVisible:ft}=e,Ct=e.UIOptions?.canvasActions,zn={...e.UIOptions,canvasActions:{...vL.canvasActions,...Ct},tools:{image:e.UIOptions?.tools?.image??!0}};Ct?.export&&(zn.canvasActions.export.saveFileToDisk=Ct.export?.saveFileToDisk??vL.canvasActions.export.saveFileToDisk),zn.canvasActions.toggleTheme===null&&typeof y>"u"&&(zn.canvasActions.toggleTheme=!0);let Cc=r$(du),vl=a$(i);vl.current=i;let fu=n$(xn=>{Cc?.(xn),vl.current?.(xn)},[Cc]);return i$(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let bo=Tl=>{typeof Tl.scale=="number"&&Tl.scale!==1&&Tl.preventDefault()};return document.addEventListener("touchmove",bo,{passive:!1}),()=>{document.removeEventListener("touchmove",bo)}},[]),Ic(e0,{store:Qe,children:Ic(nL,{langCode:u,theme:y,children:Ic(oL,{onExport:o,onChange:t,onIncrement:n,initialData:r,onHellixitboardAPI:fu,onMount:l,onUnmount:a,onInitialize:s,isCollaborating:c,onPointerUpdate:m,renderTopLeftUI:p,renderTopRightUI:d,langCode:u,viewModeEnabled:b,zenModeEnabled:g,gridModeEnabled:x,libraryReturnUrl:v,theme:y,name:E,renderCustomStats:T,UIOptions:zn,onPaste:I,detectScroll:S,handleKeyboardGlobally:M,onLibraryChange:k,autoFocus:_,generateIdForFile:P,onLinkOpen:A,generateLinkForSelection:H,onPointerDown:F,onPointerUp:Y,onScrollChange:V,onDuplicate:U,validateEmbeddable:B,renderEmbeddable:W,aiEnabled:te!==!1,showDeprecatedFonts:X,renderScrollbars:le,onFileUpload:pe,onClearCanvas:de,onReportIssue:Ee,onAddComment:Ve,onToggleComments:rt,commentsVisible:ft,children:D})})})},d$=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:l={},...a}=o,s=Object.keys(n),c=Object.keys(l);return s.length!==c.length?!1:s.every(p=>p==="getFormFactor"?!0:p==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&l?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===l.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===l?.canvasActions?.[u]):n[p]===l[p])&&s$(r,a)},m$=o$.memo(c$,d$);m$.displayName="Hellix IT";function dUe(e){return gL(e,!1)}export{ut as Button,$Ue as CaptureUpdateAction,eF as CommandPalette,NUe as DEFAULT_LASER_COLOR,Tp as DefaultSidebar,t$ as DiagramToCodePlugin,Zl as Ellipsify,_Ue as FONT_FAMILY,PK as Footer,AK as FooterRightSlot,m$ as Hellixitboard,yl as HellixitboardAPIContext,cUe as HellixitboardAPIProvider,HK as LiveCollaborationTrigger,HUe as MIME_TYPES,vt as MainMenu,RUe as ROUNDNESS,so as Sidebar,nc as Stats,DUe as THEME,Rp as TTDDialog,EL as TTDDialogTrigger,QK as TTDStreamFetch,BUe as UserIdleState,FK as WelcomeScreen,XUe as bumpVersion,cWe as convertToHellixitboardElements,Go as defaultLang,JI as elementPartiallyOverlapsWithOrContainsBBox,QI as elementsOverlappingBBox,J2 as exportToBlob,nr as exportToCanvas,g4 as exportToClipboard,ya as exportToSvg,lWe as getCommonBounds,Iu as getDataURL,GUe as getFormFactor,im as getLibraryItemsHash,bUe as getNonDeletedElements,hUe as getSceneVersion,yUe as getTextFromElements,sWe as getVisibleSceneBounds,gUe as hashElementsVersion,fUe as hashString,Sf as isElementInsideBBox,hWe as isElementLink,vUe as isInvisiblySmallElement,AUe as isLinearElement,Ga as isSpreadsheetValidForChartType,Si as languages,_c as loadFromBlob,Tu as loadLibraryFromBlob,vu as loadSceneOrLibraryFromBlob,lT as mergeLibraryItems,YUe as mutateElement,VUe as newElementWith,FUe as normalizeLink,zg as parseLibraryTokensFromUrl,jK as reconcileElements,sb as renderSpreadsheet,Ti as restoreAppState,IL as restoreElement,Lr as restoreElements,Al as restoreLibraryItems,OUe as sceneCoordsToViewportCoords,kl as serializeAsJSON,TL as serializeLibraryAsJSON,fWe as setCustomTextMetricsProvider,UUe as throttleRAF,op as tryParseSpreadsheet,fe as useEditorInterface,L4 as useHandleLibrary,mu as useHellixitboardAPI,dUe as useHellixitboardStateValue,Ie as useI18n,UK as useOnHellixitboardStateChange,at as useStylesPanelMode,zUe as viewportCoordsToSceneCoords,pv as zoomToFitBounds};