@myoc/excalidraw 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +253 -0
- package/dist/dev/{chunk-VBVJJWUO.js → chunk-A5GXRKT7.js} +24 -2
- package/dist/dev/chunk-A5GXRKT7.js.map +7 -0
- package/dist/dev/{chunk-6JJSWC4C.js → chunk-ETORD5CS.js} +41 -1
- package/dist/dev/{chunk-6JJSWC4C.js.map → chunk-ETORD5CS.js.map} +3 -3
- package/dist/dev/{chunk-EYSZ36MK.js → chunk-RCINQZKB.js} +2 -2
- package/dist/dev/{chunk-JBD373VY.js → chunk-TYPY4HGC.js} +374 -75
- package/dist/dev/chunk-TYPY4HGC.js.map +7 -0
- package/dist/dev/data/{image-KRZO2CVW.js → image-LHOOLEDU.js} +3 -3
- package/dist/dev/index.css +121 -0
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +1911 -1513
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-V2WTRX5T.js → en-5NWRTZ4G.js} +4 -2
- package/dist/dev/subset-shared.chunk.js +4 -2
- package/dist/dev/subset-worker.chunk.js +2 -2
- package/dist/prod/{chunk-THEEFQ4B.js → chunk-4M4QNZNP.js} +1 -1
- package/dist/prod/{chunk-MZBVWY5X.js → chunk-FX6OEDRJ.js} +4 -4
- package/dist/prod/chunk-UXMXN2SG.js +4 -0
- package/dist/prod/{chunk-Z5NKEFVG.js → chunk-VDR2JODW.js} +10 -10
- package/dist/prod/data/image-XO3VLL25.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +16 -16
- package/dist/prod/locales/en-3B3DKM74.js +1 -0
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +7 -2
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/element/src/types.d.ts +2 -2
- package/dist/types/excalidraw/appState.d.ts +1 -1
- package/dist/types/excalidraw/charts/charts.constants.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +15 -4
- package/dist/types/excalidraw/components/FontPicker/FontWeightPicker.d.ts +34 -0
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +3 -2
- package/dist/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +2 -1
- package/dist/types/excalidraw/fonts/Fonts.d.ts +15 -4
- package/dist/types/excalidraw/fonts/googleFonts.d.ts +40 -0
- package/dist/types/excalidraw/index.d.ts +2 -1
- package/dist/types/excalidraw/subset/subset-main.d.ts +1 -0
- package/dist/types/excalidraw/subset/subset-shared.chunk.d.ts +1 -0
- package/dist/types/excalidraw/subset/woff2/fontMetrics.d.ts +8 -0
- package/dist/types/excalidraw/types.d.ts +42 -0
- package/package.json +4 -4
- package/dist/dev/chunk-JBD373VY.js.map +0 -7
- package/dist/dev/chunk-VBVJJWUO.js.map +0 -7
- package/dist/prod/chunk-CQHKTNJ6.js +0 -4
- package/dist/prod/data/image-3WH4CMOG.js +0 -1
- package/dist/prod/locales/en-ALU5NMSJ.js +0 -1
- /package/dist/dev/{chunk-EYSZ36MK.js.map → chunk-RCINQZKB.js.map} +0 -0
- /package/dist/dev/data/{image-KRZO2CVW.js.map → image-LHOOLEDU.js.map} +0 -0
- /package/dist/dev/locales/{en-V2WTRX5T.js.map → en-5NWRTZ4G.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{$ as Vu,A as Px,B as Uu,C as Ml,D as Gc,E as Wu,F as kx,G as Mx,H as Hc,I as Al,J as Uc,K as Wc,L as Ll,M as Vc,N as Ax,O as Lx,P as Dx,Q as Yc,R as Vr,S as XA,T as Yr,U as zi,W as _x,Y as Rx,Z as Nx,_ as Kc,a as Ou,aa as Gi,b as Jn,ba as Dl,c as Io,ca as _l,d as Wr,da as Bx,e as Bi,ea as Xc,f as Qn,fa as Fx,g as wx,ga as Ox,h as Oe,ha as zx,i as vx,ia as Gx,j as de,ja as Yu,k as Fi,ka as Hx,l as jo,la as Ux,m as Ix,ma as Wx,n as zu,na as Kr,o as Tx,p as Pl,q as Sx,r as zc,s as Cx,t as Gu,u as Hu,v as To,w as qo,x as dn,y as kl,z as Oi}from"./chunk-CQHKTNJ6.js";import{a as S}from"./chunk-THEEFQ4B.js";import{G as Fu}from"./chunk-MZBVWY5X.js";import{c as yx}from"./chunk-5XKZK2GL.js";import{b as xx,c as KA,d as v}from"./chunk-SRAX5OIU.js";import KX,{useCallback as XX,useContext as ZX,useEffect as $X,useRef as jX,useState as qX}from"react";import{applyDarkModeFilter as LYe,DEFAULT_IMAGE_OPTIONS as Ln,DEFAULT_UI_OPTIONS as YA,getStrokeWidthByKey as DYe,isShallowEqual as JX}from"@excalidraw/common";import xM from"clsx";import vY from"lodash.throttle";import Mn,{useContext as Ko}from"react";import{flushSync as Ut}from"react-dom";import IY from"roughjs/bin/rough";import{nanoid as TY}from"nanoid";import{clamp as yc,pointFrom as ie,pointDistance as Eo,vector as yM,pointRotateRads as Db,vectorFromPoint as _b,vectorSubtract as wM,vectorDot as vM,vectorNormalize as IM}from"@excalidraw/math";import{CODES as Or,shouldResizeFromCenter as TM,shouldMaintainAspectRatio as wc,shouldRotateWithDiscreteAngle as SM,isArrowKey as Rb,KEYS as Y,APP_NAME as SY,CURSOR_TYPE as Le,DEFAULT_STROKE_STREAMLINE as CY,DEFAULT_STROKE_STREAMLINE_PRECISE as PY,DEFAULT_TRANSFORM_HANDLE_SPACING as kY,DEFAULT_VERTICAL_ALIGN as CM,DRAGGING_THRESHOLD as PM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as MY,ELEMENT_TRANSLATE_AMOUNT as kM,EVENT as ee,FRAME_STYLE as Ho,IMAGE_MIME_TYPES as AY,IMAGE_RENDER_TIMEOUT as LY,LINE_CONFIRM_THRESHOLD as Nb,MIME_TYPES as Pn,MQ_RIGHT_SIDEBAR_MIN_WIDTH as DY,POINTER_BUTTON as kn,ROUNDNESS as hu,SCROLL_TIMEOUT as _Y,TAP_TWICE_TIMEOUT as MM,TEXT_TO_CENTER_SNAP_THRESHOLD as RY,THEME as vc,TOUCH_CTX_MENU_TIMEOUT as NY,VERTICAL_ALIGN as BY,YOUTUBE_STATES as gu,ZOOM_STEP as FY,MIN_ZOOM as OY,POINTER_EVENTS as yl,TOOL_TYPE as Zn,supportsResizeObserver as zY,DEFAULT_COLLISION_THRESHOLD as AM,DEFAULT_TEXT_ALIGN as GY,ARROW_TYPE as zr,DEFAULT_REDUCED_GLOBAL_ALPHA as HY,isLocalLink as UY,normalizeLink as fu,toValidURL as WY,getGridPoint as Dt,getLineHeight as LM,debounce as DM,distance as wl,getFontString as Bb,getNearestScrollableContainer as VY,isInputLike as _M,isToolIcon as YY,isWritableElement as Ic,sceneCoordsToViewportCoords as Eu,tupleToCoors as Fb,viewportCoordsToSceneCoords as Se,wrapEvent as KY,updateObject as Ob,updateActiveTool as sn,isTransparent as XY,muteFSAbortError as ZY,isTestEnv as IA,isDevEnv as TA,updateStable as Tc,addEventListener as we,normalizeEOL as $Y,getDateTime as RM,isShallowEqual as NM,capitalizeString as jY,arrayToMap as Sc,applyDarkModeFilter as qY,AppEventBus as JY,randomInteger as QY,CLASSES as zb,Emitter as bo,MINIMUM_ARROW_SIZE as eK,DOUBLE_TAP_POSITION_THRESHOLD as BM,BIND_MODE_TIMEOUT as tK,invariant as xo,getFeatureFlag as Uo,createUserAgentDescriptor as SA,getFormFactor as nK,deriveStylesPanelMode as ku,isIOS as oK,isBrave as rK,isSafari as iK,loadDesktopUIModePreference as aK,setDesktopUIMode as lK,isSelectionLikeTool as bu,oneOf as FM,getStrokeWidthByKey as sK,getViewpointFlipSign as $n}from"@excalidraw/common";import{getObservedAppState as cK,getCommonBounds as vl,getElementAbsoluteCoords as OM,bindOrUnbindBindingElements as zM,fixBindingsAfterDeletion as dK,getHoveredElementForBinding as Gr,isBindingEnabled as xu,updateBoundElements as yu,LinearElementEditor as ge,newElementWith as yo,newFrameElement as mK,newFreeDrawElement as pK,newEmbeddableElement as GM,newMagicFrameElement as uK,newIframeElement as hK,newArrowElement as gK,newElement as fK,newImageElement as EK,newLinearElement as bK,newTextElement as HM,refreshTextDimensions as xK,deepCopyElement as UM,duplicateElements as WM,hasBoundTextElement as VM,isArrowElement as Cc,isBindingElement as wo,isBindingElementType as yK,isBoundToContainer as YM,isFrameLikeElement as kt,isImageElement as jn,isEmbeddableElement as Wo,isInitializedImageElement as Di,isLinearElement as Wt,isLinearElementType as wK,isUsingAdaptiveRadius as vK,isIframeElement as Gb,isIframeLikeElement as Pc,isTextBindableContainer as KM,isElbowArrow as jt,isBindableElement as Hb,isTextElement as qt,getNormalizedDimensions as IK,isElementCompletelyInViewport as TK,isElementInViewport as XM,isInvisiblySmallElement as ZM,generateThumbHash as SK,getCornerRadius as CK,isPathALoop as $M,embeddableURLValidator as Ub,maybeParseEmbedSrc as PK,getEmbedLink as wu,getInitializedImageElements as kK,normalizeSVG as jM,updateImageCache as Wb,getBoundTextElement as Vb,getContainerCenter as Yb,getContainerElement as qM,isValidTextContainer as JM,redrawTextBoundingBox as MK,hasBoundingBox as AK,getCommonFrameId as QM,getFrameChildren as Kb,getFrameChildrenInsertionIndex as LK,isCursorInFrame as eA,addElementsToFrame as Xb,replaceAllElementsInFrame as DK,removeElementsFromFrame as _K,getElementsInResizingFrame as Zb,getElementsInNewFrame as RK,getContainingFrame as $b,elementOverlapsWithFrame as NK,updateFrameMembershipOfSelectedElements as tA,isElementInFrame as nA,getFrameLikeTitle as BK,filterElementsEligibleAsFrameChildren as FK,hitElementBoundText as OK,hitElementBoundingBoxOnly as zK,hitElementItself as kc,getVisibleSceneBounds as GK,cropElement as HK,wrapText as UK,isElementLink as oA,isMeasureTextSupported as WK,normalizeText as VK,measureText as rA,getLineHeightInPx as iA,getApproxMinLineWidth as YK,getApproxMinLineHeight as KK,getMinTextElementWidth as XK,ShapeCache as _i,getRenderOpacity as ZK,editGroupForSelectedElement as $K,getElementsInGroup as Ri,getSelectedGroupIdForElement as jK,getSelectedGroupIds as qK,isElementInGroup as aA,isSelectedViaGroup as JK,selectGroupsForSelectedElements as qn,syncInvalidIndices as CA,syncMovedIndices as lA,excludeElementsInFramesFromSelection as QK,getSelectionStateForElements as sA,makeNextSelectedElementIds as Ne,getResizeOffsetXY as eX,getResizeArrowDirection as tX,transformElements as nX,getCursorForResizingElement as cA,getElementWithTransformHandleType as dA,getTransformHandleTypeFromCoords as mA,dragNewElement as pA,dragSelectedElements as oX,getDragOffsetXY as rX,Scene as uA,Store as iX,CaptureUpdateAction as Jt,hitElementBoundingBox as aX,isLineElement as jb,isSimpleArrow as qb,StoreDelta as hA,positionElementsOnGrid as gA,calculateFixedPointForNonElbowArrowBinding as fA,bindOrUnbindBindingElement as lX,mutateElement as vu,getElementBounds as EA,doBoundsIntersect as sX,isPointInElement as bA,maxBindingDistance_simple as xA,convertToExcalidrawElements as cX,getSnapOutlineMidPoint as Jb,handleFocusPointDrag as dX,handleFocusPointHover as mX,handleFocusPointPointerDown as pX,handleFocusPointPointerUp as uX,maybeHandleArrowPointlikeDrag as Iu,getUncroppedWidthAndHeight as hX,getActiveTextElement as yA,isEligibleFrameChildType as gX,getBindingStrategyForDraggingBindingElementEndpoints as fX,isNonDeletedElement as Tu}from"@excalidraw/element";import{KEYS as Ih,MOBILE_ACTION_BUTTON_BG as l3,updateActiveTool as s3}from"@excalidraw/common";import{getNonDeletedElements as ud}from"@excalidraw/element";import{fixBindingsAfterDeletion as c3}from"@excalidraw/element";import{LinearElementEditor as O0}from"@excalidraw/element/linearElementEditor";import{newElementWith as pd}from"@excalidraw/element";import{getContainerElement as z0}from"@excalidraw/element";import{isBoundToContainer as dd,isElbowArrow as d3,isFrameLikeElement as m3}from"@excalidraw/element";import{getFrameChildren as p3}from"@excalidraw/element";import{getElementsInGroup as Th,selectGroupsForSelectedElements as u3}from"@excalidraw/element";import{CaptureUpdateAction as md}from"@excalidraw/element";import{isDevEnv as qA}from"@excalidraw/common";import{atom as et,createStore as ZA}from"jotai";import{createIsolation as $A}from"jotai-scope";var Vx=$A();var{useAtom:$e,useSetAtom:Yx,useAtomValue:Hi,useStore:rZ}=Vx,Kx=Vx.Provider,Tt=ZA();var jA=xx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-ALU5NMSJ.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var JA=85,eo={code:"en",label:"English"},Wi=[eo,...[{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=>yx[e.code]>=JA).sort((e,n)=>e.label>n.label?1:-1)],$c="__test__";qA()&&Wi.unshift({code:$c,label:"test language"},{code:`${$c}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ui=eo,Zc={},jc=async e=>{if(Ui=e,document.documentElement.dir=Ui.rtl?"rtl":"ltr",document.documentElement.lang=Ui.code,e.code.startsWith($c))Zc={};else try{Zc=await jA(`./locales/${Ui.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Zc=Fu}Tt.set(Zx,e.code)},to=()=>Ui,Xx=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Ui.code.startsWith($c))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Xx(Zc,o)||Xx(Fu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Zx=et(eo.code),_e=()=>{let e=Hi(Zx);return{t:f,langCode:e}};import QA from"clsx";import rt from"react";import{THEME as e3}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var Dn=e=>"var(--icon-fill-color)",$x=e=>e===e3.LIGHT?"#fff":"#1e1e1e",A=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:QA({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ae={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Nt={width:40,height:20},xZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("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"})]}),H),yZ=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),wZ=A("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),Rl=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),H),jx=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),H),qx=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Ku=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),H),So=A(R("g",{children:[h("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"}),h("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"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("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"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("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"})})]}),ae),Jo=A(R("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("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"})]}),ae),Jx=A(h("g",{fill:"currentColor",children:h("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}),Qx=A(R(Ie,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("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"}),e1=A(R(Ie,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("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"}),t1=A(R(Ie,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("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"}),vZ=A(h("g",{fill:"currentColor",children:h("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"}),qc=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Vi=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("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"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Yi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Ki=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),H),Xi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),Jc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),Qo=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ae),n1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),no=A(R("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ae),_n=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),o1=A(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),Xr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("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"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ae),Qc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Xu=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),Zu=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),r1=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("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"}),h("path",{d:"M3 4v4h4"})]}),H),Zr=A(h("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"}),ae),er=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ae),Nl=A(R("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),Bl=A(h("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"}),ae),Fl=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("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"})}),{...ae,strokeWidth:1.5}),i1=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Ol=A(h("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"}),ae),Zi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),a1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),IZ=A(h("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"}),ae),l1=A(h("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"}),ae),s1=A(R("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),c1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),ed=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),zl=A(R("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),ae),d1=A("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}),m1=A("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}),td=A(h("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"}),ae),TZ=A("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}),SZ=A("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"),$u=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],oo=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$u.map(e=>h("path",{d:e},e))]}),H),p1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),u1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),H),h1=A("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}),CZ=A("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}),PZ=A("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}),g1=A("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"),kZ=A("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"),ju=A(h("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"}),ae),qu=A(h("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"}),ae),f1=A("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}),E1=A(h("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"}),ae),MZ=A("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"),AZ=A("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}),LZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),H),DZ=A(R(Ie,{children:[h("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"}),h("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=A(h("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}),b1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),x1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Ju=A(x1,H),Qu=A(x1,{...H,style:{transform:"rotate(180deg)"}}),eh=A(b1,H),th=A(b1,{...H,style:{transform:"rotate(180deg)"}}),nh=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),oh=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),rh=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),ih=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),y1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),w1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),ah=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),ae),lh=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),ae),nd=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),RZ=A("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"),NZ=A("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"),mn=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),BZ=A("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}),FZ=A("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}),OZ=A("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}),sh=rt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Dn(e)}),h("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:Dn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Dn(e)}),h("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:Dn(e),strokeWidth:"2"}),R("g",{fill:$x(e),stroke:Dn(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),ch=rt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Dn(e)}),h("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:Dn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Dn(e)}),h("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:Dn(e),strokeWidth:"2"}),R("g",{fill:$x(e),stroke:Dn(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),v1=A(h("g",{strokeWidth:1.25,children:h("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"})}),ae),I1=A(R(Ie,{children:[h("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"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("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"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("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"})})]}),ae),T1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[h("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"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("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"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("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"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),S1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ae,fill:"currentColor"}),dh=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),C1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),P1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),zZ=rt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:Dn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),k1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),H),M1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),H),A1=A(h("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"}),ae),L1=A(h("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"}),ae),D1=A(h("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"}),ae),mh=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),ph=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),_1=A(R("svg",{strokeWidth:"1.5",children:[h("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"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ae),R1=A(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),N1=rt.memo(({flip:e=!1})=>A(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Nt)),B1=rt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Nt)),F1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Nt)),O1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Nt)),z1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Nt)),G1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Nt)),H1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Nt)),U1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Nt)),W1=rt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),Nt)),V1=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),Nt)),Y1=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Nt)),K1=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Nt)),X1=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Nt)),Z1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),Nt)),$1=rt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),Nt)),j1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),q1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),J1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Q1=A(h(Ie,{children:h("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"})}),ae),$r=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),e0=A(h(Ie,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),H),Gl=A(h(Ie,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})})}),ae),t3=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),od=t3,t0=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),n0=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),o0=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),r0=rt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),i0=rt.memo(({theme:e})=>A(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),a0=rt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),rd=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),H),GZ=A(h("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}),HZ=A(h("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"})),l0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("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"})]}),H),uh=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),s0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),c0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),H),d0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),UZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),WZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),H),m0=A(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),p0=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),u0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),h0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),g0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),hh=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],jr=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),hh.map(e=>h("path",{d:e},e))]}),H),ro=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),H),VZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),YZ=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),KZ=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ae),qr=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),io=A(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("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"}),h("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),XZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),H),ZZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("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"})]}),H),$Z=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("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"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("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"})]}),H),jZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),Jr=A(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("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"})]}),H),f0=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("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"}),h("path",{d:"M3 3l18 18"})]}),H),qZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),JZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),ao=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),H),QZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),e$=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),E0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),b0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),t$=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),x0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),H),y0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),H),w0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),v0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),gh=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("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"})]}),H),id=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),I0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("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"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),T0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),H),tr=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),H),n$=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),S0=A(R("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),{...H,strokeWidth:1.5}),o$=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),H),r$=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),H),C0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),H),P0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),nr=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),or=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),H),rr=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),ad=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),k0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),M0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),fh=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),A0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),H),Eh=A(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),bh=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),i$=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),xh=A(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),L0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H),D0=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),yh=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),a$=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),l$=A(R("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M15 4l0 16"})]}),H),s$=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),H),c$=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),ld=h("div",{style:{width:"1rem",height:"1rem"}}),_0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),R0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),N0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H);import B0 from"clsx";import vh,{useEffect as r3,useRef as F0,useState as i3}from"react";import{isPromiseLike as a3}from"@excalidraw/common";import n3 from"react";import{jsx as wh}from"react/jsx-runtime";var o3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(n3.useRef(Date.now()).current%1600);return wh("div",{className:`Spinner ${o}`,children:wh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:wh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Co=o3;import{jsx as Hl,jsxs as sd}from"react/jsx-runtime";var $=vh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=vh.useRef(null);vh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[l,s]=i3(!1),d=F0(!0),c=async m=>{let u="onClick"in o&&o.onClick?.(m);if(a3(u))try{s(!0),await u}catch(E){if(E instanceof zc)console.warn(E);else throw E}finally{d.current&&s(!1)}};r3(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=F0(null);return o.type==="button"||o.type==="icon"?sd("button",{className:B0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:c,ref:i,disabled:l||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&sd("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Hl("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Hl(Co,{})]}),o.showAriaLabel&&sd("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",l&&Hl(Co,{})]}),o.children]}):Hl("button",{className:B0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:m=>{p.current=m.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},onClick:()=>{o.onSelect?.({pointerType:p.current})},ref:i,children:sd("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Hl("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var cd=[],O=e=>(cd=cd.concat(e),e);import{jsx as g3}from"react/jsx-runtime";var h3=(e,n,t)=>{let o=new Set(de(e.filter(c=>m3(c)),n).map(c=>c.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of o){let p=p3(e,c);for(let m of p)if(!a.has(m.id)){if(dd(m)){let u=z0(m,i);u&&(r[u.id]=!0)}else r[m.id]=!0;a.add(m.id)}}let l=!0,s=e.map(c=>{if(n.selectedElementIds[c.id]){let p=dd(c)?z0(c,i):null;return c.frameId&&o.has(c.frameId)?(l=!1,r[c.id]=!0,c):p?.frameId&&o.has(p?.frameId)?c:(c.boundElements&&c.boundElements.forEach(m=>{let u=t.scene.getNonDeletedElementsMap().get(m.id);u&&d3(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),pd(c,{isDeleted:!0}))}return c.frameId&&o.has(c.frameId)?(l=!1,dd(c)||(r[c.id]=!0),pd(c,{frameId:null})):dd(c)&&n.selectedElementIds[c.containerId]?pd(c,{isDeleted:!0}):c}),d=n.editingGroupId;if(l&&n.editingGroupId){let c=Th(s,n.editingGroupId).filter(p=>!p.isDeleted);if(c.length>1)c[0]&&(r[c[0].id]=!0);else{d=null,c[0]&&(r[c[0].id]=!0);let p=c[0];if(p){let m=p.groupIds.findIndex(E=>E===n.editingGroupId),u=p.groupIds[m+1];if(u){let E=Th(s,u).filter(g=>!g.isDeleted);E.length>1&&(d=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...n,...u3({selectedElementIds:r,editingGroupId:d},ud(s),n,null)}}},G0=(e,n)=>{if(e.editingGroupId){let t=Th(ud(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ul=O({name:"deleteSelectedElements",label:"labels.delete",icon:Zr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=n.selectedLinearElement,s=o.scene.getNonDeletedElementsMap(),d=O0.getElement(a,s);if(!d||l==null)return!1;if(l.length>=d.points.length){let c=e.map(m=>m.id===d.id?pd(m,{isDeleted:!0}):m),p=G0(n,c);return{elements:c,appState:{...p,selectedLinearElement:null},captureUpdate:md.IMMEDIATELY}}return O0.deletePoints(d,o,l),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:md.IMMEDIATELY}}let{elements:r,appState:i}=h3(e,n,o);return c3(r,r.filter(a=>a.isDeleted)),i=G0(i,r),{elements:r,appState:{...i,activeTool:s3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Oe(ud(e),n)?md.IMMEDIATELY:md.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Ih.BACKSPACE||e.key===Ih.DELETE)&&!e[Ih.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return g3($,{type:"button",icon:Zr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Oe(ud(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?l3:{}}})}});import{KEYS as $i,CODES as ji,isDarwin as hd}from"@excalidraw/common";import{moveOneLeft as f3,moveOneRight as E3,moveAllLeft as b3,moveAllRight as x3}from"@excalidraw/element";import{CaptureUpdateAction as gd}from"@excalidraw/element";import{isDarwin as H0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,H0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,H0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as fd}from"react/jsx-runtime";var Sh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Qu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:f3(e,n,o.scene),appState:n,captureUpdate:gd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[$i.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ji.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>fd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Qu})}),Ch=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Ju,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:E3(e,n,o.scene),appState:n,captureUpdate:gd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[$i.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ji.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>fd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Ju})}),Ph=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:th,trackEvent:{category:"element"},perform:(e,n)=>({elements:b3(e,n),appState:n,captureUpdate:gd.IMMEDIATELY}),keyTest:e=>hd?e[$i.CTRL_OR_CMD]&&e.altKey&&e.code===ji.BRACKET_LEFT:e[$i.CTRL_OR_CMD]&&e.shiftKey&&e.code===ji.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>fd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${hd?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:th})}),kh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:eh,trackEvent:{category:"element"},perform:(e,n)=>({elements:x3(e,n),appState:n,captureUpdate:gd.IMMEDIATELY}),keyTest:e=>hd?e[$i.CTRL_OR_CMD]&&e.altKey&&e.code===ji.BRACKET_RIGHT:e[$i.CTRL_OR_CMD]&&e.shiftKey&&e.code===ji.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>fd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${hd?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:eh})});import{getNonDeletedElements as y3}from"@excalidraw/element";import{LinearElementEditor as w3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as v3,isTextElement as I3}from"@excalidraw/element";import{arrayToMap as T3,KEYS as U0}from"@excalidraw/common";import{selectGroupsForSelectedElements as S3}from"@excalidraw/element";import{CaptureUpdateAction as C3}from"@excalidraw/element";var Mh=O({name:"selectAll",label:"labels.selectAll",icon:x0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(I3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...S3({editingGroupId:null,selectedElementIds:r},y3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&v3(e[0])?new w3(e[0],T3(e)):null},captureUpdate:C3.IMMEDIATELY}},keyTest:e=>e[U0.CTRL_OR_CMD]&&e.key===U0.A});import{DEFAULT_GRID_SIZE as W0,KEYS as V0,MOBILE_ACTION_BUTTON_BG as P3,arrayToMap as Y0}from"@excalidraw/common";import{getNonDeletedElements as K0}from"@excalidraw/element";import{LinearElementEditor as k3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as M3,getSelectionStateForElements as A3}from"@excalidraw/element";import{syncMovedIndices as L3}from"@excalidraw/element";import{duplicateElements as D3}from"@excalidraw/element";import{CaptureUpdateAction as X0}from"@excalidraw/element";import{jsx as _3}from"react/jsx-runtime";var Ah=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Nl,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=k3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:X0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=D3({type:"in-place",elements:e,idsOfElementsToDuplicate:Y0(M3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+W0/2,y:a.y+W0/2,frameId:s??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:L3(i,Y0(r)),appState:{...n,...A3(r,K0(i),n)},captureUpdate:X0.IMMEDIATELY}},keyTest:e=>e[V0.CTRL_OR_CMD]&&e.key===V0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return _3($,{type:"button",icon:Nl,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Oe(K0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?P3:{}}})}});import{pointFrom as pL}from"@excalidraw/math";import{useEffect as jh,useMemo as Qh,useRef as qh,useState as uL}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as hL,COLOR_PALETTE as gL,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as ew,DEFAULT_ELEMENT_BACKGROUND_PICKS as fL,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as EL,DEFAULT_ELEMENT_STROKE_PICKS as bL,ARROW_TYPE as gn,DEFAULT_FONT_FAMILY as xL,DEFAULT_FONT_SIZE as yL,FONT_FAMILY as wL,ROUNDNESS as Od,STROKE_WIDTH_KEYS as vL,VERTICAL_ALIGN as Bd,KEYS as aa,randomInteger as IL,arrayToMap as eg,getFontFamilyString as TL,getLineHeight as SL,isTransparent as CL,getStrokeWidthByKey as tw,reduceToCommonValue as PL,invariant as Gd,FONT_SIZES as Fd}from"@excalidraw/common";import{canBecomePolygon as kL,getNonDeletedElements as nw,isNonDeletedElement as ML}from"@excalidraw/element";import{bindBindingElement as $y,calculateFixedPointForElbowArrowBinding as jy,updateBoundElements as AL}from"@excalidraw/element";import{LinearElementEditor as ei}from"@excalidraw/element/linearElementEditor";import{newElementWith as ct}from"@excalidraw/element";import{getArrowheadForPicker as qy}from"@excalidraw/element";import{getBoundTextElement as pr,redrawTextBoundingBox as ts}from"@excalidraw/element";import{isArrowElement as zd,isBoundToContainer as LL,isElbowArrow as ow,isLinearElement as Jh,isLineElement as Jy,isTextElement as Kt,isUsingAdaptiveRadius as DL}from"@excalidraw/element";import{hasStrokeColor as _L}from"@excalidraw/element";import{updateElbowArrowPoints as RL,CaptureUpdateAction as at,toggleLinePolygonState as NL}from"@excalidraw/element";import{deriveStylesPanelMode as BL}from"@excalidraw/common";import{isDevEnv as R3}from"@excalidraw/common";var N3=new Set(["command_palette","export"]),Ye=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!N3.has(e)||R3())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import z3 from"clsx";import B3 from"clsx";import{forwardRef as F3}from"react";import{jsx as O3}from"react/jsx-runtime";var Z0=F3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:l}=e;return O3("button",{type:"button",ref:n,title:t,"data-testid":r,className:B3(o,{active:i}),onClick:l,style:e.style,children:a},t)});import{Fragment as H3,jsx as Lh,jsxs as G3}from"react/jsx-runtime";var en=e=>Lh(H3,{children:e.options.map(n=>e.type==="button"?Lh(Z0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):G3("label",{className:z3({active:e.value===n.value}),title:n.text,children:[Lh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as Py}from"radix-ui";import ky from"clsx";import{memo as s4,useRef as My,useEffect as c4}from"react";import{applyDarkModeFilter as d4,COLOR_OUTLINE_CONTRAST_THRESHOLD as Sy,COLOR_PALETTE as Ay,DEFAULT_ELEMENT_BACKGROUND_PICKS as m4,DEFAULT_ELEMENT_STROKE_PICKS as p4,isColorDark as Cy,isWritableElement as u4,THEME as h4}from"@excalidraw/common";import{jsx as U3}from"react/jsx-runtime";var Ed=()=>U3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as Z3,useLayoutEffect as $3,useRef as j3}from"react";import{createPortal as q3}from"react-dom";import{EVENT as ir,isColorDark as J3,KEYS as Q3,MIME_TYPES as e5,THEME as t5,removeDarkModeFilter as n5,rgbToHex as o5}from"@excalidraw/common";import $0 from"react";var Dh=$0.createContext(null),ye=()=>$0.useContext(Dh);import{useState as W3,useLayoutEffect as j0}from"react";import{THEME as V3}from"@excalidraw/common";var bd=e=>{let[n,t]=W3(null),o=me(),{theme:r}=ye(),{container:i}=Te();return j0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===V3.DARK))},[n,r,o.formFactor,e?.className]),j0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),n};import{useEffect as Y3}from"react";import{EVENT as xd}from"@excalidraw/common";function qi(e,n,t){Y3(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(xd.POINTER_DOWN,o),document.addEventListener(xd.TOUCH_START,o),()=>{document.removeEventListener(xd.POINTER_DOWN,o),document.removeEventListener(xd.TOUCH_START,o)}},[e,n,t])}import{useRef as K3}from"react";var Ji=e=>{let n=K3(e);return Object.assign(n.current,e),n.current};import{clamp as X3}from"@excalidraw/math";var q0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return X3(r,0,Math.max(0,t-n))},yd=({cursor:e,element:n,container:t,gap:o})=>({left:q0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:q0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as i5}from"react/jsx-runtime";var J0=hh.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),r5=`url(data:${e5.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${J0}</g><g stroke="#1b1b1f" stroke-width="1.25">${J0}</g></svg>`)}) 2 21, auto`,Yt=et(null),Q0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=bd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=Qi(),l=ft(),s=de(a,i),d=Ji({app:l,onCancel:e,onChange:n,onSelect:t,selectedElements:s}),{container:c}=Te();$3(()=>{if(r)return r.style.cursor=r5,()=>{r.style.cursor=""}},[r]),Z3(()=>{let m=p.current;if(!m||!l.canvas||!r)return;let u=!1,E=l.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return o5(L[0],L[1],L[2])},b=P=>i.theme===t5.DARK?n5(P):P,w=({clientX:P,clientY:M,altKey:L})=>{let{top:_,left:k}=yd({cursor:{x:P,y:M},element:{width:m.offsetWidth,height:m.offsetHeight},container:r.getBoundingClientRect(),gap:7});m.style.top=`${_}px`,m.style.left=`${k}px`;let D=g({clientX:P,clientY:M});u&&d.onChange(o,b(D),d.selectedElements,{altKey:L}),m.style.background=D,m.style.setProperty("--eye-dropper-preview-border-color",J3(D)?"#fff":"#222")},y=()=>{d.onCancel()},x=(P,M)=>{d.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,c?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===Q3.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:d.app.viewport.lastPosition.x,clientY:d.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(ir.KEYDOWN,C),r.addEventListener(ir.POINTER_DOWN,I),r.addEventListener(ir.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(ir.BLUR,y),()=>{u=!1,r.removeEventListener(ir.KEYDOWN,C),r.removeEventListener(ir.POINTER_DOWN,I),r.removeEventListener(ir.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(ir.BLUR,y)}},[d,l.canvas,r,o,c,i.offsetLeft,i.offsetTop,i.theme]);let p=j3(null);return qi(p,()=>{e()},m=>!!m.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?q3(i5("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as _h}from"radix-ui";import c5 from"clsx";import d5 from"react";import{isInteractive as m5}from"@excalidraw/common";import a5 from"react";import l5 from"clsx";import{jsx as s5}from"react/jsx-runtime";var Ke=a5.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>s5("div",{className:l5("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Rh,jsxs as p5}from"react/jsx-runtime";var Po=d5.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:d=!1},c)=>{let p=me(),m=p.formFactor==="phone"&&!p.isLandscape;return Rh(_h.Portal,{container:n,children:p5(_h.Content,{ref:c,className:c5("focus-visible-none",e),"data-prevent-outside-click":!0,side:m?"bottom":"right",align:m?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:u=>{d&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!m5(document.activeElement)&&n.focus(),r()},children:[Rh(Ke,{padding:3,style:o,children:t}),Rh(_h.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 u5,useCallback as Nh}from"react";var wd=()=>document.querySelector(".excalidraw-wysiwyg"),vd=()=>{let e=wd();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Wl=e=>{setTimeout(()=>{let n=wd();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Vl=(e,n,t,o)=>{n&&o&&o();let r=n&&t?vd():null;e(),n&&t&&Wl(r)},ey=()=>{let[e,n]=u5(null),t=Nh(()=>{let i=vd();n(i)},[]),o=Nh(()=>{setTimeout(()=>{let i=wd();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Nh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},ty=(e=100)=>{let n=wd();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import oy from"clsx";import{useCallback as f5,useEffect as Fh,useRef as ry,useState as iy}from"react";import{KEYS as Oh,normalizeInputColor as E5}from"@excalidraw/common";import{isTransparent as h5,MAX_CUSTOM_COLORS_USED_IN_CANVAS as g5}from"@excalidraw/common";var ar=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Yl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Bh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),ny=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[o[n]];return!h5(l)&&Bh({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[o[n]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,g5)},pn=et(null);import{Fragment as b5,jsx as Kl,jsxs as zh}from"react/jsx-runtime";var ay=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=me(),[a,l]=iy(e),[s,d]=iy(null),[c,p]=$e(pn);Fh(()=>{l(e)},[e]);let m=f5(w=>{let y=w.toLowerCase().trim(),x=E5(y);x?(n(x),d(null)):y.length===0?d(null):/^#?[0-9a-f]+$/.test(y)?d(f("colorPicker.invalidHexLength")):d(f("colorPicker.invalidColor")),l(y)},[n]),u=ry(null),E=ry(null);Fh(()=>{u.current&&u.current.focus()},[c]);let[g,b]=$e(Yt);return Fh(()=>()=>{b(null)},[b]),zh("div",{className:"color-picker__input-label-container",children:[zh("div",{className:oy("color-picker__input-label",{"has-error":s}),children:[Kl("div",{className:"color-picker__input-hash",children:"#"}),Kl("input",{ref:c==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!s,onChange:w=>{m(w.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e),d(null)},tabIndex:-1,onFocus:()=>p("hex"),onKeyDown:w=>{w.key!==Oh.TAB&&(w.key===Oh.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&zh(b5,{children:[Kl("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Kl("div",{ref:E,className:oy("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Oh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:jr})]})]}),s&&Kl("div",{className:"color-picker__error-message",role:"alert",children:s})]})};import Uh,{useEffect as Wh,useImperativeHandle as j5,useState as q5}from"react";import{EVENT as yy}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as J5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as Q5,KEYS as e4}from"@excalidraw/common";import P5 from"clsx";import{useEffect as k5,useRef as M5}from"react";import{applyDarkModeFilter as A5,THEME as L5}from"@excalidraw/common";import{isColorDark as x5}from"@excalidraw/common";import{jsxs as w5}from"react/jsx-runtime";var y5=({color:e,keyLabel:n,isShade:t=!1})=>w5("div",{className:"color-picker__button__hotkey-label",style:{color:x5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),ea=y5;import{createContext as v5,useContext as I5,useEffect as T5,useMemo as ly,useRef as sy,useState as S5}from"react";import{colorToHex as cy,isTransparent as C5}from"@excalidraw/common";var Qr="excalidraw-color-dnd-ghost",dy="excalidraw-color-dnd-active",my=10,py=100,uy=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=cy(e);return t!==null&&t===cy(n)},Gh=v5(null),un=()=>I5(Gh),hy=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=S5(null),i=sy(null),a=sy({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let l=ly(()=>{let s=null,d=()=>{s?.activated?r({color:s.color,origin:s.origin,overIndex:s.overIndex,duplicateIndex:s.duplicateIndex,slotSpan:s.slotSpan}):r(null)},c=()=>{let k=i.current;if(!k||!s)return!1;let D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((W,G)=>Number(W.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!D.length)return!1;s.slotRects=D.map(W=>W.getBoundingClientRect());let[B,K]=s.slotRects;s.slotSpan=K?K.left-B.left:B.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(s.slotSpan)/2,10);return s.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},p=(k,D)=>{s?.ghost&&(s.ghost.style.transform=`translate(${k-s.ghostW/2}px, ${D-s.ghostH/2}px)`)},m=(k,D,B,K)=>{s?.ghost&&(s.ghostW!==k||s.ghostH!==D)&&(s.ghostW=k,s.ghostH=D,s.ghost.style.width=`${k}px`,s.ghost.style.height=`${D}px`,p(B,K))},u=(k,D)=>{if(!s)return;let{sourceRect:B,sourceEl:K,color:z}=s,U=document.createElement("div");U.className=Qr;let W=document.createElement("div");if(W.className=`${Qr}__swatch`,C5(z))W.classList.add("is-transparent");else{let G=getComputedStyle(K).backgroundColor;W.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(W),document.body.appendChild(U),s.ghost=U,s.ghostW=B.width,s.ghostH=B.height,U.style.width=`${B.width}px`,U.style.height=`${B.height}px`,p(k,D),requestAnimationFrame(()=>{s?.ghost===U&&U.classList.add(`${Qr}--lifted`)}),document.body.classList.add(dy),s.activated=!0,d()},E=(k,D)=>{if(!s?.hitRect)return;let{hitRect:B,slotRects:K}=s,z=null,U=null;if(k>=B.left&&k<=B.right&&D>=B.top&&D<=B.bottom){let W=0,G=1/0;if(K.forEach((oe,le)=>{let F=Math.abs(k-(oe.left+oe.width/2));F<G&&(G=F,W=le)}),s.origin.kind==="swatch"){let oe=a.current.picks.findIndex(le=>uy(le,s.color));oe!==-1?U=oe:z=W}else z=W}if(z!==s.overIndex||U!==s.duplicateIndex){s.overIndex=z,s.duplicateIndex=U;let{ghost:W}=s;W&&(W.classList.toggle(`${Qr}--over`,z!==null),W.classList.toggle(`${Qr}--blocked`,U!==null)),d()}if(z!==null){let W=s.slotRects[z];m(W.width,W.height,k,D)}else m(s.sourceRect.width,s.sourceRect.height,k,D)},g=k=>{if(!s?.ghost)return;let{ghost:D}=s;s.ghost=null,D.classList.add(`${Qr}--dropping`);let B=k.rect;B&&(D.style.width=`${B.width}px`,D.style.height=`${B.height}px`,D.style.transform=`translate(${B.left}px, ${B.top}px)`),window.setTimeout(()=>{D.classList.add(`${Qr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!s?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let B of D)B.style.transition="none",B.style.transform="none";k.offsetWidth;for(let B of D)B.style.transition=""},w=()=>{let k=D=>{D.preventDefault(),D.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},y=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",M,!0),window.removeEventListener("keydown",L,!0)},x=()=>{y(),document.body.classList.remove(dy),s?.activationTimer!=null&&window.clearTimeout(s.activationTimer),s=null,r(null)},I=k=>{s&&(b(),s.ghost&&(k?g({rect:s.sourceRect}):(s.ghost.remove(),s.ghost=null)),x())},T=(k,D)=>{if(!(!s||s.activated)){if(!c()){x();return}u(k,D),E(k,D)}},C=k=>{if(!(!s||k.pointerId!==s.pointerId)){if(s.lastX=k.clientX,s.lastY=k.clientY,!s.activated){if(Math.hypot(k.clientX-s.startX,k.clientY-s.startY)<my){s.activationTimer!==null&&(window.clearTimeout(s.activationTimer),s.activationTimer=null);return}let D=performance.now()-s.startTime;if(D<py){s.activationTimer===null&&(s.activationTimer=window.setTimeout(()=>{s&&(s.activationTimer=null,Math.hypot(s.lastX-s.startX,s.lastY-s.startY)>=my&&T(s.lastX,s.lastY))},py-D));return}if(T(k.clientX,k.clientY),!s?.activated)return}k.preventDefault(),p(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!s||k.pointerId!==s.pointerId)return;if(!s.activated){x();return}k.preventDefault(),k.stopPropagation(),w();let{overIndex:D,origin:B,color:K,slotRects:z}=s,{picks:U,onPicksChange:W}=a.current;if(b(),D!==null){if(B.kind==="swatch"){if(!U.some(G=>uy(G,K))){let G=[...U];G[D]=K,W(G)}}else if(B.index!==D){let G=[...U],[oe]=G.splice(B.index,1);G.splice(D,0,oe),W(G)}g({rect:z[D]})}else g({rect:s.sourceRect});x()},M=k=>{s&&k.pointerId===s.pointerId&&I(!0)},L=k=>{s?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,D,B)=>{!a.current.enabled||s||k.button!==0||!D||(s={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,origin:B,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",M,!0),window.addEventListener("keydown",L,!0))},destroy:()=>I(!1)}},[]);return T5(()=>()=>l.destroy(),[l]),ly(()=>({dragState:o,startSwatchDrag:(s,d)=>l.begin(s,d,{kind:"swatch"}),startPickDrag:(s,d,c)=>l.begin(s,c,{kind:"pick",index:d}),setStripEl:s=>{i.current=s}}),[o,l])};import{jsx as Hh,jsxs as D5}from"react/jsx-runtime";var gy=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=$e(pn),l=un(),s=M5(null);return k5(()=>{s.current&&s.current.focus()},[t,i]),Hh("div",{className:"color-picker-content--default",children:n.map((d,c)=>{let p=A5(d,e===L5.DARK);return D5("button",{ref:t===d?s:void 0,tabIndex:-1,type:"button",className:P5("color-picker__button color-picker__button--large has-outline",{active:t===d,"is-transparent":d==="transparent"||!d}),onClick:()=>{o(d),a("custom")},onPointerDown:l?m=>l.startSwatchDrag(m,d):void 0,title:d,"aria-label":r,style:{"--swatch-color":p},children:[Hh("div",{className:"color-picker__button-outline"}),Hh(ea,{color:p,keyLabel:c+1})]},c)})})};import _5 from"clsx";import{useEffect as R5,useRef as N5}from"react";import{applyDarkModeFilter as B5,isColorDark as F5,THEME as O5}from"@excalidraw/common";import{jsx as Id,jsxs as G5}from"react/jsx-runtime";var z5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let l=ar({color:t,palette:n}),[s,d]=$e(pn),c=un(),p=N5(null);return R5(()=>{p.current&&s==="baseColors"&&p.current.focus()},[l?.colorName,s]),Id("div",{className:"color-picker-content--default",children:Object.entries(n).map(([m,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return Id("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},m);let b=Yl[E],w=B5(g,e===O5.DARK),y=f(`colors.${m.replace(/\d+/,"")}`,null,"");return G5("button",{ref:l?.colorName===m?p:void 0,tabIndex:-1,type:"button",className:_5("color-picker__button color-picker__button--large",{"has-outline":!F5(g,255),active:l?.colorName===m,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),d("baseColors")},onPointerDown:c?x=>c.startSwatchDrag(x,g):void 0,title:`${y}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${y} \u2014 ${b}`,style:g?{"--swatch-color":w}:void 0,"data-testid":`color-${m}`,children:[Id("div",{className:"color-picker__button-outline"}),i&&Id(ea,{color:w,keyLabel:b})]},m)})})},fy=z5;import{jsx as U5}from"react/jsx-runtime";var H5=({children:e})=>U5("div",{className:"color-picker__heading",children:e}),ta=H5;import W5 from"clsx";import{useEffect as V5,useRef as Y5}from"react";import{applyDarkModeFilter as K5,THEME as X5}from"@excalidraw/common";import{jsx as Xl,jsxs as Ey}from"react/jsx-runtime";var by=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=ar({color:n||"transparent",palette:o}),[a,l]=$e(pn),s=un(),d=Y5(null);if(V5(()=>{d.current&&a==="shades"&&d.current.focus()},[i,a]),i){let{colorName:c,shade:p}=i,m=o[c];if(Array.isArray(m))return Xl("div",{className:"color-picker-content--default shades",children:m.map((u,E)=>{let g=K5(u,e===X5.DARK);return Ey("button",{ref:E===p&&a==="shades"?d:void 0,tabIndex:-1,type:"button",className:W5("color-picker__button color-picker__button--large",{active:E===p}),"aria-label":"Shade",title:`${c} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),l("shades")},onPointerDown:s?b=>s.startSwatchDrag(b,u):void 0,children:[Xl("div",{className:"color-picker__button-outline"}),r&&Xl(ea,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return Ey("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Xl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Xl("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as na,COLOR_PALETTE as Z5,KEYS as Zl}from"@excalidraw/common";var Td=(e,n,t)=>{let o=Math.ceil(t/na);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+na;return r>=t?n%na:r}case"ArrowUp":{let r=n-na,i=r<0?na*o+r:r;return i>=t?void 0:i}}},$5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:l})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return t(o[n.colorName][s]),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 s=Yl.indexOf(e.key),d=Object.keys(o)[s],c=o[d],p=Array.isArray(c)?c[a]:c;return p==null||l?.includes(p)||(t(p),i("baseColors")),!0}return!1},xy=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:c,excludedColors:p})=>{if(e[Zl.CTRL_OR_CMD])return!1;if(e.key===Zl.ESCAPE)return c(e),!0;if(e.key===Zl.ALT)return d(!0),!0;if(e.key===Zl.I)return d(),!0;let m=ar({color:o,palette:t});if(e.key===Zl.TAB){let u={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,w=g+b>E.length-1?0:g+b<0?E.length-1:g+b,y=E[w];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(Z5.black)),e.preventDefault(),e.stopPropagation(),!0}if($5({e,colorObj:m,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s,excludedColors:p}))return!0;if(n==="shades"&&m){let{shade:u}=m,E=Td(e.key,u,na);if(E!==void 0)return r(t[m.colorName][E]),!0}if(n==="baseColors"&&m){let{colorName:u}=m,E=Object.keys(t),g=E.indexOf(u),b=Td(e.key,g,E.length),w=0;for(;b!==void 0&&w++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[s]:y;if(!p?.includes(x))break;b=Td(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[s]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=Td(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as ko,jsxs as Sd}from"react/jsx-runtime";var wy=Uh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:l,showTitle:s,onEyeDropperToggle:d,onEscape:c,showHotKey:p=!0,excludedColors:m},u)=>{let E=s?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=Uh.useState(()=>o==="canvasBackground"?[]:ny(r,o,i)),[b,w]=$e(pn),y=un(),x=ar({color:n,palette:i});Wh(()=>{if(!b){let P=!!n&&Bh({color:n,palette:i}),M=P&&!g.includes(n);w(M?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,w,x,g]);let[I,T]=q5(x?.shade??(o==="elementBackground"?J5:Q5));Wh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===e4.ALT&&d(!1)};return document.addEventListener(yy.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(yy.KEYUP,P,{capture:!0})}},[x,d]);let C=Uh.useRef(null);return j5(u,()=>C.current),Wh(()=>{C?.current?.focus()},[]),ko("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Sd("div",{ref:C,onKeyDown:P=>{xy({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:d,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:c,excludedColors:m})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&ko("div",{className:"color-picker__title",children:E}),!!g.length&&Sd("div",{children:[ko(ta,{children:f("colorPicker.mostUsedCustomColors")}),ko(gy,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),Sd("div",{children:[ko(ta,{children:f("colorPicker.colors")}),ko(fy,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:p,excludedColors:m})]}),Sd("div",{children:[ko(ta,{children:f("colorPicker.shades")}),ko(by,{theme:e,color:n,onChange:t,palette:i,showHotKey:p})]}),l,y&&ko("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import vy from"clsx";import{ContextMenu as $l}from"radix-ui";import{applyDarkModeFilter as t4,COLOR_OUTLINE_CONTRAST_THRESHOLD as n4,DEFAULT_CANVAS_BACKGROUND_PICKS as o4,DEFAULT_ELEMENT_BACKGROUND_PICKS as r4,DEFAULT_ELEMENT_STROKE_PICKS as i4,isColorDark as a4,THEME as l4}from"@excalidraw/common";import{jsx as lr,jsxs as Iy}from"react/jsx-runtime";var Ty=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let l=un(),s=l?.dragState??null,{container:d}=Te(),c;if(t==="elementStroke"&&(c=i4),t==="elementBackground"&&(c=r4),t==="canvasBackground"&&(c=o4),r&&(c=r),!c)return console.error("Invalid type for TopPicks"),null;let p=u=>{if(!s||s.origin.kind!=="pick"||s.overIndex===null)return 0;let E=s.origin.index,g=s.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*s.slotSpan},m=Iy("div",{className:vy("color-picker__top-picks",{"is-dnd-active":!!s}),ref:l?.setStripEl,children:[s&&lr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:lr("rect",{})}),c.map((u,E)=>{let g=p(E),b=t4(u,e===l4.DARK);return lr("button",{className:vy("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!a4(u,n4),"is-dnd-source":s?.origin.kind==="pick"&&s.origin.index===E,"is-dnd-target":s?.origin.kind==="swatch"&&s.overIndex===E,"is-dnd-duplicate":s?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:l?w=>l.startPickDrag(w,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:lr("div",{className:"color-picker__button-outline"})},u)})]});return i?Iy($l.Root,{children:[lr($l.Trigger,{asChild:!0,children:m}),lr($l.Portal,{container:d,children:lr($l.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:lr($l.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):m};import{jsx as hn,jsxs as Cd}from"react/jsx-runtime";var g4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Ay,updateData:a,getOpenPopup:l,appState:s,excludedColors:d})=>{let{container:c}=Te(),p=it(),m=p!=="full",u=p==="mobile",[,E]=$e(pn),[g,b]=$e(Yt),w=Cd("div",{children:[hn(ta,{children:f("colorPicker.hexCode")}),hn(ay,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=My(null),x=()=>{y.current?.focus()};return hn(Po,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}u4(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),E(null),s.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?hn(wy,{ref:y,palette:i,excludedColors:d,color:n,theme:s.theme,onChange:I=>{let T=s.editingTextElement?vd():null;t(I),s.editingTextElement&&T&&Wl(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:m,showHotKey:!u,children:w}):w})},f4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",E4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=it(),s=l!=="full",d=l==="mobile",c=un(),p=n?d4(n,o===h4.DARK):null,m=u=>{u.preventDefault(),u.stopPropagation(),a&&ty(),i()};return Cd(Py.Trigger,{type:"button",className:ky("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!Cy(n,Sy),"compact-sizing":s,"mobile-border":d}),"aria-label":e,style:p?{"--swatch-color":p}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:m,onPointerDown:c?u=>c.startSwatchDrag(u,n):void 0,children:[hn("div",{className:"color-picker__button-outline",children:!n&&p1}),s&&n&&r==="stroke"&&hn("div",{className:"color-picker__button-background",children:hn("span",{style:{color:p&&Cy(p,Sy)?"#fff":"#111"},children:D0})})]})},b4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Ay,topPicks:a,updateData:l,appState:s,excludedColors:d,customizableTopPicks:c})=>{let p=My(s.openPopup);c4(()=>{p.current=s.openPopup},[s.openPopup]);let u=it()!=="full",E=!!c&&!u,g=E&&c?s.colorTopPicks?.[c]:null,b=g?.length?g:a??(e==="elementStroke"?p4:m4),w=hy({enabled:E,picks:b,onPicksChange:y=>{c&&l({colorTopPicks:{...s.colorTopPicks,[c]:y}})}});return hn(Gh.Provider,{value:E?w:null,children:Cd("div",{role:"dialog","aria-modal":"true",className:ky("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&hn(Ty,{theme:s.theme,activeColor:n,onChange:y=>{t(y),f4(s.openPopup)&&s.openPopup!==e&&setTimeout(()=>l({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&c?()=>{l({colorTopPicks:{...s.colorTopPicks,[c]:null}})}:void 0}),!u&&hn(Ed,{}),Cd(Py.Root,{open:s.openPopup===e,onOpenChange:y=>{y&&l({openPopup:e})},children:[hn(E4,{color:n,label:o,type:e,theme:s.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&hn(g4,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:d,updateData:l,getOpenPopup:()=>p.current,appState:s})]})]})})},x4=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,oa=s4(b4,x4);import{Popover as X4}from"radix-ui";import Z4 from"clsx";import $4,{useCallback as j4,useMemo as q4}from"react";import{FONT_FAMILY as Xh}from"@excalidraw/common";import F4,{useMemo as dr,useState as O4,useRef as Ry,useEffect as Ny,useCallback as By}from"react";import{arrayToList as z4,debounce as G4,FONT_FAMILY as mr,getFontFamilyString as H4}from"@excalidraw/common";import y4 from"clsx";import w4 from"react";import{jsx as v4,jsxs as I4}from"react/jsx-runtime";var Pd=w4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>I4("div",{className:y4("QuickSearch__wrapper",e),children:[ao,v4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import T4 from"clsx";import{Children as S4}from"react";import{jsx as Ly}from"react/jsx-runtime";var kd=({className:e,placeholder:n,children:t})=>{let o=!S4.count(t);return Ly("div",{className:T4("ScrollableList__wrapper",e),role:"menu",children:o?Ly("div",{className:"empty",children:n}):t})};import{jsx as C4,jsxs as P4}from"react/jsx-runtime";var Dy=({children:e,className:n="",style:t,title:o})=>P4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&C4("p",{className:"dropdown-menu-group-title",children:o}),e]}),jl=Dy;Dy.displayName="DropdownMenuGroup";import{THEME as N4}from"@excalidraw/common";import{DropdownMenu as B4}from"radix-ui";import k4,{useContext as M4}from"react";import{composeEventHandlers as A4}from"@excalidraw/common";var Vh=k4.createContext({}),sr=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Md=e=>{let n=M4(Vh);return A4(e,t=>{n.onSelect?.(t)})};import{jsx as L4}from"react/jsx-runtime";var ql=({children:e,...n})=>L4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as _4,jsx as Jl,jsxs as R4}from"react/jsx-runtime";var D4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=me();return R4(_4,{children:[n&&Jl("div",{className:"dropdown-menu-item__icon",children:n}),Jl("div",{style:e,className:"dropdown-menu-item__text",children:Jl(ql,{children:o})}),r&&Jl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Jl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},cr=D4;import{jsx as Ad}from"react/jsx-runtime";var Yh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:l,...s})=>{let d=Md(l);return Ad(B4.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:Ad("button",{...s,value:t,className:sr(i,a),title:s.title??s["aria-label"],children:Ad(cr,{icon:e,shortcut:r,badge:n,children:o})})})};Yh.displayName="DropdownMenuItem";var ra={GREEN:"green",RED:"red",BLUE:"blue"},Ld=({type:e=ra.BLUE,children:n})=>{let{theme:t}=nn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===N4.LIGHT?"1.5px solid white":"none"};switch(e){case ra.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ra.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case ra.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Ad("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Ld.displayName="DropdownMenuItemBadge";Yh.Badge=Ld;var tn=Yh;import{KEYS as ia}from"@excalidraw/common";var _y=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[ia.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ia.F)return n.current?.focus(),!0;if(e.key===ia.ESCAPE)return r(),!0;if(e.key===ia.ENTER)return t?.value&&i(t.value),!0;if(e.key===ia.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===ia.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as Mo,jsxs as V4}from"react/jsx-runtime";var U4=e=>{switch(e){case mr.Excalifont:case mr.Virgil:return no;case mr.Nunito:case mr.Helvetica:return Gl;case mr["Lilita One"]:return e0;case mr["Comic Shanns"]:case mr.Cascadia:return od;default:return Gl}},W4=(e,n)=>Object.entries(mr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Fy=F4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Te(),s=ft(),{fonts:d}=s,{showDeprecatedFonts:c}=on(),p=it(),[m,u]=O4(""),E=Ry(null),g=dr(()=>Array.from(To.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:B}])=>{let K={value:k,icon:U4(k),text:W4(k,B)};return D.deprecated&&Object.assign(K,{deprecated:D.deprecated,badge:{type:ra.RED,placeholder:f("fontList.badge.old")}}),K}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=dr(()=>new Set(d.getSceneFamilies()),[e]),w=dr(()=>g.filter(k=>b.has(k.value)),[g,b]),y=dr(()=>g.filter(k=>!b.has(k.value)&&(c||!k.deprecated)),[g,b,c]),x=dr(()=>z4([...w,...y].filter(k=>k.text?.toLowerCase().includes(m))),[w,y,m]),I=dr(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&m&&(x[0]?.value?o(x[0].value):r()),k},[n,e,m,x,o,r]),T=By(k=>{let D=null;if(s.state.editingTextElement){let B=document.querySelector(".excalidraw-wysiwyg");B&&(D={start:B.selectionStart,end:B.selectionEnd})}t(k),s.state.editingTextElement&&D&&setTimeout(()=>{let B=document.querySelector(".excalidraw-wysiwyg");B&&D&&(B.focus(),B.selectionStart=D.start,B.selectionEnd=D.end)},0)},[t,s.state.editingTextElement]),C=By(k=>{_y({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);Ny(()=>(i(),()=>{a()}),[]);let P=dr(()=>x.filter(k=>b.has(k.value)),[x,b]),M=dr(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let B=Ry(null),K=k.value===I?.value,z=k.value===e;return Ny(()=>{K&&(D===0?B.current?.scrollIntoView?.({block:"end"}):B.current?.scrollIntoView?.({block:"nearest"}))},[K,D]),Mo("button",{ref:B,type:"button",value:k.value,className:sr("",z,K),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:Mo(cr,{icon:k.icon,badge:k.badge&&Mo(Ld,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:H4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(Mo(jl,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>Mo(L,{font:k,order:D},k.value))},"group_1")),M.length&&_.push(Mo(jl,{title:f("fontList.availableFonts"),children:M.map((k,D)=>Mo(L,{font:k,order:D+P.length},k.value))},"group_2")),V4(Po,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&Mo(Pd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:G4(u,20)}),Mo(kd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Y4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as K4}from"@excalidraw/common";import{jsx as Kh}from"react/jsx-runtime";var Oy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=ze(),r=t?{...K4,width:"2rem",height:"2rem"}:{};return Kh(Y4.Trigger,{asChild:!0,children:Kh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Kh($,{type:"toggle",icon:_n,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Ql,jsxs as zy}from"react/jsx-runtime";var Gy=[{value:Xh.Excalifont,icon:no,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Xh.Nunito,icon:Gl,text:f("labels.normal"),testId:"font-family-normal"},{value:Xh["Comic Shanns"],icon:od,text:f("labels.code"),testId:"font-family-code"}],Bte=new Set(Gy.map(e=>e.value));var Hy=$4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=q4(()=>Gy,[]),d=j4(c=>{c&&o(c)},[o]);return zy("div",{role:"dialog","aria-modal":"true",className:Z4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Ql("div",{className:"buttonList",children:Ql(en,{type:"button",options:s,value:n,onClick:d})}),!l&&Ql(Ed,{}),zy(X4.Root,{open:e,onOpenChange:a,children:[Ql(Oy,{selectedFontFamily:n,isOpened:e,compactMode:l}),e&&Ql(Fy,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:d,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Rd}from"radix-ui";import tL from"clsx";import Yy,{useEffect as nL,useMemo as oL}from"react";import{isArrowKey as rL,KEYS as Ao}from"@excalidraw/common";import{jsx as J4}from"react/jsx-runtime";var Dd=({className:e,icon:n,size:t="1em"})=>J4("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:n});import{Fragment as eL,jsx as Uy,jsxs as Wy}from"react/jsx-runtime";var Q4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Wy(eL,{children:[Wy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Uy(Dd,{icon:n?k0:ad})]}),n&&Uy("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),es=Q4;import{jsx as Rn,jsxs as Nd}from"react/jsx-runtime";var iL=et(!1),_d=4,aL="default",lL=e=>e.flatMap(n=>n.options),Vy=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},sL=(e,n)=>e.some(t=>t.options.some(n)),cL=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/_d)},(t,o)=>n.options.slice(o*_d,o*_d+_d)));function dL({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Te(),[l,s]=$e(iL),d=[...e,...n],c=lL(d),p=cL([...e,...l?n:[]]),m=g=>{let b=c.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Ao.TAB){let w=c.findIndex(x=>x.value===t),y=g.shiftKey?(c.length+w-1)%c.length:(w+1)%c.length;r(c[y].value)}else if(rL(g.key)){let w=to().rtl,y=c.findIndex(x=>x.value===t);if(y!==-1){let x=c.length,I=y;switch(g.key){case(w?Ao.ARROW_LEFT:Ao.ARROW_RIGHT):I=(y+1)%x;break;case(w?Ao.ARROW_RIGHT:Ao.ARROW_LEFT):I=(x+y-1)%x;break;case Ao.ARROW_DOWN:{let T=p.findIndex(P=>P.some(M=>M.value===t)),C=p[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=p[(T+1)%p.length],L=M[Math.min(P,M.length-1)]??c[y];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Ao.ARROW_UP:{let T=p.findIndex(P=>P.some(M=>M.value===t)),C=p[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=p[(p.length+T-1)%p.length],L=M[Math.min(P,M.length-1)]??c[y];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(c[I].value)}g.preventDefault()}else(g.key===Ao.ESCAPE||g.key===Ao.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};nL(()=>{sL(n,g=>g.value===t)&&s(!0)},[t,n,s]);let u=g=>Rn("div",{className:"picker-content",children:g.map(b=>Nd("button",{type:"button",className:tL("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:w=>{t===b.value&&setTimeout(()=>{w?.focus()},0)},children:[b.icon,b.keyBinding&&Rn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===aL?Rn(Yy.Fragment,{children:u(b.options)},`${b.name}-${w}`):Nd("div",{className:"picker-section",children:[Rn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return Rn(Rd.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:m,collisionBoundary:a??void 0,children:Nd("div",{className:"picker-sections",children:[E(e),n.length>0&&Rn(es,{label:f("labels.more_options"),open:l,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:Rn("div",{className:"picker-sections",children:E(n)})})]})})}function Zh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Yy.useState(!1),{container:l}=Te(),s=oL(()=>Vy(t,d=>d.value===e)??Vy(o??[],d=>d.value===e),[t,o,e]);return Rn("div",{children:Nd(Rd.Root,{open:i,onOpenChange:d=>a(d),children:[Rn(Rd.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Rn(Rd.Portal,{container:l,children:Rn(dL,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})})]})})}import Ky,{useEffect as mL}from"react";import{jsx as $h,jsxs as Xy}from"react/jsx-runtime";var Zy=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:l=!0,testId:s})=>{let d=Ky.useRef(null),c=Ky.useRef(null);return mL(()=>{if(d.current&&c.current){let p=d.current,m=c.current,u=p.offsetWidth,E=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;m.style.left=`${b}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),Xy("label",{className:"control-label",children:[e,Xy("div",{className:"range-wrapper",children:[$h("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:d,type:"range",min:o,max:r,step:i,onChange:p=>{t(+p.target.value)},value:n,className:"range-input","data-testid":s}),$h("div",{className:"value-bubble",ref:c,children:n!==o?n:null}),$h("div",{className:"zero-label",children:a})]})]})};import{Fragment as Ud,jsx as te,jsxs as St}from"react/jsx-runtime";var rw=.1,ti=e=>{let n=BL(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Mt=(e,n,t,o=!1)=>{let r=eg(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(ML(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},Et=function(e,n,t,o,r){let i=n.state.editingTextElement,a=nw(e),l=null;if(i&&(l=t(i)),!l)if(Oe(a,n.state)){let d=n.scene.getSelectedElements(n.state),c=o===!0?d:d.filter(p=>o(p));l=PL(c,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},FL=(e,n,t)=>LL(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),tg=(e,n,t,o,r)=>{let i=new Set,a=Mt(e,n,l=>{if(Kt(l)){let s=o(l);i.add(s);let d=ct(l,{fontSize:s});return ts(d,t.scene.getContainerElement(l),t.scene),d=FL(l,d,t.scene),d}return l},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(l=>{Kt(l)&&AL(l,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:at.IMMEDIATELY}},OL=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Mt(e,n,o=>_L(o.type)?ct(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?at.IMMEDIATELY:at.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=ti(o);return St(Ud,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.stroke")}),te(oa,{topPicks:bL,palette:EL,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:Et(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),zL=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:at.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!CL(t.currentItemBackgroundColor)&&i.every(l=>Jy(l)&&kL(l.points))){let l=eg(i);r=e.map(s=>l.has(s.id)&&Jy(s)?ct(s,{backgroundColor:t.currentItemBackgroundColor,...NL(s,!0)}):s)}else r=Mt(e,n,l=>ct(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=ti(o);return St(Ud,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(oa,{topPicks:fL,palette:ew,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:Et(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Hd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:at.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=ti(o);return St(Ud,{children:[r==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(oa,{topPicks:hL,palette:ew,excludedColors:[gL.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),GL=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ye("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Mt(e,n,r=>ct(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=de(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return St("fieldset",{children:[te("legend",{children:f("labels.fill")}),te("div",{className:"buttonList",children:te(en,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?v1:I1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:T1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:S1,testId:"fill-solid"}],value:Et(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),HL=e=>vL.find(n=>tw(e.type,n)===e.strokeWidth)??null,UL=(e,n)=>tw(e.type,n),WL=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Gd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Mt(e,n,o=>ct(o,{strokeWidth:UL(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>St("fieldset",{children:[te("legend",{children:f("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(en,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:dh,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:C1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:P1,testId:"strokeWidth-bold"}],value:Et(e,o,HL,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),VL=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Mt(e,n,o=>ct(o,{seed:IL(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>St("fieldset",{children:[te("legend",{children:f("labels.sloppiness")}),te("div",{className:"buttonList",children:te(en,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:A1},{value:1,text:f("labels.artist"),icon:L1},{value:2,text:f("labels.cartoonist"),icon:D1}],value:Et(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),YL=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Mt(e,n,r=>r.type!=="freedraw"?r:ct(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=Et(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return te($,{type:"button",icon:a?ph:mh,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return St("fieldset",{children:[te("legend",{children:f("labels.pressure")}),te("div",{className:"buttonList",children:te(en,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:mh},{value:"variable",text:f("labels.pressure_variable"),icon:ph}],value:i,onChange:a=>t(a)})})]})}}),Une=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Mt(e,n,o=>ct(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>St("fieldset",{children:[te("legend",{children:f("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(en,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:dh},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:k1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:M1}],value:Et(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),KL=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Mt(e,n,o=>ct(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Et(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return te(Zy,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),XL=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>tg(e,n,o,()=>(Gd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=ti(o);return St("fieldset",{children:[te("legend",{children:f("labels.fontSize")}),te("div",{className:"buttonList",children:te(en,{group:"font-size",options:[{value:Fd.sm,text:f("labels.small"),icon:j1,testId:"fontSize-small"},{value:Fd.md,text:f("labels.medium"),icon:q1,testId:"fontSize-medium"},{value:Fd.lg,text:f("labels.large"),icon:J1,testId:"fontSize-large"},{value:Fd.xl,text:f("labels.veryLarge"),icon:Q1,testId:"fontSize-veryLarge"}],value:Et(e,o,a=>{if(Kt(a))return a.fontSize;let l=pr(a,o.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>Kt(a)||pr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||yL),onChange:a=>{Vl(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),ng=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:$r,trackEvent:!1,perform:(e,n,t,o)=>tg(e,n,o,r=>Math.round(1/(1+rw)*r.fontSize)),keyTest:e=>e[aa.CTRL_OR_CMD]&&e.shiftKey&&(e.key===aa.CHEVRON_LEFT||e.key===aa.COMMA)}),og=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:$r,trackEvent:!1,perform:(e,n,t,o)=>tg(e,n,o,r=>Math.round(r.fontSize*(1+rw))),keyTest:e=>e[aa.CTRL_OR_CMD]&&e.shiftKey&&(e.key===aa.CHEVRON_RIGHT||e.key===aa.PERIOD)}),ZL=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Mt(e,n,g=>{let b=r?.get(g.id);return b?ct(g,{...b}):g},!0),appState:{...n,...l},captureUpdate:at.NEVER};Gd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,c=at.EVENTUALLY,p,m=!1;if(s)p=s,c=at.IMMEDIATELY;else if(d){p=d,c=at.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Kt(g));if(E.length>200)m=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let w=E[g];b+=w?.originalText.length||0,g++}b>5e3&&(m=!0)}}let u={appState:{...n,...l},captureUpdate:c};if(p&&!m){let E=new Map,g=new Set,b=!1,w=Array.from(To.loadedFontsCache.values()),y=Object.entries(wL).find(([T,C])=>C===p)?.[0];d&&y&&w.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Mt(e,n,T=>{if(Kt(T)&&(T.fontFamily!==p||s)){let C=ct(T,{fontFamily:p,lineHeight:SL(p)}),P=r?.get(T.containerId||"")||{},M=o.scene.getContainerElement(T);return a&&M&&P&&o.scene.mutateElement(M,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,M),C}return T},!0)});let x=`10px ${TL({fontFamily:p})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)ts(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let M=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;M&&ts(M,L,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=qh(new Map),i=qh(null),[a,l]=uL({}),s=qh(!0),{stylesPanelMode:d,isCompact:c}=ti(t),p=Qh(()=>{let m=(u,E)=>Et(u,t,g=>{if(Kt(g))return g.fontFamily;let b=pr(g,E);return b?b.fontFamily:null},g=>Kt(g)||pr(g,E)!==null,g=>g?null:n.currentItemFontFamily||xL);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return jh(()=>{i.current=p},[p]),jh(()=>{Object.keys(a).length&&(o(a),l({}))},[a]),jh(()=>(s.current=!1,()=>{s.current=!0}),[]),St(Ud,{children:[d==="full"&&te("legend",{children:f("labels.fontFamily")}),te(Hy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:d!=="full",onSelect:m=>{Vl(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},c,!!n.editingTextElement)},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:m=>{if(m){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,ct(E||u,{},!0))}else{let E=de(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,ct(g,{},!0))}l({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...u}),r.current.clear(),c&&n.editingTextElement&&Wl(null)}}})]})}}),$L=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Mt(e,n,r=>{if(Kt(r)){let i=ct(r,{textAlign:t});return ts(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=ti(o);return St("fieldset",{children:[te("legend",{children:f("labels.textAlign")}),te("div",{className:"buttonList",children:te(en,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:t0,testId:"align-left"},{value:"center",text:f("labels.center"),icon:n0,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:o0,testId:"align-right"}],value:Et(e,o,l=>{if(Kt(l))return l.textAlign;let s=pr(l,i);return s?s.textAlign:null},l=>Kt(l)||pr(l,i)!==null,l=>l?null:n.currentItemTextAlign),onChange:l=>{Vl(()=>t(l),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),jL=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Mt(e,n,r=>{if(Kt(r)){let i=ct(r,{verticalAlign:t});return ts(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=ti(o);return te("fieldset",{children:te("div",{className:"buttonList",children:te(en,{group:"text-align",options:[{value:Bd.TOP,text:f("labels.alignTop"),icon:te(r0,{theme:n.theme}),testId:"align-top"},{value:Bd.MIDDLE,text:f("labels.centerVertically"),icon:te(a0,{theme:n.theme}),testId:"align-middle"},{value:Bd.BOTTOM,text:f("labels.alignBottom"),icon:te(i0,{theme:n.theme}),testId:"align-bottom"}],value:Et(e,o,a=>{if(Kt(a)&&a.containerId)return a.verticalAlign;let l=pr(a,o.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>Kt(a)||pr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Bd.MIDDLE),onChange:a=>{Vl(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Wne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Mt(e,n,o=>ow(o)?o:ct(o,{roundness:t==="round"?{type:DL(o.type)?Od.ADAPTIVE_RADIUS:Od.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Fi(nw(e),n).some(l=>l.roundness?.type===Od.LEGACY);return St("fieldset",{children:[te("legend",{children:f("labels.edges")}),St("div",{className:"buttonList",children:[te(en,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:_1},{value:"round",text:f("labels.round"),icon:R1}],value:Et(e,o,l=>a?null:l.roundness?"round":"sharp",l=>!zd(l)&&l.hasOwnProperty("roundness"),l=>l?null:n.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Qy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:te(N1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:te(B1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:te(F1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:te(O1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:te(z1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(G1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:te(H1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:te(U1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:te(W1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:te(V1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:te(Y1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:te(K1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:te(X1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:te(Z1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:te($1,{flip:e}),keyBinding:null}]}]}),Vne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Gd(t,"actionChangeArrowhead: value must be defined"),{elements:Mt(e,n,o=>{if(Jh(o)){let{position:r,type:i}=t;if(r==="start")return ct(o,{startArrowhead:i});if(r==="end")return ct(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=to().rtl,i=Qh(()=>Qy(!r),[r]),a=Qh(()=>Qy(!!r),[r]);return St("fieldset",{children:[te("legend",{children:f("labels.arrowheads")}),St("div",{className:"iconSelectList buttonList",children:[te(Zh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:Et(e,o,l=>Jh(l)&&Pl(l.type)?qy(l.startArrowhead):n.currentItemStartArrowhead,!0,l=>l?null:n.currentItemStartArrowhead),onChange:l=>t({position:"start",type:l})}),te(Zh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:Et(e,o,l=>Jh(l)&&Pl(l.type)?qy(l.endArrowhead):n.currentItemEndArrowhead,!0,l=>l?null:n.currentItemEndArrowhead),onChange:l=>t({position:"end",type:l})})]})]})}}),qL=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>St("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Yne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Mt(e,n,l=>{if(!zd(l))return l;let s=o.scene.getNonDeletedElementsMap(),d=ei.getPointAtIndexGlobalCoordinates(l,0,s),c=ei.getPointAtIndexGlobalCoordinates(l,-1,s),p=ct(l,{x:t===gn.elbow?d[0]:l.x,y:t===gn.elbow?d[1]:l.y,roundness:t===gn.round?{type:Od.PROPORTIONAL_RADIUS}:null,elbowed:t===gn.elbow,angle:t===gn.elbow?0:l.angle,points:t===gn.elbow||l.elbowed?[ei.pointFromAbsoluteCoords({...l,x:d[0],y:d[1],angle:0},d,s),ei.pointFromAbsoluteCoords({...l,x:d[0],y:d[1],angle:0},c,s)]:l.points});if(ow(p)){p.fixedSegments=null;let m=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=ei.getPointAtIndexGlobalCoordinates(p,0,m),E=ei.getPointAtIndexGlobalCoordinates(p,-1,m),g=p.startBinding&&m.get(p.startBinding.elementId),b=p.endBinding&&m.get(p.endBinding.elementId),w=g&&p.startBinding?{...p.startBinding,...jy(p,g,"start",m,n.isBindingEnabled)}:null,y=b&&p.endBinding?{...p.endBinding,...jy(p,b,"end",m,n.isBindingEnabled)}:null;p={...p,startBinding:w,endBinding:y,...RL(p,m,{points:[u,E].map(x=>pL(x[0]-p.x,x[1]-p.y)),startBinding:w,endBinding:y,fixedSegments:null})}}else{let m=o.scene.getNonDeletedElementsMap();if(p.startBinding){let u=m.get(p.startBinding.elementId);u&&$y(p,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(p.endBinding){let u=m.get(p.endBinding.elementId);u&&$y(p,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return p}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new ei(l,eg(e)))}return{elements:r,appState:i,captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>St("fieldset",{children:[te("legend",{children:f("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(en,{group:"arrowtypes",options:[{value:gn.sharp,text:f("labels.arrowtype_sharp"),icon:nr,testId:"sharp-arrow"},{value:gn.round,text:f("labels.arrowtype_round"),icon:rr,testId:"round-arrow"},{value:gn.elbow,text:f("labels.arrowtype_elbowed"),icon:or,testId:"elbow-arrow"}],value:Et(e,o,r=>zd(r)?r.elbowed?gn.elbow:r.roundness?gn.round:gn.sharp:null,r=>zd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as r6,MAX_ZOOM as i6,MIN_ZOOM as a6,THEME as ns,ZOOM_STEP as lw,CODES as ni,KEYS as Vd}from"@excalidraw/common";import{getNonDeletedElements as os}from"@excalidraw/element";import{getCommonBounds as rs}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";import{useEffect as JL}from"react";import{jsx as e6}from"react/jsx-runtime";var la=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},rg=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=n.left+n.width/2-o.width/2;l<0?l=a:l+o.width>=r&&(l=r-o.width-a);let s;t==="bottom"?(s=n.top+n.height+a,s+o.height>=i&&(s=n.top-o.height-a)):(s=n.top-o.height-a,s<0&&(s=n.top+n.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},QL=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();rg(n,r)},bt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(JL(()=>()=>la().classList.remove("excalidraw-tooltip--visible"),[]),r?null:e6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>QL(i.currentTarget,la(),n,t),onPointerLeave:()=>la().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as iw,useRef as aw,useState as t6}from"react";var n6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],ig=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},qo())}return n6(o,n)};function ur(e,n=!0){let t=Wd(),[,o]=t6(0),r=aw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:ig(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=ig(t,e,n)),iw(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(l=>l+1)})},[t]),r.current.latestValue}function o6(e,n){let t=Wd(),o=aw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,iw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(ig(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as $d,jsxs as c6}from"react/jsx-runtime";var l6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?sa.IMMEDIATELY:sa.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>$d(oa,{palette:null,topPicks:r6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),Yd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Xu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Qn(n.zoom.value+lw)},n)},captureUpdate:sa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=ur(t=>t.zoom.value);return $d($,{type:"button",className:"zoom-in-button zoom-button",icon:Xu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=i6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ni.EQUAL||e.code===ni.NUM_ADD)&&(e[Vd.CTRL_OR_CMD]||e.shiftKey)}),Kd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Zu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Qn(n.zoom.value-lw)},n)},captureUpdate:sa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=ur(t=>t.zoom.value);return $d($,{type:"button",className:"zoom-out-button zoom-button",icon:Zu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=a6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ni.MINUS||e.code===ni.NUM_SUBTRACT)&&(e[Vd.CTRL_OR_CMD]||e.shiftKey)}),Xd=O({name:"resetZoom",label:"buttons.resetZoom",icon:r1,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...Io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Qn(r)},n)},captureUpdate:sa.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=ur(t=>t.zoom.value);return $d(bt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:c6($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===ni.ZERO||e.code===ni.NUM_ZERO)&&(e[Vd.CTRL_OR_CMD]||e.shiftKey)}),ag=e=>[e.x,e.y,e.x+e.width,e.y+e.height],voe=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:id,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?rs(os(r)):n.scrollConstraints?ag(n.scrollConstraints):rs(os(e)),a=Wr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Jn(a.appState)}}},keyTest:void 0}),Ioe=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:id,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?rs(os(r)):n.scrollConstraints?ag(n.scrollConstraints):rs(os(e)),a=Wr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Jn(a.appState)}}},keyTest:void 0}),s6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:id,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?ag(n.scrollConstraints):rs(os(e)),i=Wr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Jn(i.appState)}}},keyTest:void 0}),Zd=O({name:"toggleTheme",label:(e,n)=>n.theme===ns.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===ns.LIGHT?Bl:Fl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===ns.LIGHT?ns.DARK:ns.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:sa.EVENTUALLY}},keyTest:e=>!e[Vd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===ni.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as b6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Ew}from"@excalidraw/element/binding";import{isValidPolygon as bw,newElementWith as sg}from"@excalidraw/element";import{LinearElementEditor as ps}from"@excalidraw/element/linearElementEditor";import{isBindingElement as cg,isFreeDrawElement as xw,isLinearElement as yw,isLineElement as em}from"@excalidraw/element";import{KEYS as tm,arrayToMap as x6,invariant as ww,shouldRotateWithDiscreteAngle as y6,updateActiveTool as vw}from"@excalidraw/common";import{isPathALoop as w6}from"@excalidraw/element";import{isInvisiblySmallElement as dg}from"@excalidraw/element";import{CaptureUpdateAction as mg}from"@excalidraw/element";import u6 from"clsx";import{useEffect as h6,useState as g6}from"react";import{KEYS as fn,capitalizeString as oi}from"@excalidraw/common";import{useEffect as d6,useState as m6}from"react";import sw from"clsx";import{capitalizeString as jd}from"@excalidraw/common";import{Popover as qd}from"radix-ui";import{jsx as is,jsxs as p6}from"react/jsx-runtime";var ca=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a,shortcut:l})=>{let[s,d]=m6(!1),c=t.type,p=a.type===c,m=16,{container:u}=Te();return!n.some(E=>E.type===c)&&s&&d(!1),d6(()=>{let E=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>E?.()},[e]),p6(qd.Root,{open:s,children:[is(qd.Trigger,{asChild:!0,children:is($,{className:sw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:p,disabled:n.every(E=>ot(e,E.type)),title:`${jd(a.title)}${l?` \u2014 ${l}`:""}`,"aria-label":jd(a.title),"aria-keyshortcuts":l,keyBindingLabel:l?.length===1?l:void 0,"data-testid":r,onSelect:()=>{d(E=>!E),i(o)}})}),is(qd.Portal,{container:u,children:is(qd.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:u??void 0,children:n.map(({type:E,icon:g,title:b,fillable:w})=>is($,{className:sw({fillable:w}),type:"toggle",icon:g,checked:c===E,disabled:ot(e,E),title:jd(E),"aria-label":jd(b),"data-testid":`toolbar-${E}`,onSelect:()=>{e.state.activeTool.type!==E&&(Ye("toolbar",E,"ui"),e.setActiveTool({type:E}),i?.(E))}},E))})})]})};import{jsx as lg}from"react/jsx-runtime";var f6=e=>e,Me=f6({hand:{icon:l0,letterKey:fn.H,toggle:!0},selection:{icon:qc,letterKey:fn.V,fillable:!0},rectangle:{icon:Yi,letterKey:fn.R,fillable:!0},diamond:{icon:Ki,letterKey:fn.D,fillable:!0},ellipse:{icon:Xi,letterKey:fn.O,fillable:!0},arrow:{icon:Jc,letterKey:fn.A,fillable:!0},line:{icon:Qo,letterKey:fn.L,fillable:!0},freedraw:{icon:no,letterKey:fn.P},text:{icon:_n,letterKey:fn.T},image:{icon:Xr},eraser:{icon:Qc,letterKey:fn.E,toggle:!0},frame:{icon:ro,letterKey:fn.F},autoshape:{icon:qr,letterKey:fn.X,fillable:!1},embeddable:{icon:er},laser:{icon:io},bucketfill:{icon:oo},lasso:{icon:Vi,fillable:!1}}),cw=["selection","freedraw","text","image","eraser"],hr=["autoshape","rectangle","diamond","ellipse","arrow","line"],da=Object.keys(Me).filter(e=>Me[e].toggle),Jd=e=>{let{letterKey:n,shiftKey:t}=Me[e];if(!n)return n;let o=oi(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Lo=e=>Jd(e),E6=e=>{let n=Jd(e);return n?.length===1?n:void 0},dw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Me)){let{letterKey:i,shiftKey:a}=Me[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},ot=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,At=(e,n)=>{let t=Me[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:l,hideShortcut:s})=>{let d=oi(f(`toolBar.${e}`)),c=s?null:Lo(o);return lg($,{className:u6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:ot(i,e),title:c?`${d} \u2014 ${c}`:d,keyBindingLabel:l||s?void 0:E6(o),"aria-label":d,"aria-keyshortcuts":c??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:p})=>{if(!i.state.penDetected&&p==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:p});return}i.state.activeTool.type!==e&&(Ye("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${oi(e)}IconButton`,r},Qd=At("hand"),mw=At("rectangle"),pw=At("diamond"),uw=At("ellipse"),hw=At("arrow"),gw=At("line"),as=At("freedraw"),ls=At("text"),ss=At("image"),cs=At("eraser"),fw=At("frame"),qoe=At("autoshape"),ds=At("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ye("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),ms=At("lasso",{shortcutType:"selection"}),ri=({app:e,activeTool:n,setAppState:t,hideShortcut:o})=>{let r=[{type:"selection",icon:Me.selection.icon,fillable:Me.selection.fillable,title:oi(f("toolBar.selection"))},{type:"lasso",icon:Me.lasso.icon,fillable:Me.lasso.fillable,title:oi(f("toolBar.lasso"))}],i=r.find(a=>a.type===e.state.preferredSelectionTool.type)||r[0];return lg(ca,{app:e,options:r,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",shortcut:o?void 0:Lo("selection"),onToolChange:a=>{(a==="selection"||a==="lasso")&&(e.setActiveTool({type:a}),t({preferredSelectionTool:{type:a,initialized:!0}}))},displayedOption:i})},ma=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Me.freedraw.icon,fillable:Me.freedraw.fillable,title:oi(f("toolBar.freedraw"))},{type:"autoshape",icon:Me.autoshape.icon,fillable:Me.autoshape.fillable,title:oi(f("toolBar.autoshape"))}],[o,r]=g6(n.type==="autoshape"?"autoshape":"freedraw");h6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return lg(ca,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as v6}from"react/jsx-runtime";var xt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:l}=o,s=l.getNonDeletedElementsMap(),d=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=ps.getElement(n.selectedLinearElement.elementId,s);ww(y,"Arrow element should exist if selectedLinearElement is set"),ww(w,"sceneCoords should be defined if actionFinalize is called with event");let x=ps.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(cg(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=y6(b),P=b[tm.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((L,_)=>(L.set(_,{point:C?y.points[_]:ps.createPointAt(y,s,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),L),new Map)??new Map;Ew(y,M,w.x,w.y,l,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else em(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!bw(y.points)&&l.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&dg(y)&&(i=i.map(T=>T.id===y.id?sg(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||dg(y)?e.map(T=>T.id===y.id?sg(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:d?{}:n.selectedElementIds,selectedLinearElement:I||d?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:mg.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=o.drawShape.hasPendingGesture();(c||d)&&(o.drawShape.finalize(),c&&(i=o.scene.getElementsIncludingDeleted()));let p=null;if(n.multiElement)p=n.multiElement;else if(!d&&!c&&(n.newElement?.type==="freedraw"||cg(n.newElement)))p=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=s.get(Object.keys(n.selectedElementIds)[0]);b&&(p=b)}if(p){if(n.selectedLinearElement&&n.multiElement&&p.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=p,{lastCommittedPoint:w}=n.selectedLinearElement;if((!w||b[b.length-1]!==w)&&(r=!1,l.mutateElement(p,{points:p.points.slice(0,-1)}),cg(p)&&p.endBinding&&p.points.length>1)){let y=!!n.newElement,x=new Map([[p.points.length-1,{point:p.points[p.points.length-1],isDragging:!1}]]),I=ps.getPointAtIndexGlobalCoordinates(p,-1,s);Ew(p,x,I[0],I[1],l,n,{newArrow:y})}}if(p&&dg(p)&&(i=i.map(b=>b.id===p?.id?sg(b,{isDeleted:!0}):b)),yw(p)||xw(p)){if(w6(p.points,n.zoom.value)&&(em(p)||xw(p))){let w=p.points,y=w[0],x=w.map((I,T)=>T===w.length-1?b6(y[0],y[1]):I);em(p)?l.mutateElement(p,{points:x,polygon:!0}):l.mutateElement(p,{points:x})}em(p)&&!bw(p.points)&&l.mutateElement(p,{polygon:!1})}}let m;da.includes(n.activeTool.type)?m=vw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):m=vw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!p;E||o.cursor.applyForTool(m);let g=p&&yw(p)?new ps(p,x6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:d?{}:p&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[p.id]:!0}:n.selectedElementIds,selectedLinearElement:d?null:g},captureUpdate:r?mg.IMMEDIATELY:mg.NEVER}},keyTest:(e,n)=>e.key===tm.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===tm.ESCAPE||e.key===tm.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>v6($,{type:"button",icon:g1,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Sw,isSomeElementSelected as I6,makeNextSelectedElementIds as T6,selectGroupsForSelectedElements as S6}from"@excalidraw/element";import{CaptureUpdateAction as Iw}from"@excalidraw/element";import{KEYS as C6,isWritableElement as P6,updateActiveTool as Tw}from"@excalidraw/common";var k6=(e,n)=>da.includes(e.activeTool.type)?Tw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Tw(e,{type:n.state.preferredSelectionTool.type}),M6=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:Sw(o,e.editingGroupId);for(let a of i){let l=a.groupIds.indexOf(e.editingGroupId);if(l!==-1&&a.groupIds[l+1])return a.groupIds[l+1]}return null},A6=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=k6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Sw(i,n.editingGroupId).reduce((l,s)=>(l[s.id]=!0,l),{});return{appState:{...n,...S6({editingGroupId:M6(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Iw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:T6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Iw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==C6.ESCAPE||P6(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||I6(o.scene.getNonDeletedElements(),n))});import{KEYS as mm,THEME as Es}from"@excalidraw/common";import{CaptureUpdateAction as Nn}from"@excalidraw/element";import L6 from"clsx";import{jsx as Cw,jsxs as D6}from"react/jsx-runtime";var pg=({children:e,checked:n,onChange:t,className:o})=>D6("div",{className:L6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Cw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:ed}),Cw("div",{className:"Checkbox-label",children:e})]});import{THEME as us}from"@excalidraw/common";import{jsx as hs}from"react/jsx-runtime";var kw=e=>{let n=e.title||(e.value===us.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return hs($,{type:"icon",icon:e.value===us.LIGHT?Pw.MOON:Pw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===us.DARK?us.LIGHT:us.DARK),"data-testid":"toggle-dark-mode"})},Pw={SUN:hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:hs("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:hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:hs("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 _6}from"react";import{focusNearestParent as R6,KEYS as N6}from"@excalidraw/common";import{jsx as Mw,jsxs as B6}from"react/jsx-runtime";var Aw=e=>{let{id:n}=Te(),[t,o]=_6(e.value),r=a=>{e.ignoreFocus||R6(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===N6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return B6("div",{className:"ProjectName",children:[Mw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Mw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as F6,useEffect as O6,useRef as z6}from"react";import{jsx as nm,jsxs as W6}from"react/jsx-runtime";var G6=5e3,H6=({progress:e})=>nm("div",{className:"Toast__progress-bar",children:nm("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),U6=({message:e,onClose:n,closable:t=!1,duration:o=G6,style:r})=>{let i=z6(0),a=o!==1/0,l=F6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return O6(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,o,a]),W6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[nm("div",{className:"Toast__message",children:e}),t&&nm($,{icon:mn,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},om=Object.assign(U6,{ProgressBar:H6});import{DEFAULT_EXPORT_PADDING as sD,DEFAULT_FILENAME as cD,IMAGE_MIME_TYPES as Bw,isFirefox as dD,MIME_TYPES as mD,cloneJSON as pD,SVG_DOCUMENT_PREAMBLE as uD,arrayToMap as hD}from"@excalidraw/common";import{getNonDeletedElements as gD}from"@excalidraw/element";import{isFrameLikeElement as fD}from"@excalidraw/element";import{getElementsOverlappingFrame as ED}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as V6,EXPORT_DATA_TYPES as gs,MIME_TYPES as Re,arrayToMap as Y6,isMemberOf as K6,isPromiseLike as X6,EVENT as rm}from"@excalidraw/common";import{mutateElement as Z6}from"@excalidraw/element";import{deepCopyElement as $6}from"@excalidraw/element";import{isFrameLikeElement as j6,isInitializedImageElement as Dw}from"@excalidraw/element";import{getContainingFrame as Lw}from"@excalidraw/element";var _w=`web ${Re.excalidrawClipboard}`,gie="clipboard"in navigator&&"readText"in navigator.clipboard,im="clipboard"in navigator&&"writeText"in navigator.clipboard,gr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,q6=()=>"clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,J6=e=>!!([gs.excalidraw,gs.excalidrawClipboard,gs.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),am=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(rm.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Q6=({elements:e,files:n})=>{let t=Y6(e),o=new Set(e.filter(l=>j6(l))),r=!1,i=e.reduce((l,s)=>(Dw(s)&&(r=!0,n&&n[s.fileId]&&(l[s.fileId]=n[s.fileId])),l),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:gs.excalidrawClipboard,elements:e.map(l=>{if(Lw(l,t)&&!o.has(Lw(l,t))){let s=$6(l);return Z6(s,t,{frameId:null}),s}return l}),files:n?i:void 0};return JSON.stringify(a)},eD=async e=>{let n=await createImageBitmap(e);try{let t=document.createElement("canvas");t.width=n.width,t.height=n.height;let o=t.getContext("2d");if(!o)throw new Error("Could not create a canvas context for clipboard image");return o.drawImage(n,0,0),await new Promise((r,i)=>{t.toBlob(a=>{a?r(a):i(new Error("Could not encode clipboard image as PNG"))},Re.png)})}finally{n.close()}},lm=async(e,n,t)=>{let o=Q6({elements:e,files:n}),r=e.length===1&&Dw(e[0])?n?.[e[0].fileId]:null,i=r&&Vu(r.mimeType)&&r.dataURL?Ox(r.dataURL,r.fileName):null;if(i){let a=i.type===Re.png?i:eD(i);if(q6())try{await navigator.clipboard.write([new ClipboardItem({[_w]:new Blob([o],{type:Re.excalidrawClipboard}),[Re.png]:a})]);return}catch(l){console.error("Error copying image with ClipboardItem",l)}if(t?.clipboardData?.items)try{let l=i.type===Re.png?i:new File([await a],`${i.name.replace(/\.[^/.]+$/,"")||"image"}.png`,{type:Re.png});t.clipboardData.items.add(l),await lo({[Re.excalidrawClipboard]:o},t);return}catch(l){console.error("Error copying image to clipboard event",l)}}await lo({[Re.excalidrawClipboard]:o,[Re.text]:o},t)};function Rw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(Rw(t));return n}var tD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,Re.html),o=Rw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},sm=async()=>{let e={},n;try{n=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 o=await navigator.clipboard?.readText();if(o)return{[Re.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types){if(o===_w){try{e[Re.excalidrawClipboard]=await(await t.getType(o)).text()}catch(r){console.warn(`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}continue}if(K6(V6,o))try{if(o===Re.text||o===Re.html||o===Re.excalidrawClipboard)e[o]=await(await t.getType(o)).text();else if(Vu(o)){let r=await t.getType(o),i=Wx(r,o,void 0);e[o]=i}else throw new Hu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof Hu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},nD=async(e,n=!1)=>{try{let t=e.findByType(Re.html),o=!n&&t&&tD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(Re.text)??o.value.map(r=>r.value).join(`
|
|
2
|
-
`).trim()}:o:{type:"text",value:(e.getData(Re.text)||"").trim()}}catch{return{type:"text",value:""}}},
|
|
1
|
+
import{$ as Vx,A as Do,B as ar,C as pn,D as Bl,E as Vi,F as Ox,G as ju,H as Fl,I as Zc,J as qu,K as zx,L as Gx,M as $c,N as Ol,O as jc,P as qc,Q as zl,R as Jc,S as Hx,T as Ux,U as Wx,V as Qc,W as Zr,X as u3,Y as $r,Z as Yi,a as Ku,b as oo,ba as Yx,c as Ao,ca as Kx,d as Xr,da as ed,e as Ui,ea as Ju,f as ro,fa as Ki,g as Dx,ga as Gl,h as Oe,ha as Hl,i as _x,ia as Xx,j as de,ja as td,k as Wi,ka as Zx,l as ir,la as $x,m as Rx,ma as jx,n as Xu,na as qx,o as Nx,oa as Qu,p as Rl,pa as Jx,q as Bx,qa as Qx,r as Xc,ra as e1,s as Fx,sa as jr,t as Zu,u as $u,v as io,w as mn,x as Lo,y as Nl,z as p3}from"./chunk-UXMXN2SG.js";import{a as S}from"./chunk-4M4QNZNP.js";import{H as Yu}from"./chunk-FX6OEDRJ.js";import{c as Lx}from"./chunk-5XKZK2GL.js";import{b as Ax,c as m3,d as v}from"./chunk-SRAX5OIU.js";import EZ,{useCallback as bZ,useContext as xZ,useEffect as yZ,useRef as wZ,useState as vZ}from"react";import{applyDarkModeFilter as bKe,DEFAULT_IMAGE_OPTIONS as Rn,DEFAULT_UI_OPTIONS as c3,getStrokeWidthByKey as xKe,isShallowEqual as IZ}from"@excalidraw/common";import FM from"clsx";import XY from"lodash.throttle";import Dn,{useContext as tr}from"react";import{flushSync as Wt}from"react-dom";import ZY from"roughjs/bin/rough";import{nanoid as $Y}from"nanoid";import{clamp as Pc,pointFrom as ae,pointDistance as To,vector as OM,pointRotateRads as Wb,vectorFromPoint as Vb,vectorSubtract as zM,vectorDot as GM,vectorNormalize as HM}from"@excalidraw/math";import{CODES as Ur,shouldResizeFromCenter as UM,shouldMaintainAspectRatio as kc,shouldRotateWithDiscreteAngle as WM,isArrowKey as Yb,KEYS as Y,APP_NAME as jY,CURSOR_TYPE as De,DEFAULT_STROKE_STREAMLINE as qY,DEFAULT_STROKE_STREAMLINE_PRECISE as JY,DEFAULT_TRANSFORM_HANDLE_SPACING as QY,DEFAULT_VERTICAL_ALIGN as VM,DRAGGING_THRESHOLD as YM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as eK,ELEMENT_TRANSLATE_AMOUNT as KM,EVENT as ne,FRAME_STYLE as jo,IMAGE_MIME_TYPES as tK,IMAGE_RENDER_TIMEOUT as nK,LINE_CONFIRM_THRESHOLD as Kb,MIME_TYPES as An,MQ_RIGHT_SIDEBAR_MIN_WIDTH as oK,POINTER_BUTTON as Ln,ROUNDNESS as Iu,SCROLL_TIMEOUT as rK,TAP_TWICE_TIMEOUT as XM,TEXT_TO_CENTER_SNAP_THRESHOLD as iK,THEME as Mc,TOUCH_CTX_MENU_TIMEOUT as aK,VERTICAL_ALIGN as lK,YOUTUBE_STATES as Tu,ZOOM_STEP as sK,MIN_ZOOM as cK,POINTER_EVENTS as kl,TOOL_TYPE as Qn,supportsResizeObserver as dK,DEFAULT_COLLISION_THRESHOLD as ZM,DEFAULT_TEXT_ALIGN as mK,ARROW_TYPE as Wr,DEFAULT_REDUCED_GLOBAL_ALPHA as pK,isLocalLink as uK,normalizeLink as Su,toValidURL as hK,getGridPoint as Nt,getLineHeight as $M,debounce as jM,distance as Ml,getFontString as Xb,getNearestScrollableContainer as gK,isInputLike as qM,isToolIcon as fK,isWritableElement as Ac,sceneCoordsToViewportCoords as Cu,tupleToCoors as Zb,viewportCoordsToSceneCoords as Ce,wrapEvent as EK,updateObject as $b,updateActiveTool as sn,isTransparent as bK,muteFSAbortError as xK,isTestEnv as HA,isDevEnv as UA,updateStable as Lc,addEventListener as ve,normalizeEOL as yK,getDateTime as JM,isShallowEqual as QM,capitalizeString as wK,arrayToMap as Dc,applyDarkModeFilter as vK,AppEventBus as IK,randomInteger as TK,CLASSES as jb,Emitter as So,MINIMUM_ARROW_SIZE as SK,DOUBLE_TAP_POSITION_THRESHOLD as eA,BIND_MODE_TIMEOUT as CK,invariant as Co,getFeatureFlag as qo,createUserAgentDescriptor as WA,getFormFactor as PK,deriveStylesPanelMode as Fu,isIOS as kK,isBrave as MK,isSafari as AK,loadDesktopUIModePreference as LK,setDesktopUIMode as DK,isSelectionLikeTool as Pu,oneOf as tA,getStrokeWidthByKey as _K,getViewpointFlipSign as eo}from"@excalidraw/common";import{getObservedAppState as RK,getCommonBounds as Al,getElementAbsoluteCoords as nA,bindOrUnbindBindingElements as oA,fixBindingsAfterDeletion as NK,getHoveredElementForBinding as Vr,isBindingEnabled as ku,updateBoundElements as Mu,LinearElementEditor as fe,newElementWith as Po,newFrameElement as BK,newFreeDrawElement as FK,newEmbeddableElement as rA,newMagicFrameElement as OK,newIframeElement as zK,newArrowElement as GK,newElement as HK,newImageElement as UK,newLinearElement as WK,newTextElement as iA,refreshTextDimensions as VK,deepCopyElement as aA,duplicateElements as lA,hasBoundTextElement as sA,isArrowElement as _c,isBindingElement as ko,isBindingElementType as YK,isBoundToContainer as cA,isFrameLikeElement as At,isImageElement as to,isEmbeddableElement as Jo,isInitializedImageElement as Fi,isLinearElement as Vt,isLinearElementType as KK,isUsingAdaptiveRadius as XK,isIframeElement as qb,isIframeLikeElement as Rc,isTextBindableContainer as dA,isElbowArrow as qt,isBindableElement as Jb,isTextElement as Jt,getNormalizedDimensions as ZK,isElementCompletelyInViewport as $K,isElementInViewport as mA,isInvisiblySmallElement as pA,generateThumbHash as jK,getCornerRadius as qK,isPathALoop as uA,embeddableURLValidator as Qb,maybeParseEmbedSrc as JK,getEmbedLink as Au,getInitializedImageElements as QK,normalizeSVG as hA,updateImageCache as ex,getBoundTextElement as tx,getContainerCenter as nx,getContainerElement as gA,isValidTextContainer as fA,redrawTextBoundingBox as eX,hasBoundingBox as tX,getCommonFrameId as EA,getFrameChildren as ox,getFrameChildrenInsertionIndex as nX,isCursorInFrame as bA,addElementsToFrame as rx,replaceAllElementsInFrame as oX,removeElementsFromFrame as rX,getElementsInResizingFrame as ix,getElementsInNewFrame as iX,getContainingFrame as ax,elementOverlapsWithFrame as aX,updateFrameMembershipOfSelectedElements as xA,isElementInFrame as yA,getFrameLikeTitle as lX,filterElementsEligibleAsFrameChildren as sX,hitElementBoundText as cX,hitElementBoundingBoxOnly as dX,hitElementItself as Nc,getVisibleSceneBounds as mX,cropElement as pX,wrapText as uX,isElementLink as wA,isMeasureTextSupported as hX,normalizeText as gX,measureText as vA,getLineHeightInPx as IA,getApproxMinLineWidth as fX,getApproxMinLineHeight as EX,getMinTextElementWidth as bX,ShapeCache as Oi,getRenderOpacity as xX,editGroupForSelectedElement as yX,getElementsInGroup as zi,getSelectedGroupIdForElement as wX,getSelectedGroupIds as vX,isElementInGroup as TA,isSelectedViaGroup as IX,selectGroupsForSelectedElements as no,syncInvalidIndices as VA,syncMovedIndices as SA,excludeElementsInFramesFromSelection as TX,getSelectionStateForElements as CA,makeNextSelectedElementIds as Ne,getResizeOffsetXY as SX,getResizeArrowDirection as CX,transformElements as PX,getCursorForResizingElement as PA,getElementWithTransformHandleType as kA,getTransformHandleTypeFromCoords as MA,dragNewElement as AA,dragSelectedElements as kX,getDragOffsetXY as MX,Scene as LA,Store as AX,CaptureUpdateAction as Qt,hitElementBoundingBox as LX,isLineElement as lx,isSimpleArrow as sx,StoreDelta as DA,positionElementsOnGrid as _A,calculateFixedPointForNonElbowArrowBinding as RA,bindOrUnbindBindingElement as DX,mutateElement as Lu,getElementBounds as NA,doBoundsIntersect as _X,isPointInElement as BA,maxBindingDistance_simple as FA,convertToExcalidrawElements as RX,getSnapOutlineMidPoint as cx,handleFocusPointDrag as NX,handleFocusPointHover as BX,handleFocusPointPointerDown as FX,handleFocusPointPointerUp as OX,maybeHandleArrowPointlikeDrag as Du,getUncroppedWidthAndHeight as zX,getActiveTextElement as OA,isEligibleFrameChildType as GX,getBindingStrategyForDraggingBindingElementEndpoints as HX,isNonDeletedElement as _u}from"@excalidraw/element";import{KEYS as Lh,MOBILE_ACTION_BUTTON_BG as P3,updateActiveTool as k3}from"@excalidraw/common";import{getNonDeletedElements as wd}from"@excalidraw/element";import{fixBindingsAfterDeletion as M3}from"@excalidraw/element";import{LinearElementEditor as j0}from"@excalidraw/element/linearElementEditor";import{newElementWith as yd}from"@excalidraw/element";import{getContainerElement as q0}from"@excalidraw/element";import{isBoundToContainer as bd,isElbowArrow as A3,isFrameLikeElement as L3}from"@excalidraw/element";import{getFrameChildren as D3}from"@excalidraw/element";import{getElementsInGroup as Dh,selectGroupsForSelectedElements as _3}from"@excalidraw/element";import{CaptureUpdateAction as xd}from"@excalidraw/element";import{isDevEnv as E3}from"@excalidraw/common";import{atom as et,createStore as h3}from"jotai";import{createIsolation as g3}from"jotai-scope";var t1=g3();var{useAtom:$e,useSetAtom:n1,useAtomValue:Xi,useStore:MZ}=t1,o1=t1.Provider,Tt=h3();var f3=Ax({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-3B3DKM74.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var b3=85,ao={code:"en",label:"English"},$i=[ao,...[{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=>Lx[e.code]>=b3).sort((e,n)=>e.label>n.label?1:-1)],od="__test__";E3()&&$i.unshift({code:od,label:"test language"},{code:`${od}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Zi=ao,nd={},rd=async e=>{if(Zi=e,document.documentElement.dir=Zi.rtl?"rtl":"ltr",document.documentElement.lang=Zi.code,e.code.startsWith(od))nd={};else try{nd=await f3(`./locales/${Zi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),nd=Yu}Tt.set(i1,e.code)},lo=()=>Zi,r1=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Zi.code.startsWith(od))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=r1(nd,o)||r1(Yu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},i1=et(ao.code),_e=()=>{let e=Xi(i1);return{t:f,langCode:e}};import x3 from"clsx";import rt from"react";import{THEME as y3}from"@excalidraw/common";import{Fragment as Se,jsx as h,jsxs as N}from"react/jsx-runtime";var Nn=e=>"var(--icon-fill-color)",a1=e=>e===y3.LIGHT?"#fff":"#1e1e1e",A=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:x3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},W={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Bt={width:40,height:20},VZ=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),W),l1=A(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),W),YZ=A("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),Ul=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),W),s1=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),W),c1=A(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),W),eh=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),W),_o=A(N("g",{children:[h("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"}),h("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"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("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"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("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"})})]}),le),so=A(N("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("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"})]}),le),d1=A(h("g",{fill:"currentColor",children:h("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}),m1=A(N(Se,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("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"}),p1=A(N(Se,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("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"}),u1=A(N(Se,{children:[h("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"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("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"}),KZ=A(h("g",{fill:"currentColor",children:h("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"}),id=A(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ji=A(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("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"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),qi=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),W),Ji=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),W),Qi=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),W),ad=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),W),lr=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),h1=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),W),co=A(N("g",{strokeWidth:"1.25",children:[h("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"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),le),Bn=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),W),g1=A(N("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),W),qr=A(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("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"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),le),ld=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),W),th=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),nh=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),f1=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("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"}),h("path",{d:"M3 4v4h4"})]}),W),Jr=A(h("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"}),le),sr=A(N("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),le),Wl=A(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),le),Vl=A(h("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"}),le),Yl=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("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"})}),{...le,strokeWidth:1.5}),E1=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),W),Kl=A(h("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"}),le),ea=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),b1=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),XZ=A(h("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"}),le),x1=A(h("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"}),le),y1=A(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),le),w1=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),W),sd=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Xl=A(N("g",{strokeWidth:"1.25",children:[h("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"}),h("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"})]}),le),v1=A("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}),I1=A("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}),cd=A(h("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"}),le),ZZ=A("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}),$Z=A("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"),oh=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],mo=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),oh.map(e=>h("path",{d:e},e))]}),W),T1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),W),S1=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),W),C1=A("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}),jZ=A("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}),qZ=A("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}),P1=A("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"),JZ=A("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"),rh=A(h("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"}),le),ih=A(h("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"}),le),k1=A("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}),M1=A(h("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"}),le),QZ=A("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"),e$=A("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}),t$=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),W),n$=A(N(Se,{children:[h("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"}),h("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}),o$=A(h("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}),A1=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),L1=N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),ah=A(L1,W),lh=A(L1,{...W,style:{transform:"rotate(180deg)"}}),sh=A(A1,W),ch=A(A1,{...W,style:{transform:"rotate(180deg)"}}),dh=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),mh=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),ph=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),uh=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),D1=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),_1=A(N(Se,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),hh=A(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),le),gh=A(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("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"})]}),le),dd=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),W),r$=A("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),i$=A("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"),un=A(N(Se,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),a$=A("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}),l$=A("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}),s$=A("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}),fh=rt.memo(({theme:e})=>A(N(Se,{children:[h("path",{d:"M25 26H111V111H25",fill:Nn(e)}),h("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:Nn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Nn(e)}),h("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:Nn(e),strokeWidth:"2"}),N("g",{fill:a1(e),stroke:Nn(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Eh=rt.memo(({theme:e})=>A(N(Se,{children:[h("path",{d:"M25 26H111V111H25",fill:Nn(e)}),h("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:Nn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Nn(e)}),h("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:Nn(e),strokeWidth:"2"}),N("g",{fill:a1(e),stroke:Nn(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),R1=A(h("g",{strokeWidth:1.25,children:h("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"})}),le),N1=A(N(Se,{children:[h("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"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("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"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("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"})})]}),le),B1=A(N(Se,{children:[N("g",{clipPath:"url(#a)",children:[h("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"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("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"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("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"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),F1=A(N(Se,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...le,fill:"currentColor"}),bh=A(h(Se,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),O1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),z1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),c$=rt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:Nn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),G1=A(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),W),H1=A(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),W),U1=A(h("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"}),le),W1=A(h("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"}),le),V1=A(h("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"}),le),xh=A(N("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),W),yh=A(N("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),W),Y1=A(N("svg",{strokeWidth:"1.5",children:[h("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"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),le),K1=A(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),W),X1=rt.memo(({flip:e=!1})=>A(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Bt)),Z1=rt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Bt)),$1=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Bt)),j1=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Bt)),q1=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Bt)),J1=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Bt)),Q1=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Bt)),e0=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Bt)),t0=rt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),Bt)),n0=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),Bt)),o0=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Bt)),r0=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Bt)),i0=rt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Bt)),a0=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),Bt)),l0=rt.memo(({flip:e=!1})=>A(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),Bt)),s0=A(N(Se,{children:[h("g",{clipPath:"url(#a)",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),c0=A(N(Se,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),d0=A(N(Se,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),m0=A(h(Se,{children:h("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"})}),le),Qr=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),W),p0=A(h(Se,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),W),Zl=A(h(Se,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})})}),le),w3=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),W),md=w3,u0=A(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),W),h0=A(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),W),g0=A(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),W),f0=rt.memo(({theme:e})=>A(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),W)),E0=rt.memo(({theme:e})=>A(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),W)),b0=rt.memo(({theme:e})=>A(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),W)),pd=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),W),d$=A(h("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}),m$=A(h("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"})),x0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),W),wh=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),W),y0=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),W),w0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),W),v0=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),p$=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),W),u$=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),W),I0=A(N(Se,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),W),T0=A(N(Se,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),W),S0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),W),C0=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),W),P0=A(N(Se,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),W),vh=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],ei=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),vh.map(e=>h("path",{d:e},e))]}),W),po=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),W),h$=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),W),g$=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),W),f$=A(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),le),ti=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),W),uo=A(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("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"}),h("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),E$=A(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),b$=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("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"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),x$=A(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("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"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),W),y$=A(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),W),ni=A(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),W),k0=A(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("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"}),h("path",{d:"M3 3l18 18"})]}),W),w$=A(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),v$=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),hn=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),W),I$=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),W),T$=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),W),M0=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),W),A0=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("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"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),W),S$=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),W),L0=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),W),D0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),W),_0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),W),R0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),W),Ih=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),W),ud=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),W),N0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("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"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),W),B0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),W),cr=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),W),C$=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),W),F0=A(N("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...W,strokeWidth:1.5}),P$=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),W),k$=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),W),O0=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),W),z0=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("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"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),W),dr=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),W),mr=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),W),pr=A(N("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),W),hd=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),W),G0=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),W),H0=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),W),Th=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),W),U0=A(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),W),Sh=A(N("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),W),Ch=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),W),M$=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),W),Ph=A(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),W0=A(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),W),V0=A(N("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),W),kh=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),W),A$=A(N("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),W),L$=A(N("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M15 4l0 16"})]}),W),D$=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"})]}),W),_$=A(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),W),gd=h("div",{style:{width:"1rem",height:"1rem"}}),Y0=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),W),K0=A(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),W),X0=A(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),W);import Z0 from"clsx";import Ah,{useEffect as T3,useRef as $0,useState as S3}from"react";import{isPromiseLike as C3}from"@excalidraw/common";import v3 from"react";import{jsx as Mh}from"react/jsx-runtime";var I3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(v3.useRef(Date.now()).current%1600);return Mh("div",{className:`Spinner ${o}`,children:Mh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Mh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Ro=I3;import{jsx as $l,jsxs as fd}from"react/jsx-runtime";var $=Ah.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Ah.useRef(null);Ah.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[l,s]=S3(!1),d=$0(!0),c=async p=>{let u="onClick"in o&&o.onClick?.(p);if(C3(u))try{s(!0),await u}catch(E){if(E instanceof Xc)console.warn(E);else throw E}finally{d.current&&s(!1)}};T3(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=$0(null);return o.type==="button"||o.type==="icon"?fd("button",{className:Z0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:c,ref:i,disabled:l||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&fd("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&$l("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&$l(Ro,{})]}),o.showAriaLabel&&fd("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",l&&$l(Ro,{})]}),o.children]}):$l("button",{className:Z0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:fd("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&$l("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var Ed=[],G=e=>(Ed=Ed.concat(e),e);import{jsx as N3}from"react/jsx-runtime";var R3=(e,n,t)=>{let o=new Set(de(e.filter(c=>L3(c)),n).map(c=>c.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of o){let m=D3(e,c);for(let p of m)if(!a.has(p.id)){if(bd(p)){let u=q0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(c=>{if(n.selectedElementIds[c.id]){let m=bd(c)?q0(c,i):null;return c.frameId&&o.has(c.frameId)?(l=!1,r[c.id]=!0,c):m?.frameId&&o.has(m?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&A3(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),yd(c,{isDeleted:!0}))}return c.frameId&&o.has(c.frameId)?(l=!1,bd(c)||(r[c.id]=!0),yd(c,{frameId:null})):bd(c)&&n.selectedElementIds[c.containerId]?yd(c,{isDeleted:!0}):c}),d=n.editingGroupId;if(l&&n.editingGroupId){let c=Dh(s,n.editingGroupId).filter(m=>!m.isDeleted);if(c.length>1)c[0]&&(r[c[0].id]=!0);else{d=null,c[0]&&(r[c[0].id]=!0);let m=c[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=Dh(s,u).filter(g=>!g.isDeleted);E.length>1&&(d=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:s,appState:{...n,..._3({selectedElementIds:r,editingGroupId:d},wd(s),n,null)}}},J0=(e,n)=>{if(e.editingGroupId){let t=Dh(wd(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},jl=G({name:"deleteSelectedElements",label:"labels.delete",icon:Jr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=n.selectedLinearElement,s=o.scene.getNonDeletedElementsMap(),d=j0.getElement(a,s);if(!d||l==null)return!1;if(l.length>=d.points.length){let c=e.map(p=>p.id===d.id?yd(p,{isDeleted:!0}):p),m=J0(n,c);return{elements:c,appState:{...m,selectedLinearElement:null},captureUpdate:xd.IMMEDIATELY}}return j0.deletePoints(d,o,l),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:xd.IMMEDIATELY}}let{elements:r,appState:i}=R3(e,n,o);return M3(r,r.filter(a=>a.isDeleted)),i=J0(i,r),{elements:r,appState:{...i,activeTool:k3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Oe(wd(e),n)?xd.IMMEDIATELY:xd.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Lh.BACKSPACE||e.key===Lh.DELETE)&&!e[Lh.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return N3($,{type:"button",icon:Jr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Oe(wd(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?P3:{}}})}});import{KEYS as ta,CODES as na,isDarwin as vd}from"@excalidraw/common";import{moveOneLeft as B3,moveOneRight as F3,moveAllLeft as O3,moveAllRight as z3}from"@excalidraw/element";import{CaptureUpdateAction as Id}from"@excalidraw/element";import{isDarwin as Q0}from"@excalidraw/common";var B=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,Q0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,Q0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as Td}from"react/jsx-runtime";var _h=G({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:lh,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:B3(e,n,o.scene),appState:n,captureUpdate:Id.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ta.CTRL_OR_CMD]&&!e.shiftKey&&e.code===na.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Td("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${B("CtrlOrCmd+[")}`,children:lh})}),Rh=G({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:ah,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:F3(e,n,o.scene),appState:n,captureUpdate:Id.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ta.CTRL_OR_CMD]&&!e.shiftKey&&e.code===na.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Td("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${B("CtrlOrCmd+]")}`,children:ah})}),Nh=G({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:ch,trackEvent:{category:"element"},perform:(e,n)=>({elements:O3(e,n),appState:n,captureUpdate:Id.IMMEDIATELY}),keyTest:e=>vd?e[ta.CTRL_OR_CMD]&&e.altKey&&e.code===na.BRACKET_LEFT:e[ta.CTRL_OR_CMD]&&e.shiftKey&&e.code===na.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Td("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${vd?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")}`,children:ch})}),Bh=G({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:sh,trackEvent:{category:"element"},perform:(e,n)=>({elements:z3(e,n),appState:n,captureUpdate:Id.IMMEDIATELY}),keyTest:e=>vd?e[ta.CTRL_OR_CMD]&&e.altKey&&e.code===na.BRACKET_RIGHT:e[ta.CTRL_OR_CMD]&&e.shiftKey&&e.code===na.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Td("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${vd?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")}`,children:sh})});import{getNonDeletedElements as G3}from"@excalidraw/element";import{LinearElementEditor as H3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as U3,isTextElement as W3}from"@excalidraw/element";import{arrayToMap as V3,KEYS as ey}from"@excalidraw/common";import{selectGroupsForSelectedElements as Y3}from"@excalidraw/element";import{CaptureUpdateAction as K3}from"@excalidraw/element";var Fh=G({name:"selectAll",label:"labels.selectAll",icon:L0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(W3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...Y3({editingGroupId:null,selectedElementIds:r},G3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&U3(e[0])?new H3(e[0],V3(e)):null},captureUpdate:K3.IMMEDIATELY}},keyTest:e=>e[ey.CTRL_OR_CMD]&&e.key===ey.A});import{DEFAULT_GRID_SIZE as ty,KEYS as ny,MOBILE_ACTION_BUTTON_BG as X3,arrayToMap as oy}from"@excalidraw/common";import{getNonDeletedElements as ry}from"@excalidraw/element";import{LinearElementEditor as Z3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as $3,getSelectionStateForElements as j3}from"@excalidraw/element";import{syncMovedIndices as q3}from"@excalidraw/element";import{duplicateElements as J3}from"@excalidraw/element";import{CaptureUpdateAction as iy}from"@excalidraw/element";import{jsx as Q3}from"react/jsx-runtime";var Oh=G({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Wl,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=Z3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:iy.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=J3({type:"in-place",elements:e,idsOfElementsToDuplicate:oy($3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+ty/2,y:a.y+ty/2,frameId:s??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:q3(i,oy(r)),appState:{...n,...j3(r,ry(i),n)},captureUpdate:iy.IMMEDIATELY}},keyTest:e=>e[ny.CTRL_OR_CMD]&&e.key===ny.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return Q3($,{type:"button",icon:Wl,title:`${f("labels.duplicateSelection")} \u2014 ${B("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Oe(ry(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?X3:{}}})}});import{pointFrom as OL}from"@excalidraw/math";import{useEffect as lg,useMemo as dg,useRef as sg,useState as zL}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as GL,COLOR_PALETTE as HL,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as bw,DEFAULT_ELEMENT_BACKGROUND_PICKS as UL,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as WL,DEFAULT_ELEMENT_STROKE_PICKS as VL,ARROW_TYPE as bn,DEFAULT_FONT_FAMILY as mw,DEFAULT_FONT_SIZE as YL,FONT_FAMILY as KL,ROUNDNESS as Xd,STROKE_WIDTH_KEYS as XL,VERTICAL_ALIGN as Yd,KEYS as ha,randomInteger as ZL,arrayToMap as mg,getFontFamilyString as $L,getLineHeight as pw,isGoogleFontFamily as jL,isTransparent as qL,getStrokeWidthByKey as xw,reduceToCommonValue as JL,invariant as $d,FONT_SIZES as Kd}from"@excalidraw/common";import{canBecomePolygon as QL,getNonDeletedElements as yw,isNonDeletedElement as e6}from"@excalidraw/element";import{bindBindingElement as uw,calculateFixedPointForElbowArrowBinding as hw,updateBoundElements as t6}from"@excalidraw/element";import{LinearElementEditor as ii}from"@excalidraw/element/linearElementEditor";import{newElementWith as dt}from"@excalidraw/element";import{getArrowheadForPicker as gw}from"@excalidraw/element";import{getBoundTextElement as ho,redrawTextBoundingBox as ss}from"@excalidraw/element";import{isArrowElement as Zd,isBoundToContainer as n6,isElbowArrow as ww,isLinearElement as cg,isLineElement as fw,isTextElement as Ct,isUsingAdaptiveRadius as o6}from"@excalidraw/element";import{hasStrokeColor as r6}from"@excalidraw/element";import{updateElbowArrowPoints as i6,CaptureUpdateAction as at,toggleLinePolygonState as a6}from"@excalidraw/element";import{deriveStylesPanelMode as l6}from"@excalidraw/common";import{isDevEnv as e5}from"@excalidraw/common";var t5=new Set(["command_palette","export"]),Ye=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!t5.has(e)||e5())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import i5 from"clsx";import n5 from"clsx";import{forwardRef as o5}from"react";import{jsx as r5}from"react/jsx-runtime";var ay=o5((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:l}=e;return r5("button",{type:"button",ref:n,title:t,"data-testid":r,className:n5(o,{active:i}),onClick:l,style:e.style,children:a},t)});import{Fragment as l5,jsx as zh,jsxs as a5}from"react/jsx-runtime";var tn=e=>zh(l5,{children:e.options.map(n=>e.type==="button"?zh(ay,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):a5("label",{className:i5({active:e.value===n.value}),title:n.text,children:[zh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as zy}from"radix-ui";import Gy from"clsx";import{memo as k4,useRef as Hy,useEffect as M4}from"react";import{applyDarkModeFilter as A4,COLOR_OUTLINE_CONTRAST_THRESHOLD as Fy,COLOR_PALETTE as Uy,DEFAULT_ELEMENT_BACKGROUND_PICKS as L4,DEFAULT_ELEMENT_STROKE_PICKS as D4,isColorDark as Oy,isWritableElement as _4,THEME as R4}from"@excalidraw/common";import{jsx as s5}from"react/jsx-runtime";var Sd=()=>s5("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as h5,useLayoutEffect as g5,useRef as f5}from"react";import{createPortal as E5}from"react-dom";import{EVENT as ur,isColorDark as b5,KEYS as x5,MIME_TYPES as y5,THEME as w5,removeDarkModeFilter as v5,rgbToHex as I5}from"@excalidraw/common";import ly from"react";var Gh=ly.createContext(null),ye=()=>ly.useContext(Gh);import{useState as c5,useLayoutEffect as sy}from"react";import{THEME as d5}from"@excalidraw/common";var Cd=e=>{let[n,t]=c5(null),o=me(),{theme:r}=ye(),{container:i}=we();return sy(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===d5.DARK))},[n,r,o.formFactor,e?.className]),sy(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),n};import{useEffect as m5}from"react";import{EVENT as Pd}from"@excalidraw/common";function oa(e,n,t){m5(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(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]")||n(i)}return document.addEventListener(Pd.POINTER_DOWN,o),document.addEventListener(Pd.TOUCH_START,o),()=>{document.removeEventListener(Pd.POINTER_DOWN,o),document.removeEventListener(Pd.TOUCH_START,o)}},[e,n,t])}import{useRef as p5}from"react";var ra=e=>{let n=p5(e);return Object.assign(n.current,e),n.current};import{clamp as u5}from"@excalidraw/math";var cy=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return u5(r,0,Math.max(0,t-n))},kd=({cursor:e,element:n,container:t,gap:o})=>({left:cy({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:cy({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as S5}from"react/jsx-runtime";var dy=vh.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),T5=`url(data:${y5.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${dy}</g><g stroke="#1b1b1f" stroke-width="1.25">${dy}</g></svg>`)}) 2 21, auto`,Xt=et(null),my=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Cd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=ia(),l=ct(),s=de(a,i),d=ra({app:l,onCancel:e,onChange:n,onSelect:t,selectedElements:s}),{container:c}=we();g5(()=>{if(r)return r.style.cursor=T5,()=>{r.style.cursor=""}},[r]),h5(()=>{let p=m.current;if(!p||!l.canvas||!r)return;let u=!1,E=l.canvas.getContext("2d"),g=({clientX:C,clientY:k})=>{let M=E.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(k-i.offsetTop)*window.devicePixelRatio,1,1).data;return I5(M[0],M[1],M[2])},b=C=>i.theme===w5.DARK?v5(C):C,w=({clientX:C,clientY:k,altKey:M})=>{let{top:_,left:L}=kd({cursor:{x:C,y:k},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${L}px`;let R=g({clientX:C,clientY:k});u&&d.onChange(o,b(R),d.selectedElements,{altKey:M}),p.style.background=R,p.style.setProperty("--eye-dropper-preview-border-color",b5(R)?"#fff":"#222")},y=()=>{d.onCancel()},x=(C,k)=>{d.onSelect(C,k)},I=C=>{u=!0,C.stopImmediatePropagation()},T=C=>{u=!1,c?.focus(),C.stopImmediatePropagation(),C.preventDefault(),x(b(g(C)),C)},P=C=>{C.key===x5.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:d.app.viewport.lastPosition.x,clientY:d.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(ur.KEYDOWN,P),r.addEventListener(ur.POINTER_DOWN,I),r.addEventListener(ur.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(ur.BLUR,y),()=>{u=!1,r.removeEventListener(ur.KEYDOWN,P),r.removeEventListener(ur.POINTER_DOWN,I),r.removeEventListener(ur.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(ur.BLUR,y)}},[d,l.canvas,r,o,c,i.offsetLeft,i.offsetTop,i.theme]);let m=f5(null);return oa(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?E5(S5("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Hh}from"radix-ui";import M5 from"clsx";import A5 from"react";import{isInteractive as L5}from"@excalidraw/common";import C5 from"react";import P5 from"clsx";import{jsx as k5}from"react/jsx-runtime";var Ke=C5.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>k5("div",{className:P5("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Uh,jsxs as D5}from"react/jsx-runtime";var Fn=A5.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:d=!1},c)=>{let m=me(),p=m.formFactor==="phone"&&!m.isLandscape;return Uh(Hh.Portal,{container:n,children:D5(Hh.Content,{ref:c,className:M5("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:u=>{d&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!L5(document.activeElement)&&n.focus(),r()},children:[Uh(Ke,{padding:3,style:o,children:t}),Uh(Hh.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 _5,useCallback as Wh}from"react";var Md=()=>document.querySelector(".excalidraw-wysiwyg"),Ad=()=>{let e=Md();return e?{start:e.selectionStart,end:e.selectionEnd}:null},ql=e=>{setTimeout(()=>{let n=Md();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},aa=(e,n,t,o)=>{n&&o&&o();let r=n&&t?Ad():null;e(),n&&t&&ql(r)},py=()=>{let[e,n]=_5(null),t=Wh(()=>{let i=Ad();n(i)},[]),o=Wh(()=>{setTimeout(()=>{let i=Md();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Wh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},uy=(e=100)=>{let n=Md();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import gy from"clsx";import{useCallback as B5,useEffect as Yh,useRef as fy,useState as Ey}from"react";import{KEYS as Kh,normalizeInputColor as F5}from"@excalidraw/common";import{isTransparent as R5,MAX_CUSTOM_COLORS_USED_IN_CANVAS as N5}from"@excalidraw/common";var hr=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Jl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Vh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),hy=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[o[n]];return!R5(l)&&Vh({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[o[n]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,N5)},gn=et(null);import{Fragment as O5,jsx as Ql,jsxs as Xh}from"react/jsx-runtime";var by=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=me(),[a,l]=Ey(e),[s,d]=Ey(null),[c,m]=$e(gn);Yh(()=>{l(e)},[e]);let p=B5(w=>{let y=w.toLowerCase().trim(),x=F5(y);x?(n(x),d(null)):y.length===0?d(null):/^#?[0-9a-f]+$/.test(y)?d(f("colorPicker.invalidHexLength")):d(f("colorPicker.invalidColor")),l(y)},[n]),u=fy(null),E=fy(null);Yh(()=>{u.current&&u.current.focus()},[c]);let[g,b]=$e(Xt);return Yh(()=>()=>{b(null)},[b]),Xh("div",{className:"color-picker__input-label-container",children:[Xh("div",{className:gy("color-picker__input-label",{"has-error":s}),children:[Ql("div",{className:"color-picker__input-hash",children:"#"}),Ql("input",{ref:c==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!s,onChange:w=>{p(w.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e),d(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:w=>{w.key!==Kh.TAB&&(w.key===Kh.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Xh(O5,{children:[Ql("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Ql("div",{ref:E,className:gy("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Kh.I.toLocaleUpperCase()} or ${B("Alt")} `,children:ei})]})]}),s&&Ql("div",{className:"color-picker__error-message",role:"alert",children:s})]})};import jh,{useEffect as qh,useImperativeHandle as f4,useState as E4}from"react";import{EVENT as Dy}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as b4,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as x4,KEYS as y4}from"@excalidraw/common";import X5 from"clsx";import{useEffect as Z5,useRef as $5}from"react";import{applyDarkModeFilter as j5,THEME as q5}from"@excalidraw/common";import{isColorDark as z5}from"@excalidraw/common";import{jsxs as H5}from"react/jsx-runtime";var G5=({color:e,keyLabel:n,isShade:t=!1})=>H5("div",{className:"color-picker__button__hotkey-label",style:{color:z5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),la=G5;import{createContext as U5,useContext as W5,useEffect as V5,useMemo as xy,useRef as yy,useState as Y5}from"react";import{colorToHex as wy,isTransparent as K5}from"@excalidraw/common";var oi="excalidraw-color-dnd-ghost",vy="excalidraw-color-dnd-active",Iy=10,Ty=100,Sy=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=wy(e);return t!==null&&t===wy(n)},Zh=U5(null),fn=()=>W5(Zh),Cy=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=Y5(null),i=yy(null),a=yy({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let l=xy(()=>{let s=null,d=()=>{s?.activated?r({color:s.color,origin:s.origin,overIndex:s.overIndex,duplicateIndex:s.duplicateIndex,slotSpan:s.slotSpan}):r(null)},c=()=>{let L=i.current;if(!L||!s)return!1;let R=Array.from(L.querySelectorAll("[data-top-pick-index]")).sort((H,F)=>Number(H.dataset.topPickIndex)-Number(F.dataset.topPickIndex));if(!R.length)return!1;s.slotRects=R.map(H=>H.getBoundingClientRect());let[z,K]=s.slotRects;s.slotSpan=K?K.left-z.left:z.width+4;let U=L.getBoundingClientRect(),D=Math.max(Math.abs(s.slotSpan)/2,10);return s.hitRect={left:U.left-D,right:U.right+D,top:U.top-14,bottom:U.bottom+14},!0},m=(L,R)=>{s?.ghost&&(s.ghost.style.transform=`translate(${L-s.ghostW/2}px, ${R-s.ghostH/2}px)`)},p=(L,R,z,K)=>{s?.ghost&&(s.ghostW!==L||s.ghostH!==R)&&(s.ghostW=L,s.ghostH=R,s.ghost.style.width=`${L}px`,s.ghost.style.height=`${R}px`,m(z,K))},u=(L,R)=>{if(!s)return;let{sourceRect:z,sourceEl:K,color:U}=s,D=document.createElement("div");D.className=oi;let H=document.createElement("div");if(H.className=`${oi}__swatch`,K5(U))H.classList.add("is-transparent");else{let F=getComputedStyle(K).backgroundColor;H.style.backgroundColor=F&&F!=="rgba(0, 0, 0, 0)"?F:U}D.appendChild(H),document.body.appendChild(D),s.ghost=D,s.ghostW=z.width,s.ghostH=z.height,D.style.width=`${z.width}px`,D.style.height=`${z.height}px`,m(L,R),requestAnimationFrame(()=>{s?.ghost===D&&D.classList.add(`${oi}--lifted`)}),document.body.classList.add(vy),s.activated=!0,d()},E=(L,R)=>{if(!s?.hitRect)return;let{hitRect:z,slotRects:K}=s,U=null,D=null;if(L>=z.left&&L<=z.right&&R>=z.top&&R<=z.bottom){let H=0,F=1/0;if(K.forEach((J,re)=>{let O=Math.abs(L-(J.left+J.width/2));O<F&&(F=O,H=re)}),s.origin.kind==="swatch"){let J=a.current.picks.findIndex(re=>Sy(re,s.color));J!==-1?D=J:U=H}else U=H}if(U!==s.overIndex||D!==s.duplicateIndex){s.overIndex=U,s.duplicateIndex=D;let{ghost:H}=s;H&&(H.classList.toggle(`${oi}--over`,U!==null),H.classList.toggle(`${oi}--blocked`,D!==null)),d()}if(U!==null){let H=s.slotRects[U];p(H.width,H.height,L,R)}else p(s.sourceRect.width,s.sourceRect.height,L,R)},g=L=>{if(!s?.ghost)return;let{ghost:R}=s;s.ghost=null,R.classList.add(`${oi}--dropping`);let z=L.rect;z&&(R.style.width=`${z.width}px`,R.style.height=`${z.height}px`,R.style.transform=`translate(${z.left}px, ${z.top}px)`),window.setTimeout(()=>{R.classList.add(`${oi}--fade`)},160),window.setTimeout(()=>{R.remove()},340)},b=()=>{let L=i.current;if(!L||!s?.activated)return;let R=Array.from(L.querySelectorAll("[data-top-pick-index]"));for(let z of R)z.style.transition="none",z.style.transform="none";L.offsetWidth;for(let z of R)z.style.transition=""},w=()=>{let L=R=>{R.preventDefault(),R.stopPropagation()};window.addEventListener("click",L,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",L,{capture:!0})},100)},y=()=>{window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",C,!0),window.removeEventListener("pointercancel",k,!0),window.removeEventListener("keydown",M,!0)},x=()=>{y(),document.body.classList.remove(vy),s?.activationTimer!=null&&window.clearTimeout(s.activationTimer),s=null,r(null)},I=L=>{s&&(b(),s.ghost&&(L?g({rect:s.sourceRect}):(s.ghost.remove(),s.ghost=null)),x())},T=(L,R)=>{if(!(!s||s.activated)){if(!c()){x();return}u(L,R),E(L,R)}},P=L=>{if(!(!s||L.pointerId!==s.pointerId)){if(s.lastX=L.clientX,s.lastY=L.clientY,!s.activated){if(Math.hypot(L.clientX-s.startX,L.clientY-s.startY)<Iy){s.activationTimer!==null&&(window.clearTimeout(s.activationTimer),s.activationTimer=null);return}let R=performance.now()-s.startTime;if(R<Ty){s.activationTimer===null&&(s.activationTimer=window.setTimeout(()=>{s&&(s.activationTimer=null,Math.hypot(s.lastX-s.startX,s.lastY-s.startY)>=Iy&&T(s.lastX,s.lastY))},Ty-R));return}if(T(L.clientX,L.clientY),!s?.activated)return}L.preventDefault(),m(L.clientX,L.clientY),E(L.clientX,L.clientY)}},C=L=>{if(!s||L.pointerId!==s.pointerId)return;if(!s.activated){x();return}L.preventDefault(),L.stopPropagation(),w();let{overIndex:R,origin:z,color:K,slotRects:U}=s,{picks:D,onPicksChange:H}=a.current;if(b(),R!==null){if(z.kind==="swatch"){if(!D.some(F=>Sy(F,K))){let F=[...D];F[R]=K,H(F)}}else if(z.index!==R){let F=[...D],[J]=F.splice(z.index,1);F.splice(R,0,J),H(F)}g({rect:U[R]})}else g({rect:s.sourceRect});x()},k=L=>{s&&L.pointerId===s.pointerId&&I(!0)},M=L=>{s?.activated&&L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),I(!0))};return{begin:(L,R,z)=>{!a.current.enabled||s||L.button!==0||!R||(s={pointerId:L.pointerId,startX:L.clientX,startY:L.clientY,startTime:performance.now(),lastX:L.clientX,lastY:L.clientY,activationTimer:null,color:R,origin:z,sourceEl:L.currentTarget,sourceRect:L.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",C,!0),window.addEventListener("pointercancel",k,!0),window.addEventListener("keydown",M,!0))},destroy:()=>I(!1)}},[]);return V5(()=>()=>l.destroy(),[l]),xy(()=>({dragState:o,startSwatchDrag:(s,d)=>l.begin(s,d,{kind:"swatch"}),startPickDrag:(s,d,c)=>l.begin(s,c,{kind:"pick",index:d}),setStripEl:s=>{i.current=s}}),[o,l])};import{jsx as $h,jsxs as J5}from"react/jsx-runtime";var Py=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=$e(gn),l=fn(),s=$5(null);return Z5(()=>{s.current&&s.current.focus()},[t,i]),$h("div",{className:"color-picker-content--default",children:n.map((d,c)=>{let m=j5(d,e===q5.DARK);return J5("button",{ref:t===d?s:void 0,tabIndex:-1,type:"button",className:X5("color-picker__button color-picker__button--large has-outline",{active:t===d,"is-transparent":d==="transparent"||!d}),onClick:()=>{o(d),a("custom")},onPointerDown:l?p=>l.startSwatchDrag(p,d):void 0,title:d,"aria-label":r,style:{"--swatch-color":m},children:[$h("div",{className:"color-picker__button-outline"}),$h(la,{color:m,keyLabel:c+1})]},c)})})};import Q5 from"clsx";import{useEffect as e4,useRef as t4}from"react";import{applyDarkModeFilter as n4,isColorDark as o4,THEME as r4}from"@excalidraw/common";import{jsx as Ld,jsxs as a4}from"react/jsx-runtime";var i4=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let l=hr({color:t,palette:n}),[s,d]=$e(gn),c=fn(),m=t4(null);return e4(()=>{m.current&&s==="baseColors"&&m.current.focus()},[l?.colorName,s]),Ld("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return Ld("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Jl[E],w=n4(g,e===r4.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return a4("button",{ref:l?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:Q5("color-picker__button color-picker__button--large",{"has-outline":!o4(g,255),active:l?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),d("baseColors")},onPointerDown:c?x=>c.startSwatchDrag(x,g):void 0,title:`${y}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${y} \u2014 ${b}`,style:g?{"--swatch-color":w}:void 0,"data-testid":`color-${p}`,children:[Ld("div",{className:"color-picker__button-outline"}),i&&Ld(la,{color:w,keyLabel:b})]},p)})})},ky=i4;import{jsx as s4}from"react/jsx-runtime";var l4=({children:e})=>s4("div",{className:"color-picker__heading",children:e}),sa=l4;import c4 from"clsx";import{useEffect as d4,useRef as m4}from"react";import{applyDarkModeFilter as p4,THEME as u4}from"@excalidraw/common";import{jsx as es,jsxs as My}from"react/jsx-runtime";var Ay=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=hr({color:n||"transparent",palette:o}),[a,l]=$e(gn),s=fn(),d=m4(null);if(d4(()=>{d.current&&a==="shades"&&d.current.focus()},[i,a]),i){let{colorName:c,shade:m}=i,p=o[c];if(Array.isArray(p))return es("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=p4(u,e===u4.DARK);return My("button",{ref:E===m&&a==="shades"?d:void 0,tabIndex:-1,type:"button",className:c4("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${c} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),l("shades")},onPointerDown:s?b=>s.startSwatchDrag(b,u):void 0,children:[es("div",{className:"color-picker__button-outline"}),r&&es(la,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return My("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[es("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),es("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ca,COLOR_PALETTE as h4,KEYS as ts}from"@excalidraw/common";var Dd=(e,n,t)=>{let o=Math.ceil(t/ca);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+ca;return r>=t?n%ca:r}case"ArrowUp":{let r=n-ca,i=r<0?ca*o+r:r;return i>=t?void 0:i}}},g4=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:l})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return t(o[n.colorName][s]),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(Jl.includes(e.key)){let s=Jl.indexOf(e.key),d=Object.keys(o)[s],c=o[d],m=Array.isArray(c)?c[a]:c;return m==null||l?.includes(m)||(t(m),i("baseColors")),!0}return!1},Ly=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:c,excludedColors:m})=>{if(e[ts.CTRL_OR_CMD])return!1;if(e.key===ts.ESCAPE)return c(e),!0;if(e.key===ts.ALT)return d(!0),!0;if(e.key===ts.I)return d(),!0;let p=hr({color:o,palette:t});if(e.key===ts.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,w=g+b>E.length-1?0:g+b<0?E.length-1:g+b,y=E[w];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(h4.black)),e.preventDefault(),e.stopPropagation(),!0}if(g4({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=Dd(e.key,u,ca);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=Dd(e.key,g,E.length),w=0;for(;b!==void 0&&w++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[s]:y;if(!m?.includes(x))break;b=Dd(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[s]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=Dd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as No,jsxs as _d}from"react/jsx-runtime";var _y=jh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:l,showTitle:s,onEyeDropperToggle:d,onEscape:c,showHotKey:m=!0,excludedColors:p},u)=>{let E=s?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=jh.useState(()=>o==="canvasBackground"?[]:hy(r,o,i)),[b,w]=$e(gn),y=fn(),x=hr({color:n,palette:i});qh(()=>{if(!b){let C=!!n&&Vh({color:n,palette:i}),k=C&&!g.includes(n);w(k?null:C?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,w,x,g]);let[I,T]=E4(x?.shade??(o==="elementBackground"?b4:x4));qh(()=>{x?.shade!=null&&T(x.shade);let C=k=>{k.key===y4.ALT&&d(!1)};return document.addEventListener(Dy.KEYUP,C,{capture:!0}),()=>{document.removeEventListener(Dy.KEYUP,C,{capture:!0})}},[x,d]);let P=jh.useRef(null);return f4(u,()=>P.current),qh(()=>{P?.current?.focus()},[]),No("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:_d("div",{ref:P,onKeyDown:C=>{Ly({event:C,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:d,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:c,excludedColors:p})&&(C.preventDefault(),C.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&No("div",{className:"color-picker__title",children:E}),!!g.length&&_d("div",{children:[No(sa,{children:f("colorPicker.mostUsedCustomColors")}),No(Py,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),_d("div",{children:[No(sa,{children:f("colorPicker.colors")}),No(ky,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),_d("div",{children:[No(sa,{children:f("colorPicker.shades")}),No(Ay,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),l,y&&No("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import Ry from"clsx";import{ContextMenu as ns}from"radix-ui";import{applyDarkModeFilter as w4,COLOR_OUTLINE_CONTRAST_THRESHOLD as v4,DEFAULT_CANVAS_BACKGROUND_PICKS as I4,DEFAULT_ELEMENT_BACKGROUND_PICKS as T4,DEFAULT_ELEMENT_STROKE_PICKS as S4,isColorDark as C4,THEME as P4}from"@excalidraw/common";import{jsx as gr,jsxs as Ny}from"react/jsx-runtime";var By=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let l=fn(),s=l?.dragState??null,{container:d}=we(),c;if(t==="elementStroke"&&(c=S4),t==="elementBackground"&&(c=T4),t==="canvasBackground"&&(c=I4),r&&(c=r),!c)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!s||s.origin.kind!=="pick"||s.overIndex===null)return 0;let E=s.origin.index,g=s.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*s.slotSpan},p=Ny("div",{className:Ry("color-picker__top-picks",{"is-dnd-active":!!s}),ref:l?.setStripEl,children:[s&&gr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:gr("rect",{})}),c.map((u,E)=>{let g=m(E),b=w4(u,e===P4.DARK);return gr("button",{className:Ry("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!C4(u,v4),"is-dnd-source":s?.origin.kind==="pick"&&s.origin.index===E,"is-dnd-target":s?.origin.kind==="swatch"&&s.overIndex===E,"is-dnd-duplicate":s?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:l?w=>l.startPickDrag(w,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:gr("div",{className:"color-picker__button-outline"})},u)})]});return i?Ny(ns.Root,{children:[gr(ns.Trigger,{asChild:!0,children:p}),gr(ns.Portal,{container:d,children:gr(ns.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:gr(ns.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as En,jsxs as Rd}from"react/jsx-runtime";var N4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Uy,updateData:a,getOpenPopup:l,appState:s,excludedColors:d})=>{let{container:c}=we(),m=it(),p=m!=="full",u=m==="mobile",[,E]=$e(gn),[g,b]=$e(Xt),w=Rd("div",{children:[En(sa,{children:f("colorPicker.hexCode")}),En(by,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=Hy(null),x=()=>{y.current?.focus()};return En(Fn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}_4(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),E(null),s.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?En(_y,{ref:y,palette:i,excludedColors:d,color:n,theme:s.theme,onChange:I=>{let T=s.editingTextElement?Ad():null;t(I),s.editingTextElement&&T&&ql(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:w}):w})},B4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",F4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=it(),s=l!=="full",d=l==="mobile",c=fn(),m=n?A4(n,o===R4.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&uy(),i()};return Rd(zy.Trigger,{type:"button",className:Gy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!Oy(n,Fy),"compact-sizing":s,"mobile-border":d}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:c?u=>c.startSwatchDrag(u,n):void 0,children:[En("div",{className:"color-picker__button-outline",children:!n&&T1}),s&&n&&r==="stroke"&&En("div",{className:"color-picker__button-background",children:En("span",{style:{color:m&&Oy(m,Fy)?"#fff":"#111"},children:V0})})]})},O4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Uy,topPicks:a,updateData:l,appState:s,excludedColors:d,customizableTopPicks:c})=>{let m=Hy(s.openPopup);M4(()=>{m.current=s.openPopup},[s.openPopup]);let u=it()!=="full",E=!!c&&!u,g=E&&c?s.colorTopPicks?.[c]:null,b=g?.length?g:a??(e==="elementStroke"?D4:L4),w=Cy({enabled:E,picks:b,onPicksChange:y=>{c&&l({colorTopPicks:{...s.colorTopPicks,[c]:y}})}});return En(Zh.Provider,{value:E?w:null,children:Rd("div",{role:"dialog","aria-modal":"true",className:Gy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&En(By,{theme:s.theme,activeColor:n,onChange:y=>{t(y),B4(s.openPopup)&&s.openPopup!==e&&setTimeout(()=>l({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&c?()=>{l({colorTopPicks:{...s.colorTopPicks,[c]:null}})}:void 0}),!u&&En(Sd,{}),Rd(zy.Root,{open:s.openPopup===e,onOpenChange:y=>{y&&l({openPopup:e})},children:[En(F4,{color:n,label:o,type:e,theme:s.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&En(N4,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:d,updateData:l,getOpenPopup:()=>m.current,appState:s})]})]})})},z4=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,da=k4(O4,z4);import{Popover as mL}from"radix-ui";import pL from"clsx";import uL,{useCallback as hL,useMemo as gL}from"react";import{FONT_FAMILY as rg}from"@excalidraw/common";import oL,{useMemo as Oo,useState as rL,useRef as Ky,useEffect as Xy,useCallback as eg}from"react";import{arrayToList as iL,debounce as aL,FONT_FAMILY as fr,getFontFamilyString as lL,isGoogleFontFamily as Gd}from"@excalidraw/common";import G4 from"clsx";import H4 from"react";import{jsx as U4,jsxs as W4}from"react/jsx-runtime";var Nd=H4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>W4("div",{className:G4("QuickSearch__wrapper",e),children:[hn,U4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import V4 from"clsx";import{Children as Y4}from"react";import{jsx as Wy}from"react/jsx-runtime";var Bd=({className:e,placeholder:n,children:t})=>{let o=!Y4.count(t);return Wy("div",{className:V4("ScrollableList__wrapper",e),role:"menu",children:o?Wy("div",{className:"empty",children:n}):t})};import{jsx as K4,jsxs as X4}from"react/jsx-runtime";var Vy=({children:e,className:n="",style:t,title:o})=>X4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&K4("p",{className:"dropdown-menu-group-title",children:o}),e]}),ri=Vy;Vy.displayName="DropdownMenuGroup";import{THEME as tL}from"@excalidraw/common";import{DropdownMenu as nL}from"radix-ui";import Z4,{useContext as $4}from"react";import{composeEventHandlers as j4}from"@excalidraw/common";var Jh=Z4.createContext({}),Bo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Fd=e=>{let n=$4(Jh);return j4(e,t=>{n.onSelect?.(t)})};import{jsx as q4}from"react/jsx-runtime";var os=({children:e,...n})=>q4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as Q4,jsx as rs,jsxs as eL}from"react/jsx-runtime";var J4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=me();return eL(Q4,{children:[n&&rs("div",{className:"dropdown-menu-item__icon",children:n}),rs("div",{style:e,className:"dropdown-menu-item__text",children:rs(os,{children:o})}),r&&rs("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&rs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Fo=J4;import{jsx as Od}from"react/jsx-runtime";var Qh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:l,...s})=>{let d=Fd(l);return Od(nL.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:Od("button",{...s,value:t,className:Bo(i,a),title:s.title??s["aria-label"],children:Od(Fo,{icon:e,shortcut:r,badge:n,children:o})})})};Qh.displayName="DropdownMenuItem";var ma={GREEN:"green",RED:"red",BLUE:"blue"},zd=({type:e=ma.BLUE,children:n})=>{let{theme:t}=on(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===tL.LIGHT?"1.5px solid white":"none"};switch(e){case ma.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ma.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case ma.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Od("div",{className:"DropDownMenuItemBadge",style:o,children:n})};zd.displayName="DropdownMenuItemBadge";Qh.Badge=zd;var nn=Qh;import{KEYS as pa}from"@excalidraw/common";var Yy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[pa.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===pa.F)return n.current?.focus(),!0;if(e.key===pa.ESCAPE)return r(),!0;if(e.key===pa.ENTER)return t?.value&&i(t.value),!0;if(e.key===pa.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===pa.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as Lt,jsxs as ng}from"react/jsx-runtime";var tg=e=>{switch(e){case fr.Excalifont:case fr.Virgil:return co;case fr.Nunito:case fr.Helvetica:return Zl;case fr["Lilita One"]:return p0;case fr["Comic Shanns"]:case fr.Cascadia:return md;default:return Zl}},sL=(e,n)=>Gd(e)?mn(e)?.family??"Unknown":Object.entries(fr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Zy=oL.memo(({googleFonts:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onOpen:a,onClose:l})=>{let{container:s}=we(),d=ct(),{fonts:c}=d,{showDeprecatedFonts:m}=St(),p=!!e&&!d.state.viewModeEnabled,u=it(),[E,g]=rL(""),b=Ky(null),w=Oo(()=>new Set(c.getSceneFamilies()),[n]),y=Oo(()=>Array.from(Do.registered.entries()).filter(([D,{metadata:H}])=>!H.private&&!H.fallback&&!Gd(D)).map(([D,{metadata:H,fontFaces:F}])=>{let J={value:D,icon:tg(D),text:sL(D,F)};return H.deprecated&&Object.assign(J,{deprecated:H.deprecated,badge:{type:ma.RED,placeholder:f("fontList.badge.old")}}),J}).sort((D,H)=>D.text.toLowerCase()>H.text.toLowerCase()?1:-1),[]),x=Oo(()=>new Map((e?.libraryFonts??[]).map(D=>[D.family,D])),[e?.libraryFonts]),I=Oo(()=>{let D=y.filter(F=>w.has(F.value)),H=Array.from(w).filter(Gd).map(F=>{let{family:J,weight:re}=mn(F),O=x.get(J),V=p&&!O&&e.addToLibrary!=="unavailable"?e.addToLibrary:void 0,ce=re===io?J:`${J} ${re}`,pe=!!e&&!e.canApplyGoogleFonts;return{value:F,icon:tg(F),text:ce,title:pe?f("fontList.upgradeToUse"):ce,disabled:pe,addToLibrary:V&&{family:J,state:V}}});return[...D,...H]},[y,w,x,e,p]),T=Oo(()=>(e?.libraryFonts??[]).map(D=>{let H=D.weights.includes(io)?io:D.weights.length?Math.min(...D.weights):io,F=Lo(D.family,H);return{value:F,icon:tg(F),text:H===io?D.family:`${D.family} ${H}`,disabled:!D.enabled}}).filter(D=>!w.has(D.value)),[e,w]),P=Oo(()=>y.filter(D=>!w.has(D.value)&&(m||!D.deprecated)),[y,w,m]),C=Oo(()=>{let D=E.trim().toLowerCase(),H=F=>F.text.toLowerCase().includes(D);return{scene:I.filter(H),library:T.filter(H),available:P.filter(H)}},[I,T,P,E]),k=Oo(()=>iL([...C.scene,...C.library,...C.available].filter(D=>!D.disabled)),[C]),M=eg(D=>{if(r(D),Gd(D)){let H=k.find(F=>F.value===D);c.loadFontFamily(D,H?.text||mn(D)?.family||"").catch(F=>{console.error(`Failed to preview Google Font "${D}"`,F)})}},[k,c,r]),_=Oo(()=>{let D;return t?D=k.find(H=>H.value===t):n&&(D=k.find(H=>H.value===n)),!D&&E&&(k[0]?.value?M(k[0].value):i()),D},[t,n,E,k,M,i]),L=eg(D=>{let H=null;if(d.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(H={start:F.selectionStart,end:F.selectionEnd})}o(D),d.state.editingTextElement&&H&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&H&&(F.focus(),F.selectionStart=H.start,F.selectionEnd=H.end)},0)},[o,d.state.editingTextElement]),R=eg(D=>{Yy({event:D,inputRef:b,hoveredFont:_,filteredFonts:k,onSelect:L,onHover:M,onClose:l})&&(D.preventDefault(),D.stopPropagation())},[_,k,L,M,l]);Xy(()=>(a(),()=>{l()}),[]);let z=({font:D,order:H})=>{let{disabled:F}=D,J=Ky(null),re=D.value===_?.value,O=D.value===n;Xy(()=>{re&&(H===0?J.current?.scrollIntoView?.({block:"end"}):J.current?.scrollIntoView?.({block:"nearest"}))},[re,H]);let V=D.addToLibrary?.state==="locked"?f("fontList.addToLibraryLocked"):f("fontList.addToLibrary");return ng("div",{className:"FontPicker__row","data-testid":"font-picker-row",children:[Lt("button",{ref:J,type:"button",value:D.value,disabled:F,"data-testid":`font-picker-item-${D.value}`,className:Bo("",O,re),title:D.title??D.text,tabIndex:O?0:-1,onClick:()=>{F||L(D.value)},onMouseMove:()=>{!F&&_?.value!==D.value&&M(D.value)},children:Lt(Fo,{icon:D.icon,badge:D.badge&&Lt(zd,{type:D.badge.type,children:D.badge.placeholder}),textStyle:{fontFamily:lL({fontFamily:D.value})},children:D.text})}),D.addToLibrary&&Lt("button",{type:"button",className:"FontPicker__row-action","data-testid":`font-picker-add-${D.value}`,"data-locked":D.addToLibrary.state==="locked"||void 0,title:V,"aria-label":V,onClick:()=>e?.onAddToLibrary?.(D.addToLibrary.family),children:D.addToLibrary.state==="locked"?so:l1})]})},K=[],U=0;return C.scene.length&&(K.push(Lt(ri,{title:f("fontList.sceneFonts"),children:C.scene.map((D,H)=>Lt(z,{font:D,order:H},D.value))},"group_1")),U+=C.scene.length),C.library.length&&(K.push(Lt(ri,{title:f("fontList.myFonts"),children:C.library.map((D,H)=>Lt(z,{font:D,order:H+U},D.value))},"group_2")),U+=C.library.length),C.available.length&&K.push(Lt(ri,{title:f("fontList.builtInFonts"),children:C.available.map((D,H)=>Lt(z,{font:D,order:H+U},D.value))},"group_3")),p&&e.onBrowse&&K.push(ng(ri,{children:[!(e.libraryFonts??[]).length&&Lt("p",{className:"FontPicker__empty-library",children:f("fontList.emptyLibrary")}),Lt("button",{type:"button",className:Bo(),"data-testid":"font-picker-browse",onClick:()=>e.onBrowse?.(),children:Lt(Fo,{icon:hn,children:f("fontList.browse")})})]},"group_browse")),ng(Fn,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{l(),d.state.editingTextElement&&setTimeout(()=>{let D=document.querySelector(".excalidraw-wysiwyg");D&&D.focus()},0)},onPointerLeave:i,onKeyDown:R,preventAutoFocusOnTouch:!!d.state.editingTextElement,children:[(u==="full"||!!e?.libraryFonts?.length)&&Lt(Nd,{ref:b,placeholder:f("quickSearch.placeholder"),onChange:aL(g,20)}),Lt(Bd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:K.length?K:null}),e?.upgradeAction&&Lt("div",{className:"FontPicker__upgrade-action",children:e.upgradeAction})]})},(e,n)=>e.googleFonts===n.googleFonts&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as cL}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as dL}from"@excalidraw/common";import{jsx as og}from"react/jsx-runtime";var $y=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=ze(),r=t?{...dL,width:"2rem",height:"2rem"}:{};return og(cL.Trigger,{asChild:!0,children:og("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:og($,{type:"toggle",icon:Bn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as is,jsxs as jy}from"react/jsx-runtime";var qy=[{value:rg.Excalifont,icon:co,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:rg.Nunito,icon:Zl,text:f("labels.normal"),testId:"font-family-normal"},{value:rg["Comic Shanns"],icon:md,text:f("labels.code"),testId:"font-family-code"}],sne=new Set(qy.map(e=>e.value));var Jy=uL.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let{googleFonts:s}=St(),d=gL(()=>qy,[]),c=hL(m=>{m&&o(m)},[o]);return jy("div",{role:"dialog","aria-modal":"true",className:pL("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&is("div",{className:"buttonList",children:is(tn,{type:"button",options:d,value:n,onClick:c})}),!l&&is(Sd,{}),jy(mL.Root,{open:e,onOpenChange:a,children:[is($y,{selectedFontFamily:n,isOpened:e,compactMode:l}),e&&is(Zy,{googleFonts:s,selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Qy}from"radix-ui";import fL from"clsx";import{useEffect as EL,useState as bL}from"react";import{getFontFamilyString as xL}from"@excalidraw/common";import{Fragment as IL,jsx as On,jsxs as ua}from"react/jsx-runtime";var yL={100:"thin",200:"extraLight",300:"light",400:"regular",500:"medium",600:"semiBold",700:"bold",800:"extraBold",900:"black"},as=e=>{let n=yL[e];return n?f(`fontWeight.${n}`):String(e)},wL=e=>e.includes(io)?io:e.length?Math.min(...e):io,tw=(e,n,t,o)=>{let r=mn(e),i=mn(n);if(!r||!i||r.family===i.family||o.includes(e))return e;let a=t?.find(l=>l.family===r.family);return a&&r.weight===wL(a.weights)&&a.weights.includes(i.weight)?Lo(r.family,i.weight):e},nw=(e,n)=>{let t=e.googleFamily,o=t&&n?.canApplyGoogleFonts?n.libraryFonts.find(r=>r.family===t&&r.enabled):void 0;return{family:t,weights:o?.weights,selectedWeight:mn(e.fontFamily)?.weight??null}},vL=e=>e==="ArrowLeft"||e==="ArrowRight"||e==="ArrowUp"||e==="ArrowDown",ew=e=>{vL(e.key)&&e.stopPropagation()},ow=({family:e,weights:n,selectedWeight:t,onSelect:o,onEditWeights:r,compactMode:i=!1})=>{let{fonts:a}=ct(),{container:l}=we(),[s,d]=bL(!1),c=[...n].sort((u,E)=>u-E),m=c.join(",");if(EL(()=>{for(let u of c){let E=Lo(e,u);a.loadFontFamily(E,as(u)).catch(g=>{console.error(`Failed to load font weight "${E}"`,g)})}},[a,e,m]),c.length<2)return null;let p=u=>xL({fontFamily:Lo(e,u)});return i?On("fieldset",{className:"FontWeightPicker FontWeightPicker--compact","data-testid":"font-weight-picker",children:ua(Qy.Root,{open:s,onOpenChange:d,children:[On(Qy.Trigger,{asChild:!0,children:ua("button",{type:"button",className:"FontWeightPicker__trigger","data-testid":"font-weight-trigger","aria-label":t!==null?`${f("labels.fontWeight")}: ${as(t)}`:f("labels.fontWeight"),style:t!==null?{fontFamily:p(t)}:void 0,children:[t!==null?as(t):f("labels.fontWeight")," ","\u25BE"]})}),s&&On(Fn,{onKeyDown:ew,className:"FontWeightPicker__popover",container:l,onClose:()=>{},children:ua("div",{className:"FontWeightPicker__menu",children:[c.map(u=>ua("button",{type:"button",className:"FontWeightPicker__menu-item","aria-pressed":u===t,"data-testid":`font-weight-${u}`,style:{fontFamily:p(u)},onClick:()=>{d(!1),o(u)},children:[On("span",{children:as(u)}),u===t&&On("span",{"aria-hidden":"true",children:"\u2713"})]},u)),r&&ua(IL,{children:[On("hr",{className:"FontWeightPicker__divider"}),On("button",{type:"button",className:"FontWeightPicker__menu-item","data-testid":"font-weight-more",onClick:()=>{d(!1),r(e)},children:f("fontWeight.more")})]})]})})]})}):ua("fieldset",{onKeyDown:ew,className:"FontWeightPicker","data-testid":"font-weight-picker",children:[On("legend",{children:f("labels.fontWeight")}),On("div",{className:"FontWeightPicker__options",role:"group","aria-label":f("labels.fontWeight"),children:c.map(u=>On("button",{type:"button",className:fL("FontWeightPicker__option",{active:u===t}),"aria-pressed":u===t,"data-testid":`font-weight-${u}`,style:{fontFamily:p(u)},onClick:()=>o(u),children:as(u)},u))}),r&&On("button",{type:"button",className:"FontWeightPicker__more","data-testid":"font-weight-more",onClick:()=>r(e),children:f("fontWeight.more")})]})};import{Popover as Wd}from"radix-ui";import PL from"clsx";import lw,{useEffect as kL,useMemo as ML}from"react";import{isArrowKey as AL,KEYS as zo}from"@excalidraw/common";import{jsx as TL}from"react/jsx-runtime";var Hd=({className:e,icon:n,size:t="1em"})=>TL("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:n});import{Fragment as CL,jsx as rw,jsxs as iw}from"react/jsx-runtime";var SL=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>iw(CL,{children:[iw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&rw(Hd,{icon:n?G0:hd})]}),n&&rw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),ls=SL;import{jsx as zn,jsxs as Vd}from"react/jsx-runtime";var LL=et(!1),Ud=4,DL="default",_L=e=>e.flatMap(n=>n.options),aw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},RL=(e,n)=>e.some(t=>t.options.some(n)),NL=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/Ud)},(t,o)=>n.options.slice(o*Ud,o*Ud+Ud)));function BL({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=we(),[l,s]=$e(LL),d=[...e,...n],c=_L(d),m=NL([...e,...l?n:[]]),p=g=>{let b=c.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===zo.TAB){let w=c.findIndex(x=>x.value===t),y=g.shiftKey?(c.length+w-1)%c.length:(w+1)%c.length;r(c[y].value)}else if(AL(g.key)){let w=lo().rtl,y=c.findIndex(x=>x.value===t);if(y!==-1){let x=c.length,I=y;switch(g.key){case(w?zo.ARROW_LEFT:zo.ARROW_RIGHT):I=(y+1)%x;break;case(w?zo.ARROW_RIGHT:zo.ARROW_LEFT):I=(x+y-1)%x;break;case zo.ARROW_DOWN:{let T=m.findIndex(C=>C.some(k=>k.value===t)),P=m[T];if(T!==-1&&P){let C=P.findIndex(_=>_.value===t),k=m[(T+1)%m.length],M=k[Math.min(C,k.length-1)]??c[y];r(M.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case zo.ARROW_UP:{let T=m.findIndex(C=>C.some(k=>k.value===t)),P=m[T];if(T!==-1&&P){let C=P.findIndex(_=>_.value===t),k=m[(m.length+T-1)%m.length],M=k[Math.min(C,k.length-1)]??c[y];r(M.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(c[I].value)}g.preventDefault()}else(g.key===zo.ESCAPE||g.key===zo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};kL(()=>{RL(n,g=>g.value===t)&&s(!0)},[t,n,s]);let u=g=>zn("div",{className:"picker-content",children:g.map(b=>Vd("button",{type:"button",className:PL("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:w=>{t===b.value&&setTimeout(()=>{w?.focus()},0)},children:[b.icon,b.keyBinding&&zn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===DL?zn(lw.Fragment,{children:u(b.options)},`${b.name}-${w}`):Vd("div",{className:"picker-section",children:[zn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return zn(Wd.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:Vd("div",{className:"picker-sections",children:[E(e),n.length>0&&zn(ls,{label:f("labels.more_options"),open:l,openTrigger:()=>{s(g=>!g)},className:"picker-collapsible",children:zn("div",{className:"picker-sections",children:E(n)})})]})})}function ig({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=lw.useState(!1),{container:l}=we(),s=ML(()=>aw(t,d=>d.value===e)??aw(o??[],d=>d.value===e),[t,o,e]);return zn("div",{children:Vd(Wd.Root,{open:i,onOpenChange:d=>a(d),children:[zn(Wd.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&zn(Wd.Portal,{container:l,children:zn(BL,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})})]})})}import sw,{useEffect as FL}from"react";import{jsx as ag,jsxs as cw}from"react/jsx-runtime";var dw=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:l=!0,testId:s})=>{let d=sw.useRef(null),c=sw.useRef(null);return FL(()=>{if(d.current&&c.current){let m=d.current,p=c.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),cw("label",{className:"control-label",children:[e,cw("div",{className:"range-wrapper",children:[ag("input",{style:{"--color-slider-track":l?void 0:"var(--button-bg)"},ref:d,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":s}),ag("div",{className:"value-bubble",ref:c,children:n!==o?n:null}),ag("div",{className:"zero-label",children:a})]})]})};import{Fragment as qd,jsx as te,jsxs as Pt}from"react/jsx-runtime";var vw=.1,ai=e=>{let n=l6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Dt=(e,n,t,o=!1)=>{let r=mg(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(e6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},ht=function(e,n,t,o,r){let i=n.state.editingTextElement,a=yw(e),l=null;if(i&&(l=t(i)),!l)if(Oe(a,n.state)){let d=n.scene.getSelectedElements(n.state),c=o===!0?d:d.filter(m=>o(m));l=JL(c,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},s6=(e,n,t)=>n6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),pg=(e,n,t,o,r)=>{let i=new Set,a=Dt(e,n,l=>{if(Ct(l)){let s=o(l);i.add(s);let d=dt(l,{fontSize:s});return ss(d,t.scene.getContainerElement(l),t.scene),d=s6(l,d,t.scene),d}return l},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(l=>{Ct(l)&&t6(l,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:at.IMMEDIATELY}},c6=G({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Dt(e,n,o=>r6(o.type)?dt(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?at.IMMEDIATELY:at.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=ai(o);return Pt(qd,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.stroke")}),te(da,{topPicks:VL,palette:WL,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:ht(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),d6=G({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:at.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!qL(t.currentItemBackgroundColor)&&i.every(l=>fw(l)&&QL(l.points))){let l=mg(i);r=e.map(s=>l.has(s.id)&&fw(s)?dt(s,{backgroundColor:t.currentItemBackgroundColor,...a6(s,!0)}):s)}else r=Dt(e,n,l=>dt(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=ai(o);return Pt(qd,{children:[i==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(da,{topPicks:UL,palette:bw,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:ht(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),jd=G({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:at.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=ai(o);return Pt(qd,{children:[r==="full"&&te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(da,{topPicks:GL,palette:bw,excludedColors:[HL.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),m6=G({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ye("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Dt(e,n,r=>dt(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=de(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return Pt("fieldset",{children:[te("legend",{children:f("labels.fill")}),te("div",{className:"buttonList",children:te(tn,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${B("Alt-Click")})`,icon:i?R1:N1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:B1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:F1,testId:"fill-solid"}],value:ht(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),p6=e=>XL.find(n=>xw(e.type,n)===e.strokeWidth)??null,u6=(e,n)=>xw(e.type,n),h6=G({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>($d(t,"actionChangeStrokeWidth: value must be defined"),{elements:Dt(e,n,o=>dt(o,{strokeWidth:u6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>Pt("fieldset",{children:[te("legend",{children:f("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(tn,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:bh,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:O1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:z1,testId:"strokeWidth-bold"}],value:ht(e,o,p6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),g6=G({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Dt(e,n,o=>dt(o,{seed:ZL(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>Pt("fieldset",{children:[te("legend",{children:f("labels.sloppiness")}),te("div",{className:"buttonList",children:te(tn,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:U1},{value:1,text:f("labels.artist"),icon:W1},{value:2,text:f("labels.cartoonist"),icon:V1}],value:ht(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),f6=G({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Dt(e,n,r=>r.type!=="freedraw"?r:dt(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=ht(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return te($,{type:"button",icon:a?yh:xh,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return Pt("fieldset",{children:[te("legend",{children:f("labels.pressure")}),te("div",{className:"buttonList",children:te(tn,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:xh},{value:"variable",text:f("labels.pressure_variable"),icon:yh}],value:i,onChange:a=>t(a)})})]})}}),koe=G({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Dt(e,n,o=>dt(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>Pt("fieldset",{children:[te("legend",{children:f("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(tn,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:bh},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:G1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:H1}],value:ht(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),E6=G({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Dt(e,n,o=>dt(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=ht(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return te(dw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),b6=G({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>pg(e,n,o,()=>($d(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=ai(o);return Pt("fieldset",{children:[te("legend",{children:f("labels.fontSize")}),te("div",{className:"buttonList",children:te(tn,{group:"font-size",options:[{value:Kd.sm,text:f("labels.small"),icon:s0,testId:"fontSize-small"},{value:Kd.md,text:f("labels.medium"),icon:c0,testId:"fontSize-medium"},{value:Kd.lg,text:f("labels.large"),icon:d0,testId:"fontSize-large"},{value:Kd.xl,text:f("labels.veryLarge"),icon:m0,testId:"fontSize-veryLarge"}],value:ht(e,o,a=>{if(Ct(a))return a.fontSize;let l=ho(a,o.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>Ct(a)||ho(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||YL),onChange:a=>{aa(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),ug=G({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Qr,trackEvent:!1,perform:(e,n,t,o)=>pg(e,n,o,r=>Math.round(1/(1+vw)*r.fontSize)),keyTest:e=>e[ha.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ha.CHEVRON_LEFT||e.key===ha.COMMA)}),hg=G({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Qr,trackEvent:!1,perform:(e,n,t,o)=>pg(e,n,o,r=>Math.round(r.fontSize*(1+vw))),keyTest:e=>e[ha.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ha.CHEVRON_RIGHT||e.key===ha.PERIOD)}),x6=G({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Dt(e,n,g=>{let b=r?.get(g.id);return b?dt(g,{...b}):g},!0),appState:{...n,...l},captureUpdate:at.NEVER};$d(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,c=at.EVENTUALLY,m,p=!1;if(s)m=s,c=at.IMMEDIATELY;else if(d){m=d,c=at.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Ct(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let w=E[g];b+=w?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...l},captureUpdate:c};if(m&&!p){let E=new Map,g=new Set,b=!1,w=Array.from(Do.loadedFontsCache.values()),y=Object.entries(KL).find(([T,P])=>P===m)?.[0];d&&y&&w.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Dt(e,n,T=>{if(Ct(T)&&(T.fontFamily!==m||s)){let P=dt(T,{fontFamily:m,lineHeight:pw(m)}),C=r?.get(T.containerId||"")||{},k=o.scene.getContainerElement(T);return a&&k&&C&&o.scene.mutateElement(k,{...C}),b||(g=new Set([...g,...Array.from(P.originalText)])),E.set(P,k),P}return T},!0)});let x=`10px ${$L({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,P]of E)ss(T,P,o.scene);else o.fonts.loadFontFamily(m,I).then(()=>{for(let[T,P]of E){let C=o.scene.getElement(T.id),k=P?o.scene.getElement(P.id):null;C&&(jL(m)&&Ct(C)&&C.fontFamily===m&&(o.scene.mutateElement(C,{lineHeight:pw(m)}),C=o.scene.getElement(T.id)??C),ss(C,k,o.scene))}}).catch(T=>{console.error("Failed to load selected font",T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=sg(new Map),i=sg({fontFamily:null,googleFamily:null}),[a,l]=zL({}),s=sg(!0),{stylesPanelMode:d,isCompact:c}=ai(t),m=dg(()=>{let y=(T,P)=>ht(T,t,C=>{if(Ct(C))return C.fontFamily;let k=ho(C,P);return k?k.fontFamily:null},C=>Ct(C)||ho(C,P)!==null,C=>C?null:n.currentItemFontFamily||mw),x=(T,P)=>ht(T,t,C=>{let k=Ct(C)?C:ho(C,P);return k?mn(k.fontFamily)?.family??null:null},C=>Ct(C)||ho(C,P)!==null,C=>C?null:mn(n.currentItemFontFamily||mw)?.family??null),I=(T,P)=>({fontFamily:y(T,P),googleFamily:x(T,P)});return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?I(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?I(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]),p=m.fontFamily;lg(()=>{i.current=m},[m]);let{googleFonts:u}=St(),{family:E,weights:g,selectedWeight:b}=nw(m,u),w=y=>tw(y,p,u?.libraryFonts,t.fonts.getSceneFamilies());return lg(()=>{Object.keys(a).length&&(o(a),l({}))},[a]),lg(()=>(s.current=!1,()=>{s.current=!0}),[]),Pt(qd,{children:[d==="full"&&te("legend",{children:f("labels.fontFamily")}),te(Jy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:d!=="full",onSelect:y=>{let x=w(y);aa(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:x}),r.current.clear()},c,!!n.editingTextElement)},onHover:y=>{l({currentHoveredFontFamily:w(y),cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:y=>{if(y){r.current.clear();let{editingTextElement:x}=n;if(x?.type==="text"){let I=t.scene.getElement(x.id);r.current.set(x.id,dt(I||x,{},!0))}else{let I=de(e,n,{includeBoundTextElement:!0});for(let T of I)r.current.set(T.id,dt(T,{},!0))}l({...a,openPopup:"fontFamily"})}else{let x={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...x}),r.current.clear(),c&&n.editingTextElement&&ql(null)}}}),E&&g&&g.length>1&&te(ow,{family:E,weights:g,selectedWeight:b,compactMode:d!=="full",onEditWeights:u?.onEditWeights,onSelect:y=>{aa(()=>l({currentItemFontFamily:Lo(E,y)}),c,!!n.editingTextElement)}})]})}}),y6=G({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Dt(e,n,r=>{if(Ct(r)){let i=dt(r,{textAlign:t});return ss(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=ai(o);return Pt("fieldset",{children:[te("legend",{children:f("labels.textAlign")}),te("div",{className:"buttonList",children:te(tn,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:u0,testId:"align-left"},{value:"center",text:f("labels.center"),icon:h0,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:g0,testId:"align-right"}],value:ht(e,o,l=>{if(Ct(l))return l.textAlign;let s=ho(l,i);return s?s.textAlign:null},l=>Ct(l)||ho(l,i)!==null,l=>l?null:n.currentItemTextAlign),onChange:l=>{aa(()=>t(l),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),w6=G({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Dt(e,n,r=>{if(Ct(r)){let i=dt(r,{verticalAlign:t});return ss(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=ai(o);return te("fieldset",{children:te("div",{className:"buttonList",children:te(tn,{group:"text-align",options:[{value:Yd.TOP,text:f("labels.alignTop"),icon:te(f0,{theme:n.theme}),testId:"align-top"},{value:Yd.MIDDLE,text:f("labels.centerVertically"),icon:te(b0,{theme:n.theme}),testId:"align-middle"},{value:Yd.BOTTOM,text:f("labels.alignBottom"),icon:te(E0,{theme:n.theme}),testId:"align-bottom"}],value:ht(e,o,a=>{if(Ct(a)&&a.containerId)return a.verticalAlign;let l=ho(a,o.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>Ct(a)||ho(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Yd.MIDDLE),onChange:a=>{aa(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Moe=G({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Dt(e,n,o=>ww(o)?o:dt(o,{roundness:t==="round"?{type:o6(o.type)?Xd.ADAPTIVE_RADIUS:Xd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Wi(yw(e),n).some(l=>l.roundness?.type===Xd.LEGACY);return Pt("fieldset",{children:[te("legend",{children:f("labels.edges")}),Pt("div",{className:"buttonList",children:[te(tn,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:Y1},{value:"round",text:f("labels.round"),icon:K1}],value:ht(e,o,l=>a?null:l.roundness?"round":"sharp",l=>!Zd(l)&&l.hasOwnProperty("roundness"),l=>l?null:n.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),Ew=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:te(X1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:te(Z1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:te($1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:te(j1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:te(q1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(J1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:te(Q1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:te(e0,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:te(t0,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:te(n0,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:te(o0,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:te(r0,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:te(i0,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:te(a0,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:te(l0,{flip:e}),keyBinding:null}]}]}),Aoe=G({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>($d(t,"actionChangeArrowhead: value must be defined"),{elements:Dt(e,n,o=>{if(cg(o)){let{position:r,type:i}=t;if(r==="start")return dt(o,{startArrowhead:i});if(r==="end")return dt(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:at.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=lo().rtl,i=dg(()=>Ew(!r),[r]),a=dg(()=>Ew(!!r),[r]);return Pt("fieldset",{children:[te("legend",{children:f("labels.arrowheads")}),Pt("div",{className:"iconSelectList buttonList",children:[te(ig,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:ht(e,o,l=>cg(l)&&Rl(l.type)?gw(l.startArrowhead):n.currentItemStartArrowhead,!0,l=>l?null:n.currentItemStartArrowhead),onChange:l=>t({position:"start",type:l})}),te(ig,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:ht(e,o,l=>cg(l)&&Rl(l.type)?gw(l.endArrowhead):n.currentItemEndArrowhead,!0,l=>l?null:n.currentItemEndArrowhead),onChange:l=>t({position:"end",type:l})})]})]})}}),v6=G({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>Pt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Loe=G({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Dt(e,n,l=>{if(!Zd(l))return l;let s=o.scene.getNonDeletedElementsMap(),d=ii.getPointAtIndexGlobalCoordinates(l,0,s),c=ii.getPointAtIndexGlobalCoordinates(l,-1,s),m=dt(l,{x:t===bn.elbow?d[0]:l.x,y:t===bn.elbow?d[1]:l.y,roundness:t===bn.round?{type:Xd.PROPORTIONAL_RADIUS}:null,elbowed:t===bn.elbow,angle:t===bn.elbow?0:l.angle,points:t===bn.elbow||l.elbowed?[ii.pointFromAbsoluteCoords({...l,x:d[0],y:d[1],angle:0},d,s),ii.pointFromAbsoluteCoords({...l,x:d[0],y:d[1],angle:0},c,s)]:l.points});if(ww(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=ii.getPointAtIndexGlobalCoordinates(m,0,p),E=ii.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),w=g&&m.startBinding?{...m.startBinding,...hw(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...hw(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...i6(m,p,{points:[u,E].map(x=>OL(x[0]-m.x,x[1]-m.y)),startBinding:w,endBinding:y,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&uw(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&uw(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new ii(l,mg(e)))}return{elements:r,appState:i,captureUpdate:at.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Pt("fieldset",{children:[te("legend",{children:f("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(tn,{group:"arrowtypes",options:[{value:bn.sharp,text:f("labels.arrowtype_sharp"),icon:dr,testId:"sharp-arrow"},{value:bn.round,text:f("labels.arrowtype_round"),icon:pr,testId:"round-arrow"},{value:bn.elbow,text:f("labels.arrowtype_elbowed"),icon:mr,testId:"elbow-arrow"}],value:ht(e,o,r=>Zd(r)?r.elbowed?bn.elbow:r.roundness?bn.round:bn.sharp:null,r=>Zd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as M6,MAX_ZOOM as A6,MIN_ZOOM as L6,THEME as cs,ZOOM_STEP as Sw,CODES as li,KEYS as Qd}from"@excalidraw/common";import{getNonDeletedElements as ds}from"@excalidraw/element";import{getCommonBounds as ms}from"@excalidraw/element";import{CaptureUpdateAction as fa}from"@excalidraw/element";import{useEffect as I6}from"react";import{jsx as S6}from"react/jsx-runtime";var ga=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},gg=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=n.left+n.width/2-o.width/2;l<0?l=a:l+o.width>=r&&(l=r-o.width-a);let s;t==="bottom"?(s=n.top+n.height+a,s+o.height>=i&&(s=n.top-o.height-a)):(s=n.top-o.height-a,s<0&&(s=n.top+n.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},T6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();gg(n,r)},bt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(I6(()=>()=>ga().classList.remove("excalidraw-tooltip--visible"),[]),r?null:S6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>T6(i.currentTarget,ga(),n,t),onPointerLeave:()=>ga().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Iw,useRef as Tw,useState as C6}from"react";var P6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],fg=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},ar())}return P6(o,n)};function Er(e,n=!0){let t=Jd(),[,o]=C6(0),r=Tw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:fg(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=fg(t,e,n)),Iw(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(l=>l+1)})},[t]),r.current.latestValue}function k6(e,n){let t=Jd(),o=Tw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Iw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(fg(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as rm,jsxs as R6}from"react/jsx-runtime";var D6=G({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?fa.IMMEDIATELY:fa.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>rm(da,{palette:null,topPicks:M6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),em=G({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:th,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Ao({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:ro(n.zoom.value+Sw)},n)},captureUpdate:fa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Er(t=>t.zoom.value);return rm($,{type:"button",className:"zoom-in-button zoom-button",icon:th,title:`${f("buttons.zoomIn")} \u2014 ${B("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=A6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===li.EQUAL||e.code===li.NUM_ADD)&&(e[Qd.CTRL_OR_CMD]||e.shiftKey)}),tm=G({name:"zoomOut",label:"buttons.zoomOut",icon:nh,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Ao({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:ro(n.zoom.value-Sw)},n)},captureUpdate:fa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Er(t=>t.zoom.value);return rm($,{type:"button",className:"zoom-out-button zoom-button",icon:nh,title:`${f("buttons.zoomOut")} \u2014 ${B("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=L6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===li.MINUS||e.code===li.NUM_SUBTRACT)&&(e[Qd.CTRL_OR_CMD]||e.shiftKey)}),nm=G({name:"resetZoom",label:"buttons.resetZoom",icon:f1,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...Ao({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:ro(r)},n)},captureUpdate:fa.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Er(t=>t.zoom.value);return rm(bt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:R6($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===li.ZERO||e.code===li.NUM_ZERO)&&(e[Qd.CTRL_OR_CMD]||e.shiftKey)}),Eg=e=>[e.x,e.y,e.x+e.width,e.y+e.height],sre=G({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ud,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?ms(ds(r)):n.scrollConstraints?Eg(n.scrollConstraints):ms(ds(e)),a=Xr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...oo(a.appState)}}},keyTest:void 0}),cre=G({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ud,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?ms(ds(r)):n.scrollConstraints?Eg(n.scrollConstraints):ms(ds(e)),a=Xr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...oo(a.appState)}}},keyTest:void 0}),_6=G({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ud,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Eg(n.scrollConstraints):ms(ds(e)),i=Xr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...oo(i.appState)}}},keyTest:void 0}),om=G({name:"toggleTheme",label:(e,n)=>n.theme===cs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===cs.LIGHT?Vl:Yl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===cs.LIGHT?cs.DARK:cs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:fa.EVENTUALLY}},keyTest:e=>!e[Qd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===li.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as W6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Nw}from"@excalidraw/element/binding";import{isValidPolygon as Bw,newElementWith as xg}from"@excalidraw/element";import{LinearElementEditor as xs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as yg,isFreeDrawElement as Fw,isLinearElement as Ow,isLineElement as cm}from"@excalidraw/element";import{KEYS as dm,arrayToMap as V6,invariant as zw,shouldRotateWithDiscreteAngle as Y6,updateActiveTool as Gw}from"@excalidraw/common";import{isPathALoop as K6}from"@excalidraw/element";import{isInvisiblySmallElement as wg}from"@excalidraw/element";import{CaptureUpdateAction as vg}from"@excalidraw/element";import O6 from"clsx";import{useEffect as z6,useState as G6}from"react";import{KEYS as xn,capitalizeString as si}from"@excalidraw/common";import{useEffect as N6,useState as B6}from"react";import Cw from"clsx";import{capitalizeString as im}from"@excalidraw/common";import{Popover as am}from"radix-ui";import{jsx as ps,jsxs as F6}from"react/jsx-runtime";var Ea=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a,shortcut:l})=>{let[s,d]=B6(!1),c=t.type,m=a.type===c,p=16,{container:u}=we();return!n.some(E=>E.type===c)&&s&&d(!1),N6(()=>{let E=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>E?.()},[e]),F6(am.Root,{open:s,children:[ps(am.Trigger,{asChild:!0,children:ps($,{className:Cw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:m,disabled:n.every(E=>ot(e,E.type)),title:`${im(a.title)}${l?` \u2014 ${l}`:""}`,"aria-label":im(a.title),"aria-keyshortcuts":l,keyBindingLabel:l?.length===1?l:void 0,"data-testid":r,onSelect:()=>{d(E=>!E),i(o)}})}),ps(am.Portal,{container:u,children:ps(am.Content,{className:"tool-popover-content",sideOffset:p,collisionBoundary:u??void 0,children:n.map(({type:E,icon:g,title:b,fillable:w})=>ps($,{className:Cw({fillable:w}),type:"toggle",icon:g,checked:c===E,disabled:ot(e,E),title:im(E),"aria-label":im(b),"data-testid":`toolbar-${E}`,onSelect:()=>{e.state.activeTool.type!==E&&(Ye("toolbar",E,"ui"),e.setActiveTool({type:E}),i?.(E))}},E))})})]})};import{jsx as bg}from"react/jsx-runtime";var H6=e=>e,Ae=H6({hand:{icon:x0,letterKey:xn.H,toggle:!0},selection:{icon:id,letterKey:xn.V,fillable:!0},rectangle:{icon:qi,letterKey:xn.R,fillable:!0},diamond:{icon:Ji,letterKey:xn.D,fillable:!0},ellipse:{icon:Qi,letterKey:xn.O,fillable:!0},arrow:{icon:ad,letterKey:xn.A,fillable:!0},line:{icon:lr,letterKey:xn.L,fillable:!0},freedraw:{icon:co,letterKey:xn.P},text:{icon:Bn,letterKey:xn.T},image:{icon:qr},eraser:{icon:ld,letterKey:xn.E,toggle:!0},frame:{icon:po,letterKey:xn.F},autoshape:{icon:ti,letterKey:xn.X,fillable:!1},embeddable:{icon:sr},laser:{icon:uo},bucketfill:{icon:mo},lasso:{icon:ji,fillable:!1}}),Pw=["selection","freedraw","text","image","eraser"],br=["autoshape","rectangle","diamond","ellipse","arrow","line"],ba=Object.keys(Ae).filter(e=>Ae[e].toggle),lm=e=>{let{letterKey:n,shiftKey:t}=Ae[e];if(!n)return n;let o=si(typeof n=="string"?n:n[0]);return t?B(`Shift+${o}`):o},Go=e=>lm(e),U6=e=>{let n=lm(e);return n?.length===1?n:void 0},kw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ae)){let{letterKey:i,shiftKey:a}=Ae[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},ot=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,_t=(e,n)=>{let t=Ae[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:l,hideShortcut:s})=>{let d=si(f(`toolBar.${e}`)),c=s?null:Go(o);return bg($,{className:O6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:ot(i,e),title:c?`${d} \u2014 ${c}`:d,keyBindingLabel:l||s?void 0:U6(o),"aria-label":d,"aria-keyshortcuts":c??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Ye("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${si(e)}IconButton`,r},sm=_t("hand"),Mw=_t("rectangle"),Aw=_t("diamond"),Lw=_t("ellipse"),Dw=_t("arrow"),_w=_t("line"),us=_t("freedraw"),hs=_t("text"),gs=_t("image"),fs=_t("eraser"),Rw=_t("frame"),Fre=_t("autoshape"),Es=_t("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ye("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),bs=_t("lasso",{shortcutType:"selection"}),ci=({app:e,activeTool:n,setAppState:t,hideShortcut:o})=>{let r=[{type:"selection",icon:Ae.selection.icon,fillable:Ae.selection.fillable,title:si(f("toolBar.selection"))},{type:"lasso",icon:Ae.lasso.icon,fillable:Ae.lasso.fillable,title:si(f("toolBar.lasso"))}],i=r.find(a=>a.type===e.state.preferredSelectionTool.type)||r[0];return bg(Ea,{app:e,options:r,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",shortcut:o?void 0:Go("selection"),onToolChange:a=>{(a==="selection"||a==="lasso")&&(e.setActiveTool({type:a}),t({preferredSelectionTool:{type:a,initialized:!0}}))},displayedOption:i})},xa=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ae.freedraw.icon,fillable:Ae.freedraw.fillable,title:si(f("toolBar.freedraw"))},{type:"autoshape",icon:Ae.autoshape.icon,fillable:Ae.autoshape.fillable,title:si(f("toolBar.autoshape"))}],[o,r]=G6(n.type==="autoshape"?"autoshape":"freedraw");z6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return bg(Ea,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as X6}from"react/jsx-runtime";var xt=G({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:l}=o,s=l.getNonDeletedElementsMap(),d=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=xs.getElement(n.selectedLinearElement.elementId,s);zw(y,"Arrow element should exist if selectedLinearElement is set"),zw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=xs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(yg(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,P=Y6(b),C=b[dm.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),k=T.reduce((M,_)=>(M.set(_,{point:P?y.points[_]:xs.createPointAt(y,s,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,C)}),M),new Map)??new Map;Nw(y,k,w.x,w.y,l,n,{newArrow:I,altKey:b.altKey,angleLocked:P,gridSize:o.getEffectiveGridSize()})}else cm(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Bw(y.points)&&l.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&wg(y)&&(i=i.map(T=>T.id===y.id?xg(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||wg(y)?e.map(T=>T.id===y.id?xg(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:d?{}:n.selectedElementIds,selectedLinearElement:I||d?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:vg.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=o.drawShape.hasPendingGesture();(c||d)&&(o.drawShape.finalize(),c&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!d&&!c&&(n.newElement?.type==="freedraw"||yg(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=s.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:w}=n.selectedLinearElement;if((!w||b[b.length-1]!==w)&&(r=!1,l.mutateElement(m,{points:m.points.slice(0,-1)}),yg(m)&&m.endBinding&&m.points.length>1)){let y=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=xs.getPointAtIndexGlobalCoordinates(m,-1,s);Nw(m,x,I[0],I[1],l,n,{newArrow:y})}}if(m&&wg(m)&&(i=i.map(b=>b.id===m?.id?xg(b,{isDeleted:!0}):b)),Ow(m)||Fw(m)){if(K6(m.points,n.zoom.value)&&(cm(m)||Fw(m))){let w=m.points,y=w[0],x=w.map((I,T)=>T===w.length-1?W6(y[0],y[1]):I);cm(m)?l.mutateElement(m,{points:x,polygon:!0}):l.mutateElement(m,{points:x})}cm(m)&&!Bw(m.points)&&l.mutateElement(m,{polygon:!1})}}let p;ba.includes(n.activeTool.type)?p=Gw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=Gw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&Ow(m)?new xs(m,V6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:d?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:d?null:g},captureUpdate:r?vg.IMMEDIATELY:vg.NEVER}},keyTest:(e,n)=>e.key===dm.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===dm.ESCAPE||e.key===dm.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>X6($,{type:"button",icon:P1,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Ww,isSomeElementSelected as Z6,makeNextSelectedElementIds as $6,selectGroupsForSelectedElements as j6}from"@excalidraw/element";import{CaptureUpdateAction as Hw}from"@excalidraw/element";import{KEYS as q6,isWritableElement as J6,updateActiveTool as Uw}from"@excalidraw/common";var Q6=(e,n)=>ba.includes(e.activeTool.type)?Uw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Uw(e,{type:n.state.preferredSelectionTool.type}),eD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:Ww(o,e.editingGroupId);for(let a of i){let l=a.groupIds.indexOf(e.editingGroupId);if(l!==-1&&a.groupIds[l+1])return a.groupIds[l+1]}return null},tD=G({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=Q6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Ww(i,n.editingGroupId).reduce((l,s)=>(l[s.id]=!0,l),{});return{appState:{...n,...j6({editingGroupId:eD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Hw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:$6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Hw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==q6.ESCAPE||J6(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||Z6(o.scene.getNonDeletedElements(),n))});import{KEYS as ym,THEME as Ts}from"@excalidraw/common";import{CaptureUpdateAction as Gn}from"@excalidraw/element";import nD from"clsx";import{jsx as Vw,jsxs as oD}from"react/jsx-runtime";var Ig=({children:e,checked:n,onChange:t,className:o})=>oD("div",{className:nD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Vw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:sd}),Vw("div",{className:"Checkbox-label",children:e})]});import{THEME as ys}from"@excalidraw/common";import{jsx as ws}from"react/jsx-runtime";var Kw=e=>{let n=e.title||(e.value===ys.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return ws($,{type:"icon",icon:e.value===ys.LIGHT?Yw.MOON:Yw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===ys.DARK?ys.LIGHT:ys.DARK),"data-testid":"toggle-dark-mode"})},Yw={SUN:ws("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ws("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:ws("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ws("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 rD}from"react";import{focusNearestParent as iD,KEYS as aD}from"@excalidraw/common";import{jsx as Xw,jsxs as lD}from"react/jsx-runtime";var Zw=e=>{let{id:n}=we(),[t,o]=rD(e.value),r=a=>{e.ignoreFocus||iD(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===aD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return lD("div",{className:"ProjectName",children:[Xw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Xw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as sD,useEffect as cD,useRef as dD}from"react";import{jsx as mm,jsxs as hD}from"react/jsx-runtime";var mD=5e3,pD=({progress:e})=>mm("div",{className:"Toast__progress-bar",children:mm("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),uD=({message:e,onClose:n,closable:t=!1,duration:o=mD,style:r})=>{let i=dD(0),a=o!==1/0,l=sD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return cD(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,o,a]),hD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[mm("div",{className:"Toast__message",children:e}),t&&mm($,{icon:un,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},pm=Object.assign(uD,{ProgressBar:pD});import{DEFAULT_EXPORT_PADDING as _D,DEFAULT_FILENAME as RD,IMAGE_MIME_TYPES as ev,isFirefox as ND,MIME_TYPES as BD,cloneJSON as FD,SVG_DOCUMENT_PREAMBLE as OD,arrayToMap as zD}from"@excalidraw/common";import{getNonDeletedElements as GD}from"@excalidraw/element";import{isFrameLikeElement as HD}from"@excalidraw/element";import{getElementsOverlappingFrame as UD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as gD,EXPORT_DATA_TYPES as vs,MIME_TYPES as Re,arrayToMap as fD,isMemberOf as ED,isPromiseLike as bD,EVENT as um}from"@excalidraw/common";import{mutateElement as xD}from"@excalidraw/element";import{deepCopyElement as yD}from"@excalidraw/element";import{isFrameLikeElement as wD,isInitializedImageElement as jw}from"@excalidraw/element";import{getContainingFrame as $w}from"@excalidraw/element";var qw=`web ${Re.excalidrawClipboard}`,tae="clipboard"in navigator&&"readText"in navigator.clipboard,hm="clipboard"in navigator&&"writeText"in navigator.clipboard,xr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,vD=()=>"clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,ID=e=>!!([vs.excalidraw,vs.excalidrawClipboard,vs.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),gm=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(um.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},TD=({elements:e,files:n})=>{let t=fD(e),o=new Set(e.filter(l=>wD(l))),r=!1,i=e.reduce((l,s)=>(jw(s)&&(r=!0,n&&n[s.fileId]&&(l[s.fileId]=n[s.fileId])),l),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:vs.excalidrawClipboard,elements:e.map(l=>{if($w(l,t)&&!o.has($w(l,t))){let s=yD(l);return xD(s,t,{frameId:null}),s}return l}),files:n?i:void 0};return JSON.stringify(a)},SD=async e=>{let n=await createImageBitmap(e);try{let t=document.createElement("canvas");t.width=n.width,t.height=n.height;let o=t.getContext("2d");if(!o)throw new Error("Could not create a canvas context for clipboard image");return o.drawImage(n,0,0),await new Promise((r,i)=>{t.toBlob(a=>{a?r(a):i(new Error("Could not encode clipboard image as PNG"))},Re.png)})}finally{n.close()}},fm=async(e,n,t)=>{let o=TD({elements:e,files:n}),r=e.length===1&&jw(e[0])?n?.[e[0].fileId]:null,i=r&&Ju(r.mimeType)&&r.dataURL?$x(r.dataURL,r.fileName):null;if(i){let a=i.type===Re.png?i:SD(i);if(vD())try{await navigator.clipboard.write([new ClipboardItem({[qw]:new Blob([o],{type:Re.excalidrawClipboard}),[Re.png]:a})]);return}catch(l){console.error("Error copying image with ClipboardItem",l)}if(t?.clipboardData?.items)try{let l=i.type===Re.png?i:new File([await a],`${i.name.replace(/\.[^/.]+$/,"")||"image"}.png`,{type:Re.png});t.clipboardData.items.add(l),await go({[Re.excalidrawClipboard]:o},t);return}catch(l){console.error("Error copying image to clipboard event",l)}}await go({[Re.excalidrawClipboard]:o,[Re.text]:o},t)};function Jw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(Jw(t));return n}var CD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,Re.html),o=Jw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Em=async()=>{let e={},n;try{n=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 o=await navigator.clipboard?.readText();if(o)return{[Re.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types){if(o===qw){try{e[Re.excalidrawClipboard]=await(await t.getType(o)).text()}catch(r){console.warn(`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}continue}if(ED(gD,o))try{if(o===Re.text||o===Re.html||o===Re.excalidrawClipboard)e[o]=await(await t.getType(o)).text();else if(Ju(o)){let r=await t.getType(o),i=e1(r,o,void 0);e[o]=i}else throw new $u(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof $u?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},PD=async(e,n=!1)=>{try{let t=e.findByType(Re.html),o=!n&&t&&CD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(Re.text)??o.value.map(r=>r.value).join(`
|
|
2
|
+
`).trim()}:o:{type:"text",value:(e.getData(Re.text)||"").trim()}}catch{return{type:"text",value:""}}},kD=function(e){return this.find(n=>n.type===e)||null},MD=function(e){return this.find(t=>t.type===e)?.value??null},AD=function(){return this.filter(e=>e.kind==="file")},Tg=e=>{let n=Sg(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),Re.text,Re.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},LD=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),bm=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},l=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===Re.html)try{let E=new DOMParser().parseFromString(u.value,Re.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===Re.text?a(r,u.value):u.type==="text/uri-list"&&l(r,u.value)});let s=[...o,...r.filter(u=>!o.includes(u))],d=Array.from({length:n},()=>({})),c={...t??{items:[],files:[],types:[],data:{}},parsedItems:LD(e)};d.forEach((u,E)=>{let g=s[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=c});let m=s.slice(d.length),p=d[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),d},Qw=e=>{let n;Sg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},yr=async e=>{let n;Sg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await Qx(o);return r=await jr(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(l=>a(l))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:kD,getData:MD,getFiles:AD})},Is=async(e,n=!1)=>{let t=e.getData(Re.excalidrawClipboard),o=t?{type:"text",value:t}:await PD(e,n);if(o.type==="mixedContent")return{mixedContent:o.value};try{let r=JSON.parse(o.value),i=r.type===vs.excalidrawClipboardWithAPI;if(ID(r))return{elements:r.elements,files:r.files,text:n?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:i}}catch{}return{text:o.value}},xm=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[Re.png]:e})])}catch(n){if(bD(e))await navigator.clipboard.write([new ClipboardItem({[Re.png]:await e})]);else throw n}},go=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[Re.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===Re.text);if(hm&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!DD(o[1]))throw new Error("Error copying to clipboard.")},DD=e=>{e||(e=" ");let n=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[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}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},Sg=e=>e.type===um.PASTE||e.type===um.COPY||e.type===um.CUT;var di=(e,{selectedElementIds:n},t)=>{let o=GD(e),r=zD(o),i=t&&Oe(o,{selectedElementIds:n}),a=null,l=i?de(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let s=l[0];l.length===1&&HD(s)?(a=s,l=UD(o,s,r)):l.length>1&&(l=de(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:FD(l)}},mi=async(e,n,t,o,{exportBackground:r,exportPadding:i=_D,viewBackgroundColor:a,name:l=t.name||RD,fileHandle:s=null,exportingFrame:d=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Zr(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:d});if(e==="svg")return ju(m.then(p=>new Blob([OD+p.outerHTML],{type:BD.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ev.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await go(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let c=Qc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let m=Hl(c);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-XO3VLL25.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Fl(n,t,o,"local")})))),ju(m,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ev.png],fileHandle:s})}else if(e==="clipboard")try{let m=Hl(c);await xm(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):ND&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
|
|
3
3
|
|
|
4
|
-
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Fw=async(e,n,t)=>{let o=Rx(n);if(!Nx(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:l,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:d,exportingFrame:c}=ii(r,i,!1);return await ai(o,d,i,a,{exportBackground:l,viewBackgroundColor:s,name:t,fileHandle:n,exportingFrame:c}),{fileHandle:n}};import{Fragment as xD,jsx as Er,jsxs as Hw}from"react/jsx-runtime";var fg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Nn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>Er(Aw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Ow=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Nn.EVENTUALLY})}),Eg=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Nn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Er(pg,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),pm=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Nn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Hw(pg,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),Er(bt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Er("div",{className:"excalidraw-tooltip-icon",children:f1})})]})}),pa=!1,gg=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Hw(xD,{children:[t,Er(om.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function bD(e,n){if(n.app.state.isLoading&&(gg(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")gg(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(gg(n.app,{progress:null}),await e)}function zw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async l=>{try{o.props.onExport&&await bD(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,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)}l({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var li=O({name:"saveToActiveFile",label:"buttons.save",icon:Ol,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(pa)return!1;pa=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:l}=zw(e,n,o.files,o);try{let{fileHandle:s}=Kc(r)?await Fw(l,r,i):await Gc({data:l,filename:i,fileHandle:r});return{captureUpdate:Nn.NEVER,appState:{fileHandle:s,toast:{message:r&&s?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(s){return a.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:Nn.NEVER,appState:{toast:null}}}finally{pa=!1}},keyTest:e=>!1}),bs=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Ol,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(pa)return!1;pa=!0;let{abortController:r,data:i}=zw(e,n,o.files,o);try{let{fileHandle:a}=await Gc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Nn.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:Nn.NEVER,appState:{toast:null}}}finally{pa=!1}},keyTest:e=>e.key.toLowerCase()===mm.S&&e.shiftKey&&e[mm.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Er($,{type:"button",icon:m1,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:me().formFactor==="phone",hidden:!Oi,onClick:()=>e(null),"data-testid":"save-as-button"})}),ua=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await Wu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Nn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Nn.EVENTUALLY}}},keyTest:e=>e[mm.CTRL_OR_CMD]&&e.key===mm.O}),Gw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Es.DARK:Es.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Nn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Er("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Er(kw,{value:e.exportWithDarkMode?Es.DARK:Es.LIGHT,onChange:t=>{n(t===Es.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as yD,DEFAULT_FONT_FAMILY as wD,DEFAULT_TEXT_ALIGN as vD,getLineHeight as ID}from"@excalidraw/common";import{newElementWith as um}from"@excalidraw/element";import{hasBoundTextElement as TD,canApplyRoundnessTypeToElement as SD,getDefaultRoundnessTypeForElement as CD,isFrameLikeElement as PD,isArrowElement as kD,isExcalidrawElement as MD,isTextElement as Uw}from"@excalidraw/element";import{getBoundTextElement as AD,redrawTextBoundingBox as LD}from"@excalidraw/element";import{CaptureUpdateAction as bg}from"@excalidraw/element";var Ww="{}",DD=O({name:"copyStyles",label:"labels.copyStyles",icon:gh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&TD(i)){let a=AD(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Ww=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:bg.EVENTUALLY}}}),_D=O({name:"pasteStyles",label:"labels.pasteStyles",icon:gh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Ww),i=r[0],a=r[1];if(!MD(i))return{elements:e,captureUpdate:bg.EVENTUALLY};let l=de(e,n,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let c=i;if(Uw(d)&&d.containerId&&(c=a),!c)return d;let p=um(d,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?SD(c.roundness.type,d)?c.roundness:CD(d):null});if(Uw(p)){let m=c.fontSize||yD,u=c.fontFamily||wD,E=um(p,{fontSize:m,fontFamily:u,textAlign:c.textAlign||vD,lineHeight:c.lineHeight||ID(u)});p=E;let g=null;E.containerId&&(g=l.find(b=>b.id===E.containerId)||null),LD(E,g,o.scene)}return p.type==="arrow"&&kD(c)&&(p=um(p,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),PD(d)&&(p=um(p,{roundness:null,backgroundColor:"transparent"})),p}return d}),captureUpdate:bg.IMMEDIATELY}}});import{KEYS as RD}from"@excalidraw/common";import{CaptureUpdateAction as ND}from"@excalidraw/element";var si=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:a1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:ND.EVENTUALLY}),keyTest:e=>e.key===RD.QUESTION_MARK});import{getNonDeletedElements as gm}from"@excalidraw/element";import{newElementWith as Yw}from"@excalidraw/element";import{isBoundToContainer as BD}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as FD,getElementsInResizingFrame as OD,getFrameLikeElements as zD,getRootElements as GD,groupByFrameLikes as HD,removeElementsFromFrame as UD,replaceAllElementsInFrame as WD}from"@excalidraw/element";import{KEYS as fm,randomId as VD,arrayToMap as yg}from"@excalidraw/common";import{getSelectedGroupIds as hm,selectGroup as YD,selectGroupsForSelectedElements as KD,getElementsInGroup as Vw,addToGroup as XD,removeFromSelectedGroups as ZD,isElementInGroup as Kw}from"@excalidraw/element";import{syncMovedIndices as $D}from"@excalidraw/element";import{CaptureUpdateAction as xs}from"@excalidraw/element";import{jsx as ha}from"react/jsx-runtime";var jD=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>Kw(i,r)))return!0}return!1},xg=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!jD(t,e.editingGroupId)&&!FD(t)},wg=O({name:"group",label:"labels.group",icon:e=>ha(sh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!xg(n,o))return!1;let r=GD(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:xs.EVENTUALLY};let i=hm(n);if(i.length===1){let b=i[0],w=new Set(Vw(e,b).map(I=>I.id)),y=new Set(r.map(I=>I.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:n,elements:e,captureUpdate:xs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&HD(r).forEach((w,y)=>{UD(w,o.scene.getNonDeletedElementsMap())});let s=VD(),d=yg(r);a=a.map(b=>d.get(b.id)?Yw(b,{groupIds:XD(b.groupIds,s,n.editingGroupId)}):b);let c=Vw(a,s),p=c[c.length-1],m=a.lastIndexOf(p),u=a.slice(m+1),E=a.slice(0,m).filter(b=>!Kw(b,s)),g=$D([...E,...c,...u],yg(c));return{appState:{...n,...YD(s,{...n,selectedGroupIds:{}},gm(a))},elements:g,captureUpdate:xs.IMMEDIATELY}},predicate:(e,n,t,o)=>xg(n,o),keyTest:e=>!e.shiftKey&&e[fm.CTRL_OR_CMD]&&e.key===fm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ha($,{hidden:!xg(n,o),type:"button",icon:ha(sh,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Oe(gm(e),n)})}),vg=O({name:"ungroup",label:"labels.ungroup",icon:e=>ha(ch,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=hm(n),i=yg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:xs.EVENTUALLY};let a=[...e],l=[];a=a.map(m=>{BD(m)&&l.push(m.id);let u=ZD(m.groupIds,n.selectedGroupIds);return u.length===m.groupIds.length?m:Yw(m,{groupIds:u})});let s=KD(n,gm(a),n,null),d=o.scene.getSelectedElements(n),c=new Set(d.filter(m=>m.frameId).map(m=>m.frameId));return zD(e).filter(m=>c.has(m.id)).forEach(m=>{m&&(a=WD(a,OD(a,m,n,i),m))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((m,[u,E])=>(E&&!l.includes(u)&&(m[u]=!0),m),{}),{appState:{...n,...s},elements:a,captureUpdate:xs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[fm.CTRL_OR_CMD]&&e.key===fm.G.toUpperCase(),predicate:(e,n)=>hm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ha($,{type:"button",hidden:hm(n).length===0,icon:ha(ch,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Oe(gm(e),n)})});import o_ from"clsx";import{CaptureUpdateAction as qw}from"@excalidraw/element";import{invariant as r_}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as qD,COLOR_VOICE_CALL as JD,COLOR_WHITE as bm,THEME as QD,UserIdleState as Xw}from"@excalidraw/common";var Em=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function e_(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var ci=(e,n)=>`hsl(${Math.abs(e_(n?.id||e))%37*10}, 100%, 83%)`,Zw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},$w=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,p=14,m=l<0||l>o-c||s<0||s>r-p;l=Math.max(l,0),l=Math.min(l,o-c),s=Math.max(s,0),s=Math.min(s,r-p);let u=ci(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=m||E===Xw.IDLE||E===Xw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===QD.DARK?"#2f6330":JD,w=d?.isSpeaking;w&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=bm,e.strokeStyle=bm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!m&&y){e.font="600 12px sans-serif";let x=(w?l+0:l)+c/2,I=(w?s+0:s)+p+2,T=5,C=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(M,12),_=x-1,k=I-1,D=P.width+2+T*2+2,B=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,B,8),e.fillStyle=u,e.fill(),e.strokeStyle=bm,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,B+4,8),e.strokeStyle=b,e.stroke())):Em(e,_,k,D,B,8,bm),e.fillStyle=qD,e.fillText(y,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((L-M)/2)+2),w){e.fillStyle=b;let K=8,z=8,U=5;e.fillRect(_+D+z,k+(B/2-K/2),2,K),e.fillRect(_+D+z+U,k+(B/2-K*2/2),2,K*2),e.fillRect(_+D+z+U*2,k+(B/2-K/2),2,K)}}e.restore(),e.closePath()}};import t_ from"clsx";import{useState as n_}from"react";import{jsx as jw}from"react/jsx-runtime";var Ig=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Zw(t),[a,l]=n_(!1),s=!a&&o,d=s?void 0:{background:e};return jw("div",{className:t_("Avatar",r),style:d,onClick:n,children:s?jw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as so,jsxs as xm}from"react/jsx-runtime";var i_=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(r_(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:qw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:qw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,l=ci(o,r),s=o_({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?xm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[so("div",{}),so("div",{}),so("div",{})]}):r.isMuted?so("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:b0}):so("div",{title:f("userList.hint.inCall"),children:E0}):null;return i?xm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[so(Ig,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),so("div",{className:"UserList__collaborator-name",children:r.username}),xm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&so("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Jr}),r.isCurrentUser&&` (${f("labels.you")})`,d]})]}):xm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[so(Ig,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),d&&so("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{getNonDeletedElements as ga}from"@excalidraw/element";import{isFrameLikeElement as c_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as d_}from"@excalidraw/element";import{KEYS as br,arrayToMap as m_}from"@excalidraw/common";import{alignElements as p_}from"@excalidraw/element";import{CaptureUpdateAction as mi}from"@excalidraw/element";import{getSelectedElementsByGroup as u_}from"@excalidraw/element";import a_ from"clsx";import{jsx as Jw}from"react/jsx-runtime";var di=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>Jw("div",{className:a_("Switch",{toggled:t,disabled:r}),children:Jw("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var l_={stacking:!1},s_={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},co=(e,n)=>({smartZoom:{...s_,...n?.smartZoom},align:{...l_,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as xr,jsxs as w_}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return u_(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>c_(o))},fa=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=co(n,t.props.editorPreferences),l=p_(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),s=m_(l);return d_(e.map(d=>s.get(d.id)||d),n,t)},h_=O({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>{let r=co(n,o.props.editorPreferences).align.stacking,i=typeof t=="boolean"?t:!r;return o.props.onEditorPreferencesChange?.({align:{stacking:i}}),{appState:{...n,alignConfiguration:{stacking:i}},captureUpdate:mi.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=co(e,t.editorPreferences).align.stacking;return w_("div",{className:"align-stacking-toggle",children:[xr("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),xr(di,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),g_=O({name:"alignTop",label:"labels.alignTop",icon:nh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"start",axis:"y"}),captureUpdate:mi.IMMEDIATELY}),keyTest:e=>e[br.CTRL_OR_CMD]&&e.shiftKey&&e.key===br.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:nh,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Oe(ga(e),n)})}),f_=O({name:"alignBottom",label:"labels.alignBottom",icon:oh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"end",axis:"y"}),captureUpdate:mi.IMMEDIATELY}),keyTest:e=>e[br.CTRL_OR_CMD]&&e.shiftKey&&e.key===br.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:oh,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Oe(ga(e),n)})}),E_=O({name:"alignLeft",label:"labels.alignLeft",icon:rh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"start",axis:"x"}),captureUpdate:mi.IMMEDIATELY}),keyTest:e=>e[br.CTRL_OR_CMD]&&e.shiftKey&&e.key===br.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:rh,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Oe(ga(e),n)})}),b_=O({name:"alignRight",label:"labels.alignRight",icon:ih,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"end",axis:"x"}),captureUpdate:mi.IMMEDIATELY}),keyTest:e=>e[br.CTRL_OR_CMD]&&e.shiftKey&&e.key===br.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:ih,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Oe(ga(e),n)})}),x_=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:ah,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"center",axis:"y"}),captureUpdate:mi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:ah,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Oe(ga(e),n)})}),y_=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:lh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:fa(e,n,o,{position:"center",axis:"x"}),captureUpdate:mi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xr($,{hidden:!dt(n,o),type:"button",icon:lh,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Oe(ga(e),n)})});import{getNonDeletedElements as Qw}from"@excalidraw/element";import{isFrameLikeElement as v_}from"@excalidraw/element";import{CODES as ev,KEYS as tv,arrayToMap as I_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as T_}from"@excalidraw/element";import{distributeElements as S_}from"@excalidraw/element";import{CaptureUpdateAction as nv}from"@excalidraw/element";import{getSelectedElementsByGroup as C_}from"@excalidraw/element";import{jsx as iv}from"react/jsx-runtime";var ov=(e,n)=>{let t=n.scene.getSelectedElements(e);return C_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>v_(o))},rv=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=S_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=I_(i);return T_(e.map(l=>a.get(l.id)||l),n,t)},P_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:rv(e,n,o,{space:"between",axis:"x"}),captureUpdate:nv.IMMEDIATELY}),keyTest:e=>!e[tv.CTRL_OR_CMD]&&e.altKey&&e.code===ev.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>iv($,{hidden:!ov(n,o),type:"button",icon:y1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Oe(Qw(e),n)})}),k_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:rv(e,n,o,{space:"between",axis:"y"}),captureUpdate:nv.IMMEDIATELY}),keyTest:e=>!e[tv.CTRL_OR_CMD]&&e.altKey&&e.code===ev.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>iv($,{hidden:!ov(n,o),type:"button",icon:w1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Oe(Qw(e),n)})});import{arrayToMap as av,KEYS as M_,matchKey as A_}from"@excalidraw/common";import{CaptureUpdateAction as L_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as D_}from"@excalidraw/element/frame";import{arrangeElements as __}from"@excalidraw/element/arrange";import{jsx as B_}from"react/jsx-runtime";var R_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=av(e),{arrange:i}=co(n,t.props.editorPreferences),a=__(t.scene,o,r,i.algorithm,i.gap),l=av(a);return D_(e.map(s=>l.get(s.id)||s),n,t)},N_=dt,Tg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Eh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>N_(n,o),perform:(e,n,t,o)=>({appState:n,elements:R_(e,n,o),captureUpdate:L_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&A_(e,M_.A),PanelComponent:({updateData:e})=>B_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+A")}`,children:Eh})});import{arrayToMap as lv}from"@excalidraw/common";import{CaptureUpdateAction as F_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as O_}from"@excalidraw/element/frame";import{normaliseElements as z_}from"@excalidraw/element/normalise";import{jsx as U_}from"react/jsx-runtime";var G_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=lv(e),{normalise:i}=co(n,t.props.editorPreferences),a=z_(t.scene,o,r,i.mode,i.metric),l=lv(a);return O_(e.map(s=>l.get(s.id)||s),n,t)},H_=dt,Sg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:bh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>H_(n,o),perform:(e,n,t,o)=>({appState:n,elements:G_(e,n,o),captureUpdate:F_.IMMEDIATELY}),PanelComponent:({updateData:e})=>U_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:bh})});import{getNonDeletedElements as W_}from"@excalidraw/element";import{bindOrUnbindBindingElements as V_}from"@excalidraw/element";import{getCommonBoundingBox as sv}from"@excalidraw/element";import{newElementWith as Y_}from"@excalidraw/element";import{deepCopyElement as K_}from"@excalidraw/element";import{resizeMultipleElements as X_}from"@excalidraw/element";import{isArrowElement as cv,isElbowArrow as Z_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as dv}from"@excalidraw/element";import{CODES as mv,KEYS as $_,arrayToMap as j_}from"@excalidraw/common";import{CaptureUpdateAction as pv}from"@excalidraw/element";var Cg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:v0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:dv(uv(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:pv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===mv.H}),Pg=O({name:"flipVertical",label:"labels.flipVertical",icon:w0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:dv(uv(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:pv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===mv.V&&!e[$_.CTRL_OR_CMD]}),uv=(e,n,t,o,r)=>{let i=de(W_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=q_(i,n,o,r),l=j_(a);return e.map(s=>l.get(s.id)||s)},q_=(e,n,t,o)=>{if(e.every(m=>cv(m)&&(m.startBinding||m.endBinding)))return e.map(m=>{let u=m;return Y_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=sv(e);X_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(m=>[m.id,K_(m)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),V_(e.filter(cv),o.scene,o.state);let{elbowArrows:a,otherElements:l}=e.reduce((m,u)=>Z_(u)?{...m,elbowArrows:m.elbowArrows.concat(u)}:{...m,otherElements:m.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:d}=sv(e),[c,p]=[r-s,i-d];return l.forEach(m=>o.scene.mutateElement(m,{x:m.x+c,y:m.y+p})),a.forEach(m=>o.scene.mutateElement(m,{x:m.x+c,y:m.y+p})),e};import{CODES as hv,KEYS as gv}from"@excalidraw/common";import{CaptureUpdateAction as J_}from"@excalidraw/element";var fv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:J_.NEVER}),Ea=O({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>fv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[gv.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===hv.R}),ba=O({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>fv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[gv.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===hv.R});import{isTextElement as Q_}from"@excalidraw/element";import{getTextFromElements as eR}from"@excalidraw/element";import{CODES as tR,KEYS as ym,isFirefox as nR}from"@excalidraw/common";import{CaptureUpdateAction as rn}from"@excalidraw/element";var xa=O({name:"copy",label:"labels.copy",icon:Nl,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await lm(r,o.files,t)}catch(i){return{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:rn.EVENTUALLY}},keyTest:e=>e[ym.CTRL_OR_CMD]&&e.key===ym.C}),kg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await sm()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),nR?{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(am({types:r}))}catch(i){return console.error(i),{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:rn.EVENTUALLY}},keyTest:void 0}),wm=O({name:"cut",label:"labels.cut",icon:c0,trackEvent:{category:"element"},perform:(e,n,t,o)=>(xa.perform(e,n,t,o),Ul.perform(e,n,null,o)),keyTest:e=>e[ym.CTRL_OR_CMD]&&e.key===ym.X}),oR=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:I0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:rn.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=ii(e,n,!0);try{await ai("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:rn.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:rn.EVENTUALLY}}},predicate:e=>im&&e.length>0,keywords:["svg","clipboard","copy"]}),rR=O({name:"copyAsPng",label:"labels.copyAsPng",icon:T0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:rn.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=ii(e,n,!0);try{return await ai("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:rn.EVENTUALLY}}catch(l){return console.error(l),{appState:{...n,errorMessage:l.message},captureUpdate:rn.EVENTUALLY}}},predicate:e=>gr&&e.length>0,keyTest:e=>e.code===tR.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),iR=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{lo(eR(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:rn.EVENTUALLY}},predicate:(e,n,t,o)=>im&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(Q_),keywords:["text","clipboard","copy"]});import{CODES as aR,KEYS as lR}from"@excalidraw/common";import{CaptureUpdateAction as sR}from"@excalidraw/element";var ya=O({name:"gridMode",icon:C0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:sR.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[lR.CTRL_OR_CMD]&&e.code===aR.QUOTE});import cR from"clsx";import{KEYS as Ev}from"@excalidraw/common";import{CaptureUpdateAction as dR}from"@excalidraw/element/store";import{getElementBounds as bv}from"@excalidraw/element";import{isImageElement as mR}from"@excalidraw/element/typeChecks";import{jsx as uR}from"react/jsx-runtime";var xv="Press <kbd>F</kbd> quickly to smart zoom the canvas, or hold and click on an item to smart zoom to it",wa=et(!1),yv=(e,n,t,o)=>{let r=e.filter(mR).sort((l,s)=>{let[d,c]=bv(l,n),[p,m]=bv(s,n);return c-m||d-p});if(r.length===0)return null;let i=r.findIndex(l=>l.id===t),a=o==="next"?(i+1)%r.length:(i<0?r.length-1:i-1+r.length)%r.length;return r[a]},pR=({data:e,updateData:n})=>{let t=Hi(wa);return uR($,{type:"button",icon:xh,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${Ev.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:Ev.F.toLocaleUpperCase(),className:cR({"smart-zoom-button--key-held":t})})},Bn=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:xh,viewMode:!0,perform:(e,n,t,o)=>{let r=co(n,o.props.editorPreferences).smartZoom,i=t&&t.length>0?t:de(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:dR.NEVER}},PanelComponent:pR});import{CODES as hR,KEYS as gR}from"@excalidraw/common";import{CaptureUpdateAction as fR}from"@excalidraw/element";var Bt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:tr,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:fR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[gR.CTRL_OR_CMD]&&e.altKey&&e.code===hR.S});import{CaptureUpdateAction as ER}from"@excalidraw/element";var ys=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:ER.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as bR}from"@excalidraw/element";var ws=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:bR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as xR,KEYS as yR}from"@excalidraw/common";import{CaptureUpdateAction as wR}from"@excalidraw/element";var yr=O({name:"stats",label:"stats.fullTitle",icon:y0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:wR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[yR.CTRL_OR_CMD]&&e.altKey&&e.code===xR.SLASH});import{BOUND_TEXT_PADDING as wv,ROUNDNESS as vv,TEXT_ALIGN as Sv,VERTICAL_ALIGN as Cv,arrayToMap as Pv,getFontString as vR,getStrokeWidthByKey as IR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as TR,isBoundToContainer as Iv,resetOriginalContainerCache as SR,updateOriginalContainerCache as CR}from"@excalidraw/element";import{computeBoundTextPosition as PR,computeContainerDimensionForBoundText as Tv,getBoundTextElement as kv,redrawTextBoundingBox as Mv}from"@excalidraw/element";import{hasBoundTextElement as kR,isArrowElement as MR,isTextBindableContainer as Mg,isTextElement as vs,isUsingAdaptiveRadius as AR}from"@excalidraw/element";import{measureText as LR}from"@excalidraw/element";import{syncMovedIndices as Av}from"@excalidraw/element";import{newElement as DR}from"@excalidraw/element";import{CaptureUpdateAction as Ag}from"@excalidraw/element";var Lg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>kR(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=kv(a,i);if(l){let{width:s,height:d}=LR(l.originalText,vR(l),l.lineHeight),c=TR(a.id);SR(a.id);let{x:p,y:m}=PR(a,l,i);o.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:p,y:m}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:n,captureUpdate:Ag.IMMEDIATELY}}}),Dg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=vs(r[0])||vs(r[1]),a;if(Mg(r[0])?a=r[0]:Mg(r[1])&&(a=r[1]),i&&a&&kv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;vs(r[0])&&Mg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Cv.MIDDLE,textAlign:Sv.CENTER,autoResize:!0,angle:MR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Mv(i,a,o.scene),CR(a.id,l),{elements:_R(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Ag.IMMEDIATELY}}}),_R=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),Av(o,Pv([n,t])),o},RR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),Av(o,Pv([n,t])),o},Lv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>vs(a)&&!Iv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let l of r)if(vs(l)&&!Iv(l)){let s=DR({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:IR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:AR("rectangle")?vv.ADAPTIVE_RADIUS:vv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-wv,y:l.y-wv,width:Tv(l.width,"rectangle"),height:Tv(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>d.includes(p.id)).forEach(p=>{let m=p.startBinding,u=p.endBinding;m?.elementId===l.id&&(m={...m,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(m||u)&&o.scene.mutateElement(p,{startBinding:m,endBinding:u})})}o.scene.mutateElement(l,{containerId:s.id,verticalAlign:Cv.MIDDLE,boundElements:null,textAlign:Sv.CENTER,autoResize:!0}),Mv(l,s,o.scene),i=RR([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Ag.IMMEDIATELY}}});import{getNonDeletedElements as Hv,isEmbeddableElement as qR}from"@excalidraw/element";import{KEYS as Uv}from"@excalidraw/common";import{CaptureUpdateAction as JR}from"@excalidraw/element";import{pointFrom as Nv}from"@excalidraw/math";import NR from"clsx";import{useCallback as Dv,useEffect as _v,useLayoutEffect as BR,useRef as FR,useState as OR}from"react";import{EVENT as _g,HYPERLINK_TOOLTIP_DELAY as zR,KEYS as vm}from"@excalidraw/common";import{getElementAbsoluteCoords as Og}from"@excalidraw/element";import{hitElementBoundingBox as GR}from"@excalidraw/element";import{isElementLink as HR}from"@excalidraw/element";import{getEmbedLink as UR,embeddableURLValidator as WR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Bv,viewportCoordsToSceneCoords as VR,wrapEvent as YR,isLocalLink as KR,normalizeLink as Rg}from"@excalidraw/common";import{isEmbeddableElement as Ng}from"@excalidraw/element";import{jsx as va,jsxs as Rv}from"react/jsx-runtime";var zg=380,XR=42,Bg=5,Fv=85,ZR=500,Fg=!1,Im=new Map,Ov=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),l=nn(),s=on(),d=me(),c=e.link||"",[p,m]=OR(c),u=FR(null),E=l.showHyperlinkPopup==="editor",g=Dv(()=>{if(!u.current)return;let I=Rg(u.current.value)||null;if(!e.link&&I&&Ye("hyperlink","create"),Ng(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!WR(I,s.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Im.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=UR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=Im.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),Im.has(e.id)&&Im.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);BR(()=>()=>{g()},[g]),_v(()=>{E&&u?.current&&!(d.formFactor==="phone"||d.isTouchScreen)&&u.current.select()},[E,d.formFactor,d.isTouchScreen]),_v(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),jR(e,a,l,Nv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},ZR))};return window.addEventListener(_g.POINTER_MOVE,T,!1),()=>{window.removeEventListener(_g.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[l,e,E,t,a]);let b=Dv(()=>{Ye("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{Ye("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=zv(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:Rv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:zg,padding:Bg},children:[E?va("input",{className:NR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:p,onChange:I=>m(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[vm.CTRL_OR_CMD]&&I.key===vm.K&&I.preventDefault(),(I.key===vm.ENTER||I.key===vm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?va("a",{href:Rg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:KR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=YR(_g.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:Rg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):va("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Rv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&va($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:no}),va($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:A0}),c&&!Ng(e)&&va($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Zr})]})]})},zv=(e,n,t)=>{let[o,r]=Og(e,t),{x:i,y:a}=Bv({sceneX:o+e.width/2,sceneY:r},n),l=i-n.offsetLeft-zg/2,s=a-n.offsetTop-Fv;return{x:l,y:s}},Gg=(e,n)=>{let t=de(e,n);return Ng(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Is=null,Gv=(e,n,t)=>{Is&&clearTimeout(Is),Is=window.setTimeout(()=>$R(e,n,t),zR)},$R=(e,n,t)=>{if(!e.link)return;let o=la();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=HR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,l]=Og(e,t),[s,d,c,p]=kx([r,i,a,l],e.angle,n),m=Bv({sceneX:s,sceneY:d},n);rg(o,{left:m.x,top:m.y,width:c,height:p},"top"),Ye("hyperlink","tooltip","link-icon"),Fg=!0},Tm=()=>{Is&&clearTimeout(Is),Fg&&(Fg=!1,la().classList.remove("excalidraw-tooltip--visible"))},jR=(e,n,t,[o,r])=>{let{x:i,y:a}=VR({clientX:o,clientY:r},t),l=15/t.zoom.value;if(GR(Nv(i,a),e,n))return!1;let[s,d,c]=Og(e,n);if(i>=s&&i<=c&&a>=d-Fv&&a<=d)return!1;let{x:p,y:m}=zv(e,t,n);return!(o>=p-l&&o<=p+zg+Bg*2+l&&r>=m-l&&r<=m+l+Bg*2+XR)};import{jsx as QR}from"react/jsx-runtime";var Hg=O({name:"hyperlink",label:(e,n)=>Gg(Hv(e),n),icon:zl,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:JR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Uv.CTRL_OR_CMD]&&e.key===Uv.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return QR($,{type:"toggle",icon:zl,"aria-label":f(Gg(Hv(e),n)),title:`${qR(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as Wv,arrayToMap as Wg,randomId as eN}from"@excalidraw/common";import{elementsAreInSameGroup as tN,getNonDeletedElements as Vv,newElementWith as Yv,selectGroupsFromGivenElements as Kv}from"@excalidraw/element";import{CaptureUpdateAction as Xv}from"@excalidraw/element";var Ug=e=>e.every(n=>!n.locked),Ts=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Ug(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Ug(t)?Jo:So},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Ug(r),a=Wg(r),l=r.length>1&&tN(r),d=r.length===1||l?null:eN(),c={...n.lockedMultiSelections};if(i)c={...n.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete c[w]}let p=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?d&&(y=[...y,d]):y=y.filter(x=>!n.lockedMultiSelections[x]),Yv(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),m=Wg(p),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>m.get(w.id)||w),g=i?{}:Kv(Vv(E),n),b=i?d||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:c,activeLockedId:b},captureUpdate:Xv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Wv.L&&e[Wv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Zv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:So,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(l=>l.locked),o=e.map(l=>{if(l.locked){let s=l.groupIds.filter(d=>!n.lockedMultiSelections[d]);return Yv(l,{locked:!1,groupIds:l.groupIds.length!==s.length?s:l.groupIds})}return l}),r=Wg(o),i=t.map(l=>r.get(l.id)||l),a=Vv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(l=>[l.id,!0])),selectedGroupIds:Kv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Xv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as h8,isLinearElement as g8,isLineElement as Aa}from"@excalidraw/element";import{arrayToMap as f8,invariant as L2}from"@excalidraw/common";import{toggleLinePolygonState as E8,CaptureUpdateAction as D2}from"@excalidraw/element";import{getSizeFromPoints as CSe,randomInteger as p8,getUpdatedTimestamp as u8}from"@excalidraw/common";import{simplify as KN}from"points-on-curve";import{getStroke as XN,getStrokePoints as lSe}from"perfect-freehand";function tt([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Ia([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function lt([e,n,t],o){return[e*o,n*o,t*o]}function ui([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Ct([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function $v(e,n,t){return tt(e,lt(Ia(n,e),t))}function Vg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Yg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Kg([e,n]){return Math.sqrt(e**2+n**2)}function pi([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function jv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=pi(e[t-1],e[t]);return n+=pi(e[e.length-2],e[e.length-1]),n}var nN=(e,n,t)=>Math.max(n,Math.min(t,e));function qv(e,n,t){let o=pi(n,t);if(o===0)return pi(e,n);let r=nN(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return pi(i,e)}function Ss(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,l],s,d)=>{let c=qv(s,t,o);return c>a?[c,d]:[a,l]},[0,-1]);if(r>=n){let a=e[i];return[...Ss([t,...e.slice(1,i),a],n).slice(0,-1),a,...Ss([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var wr=class wr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},wr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=$v(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),jv(this.tailPoints)>wr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=Ss(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],M=this.getSize(n,P[2],0,o,0);if(M<.5)return[];let L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(tt(P,lt(Ct([1,0,0],_),M)));return L.push(tt(P,lt([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],M=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=Vg(P,[P[0],P[1]-100,P[2]],M);for(let B=D;B<=Math.PI+D;B+=Math.PI/16)k.push(tt(P,lt(Ct([1,0,0],B),L)));for(let B=Math.PI+D;B<=Math.PI*2+D;B+=Math.PI/16)k.push(tt(M,lt(Ct([1,0,0],B),_)));return k.push(k[0]),k}let r=[],i=[],a=0,l=0,s=0,d=0;for(let P=1;P<o-1;P++){let M=t[P-1],L=t[P],_=t[P+1],k=L[2],D=pi(M,L);d+=D,a=l+(D-l)*.2;let B=this.getSize(n,k,P,o,d);if(B===0){s=P+1;continue}let K=ui(Ia(M,L)),z=ui(Ia(_,L)),U=Ct(K,Math.PI/2),W=Ct(K,-Math.PI/2),G=Ct(z,Math.PI/2),oe=Ct(z,-Math.PI/2),le=tt(L,lt(U,B)),F=tt(L,lt(W,B)),V=tt(L,lt(G,B)),ce=tt(L,lt(oe,B)),fe=tt(U,oe),Be=tt(W,G),Ee=tt(L,lt(Kg(fe)===0?K:ui(fe),B)),He=tt(L,lt(Kg(Be)===0?z:ui(Be),B)),se=Yg(Vg(L,M,_)),Pe=wr.constants.cornerDetectionMaxAngle/180*Math.PI*wr.constants.cornerDetectionVariance(a);if(Math.abs(se)<Pe){let ke=Math.abs(Yg(Math.PI-se));if(ke===0)continue;if(se<0){i.push(F,He);for(let xe=0;xe<=ke;xe+=ke/4)r.push(tt(L,Ct(lt(U,B),xe)));for(let xe=ke;xe>=0;xe-=ke/4)i.push(tt(L,Ct(lt(U,B),xe)));i.push(He,V)}else{r.push(le,Ee);for(let xe=0;xe<=ke;xe+=ke/4)i.push(tt(L,Ct(lt(U,-B),-xe)));for(let xe=ke;xe>=0;xe-=ke/4)r.push(tt(L,Ct(lt(U,-B),-xe)));r.push(Ee,ce)}}else r.push(Ee),i.push(He);l=a}if(s>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)M.push(tt(P,lt(Ct([1,0,0],L),this.options.size)));return M.push(tt(P,lt([1,0,0],this.options.size))),M}return[]}let c=t[s],p=t[s+1],m=t[o-2],u=t[o-1],E=ui(Ia(p,c)),g=ui(Ia(m,u)),b=Ct(E,-Math.PI/2),w=Ct(g,Math.PI/2),y=this.getSize(n,c[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,m[2],o-2,o,d),T=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(tt(c,Ct(lt(b,y),-P)));x.unshift(tt(c,lt(b,-y)))}else x.push(c);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(tt(u,Ct(lt(w,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?Ss(C,this.options.simplify):C}};v(wr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(wr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Ta=wr;import{pointsOnBezierCurves as ome}from"points-on-curve";import{invariant as ime}from"@excalidraw/common";import{curve as lme,lineSegment as sme,pointFrom as cme,pointDistance as dme,pointFromArray as mme,pointFromVector as pme,pointRotateRads as ume,polygon as hme,polygonFromPoints as gme,PRECISION as fme,segmentsIntersectAt as Eme,vector as bme,vectorAdd as xme,vectorFromPoint as yme,vectorScale as wme}from"@excalidraw/math";import{getElementAbsoluteCoords as Ime}from"@excalidraw/element";var Xg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as ZN,pointDistance as S2,pointRotateRads as mSe}from"@excalidraw/math";import{ROUGHNESS as $N,THEME as uf,isTransparent as Os,assertNever as jN,COLOR_PALETTE as qN,LINE_POLYGON_POINT_MERGE_DISTANCE as uSe,applyDarkModeFilter as zs,DEFAULT_STROKE_STREAMLINE as JN}from"@excalidraw/common";import{RoughGenerator as QN}from"roughjs/bin/generator";import bTe from"roughjs/bin/rough";import{isRightAngleRads as yTe,lineSegment as wTe,pointFrom as vTe,pointRotateRads as ITe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as STe,DEFAULT_REDUCED_GLOBAL_ALPHA as CTe,ELEMENT_READY_TO_ERASE_OPACITY as PTe,FRAME_STYLE as kTe,DARK_THEME_FILTER as MTe,MIME_TYPES as T2,THEME as ATe,distance as LTe,getFontString as DTe,isRTL as _Te,getVerticalOffset as RTe,invariant as NTe,applyDarkModeFilter as BTe,isSafari as FTe}from"@excalidraw/common";import HIe from"roughjs/bin/rough";import{arrayToMap as WIe,invariant as I2,rescalePoints as VIe,sizeOf as YIe}from"@excalidraw/common";import{degreesToRadians as cf,lineSegment as XIe,pointFrom as Pt,pointFromArray as zN,pointRotateRads as Ma}from"@excalidraw/math";import{pointsOnBezierCurves as jIe}from"points-on-curve";import{pointCenter as iIe,pointFrom as aIe,pointRotateRads as lIe,pointsEqual as sIe,pointDistance as cIe,vectorFromPoint as dIe,curveLength as mIe,curvePointAtLength as pIe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as gIe,KEYS as fIe,shouldRotateWithDiscreteAngle as EIe,getGridPoint as bIe,invariant as xIe,isShallowEqual as yIe,getFeatureFlag as wIe}from"@excalidraw/common";import{arrayToMap as y2e,getFeatureFlag as w2e,getGridPoint as v2e,invariant as I2e,isTransparent as T2e}from"@excalidraw/common";import{PRECISION as C2e,clamp as P2e,lineSegment as k2e,pointDistance as M2e,pointDistanceSq as A2e,pointFrom as L2e,pointFromArray as D2e,pointFromVector as _2e,pointRotateRads as R2e,pointsEqual as N2e,vectorFromPoint as B2e,vectorNormalize as F2e,vectorScale as O2e}from"@excalidraw/math";import{invariant as Hve,isTransparent as Uve}from"@excalidraw/common";import{curveIntersectLineSegment as Vve,isPointWithinBounds as Yve,lineSegment as Kve,lineSegmentIntersectionPoints as Xve,pointFrom as Zve,pointFromVector as $ve,pointRotateRads as jve,pointsEqual as qve,vectorFromPoint as Jve,vectorNormalize as Qve,vectorScale as e2e}from"@excalidraw/math";import{ellipse as n2e,ellipseSegmentInterceptPoints as o2e}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as aN,DEFAULT_PROPORTIONAL_RADIUS as jg,invariant as Rme,LINE_CONFIRM_THRESHOLD as lN,ROUNDNESS as qg}from"@excalidraw/common";import{bezierEquation as Bme,curve as Fme,curveCatmullRomCubicApproxPoints as Ome,curveOffsetPoints as zme,lineSegment as Gme,lineSegmentIntersectionPoints as Hme,pointDistance as sN,pointFrom as Ume,pointFromArray as Wme,pointFromVector as Vme,pointRotateRads as Yme,pointTranslate as Kme,rectangle as Xme,vectorFromPoint as Zme,vectorNormalize as $me,vectorScale as jme}from"@excalidraw/math";import{ROUNDNESS as Pme,assertNever as kme}from"@excalidraw/common";import{pointsEqual as Ame}from"@excalidraw/math";var Jv=e=>!!e&&e.type==="embeddable",Zg=e=>!!e&&e.type==="iframe",$g=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),En=e=>e!=null&&e.type==="text";var mo=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var bn=e=>e!=null&&rN(e.type);var Fn=e=>e!=null&&e.type==="arrow",On=e=>Fn(e)&&e.elbowed;var rN=e=>e==="arrow"||e==="line";var Do=e=>e!==null&&"containerId"in e&&e.containerId!==null&&En(e);var Sa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return sN(t,o)<=lN/n}return!1},Cs=(e,n)=>{if(n.roundness?.type===qg.PROPORTIONAL_RADIUS||n.roundness?.type===qg.LEGACY)return e*jg;if(n.roundness?.type===qg.ADAPTIVE_RADIUS){let t=n.roundness?.value??aN,o=t/jg;return e<=o?e*jg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as yve,ARROW_LABEL_WIDTH_FRACTION as wve,BOUND_TEXT_PADDING as vve,DEFAULT_FONT_SIZE as Ive,TEXT_ALIGN as Tve,VERTICAL_ALIGN as Sve,getFontString as Cve,isProdEnv as Pve,invariant as kve}from"@excalidraw/common";import{pointFrom as Ave,pointRotateRads as Lve}from"@excalidraw/math";import{BOUND_TEXT_PADDING as dpe,DEFAULT_FONT_SIZE as mpe,DEFAULT_FONT_FAMILY as ppe,getFontString as upe,isTestEnv as hpe,normalizeEOL as gpe}from"@excalidraw/common";var fpe="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ipe,isTestEnv as Tpe}from"@excalidraw/common";import{toIterable as uwe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Mpe,viewportCoordsToSceneCoords as Ape}from"@excalidraw/common";import{normalizeRadians as Dpe,radiansBetweenAngles as _pe,radiansDifference as Rpe}from"@excalidraw/math";import{pointsEqual as Bpe}from"@excalidraw/math";import{arrayToMap as yue,isShallowEqual as pN}from"@excalidraw/common";import{arrayToMap as eue}from"@excalidraw/common";import{isPointWithinBounds as nue,pointFrom as oue,segmentsIntersectAt as rue}from"@excalidraw/math";import{arrayToMap as Upe}from"@excalidraw/common";import{validateOrderKey as Vpe,generateNKeysBetween as Ype}from"@excalidraw/fractional-indexing";var Jg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var kue=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),Ls=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){hi(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Do(i)&&hi(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{mo(a)&&Jg(e,a.id).forEach(l=>!o.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var ef=(e,n)=>pN(n.selectedElementIds,e)?n.selectedElementIds:e;var uN=function(){let e=null,n=null,t=null,o=(i,a,l,s)=>{if(t!==void 0&&a===n&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let d={};for(let m of i){let u=m.groupIds;if(l.editingGroupId){let E=u.indexOf(l.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];d[E]=!0}}let c={},p=a.reduce((m,u)=>{if(u.isDeleted)return m;let E=u.groupIds.find(g=>d[g]);return E&&(m[u.id]=!0,Array.isArray(c[E])?c[E].push(u.id):c[E]=[u.id]),m},{});for(let m of Object.keys(c))c[m].length<2&&d[m]&&(d[m]=!1);return n=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:ef({...l.selectedElementIds,...p},s)},t},r=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Ls(a,i);return d.length?o(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:ef(i.selectedElementIds,l)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Kue=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Uhe,VERTICAL_ALIGN as Whe}from"@excalidraw/common";import{pointDistance as Yhe,pointFromVector as Khe,pointsEqual as Xhe,vector as Zhe,vectorDot as $he,vectorFromPoint as jhe,vectorNormalize as qhe,vectorScale as Jhe}from"@excalidraw/math";import{invariant as rhe,isDevEnv as ihe,isTestEnv as ahe}from"@excalidraw/common";import{pointFrom as she,pointFromVector as che,pointRotateRads as dhe,pointScaleFromOrigin as mhe,pointsEqual as phe,triangleIncludesPoint as uhe,vectorCross as hhe,vectorFromPoint as fN,vectorScale as ghe}from"@excalidraw/math";var Rs=[1,0],Mm=[0,1],Ns=[-1,0],Am=[0,-1],Lm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Rs:n<=-r?Ns:t>o?Mm:Am},l2=(e,n)=>Lm(fN(e,n)),Dm=(e,n)=>_m(l2(e,n)),_s=(e,n)=>e[0]===n[0]&&e[1]===n[1],_m=e=>_s(e,Rs)||_s(e,Ns);import{DEFAULT_ELEMENT_PROPS as yhe,DEFAULT_FONT_FAMILY as whe,DEFAULT_FONT_SIZE as vhe,DEFAULT_TEXT_ALIGN as Ihe,DEFAULT_VERTICAL_ALIGN as The,DEFAULT_STROKE_STREAMLINE as She,VERTICAL_ALIGN as Che,randomInteger as Phe,randomId as khe,getFontString as Mhe,getUpdatedTimestamp as Ahe,getLineHeight as Lhe}from"@excalidraw/common";import{pointsOnBezierCurves as wge,simplify as vge}from"points-on-curve";import{curveToBezier as Tge}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Cge,lineSegment as Pge,lineSegmentIntersectionPoints as kge,pointDistance as Mge,pointFrom as Age,pointRotateRads as Lge,polygonArea as Dge,polygonIncludesPoint as _ge,polygonIncludesPointNonZero as Rge,polygonSignedArea as Nge}from"@excalidraw/math";import{isOpaqueColor as Fge,isTransparent as Oge}from"@excalidraw/common";var m2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as cge,distanceToLineSegment as dge,pointRotateRads as mge}from"@excalidraw/math";import{ellipse as uge,ellipseDistanceFromPoint as hge}from"@excalidraw/math/ellipse";import{pointFrom as Jge,pointCenter as Qge,pointRotateRads as efe,vectorFromPoint as tfe,vectorNormalize as nfe,vectorSubtract as ofe,vectorAdd as rfe,vectorScale as ife,pointFromVector as afe,clamp as lfe,isCloseTo as sfe}from"@excalidraw/math";import{arrayToMap as FEe,arrayToObject as OEe,assertNever as zEe,isDevEnv as GEe,isShallowEqual as HEe,isTestEnv as UEe,randomInteger as WEe}from"@excalidraw/common";import{assertNever as Vfe,COLOR_PALETTE as Yfe,isDevEnv as Kfe,isTestEnv as Xfe,randomId as Zfe,Emitter as $fe,toIterable as jfe}from"@excalidraw/common";import{ORIG_ID as wfe,randomId as vfe,randomInteger as Ife,arrayToMap as Tfe,castArray as Sfe,findLastIndex as Cfe,getUpdatedTimestamp as Pfe,isTestEnv as kfe}from"@excalidraw/common";import{arrayToMap as ufe}from"@excalidraw/common";import xN from"lodash.throttle";import{randomInteger as mEe,arrayToMap as pEe,toBrandedType as uEe,isDevEnv as h2,isTestEnv as g2,toArray as hEe}from"@excalidraw/common";import{isNonDeletedElement as fEe}from"@excalidraw/element";import{isFrameLikeElement as bEe}from"@excalidraw/element";import{getElementsInGroup as yEe}from"@excalidraw/element";import{syncInvalidIndices as vEe,syncMovedIndices as IEe,validateFractionalIndices as yN}from"@excalidraw/element";import{getSelectedElements as SEe}from"@excalidraw/element";import{mutateElement as PEe}from"@excalidraw/element";var kEe=xN(e=>{(h2()||g2()||window?.DEBUG_FRACTIONAL_INDICES)&&yN(e,{shouldThrow:h2()||g2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as hbe,getGridPoint as gbe,getFontString as fbe,DRAGGING_THRESHOLD as Ebe}from"@excalidraw/common";import{clamp as kbe,pointDistance as Mbe,pointFrom as Abe,pointScaleFromOrigin as Lbe,pointsEqual as Dbe,pointTranslate as _be,vector as Rbe,vectorCross as Nbe,vectorFromPoint as Bbe,vectorScale as Fbe}from"@excalidraw/math";import{BinaryHeap as zbe,invariant as Gbe,isAnyTrue as Hbe,getSizeFromPoints as Ube,isDevEnv as Wbe,arrayToMap as Vbe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as rxe,normalizeLink as ixe}from"@excalidraw/common";import{FONT_FAMILY as dxe,VERTICAL_ALIGN as mxe,escapeDoubleQuotes as pxe,getFontString as uxe}from"@excalidraw/common";import{invariant as vxe,toBrandedType as Ixe}from"@excalidraw/common";import{clamp as Sxe,pointFrom as Cxe}from"@excalidraw/math";import{pointDistance as t1e,pointFrom as n1e}from"@excalidraw/math";import{invariant as r1e}from"@excalidraw/common";import{arrayToMap as Gxe,findIndex as Hxe,findLastIndex as Uxe}from"@excalidraw/common";import{isFiniteNumber as Vxe}from"@excalidraw/math";import{decodeAnimated as h1e}from"@discourse/gif";var NN="gif.worker.js";var f1e=new URL(NN,import.meta.url).toString();import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as v1e,MIME_TYPES as I1e,SVG_NS as T1e}from"@excalidraw/common";import{rgbaToThumbHash as C1e,thumbHashToRGBA as P1e}from"thumbhash";import{pointCenter as K1e,normalizeRadians as X1e,pointFrom as Z1e,pointRotateRads as $1e}from"@excalidraw/math";import{MIN_FONT_SIZE as q1e,SHIFT_LOCKING_ANGLE as J1e,rescalePoints as Q1e,getFontString as e0e}from"@excalidraw/common";import{pointFrom as P0e,pointOnLineSegment as k0e,pointRotateRads as M0e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as L0e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as h0e}from"@excalidraw/common";import{pointFrom as f0e,pointRotateRads as E0e}from"@excalidraw/math";import{KEYS as Gn}from"@excalidraw/common";var U0e=[{icon:qc,value:"selection",key:Gn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Yi,value:"rectangle",key:Gn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ki,value:"diamond",key:Gn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Xi,value:"ellipse",key:Gn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Jc,value:"arrow",key:Gn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Qo,value:"line",key:Gn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:no,value:"freedraw",key:[Gn.P,Gn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:_n,value:"text",key:Gn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Xr,value:"image",key:[Gn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Qc,value:"eraser",key:Gn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as eye}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as nye,DEFAULT_FONT_SIZE as oye,TEXT_ALIGN as rye,VERTICAL_ALIGN as iye,getSizeFromPoints as aye,randomId as lye,arrayToMap as sye,assertNever as cye,cloneJSON as dye,getFontString as mye,isDevEnv as pye,toBrandedType as uye,getLineHeight as hye}from"@excalidraw/common";import{getBoundsFromPoints as Fye,getElementAbsoluteCoords as Oye}from"@excalidraw/element/bounds";import{newArrowElement as Gye,newElement as Hye,newLinearElement as Uye}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Vye,getStrokeWidthByKey as Yye,ROUNDNESS as Kye}from"@excalidraw/common";import{convexHull as Zye,distanceToLineSegment as $ye,elongation as jye,kurtosis as qye,lineSegment as Jye,orientPrincipalAxes as Qye,pointFrom as ewe,polygonArea as twe,principalAxes as nwe,principalCoords as owe,skewness as rwe}from"@excalidraw/math";var swe=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var hi=e=>!e.isDeleted;var LN=10/1.5;var Sm=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var GN=20,HN=15,UN=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 HN;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return GN;default:return 15}},WN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Ot=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Xg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,l=i[a].data;I2(l.length===6,"Op data length is not 6");let s=Pt(l[4],l[5]),d=Pt(l[2],l[3]),c=Pt(l[0],l[1]),p=i[a-1],m=Pt(0,0);if(p.op==="move"){let G=zN(p.data);I2(G!=null,"Op data is not a point"),m=G}else p.op==="bcurveTo"&&(m=Pt(p.data[4],p.data[5]));let u=(G,oe)=>Math.pow(1-G,3)*s[oe]+3*G*Math.pow(1-G,2)*d[oe]+3*Math.pow(G,2)*(1-G)*c[oe]+m[oe]*Math.pow(G,3),[E,g]=t==="start"?m:s,[b,w]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-w),x=(E-b)/y,I=(g-w)/y,T=UN(o),C=0;{let[G,oe]=t==="end"?e.points[e.points.length-1]:e.points[0],[le,F]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-le,oe-F)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*M*r,_=g-I*M*r,k=L-x*M,D=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,G]}let B=WN(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,oe]=Ma(Pt(L,_),Pt(k,D),cf(-B)),[le,F]=Ma(Pt(L,_),Pt(k,D),cf(B));return[k,D,G,oe,le,F]}let[K,z]=Ma(Pt(k,D),Pt(L,_),-B*Math.PI/180),[U,W]=Ma(Pt(k,D),Pt(L,_),cf(B));if(o==="diamond"||o==="diamond_outline"){let G,oe;if(t==="start"){let[le,F]=e.points.length>1?e.points[1]:[0,0];[G,oe]=Ma(Pt(L+M*2,_),Pt(L,_),Math.atan2(F-_,le-L))}else{let[le,F]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,oe]=Ma(Pt(L-M*2,_),Pt(L,_),Math.atan2(_-F,L-le))}return[L,_,K,z,G,oe,U,W]}return[L,_,K,z,U,W]};var VN=typeof document<"u"?document.createElement("img"):{src:""};VN.src=`data:${T2.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 YN=typeof document<"u"?document.createElement("img"):{src:""};YN.src=`data:${T2.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 df=new WeakMap;var Xt=class Xt{};v(Xt,"rg",new QN),v(Xt,"cache",new WeakMap),v(Xt,"get",(n,t)=>{let o=Xt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Xt,"delete",n=>{Xt.cache.delete(n),df.delete(n)}),v(Xt,"destroy",()=>{Xt.cache=new WeakMap}),v(Xt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Xt.get(n,t?t.theme:null);if(o!==void 0)return o;df.delete(n);let r=n8(n,Xt.rg,t||{isExporting:!1,canvasBackgroundColor:qN.white,embedsValidationStatus:null,theme:uf.LIGHT});return t?.isExporting||Xt.cache.set(n,{shape:r,theme:t?.theme||uf.LIGHT}),r});var ka=Xt,e8=e=>[8,8+e],M2=e=>[1.5,6+e];function t8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&m2(e.type)||bn(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Ro=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?e8(e.strokeWidth):e.strokeStyle==="dotted"?M2(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:t8(e),stroke:zs(e.strokeColor,t),preserveVertices:n||e.roughness<$N.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Os(e.backgroundColor)?void 0:zs(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Sa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:zs(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},C2=(e,n,t)=>$g(e)&&(n||Jv(e)&&t?.get(e.id)!==!0)&&Os(e.backgroundColor)&&Os(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Zg(e)?{...e,strokeColor:Os(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Os(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Fs=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Nm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,l,s]=n;return[e.line(i,a,o,r,t),e.line(l,s,o,r,t)]},fi=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=M2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},mf=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,l,s]=o,d={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete d.strokeLineDash,[e.circle(a,l,s*i,d)]},P2=(e,n,t,o,r,i,a,l)=>{if(o===null)return[];let s=zs(e.strokeColor,l),d=zs(a,l),c=-.25,p=.8;switch(o){case"circle":case"circle_outline":return mf(r,i,s,Ot(e,n,t,o),o==="circle_outline"?d:s);case"triangle":case"triangle_outline":{let m=Ot(e,n,t,o);if(m===null)return[];let[u,E,g,b,w,y]=m,x={...i,fill:o==="triangle_outline"?d:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[u,E]],x)]}case"diamond":case"diamond_outline":{let m=Ot(e,n,t,o);if(m===null)return[];let[u,E,g,b,w,y,x,I]=m,T={...i,fill:o==="diamond_outline"?d:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[x,I],[u,E]],T)]}case"cardinality_one":return Fs(r,Ot(e,n,t,o),fi(e,i));case"cardinality_many":return Nm(r,Ot(e,n,t,o),fi(e,i));case"cardinality_one_or_many":{let m=fi(e,i);return[...Nm(r,Ot(e,n,t,"cardinality_many"),m),...Fs(r,Ot(e,n,t,"cardinality_one",c),m)]}case"cardinality_exactly_one":{let m=fi(e,i);return[...Fs(r,Ot(e,n,t,"cardinality_one",-.5),m),...Fs(r,Ot(e,n,t,"cardinality_one"),m)]}case"cardinality_zero_or_one":{let m=fi(e,i);return[...mf(r,i,s,Ot(e,n,t,"circle_outline",1.5),d,p),...Fs(r,Ot(e,n,t,"cardinality_one",-.5),m)]}case"cardinality_zero_or_many":{let m=fi(e,i);return[...Nm(r,Ot(e,n,t,"cardinality_many"),m),...mf(r,i,s,Ot(e,n,t,"circle_outline",1.5),d,p)]}case"bar":case"arrow":default:return Nm(r,Ot(e,n,t,o),fi(e,i))}};var n8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===uf.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let l;if(e.roundness){let s=e.width,d=e.height,c=Cs(Math.min(s,d),e);l=n.path(`M ${c} 0 L ${s-c} 0 Q ${s} 0, ${s} ${c} L ${s} ${d-c} Q ${s} ${d}, ${s-c} ${d} L ${c} ${d} Q 0 ${d}, 0 ${d-c} L 0 ${c} Q 0 0, ${c} 0`,Ro(C2(e,t,r),!0,a))}else l=n.rectangle(0,0,e.width,e.height,Ro(C2(e,t,r),!1,a));return l}case"diamond":{let l,[s,d,c,p,m,u,E,g]=Sm(e);if(e.roundness){let b=Cs(Math.abs(s-E),e),w=Cs(Math.abs(p-d),e);l=n.path(`M ${s+b} ${d+w} L ${c-b} ${p-w}
|
|
5
|
-
C ${c} ${
|
|
6
|
-
L ${
|
|
7
|
-
C ${
|
|
4
|
+
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var tv=async(e,n,t)=>{let o=Yx(n);if(!Kx(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:l,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:d,exportingFrame:c}=di(r,i,!1);return await mi(o,d,i,a,{exportBackground:l,viewBackgroundColor:s,name:t,fileHandle:n,exportingFrame:c}),{fileHandle:n}};import{Fragment as VD,jsx as wr,jsxs as iv}from"react/jsx-runtime";var Pg=G({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Gn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>wr(Zw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),nv=G({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Gn.EVENTUALLY})}),kg=G({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Gn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>wr(Ig,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),wm=G({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Gn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>iv(Ig,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),wr(bt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:wr("div",{className:"excalidraw-tooltip-icon",children:k1})})]})}),ya=!1,Cg=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?iv(VD,{children:[t,wr(pm.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function WD(e,n){if(n.app.state.isLoading&&(Cg(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")Cg(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Cg(n.app,{progress:null}),await e)}function ov(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async l=>{try{o.props.onExport&&await WD(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,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)}l({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var pi=G({name:"saveToActiveFile",label:"buttons.save",icon:Kl,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(ya)return!1;ya=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:l}=ov(e,n,o.files,o);try{let{fileHandle:s}=ed(r)?await tv(l,r,i):await Zc({data:l,filename:i,fileHandle:r});return{captureUpdate:Gn.NEVER,appState:{fileHandle:s,toast:{message:r&&s?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(s){return a.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:Gn.NEVER,appState:{toast:null}}}finally{ya=!1}},keyTest:e=>!1}),Ss=G({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Kl,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(ya)return!1;ya=!0;let{abortController:r,data:i}=ov(e,n,o.files,o);try{let{fileHandle:a}=await Zc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Gn.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:Gn.NEVER,appState:{toast:null}}}finally{ya=!1}},keyTest:e=>e.key.toLowerCase()===ym.S&&e.shiftKey&&e[ym.CTRL_OR_CMD],PanelComponent:({updateData:e})=>wr($,{type:"button",icon:I1,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:me().formFactor==="phone",hidden:!Vi,onClick:()=>e(null),"data-testid":"save-as-button"})}),wa=G({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await qu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Gn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Gn.EVENTUALLY}}},keyTest:e=>e[ym.CTRL_OR_CMD]&&e.key===ym.O}),rv=G({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Ts.DARK:Ts.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Gn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>wr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:wr(Kw,{value:e.exportWithDarkMode?Ts.DARK:Ts.LIGHT,onChange:t=>{n(t===Ts.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as YD,DEFAULT_FONT_FAMILY as KD,DEFAULT_TEXT_ALIGN as XD,getLineHeight as ZD}from"@excalidraw/common";import{newElementWith as vm}from"@excalidraw/element";import{hasBoundTextElement as $D,canApplyRoundnessTypeToElement as jD,getDefaultRoundnessTypeForElement as qD,isFrameLikeElement as JD,isArrowElement as QD,isExcalidrawElement as e_,isTextElement as av}from"@excalidraw/element";import{getBoundTextElement as t_,redrawTextBoundingBox as n_}from"@excalidraw/element";import{CaptureUpdateAction as Mg}from"@excalidraw/element";var lv="{}",o_=G({name:"copyStyles",label:"labels.copyStyles",icon:Ih,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&$D(i)){let a=t_(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(lv=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:Mg.EVENTUALLY}}}),r_=G({name:"pasteStyles",label:"labels.pasteStyles",icon:Ih,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(lv),i=r[0],a=r[1];if(!e_(i))return{elements:e,captureUpdate:Mg.EVENTUALLY};let l=de(e,n,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let c=i;if(av(d)&&d.containerId&&(c=a),!c)return d;let m=vm(d,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?jD(c.roundness.type,d)?c.roundness:qD(d):null});if(av(m)){let p=c.fontSize||YD,u=c.fontFamily||KD,E=vm(m,{fontSize:p,fontFamily:u,textAlign:c.textAlign||XD,lineHeight:c.lineHeight||ZD(u)});m=E;let g=null;E.containerId&&(g=l.find(b=>b.id===E.containerId)||null),n_(E,g,o.scene)}return m.type==="arrow"&&QD(c)&&(m=vm(m,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),JD(d)&&(m=vm(m,{roundness:null,backgroundColor:"transparent"})),m}return d}),captureUpdate:Mg.IMMEDIATELY}}});import{KEYS as i_}from"@excalidraw/common";import{CaptureUpdateAction as a_}from"@excalidraw/element";var ui=G({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:b1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:a_.EVENTUALLY}),keyTest:e=>e.key===i_.QUESTION_MARK});import{getNonDeletedElements as Tm}from"@excalidraw/element";import{newElementWith as cv}from"@excalidraw/element";import{isBoundToContainer as l_}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as s_,getElementsInResizingFrame as c_,getFrameLikeElements as d_,getRootElements as m_,groupByFrameLikes as p_,removeElementsFromFrame as u_,replaceAllElementsInFrame as h_}from"@excalidraw/element";import{KEYS as Sm,randomId as g_,arrayToMap as Lg}from"@excalidraw/common";import{getSelectedGroupIds as Im,selectGroup as f_,selectGroupsForSelectedElements as E_,getElementsInGroup as sv,addToGroup as b_,removeFromSelectedGroups as x_,isElementInGroup as dv}from"@excalidraw/element";import{syncMovedIndices as y_}from"@excalidraw/element";import{CaptureUpdateAction as Cs}from"@excalidraw/element";import{jsx as va}from"react/jsx-runtime";var w_=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>dv(i,r)))return!0}return!1},Ag=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!w_(t,e.editingGroupId)&&!s_(t)},Dg=G({name:"group",label:"labels.group",icon:e=>va(fh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Ag(n,o))return!1;let r=m_(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Cs.EVENTUALLY};let i=Im(n);if(i.length===1){let b=i[0],w=new Set(sv(e,b).map(I=>I.id)),y=new Set(r.map(I=>I.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:n,elements:e,captureUpdate:Cs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&p_(r).forEach((w,y)=>{u_(w,o.scene.getNonDeletedElementsMap())});let s=g_(),d=Lg(r);a=a.map(b=>d.get(b.id)?cv(b,{groupIds:b_(b.groupIds,s,n.editingGroupId)}):b);let c=sv(a,s),m=c[c.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!dv(b,s)),g=y_([...E,...c,...u],Lg(c));return{appState:{...n,...f_(s,{...n,selectedGroupIds:{}},Tm(a))},elements:g,captureUpdate:Cs.IMMEDIATELY}},predicate:(e,n,t,o)=>Ag(n,o),keyTest:e=>!e.shiftKey&&e[Sm.CTRL_OR_CMD]&&e.key===Sm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>va($,{hidden:!Ag(n,o),type:"button",icon:va(fh,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${B("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Oe(Tm(e),n)})}),_g=G({name:"ungroup",label:"labels.ungroup",icon:e=>va(Eh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Im(n),i=Lg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Cs.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{l_(p)&&l.push(p.id);let u=x_(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:cv(p,{groupIds:u})});let s=E_(n,Tm(a),n,null),d=o.scene.getSelectedElements(n),c=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return d_(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=h_(a,c_(a,p,n,i),p))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,E])=>(E&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...s},elements:a,captureUpdate:Cs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Sm.CTRL_OR_CMD]&&e.key===Sm.G.toUpperCase(),predicate:(e,n)=>Im(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>va($,{type:"button",hidden:Im(n).length===0,icon:va(Eh,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${B("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Oe(Tm(e),n)})});import k_ from"clsx";import{CaptureUpdateAction as gv}from"@excalidraw/element";import{invariant as M_}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as v_,COLOR_VOICE_CALL as I_,COLOR_WHITE as Pm,THEME as T_,UserIdleState as mv}from"@excalidraw/common";var Cm=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function S_(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var hi=(e,n)=>`hsl(${Math.abs(S_(n?.id||e))%37*10}, 100%, 83%)`,pv=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},uv=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,m=14,p=l<0||l>o-c||s<0||s>r-m;l=Math.max(l,0),l=Math.min(l,o-c),s=Math.max(s,0),s=Math.min(s,r-m);let u=hi(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===mv.IDLE||E===mv.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===T_.DARK?"#2f6330":I_,w=d?.isSpeaking;w&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Pm,e.strokeStyle=Pm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let x=(w?l+0:l)+c/2,I=(w?s+0:s)+m+2,T=5,P=3,C=e.measureText(y),k=C.actualBoundingBoxDescent+C.actualBoundingBoxAscent,M=Math.max(k,12),_=x-1,L=I-1,R=C.width+2+T*2+2,z=M+2+P*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,L,R,z,8),e.fillStyle=u,e.fill(),e.strokeStyle=Pm,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,L-2,R+4,z+4,8),e.strokeStyle=b,e.stroke())):Cm(e,_,L,R,z,8,Pm),e.fillStyle=v_,e.fillText(y,x+T+1,I+P+C.actualBoundingBoxAscent+Math.floor((M-k)/2)+2),w){e.fillStyle=b;let K=8,U=8,D=5;e.fillRect(_+R+U,L+(z/2-K/2),2,K),e.fillRect(_+R+U+D,L+(z/2-K*2/2),2,K*2),e.fillRect(_+R+U+D*2,L+(z/2-K/2),2,K)}}e.restore(),e.closePath()}};import C_ from"clsx";import{useState as P_}from"react";import{jsx as hv}from"react/jsx-runtime";var Rg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=pv(t),[a,l]=P_(!1),s=!a&&o,d=s?void 0:{background:e};return hv("div",{className:C_("Avatar",r),style:d,onClick:n,children:s?hv("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as fo,jsxs as km}from"react/jsx-runtime";var A_=G({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(M_(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:gv.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:gv.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,l=hi(o,r),s=k_({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?km("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[fo("div",{}),fo("div",{}),fo("div",{})]}):r.isMuted?fo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:A0}):fo("div",{title:f("userList.hint.inCall"),children:M0}):null;return i?km("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[fo(Rg,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),fo("div",{className:"UserList__collaborator-name",children:r.username}),km("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&fo("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:ni}),r.isCurrentUser&&` (${f("labels.you")})`,d]})]}):km("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[fo(Rg,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),d&&fo("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{getNonDeletedElements as Ia}from"@excalidraw/element";import{isFrameLikeElement as R_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as N_}from"@excalidraw/element";import{KEYS as vr,arrayToMap as B_}from"@excalidraw/common";import{alignElements as F_}from"@excalidraw/element";import{CaptureUpdateAction as fi}from"@excalidraw/element";import{getSelectedElementsByGroup as O_}from"@excalidraw/element";import L_ from"clsx";import{jsx as fv}from"react/jsx-runtime";var gi=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>fv("div",{className:L_("Switch",{toggled:t,disabled:r}),children:fv("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var D_={stacking:!1},__={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},Eo=(e,n)=>({smartZoom:{...__,...n?.smartZoom},align:{...D_,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as Ir,jsxs as K_}from"react/jsx-runtime";var mt=(e,n)=>{let t=n.scene.getSelectedElements(e);return O_(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>R_(o))},Ta=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=Eo(n,t.props.editorPreferences),l=F_(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),s=B_(l);return N_(e.map(d=>s.get(d.id)||d),n,t)},z_=G({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>{let r=Eo(n,o.props.editorPreferences).align.stacking,i=typeof t=="boolean"?t:!r;return o.props.onEditorPreferencesChange?.({align:{stacking:i}}),{appState:{...n,alignConfiguration:{stacking:i}},captureUpdate:fi.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=Eo(e,t.editorPreferences).align.stacking;return K_("div",{className:"align-stacking-toggle",children:[Ir("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),Ir(gi,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),G_=G({name:"alignTop",label:"labels.alignTop",icon:dh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"start",axis:"y"}),captureUpdate:fi.IMMEDIATELY}),keyTest:e=>e[vr.CTRL_OR_CMD]&&e.shiftKey&&e.key===vr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:dh,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${B("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Oe(Ia(e),n)})}),H_=G({name:"alignBottom",label:"labels.alignBottom",icon:mh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"end",axis:"y"}),captureUpdate:fi.IMMEDIATELY}),keyTest:e=>e[vr.CTRL_OR_CMD]&&e.shiftKey&&e.key===vr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:mh,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${B("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Oe(Ia(e),n)})}),U_=G({name:"alignLeft",label:"labels.alignLeft",icon:ph,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"start",axis:"x"}),captureUpdate:fi.IMMEDIATELY}),keyTest:e=>e[vr.CTRL_OR_CMD]&&e.shiftKey&&e.key===vr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:ph,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${B("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Oe(Ia(e),n)})}),W_=G({name:"alignRight",label:"labels.alignRight",icon:uh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"end",axis:"x"}),captureUpdate:fi.IMMEDIATELY}),keyTest:e=>e[vr.CTRL_OR_CMD]&&e.shiftKey&&e.key===vr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:uh,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${B("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Oe(Ia(e),n)})}),V_=G({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:hh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"center",axis:"y"}),captureUpdate:fi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:hh,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Oe(Ia(e),n)})}),Y_=G({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:gh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Ta(e,n,o,{position:"center",axis:"x"}),captureUpdate:fi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ir($,{hidden:!mt(n,o),type:"button",icon:gh,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Oe(Ia(e),n)})});import{getNonDeletedElements as Ev}from"@excalidraw/element";import{isFrameLikeElement as X_}from"@excalidraw/element";import{CODES as bv,KEYS as xv,arrayToMap as Z_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as $_}from"@excalidraw/element";import{distributeElements as j_}from"@excalidraw/element";import{CaptureUpdateAction as yv}from"@excalidraw/element";import{getSelectedElementsByGroup as q_}from"@excalidraw/element";import{jsx as Iv}from"react/jsx-runtime";var wv=(e,n)=>{let t=n.scene.getSelectedElements(e);return q_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>X_(o))},vv=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=j_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=Z_(i);return $_(e.map(l=>a.get(l.id)||l),n,t)},J_=G({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:vv(e,n,o,{space:"between",axis:"x"}),captureUpdate:yv.IMMEDIATELY}),keyTest:e=>!e[xv.CTRL_OR_CMD]&&e.altKey&&e.code===bv.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Iv($,{hidden:!wv(n,o),type:"button",icon:D1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${B("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Oe(Ev(e),n)})}),Q_=G({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:vv(e,n,o,{space:"between",axis:"y"}),captureUpdate:yv.IMMEDIATELY}),keyTest:e=>!e[xv.CTRL_OR_CMD]&&e.altKey&&e.code===bv.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Iv($,{hidden:!wv(n,o),type:"button",icon:_1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${B("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Oe(Ev(e),n)})});import{arrayToMap as Tv,KEYS as eR,matchKey as tR}from"@excalidraw/common";import{CaptureUpdateAction as nR}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as oR}from"@excalidraw/element/frame";import{arrangeElements as rR}from"@excalidraw/element/arrange";import{jsx as lR}from"react/jsx-runtime";var iR=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Tv(e),{arrange:i}=Eo(n,t.props.editorPreferences),a=rR(t.scene,o,r,i.algorithm,i.gap),l=Tv(a);return oR(e.map(s=>l.get(s.id)||s),n,t)},aR=mt,Ng=G({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Sh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>aR(n,o),perform:(e,n,t,o)=>({appState:n,elements:iR(e,n,o),captureUpdate:nR.IMMEDIATELY}),keyTest:e=>e.shiftKey&&tR(e,eR.A),PanelComponent:({updateData:e})=>lR("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${B("Shift+A")}`,children:Sh})});import{arrayToMap as Sv}from"@excalidraw/common";import{CaptureUpdateAction as sR}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as cR}from"@excalidraw/element/frame";import{normaliseElements as dR}from"@excalidraw/element/normalise";import{jsx as uR}from"react/jsx-runtime";var mR=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Sv(e),{normalise:i}=Eo(n,t.props.editorPreferences),a=dR(t.scene,o,r,i.mode,i.metric),l=Sv(a);return cR(e.map(s=>l.get(s.id)||s),n,t)},pR=mt,Bg=G({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Ch,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>pR(n,o),perform:(e,n,t,o)=>({appState:n,elements:mR(e,n,o),captureUpdate:sR.IMMEDIATELY}),PanelComponent:({updateData:e})=>uR("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:Ch})});import{getNonDeletedElements as hR}from"@excalidraw/element";import{bindOrUnbindBindingElements as gR}from"@excalidraw/element";import{getCommonBoundingBox as Cv}from"@excalidraw/element";import{newElementWith as fR}from"@excalidraw/element";import{deepCopyElement as ER}from"@excalidraw/element";import{resizeMultipleElements as bR}from"@excalidraw/element";import{isArrowElement as Pv,isElbowArrow as xR}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as kv}from"@excalidraw/element";import{CODES as Mv,KEYS as yR,arrayToMap as wR}from"@excalidraw/common";import{CaptureUpdateAction as Av}from"@excalidraw/element";var Fg=G({name:"flipHorizontal",label:"labels.flipHorizontal",icon:R0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:kv(Lv(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:Av.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Mv.H}),Og=G({name:"flipVertical",label:"labels.flipVertical",icon:_0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:kv(Lv(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:Av.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Mv.V&&!e[yR.CTRL_OR_CMD]}),Lv=(e,n,t,o,r)=>{let i=de(hR(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=vR(i,n,o,r),l=wR(a);return e.map(s=>l.get(s.id)||s)},vR=(e,n,t,o)=>{if(e.every(p=>Pv(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return fR(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Cv(e);bR(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,ER(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),gR(e.filter(Pv),o.scene,o.state);let{elbowArrows:a,otherElements:l}=e.reduce((p,u)=>xR(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:d}=Cv(e),[c,m]=[r-s,i-d];return l.forEach(p=>o.scene.mutateElement(p,{x:p.x+c,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+c,y:p.y+m})),e};import{CODES as Dv,KEYS as _v}from"@excalidraw/common";import{CaptureUpdateAction as IR}from"@excalidraw/element";var Rv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:IR.NEVER}),Sa=G({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>Rv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[_v.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===Dv.R}),Ca=G({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>Rv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[_v.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Dv.R});import{isTextElement as TR}from"@excalidraw/element";import{getTextFromElements as SR}from"@excalidraw/element";import{CODES as CR,KEYS as Mm,isFirefox as PR}from"@excalidraw/common";import{CaptureUpdateAction as rn}from"@excalidraw/element";var Pa=G({name:"copy",label:"labels.copy",icon:Wl,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await fm(r,o.files,t)}catch(i){return{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:rn.EVENTUALLY}},keyTest:e=>e[Mm.CTRL_OR_CMD]&&e.key===Mm.C}),zg=G({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Em()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),PR?{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(gm({types:r}))}catch(i){return console.error(i),{captureUpdate:rn.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:rn.EVENTUALLY}},keyTest:void 0}),Am=G({name:"cut",label:"labels.cut",icon:w0,trackEvent:{category:"element"},perform:(e,n,t,o)=>(Pa.perform(e,n,t,o),jl.perform(e,n,null,o)),keyTest:e=>e[Mm.CTRL_OR_CMD]&&e.key===Mm.X}),kR=G({name:"copyAsSvg",label:"labels.copyAsSvg",icon:N0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:rn.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=di(e,n,!0);try{await mi("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:rn.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:rn.EVENTUALLY}}},predicate:e=>hm&&e.length>0,keywords:["svg","clipboard","copy"]}),MR=G({name:"copyAsPng",label:"labels.copyAsPng",icon:B0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:rn.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=di(e,n,!0);try{return await mi("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:rn.EVENTUALLY}}catch(l){return console.error(l),{appState:{...n,errorMessage:l.message},captureUpdate:rn.EVENTUALLY}}},predicate:e=>xr&&e.length>0,keyTest:e=>e.code===CR.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),AR=G({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{go(SR(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:rn.EVENTUALLY}},predicate:(e,n,t,o)=>hm&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(TR),keywords:["text","clipboard","copy"]});import{CODES as LR,KEYS as DR}from"@excalidraw/common";import{CaptureUpdateAction as _R}from"@excalidraw/element";var ka=G({name:"gridMode",icon:O0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:_R.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[DR.CTRL_OR_CMD]&&e.code===LR.QUOTE});import RR from"clsx";import{KEYS as Nv}from"@excalidraw/common";import{CaptureUpdateAction as NR}from"@excalidraw/element/store";import{getElementBounds as Bv}from"@excalidraw/element";import{isImageElement as BR}from"@excalidraw/element/typeChecks";import{jsx as OR}from"react/jsx-runtime";var Fv="Press <kbd>F</kbd> quickly to smart zoom the canvas, or hold and click on an item to smart zoom to it",Ma=et(!1),Ov=(e,n,t,o)=>{let r=e.filter(BR).sort((l,s)=>{let[d,c]=Bv(l,n),[m,p]=Bv(s,n);return c-p||d-m});if(r.length===0)return null;let i=r.findIndex(l=>l.id===t),a=o==="next"?(i+1)%r.length:(i<0?r.length-1:i-1+r.length)%r.length;return r[a]},FR=({data:e,updateData:n})=>{let t=Xi(Ma);return OR($,{type:"button",icon:Ph,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${Nv.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:Nv.F.toLocaleUpperCase(),className:RR({"smart-zoom-button--key-held":t})})},Hn=G({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Ph,viewMode:!0,perform:(e,n,t,o)=>{let r=Eo(n,o.props.editorPreferences).smartZoom,i=t&&t.length>0?t:de(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:NR.NEVER}},PanelComponent:FR});import{CODES as zR,KEYS as GR}from"@excalidraw/common";import{CaptureUpdateAction as HR}from"@excalidraw/element";var Ft=G({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:cr,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:HR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[GR.CTRL_OR_CMD]&&e.altKey&&e.code===zR.S});import{CaptureUpdateAction as UR}from"@excalidraw/element";var Ps=G({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:UR.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as WR}from"@excalidraw/element";var ks=G({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:WR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as VR,KEYS as YR}from"@excalidraw/common";import{CaptureUpdateAction as KR}from"@excalidraw/element";var Tr=G({name:"stats",label:"stats.fullTitle",icon:D0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:KR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[YR.CTRL_OR_CMD]&&e.altKey&&e.code===VR.SLASH});import{BOUND_TEXT_PADDING as zv,ROUNDNESS as Gv,TEXT_ALIGN as Wv,VERTICAL_ALIGN as Vv,arrayToMap as Yv,getFontString as XR,getStrokeWidthByKey as ZR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as $R,isBoundToContainer as Hv,resetOriginalContainerCache as jR,updateOriginalContainerCache as qR}from"@excalidraw/element";import{computeBoundTextPosition as JR,computeContainerDimensionForBoundText as Uv,getBoundTextElement as Kv,redrawTextBoundingBox as Xv}from"@excalidraw/element";import{hasBoundTextElement as QR,isArrowElement as eN,isTextBindableContainer as Gg,isTextElement as Ms,isUsingAdaptiveRadius as tN}from"@excalidraw/element";import{measureText as nN}from"@excalidraw/element";import{syncMovedIndices as Zv}from"@excalidraw/element";import{newElement as oN}from"@excalidraw/element";import{CaptureUpdateAction as Hg}from"@excalidraw/element";var Ug=G({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>QR(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=Kv(a,i);if(l){let{width:s,height:d}=nN(l.originalText,XR(l),l.lineHeight),c=$R(a.id);jR(a.id);let{x:m,y:p}=JR(a,l,i);o.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:n,captureUpdate:Hg.IMMEDIATELY}}}),Wg=G({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=Ms(r[0])||Ms(r[1]),a;if(Gg(r[0])?a=r[0]:Gg(r[1])&&(a=r[1]),i&&a&&Kv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;Ms(r[0])&&Gg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Vv.MIDDLE,textAlign:Wv.CENTER,autoResize:!0,angle:eN(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Xv(i,a,o.scene),qR(a.id,l),{elements:rN(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Hg.IMMEDIATELY}}}),rN=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),Zv(o,Yv([n,t])),o},iN=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),Zv(o,Yv([n,t])),o},$v=G({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>Ms(a)&&!Hv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let l of r)if(Ms(l)&&!Hv(l)){let s=oN({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:ZR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:tN("rectangle")?Gv.ADAPTIVE_RADIUS:Gv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-zv,y:l.y-zv,width:Uv(l.width,"rectangle"),height:Uv(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>d.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(l,{containerId:s.id,verticalAlign:Vv.MIDDLE,boundElements:null,textAlign:Wv.CENTER,autoResize:!0}),Xv(l,s,o.scene),i=iN([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Hg.IMMEDIATELY}}});import{getNonDeletedElements as i2,isEmbeddableElement as vN}from"@excalidraw/element";import{KEYS as a2}from"@excalidraw/common";import{CaptureUpdateAction as IN}from"@excalidraw/element";import{pointFrom as Qv}from"@excalidraw/math";import aN from"clsx";import{useCallback as jv,useEffect as qv,useLayoutEffect as lN,useRef as sN,useState as cN}from"react";import{EVENT as Vg,HYPERLINK_TOOLTIP_DELAY as dN,KEYS as Lm}from"@excalidraw/common";import{getElementAbsoluteCoords as $g}from"@excalidraw/element";import{hitElementBoundingBox as mN}from"@excalidraw/element";import{isElementLink as pN}from"@excalidraw/element";import{getEmbedLink as uN,embeddableURLValidator as hN}from"@excalidraw/element";import{sceneCoordsToViewportCoords as e2,viewportCoordsToSceneCoords as gN,wrapEvent as fN,isLocalLink as EN,normalizeLink as Yg}from"@excalidraw/common";import{isEmbeddableElement as Kg}from"@excalidraw/element";import{jsx as Aa,jsxs as Jv}from"react/jsx-runtime";var jg=380,bN=42,Xg=5,t2=85,xN=500,Zg=!1,Dm=new Map,n2=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),l=on(),s=St(),d=me(),c=e.link||"",[m,p]=cN(c),u=sN(null),E=l.showHyperlinkPopup==="editor",g=jv(()=>{if(!u.current)return;let I=Yg(u.current.value)||null;if(!e.link&&I&&Ye("hyperlink","create"),Kg(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!hN(I,s.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Dm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:P}=e,C=uN(I);C?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let k=C?C.intrinsicSize.w/C.intrinsicSize.h:1,M=Dm.get(e.id)!==e.link;n.mutateElement(e,{...M?{width:C?.type==="video"?T>P?T:P*k:T,height:C?.type==="video"&&T>P?T/k:P}:{},link:I}),i(e,!0),Dm.has(e.id)&&Dm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);lN(()=>()=>{g()},[g]),qv(()=>{E&&u?.current&&!(d.formFactor==="phone"||d.isTouchScreen)&&u.current.select()},[E,d.formFactor,d.isTouchScreen]),qv(()=>{let I=null,T=P=>{if(E)return;I&&clearTimeout(I),wN(e,a,l,Qv(P.clientX,P.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},xN))};return window.addEventListener(Vg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(Vg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[l,e,E,t,a]);let b=jv(()=>{Ye("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{Ye("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=o2(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:Jv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:jg,padding:Xg},children:[E?Aa("input",{className:aN("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[Lm.CTRL_OR_CMD]&&I.key===Lm.K&&I.preventDefault(),(I.key===Lm.ENTER||I.key===Lm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Aa("a",{href:Yg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:EN(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=fN(Vg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:Yg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Aa("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Jv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&Aa($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:co}),Aa($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:U0}),c&&!Kg(e)&&Aa($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Jr})]})]})},o2=(e,n,t)=>{let[o,r]=$g(e,t),{x:i,y:a}=e2({sceneX:o+e.width/2,sceneY:r},n),l=i-n.offsetLeft-jg/2,s=a-n.offsetTop-t2;return{x:l,y:s}},qg=(e,n)=>{let t=de(e,n);return Kg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},As=null,r2=(e,n,t)=>{As&&clearTimeout(As),As=window.setTimeout(()=>yN(e,n,t),dN)},yN=(e,n,t)=>{if(!e.link)return;let o=ga();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=pN(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,l]=$g(e,t),[s,d,c,m]=zx([r,i,a,l],e.angle,n),p=e2({sceneX:s,sceneY:d},n);gg(o,{left:p.x,top:p.y,width:c,height:m},"top"),Ye("hyperlink","tooltip","link-icon"),Zg=!0},_m=()=>{As&&clearTimeout(As),Zg&&(Zg=!1,ga().classList.remove("excalidraw-tooltip--visible"))},wN=(e,n,t,[o,r])=>{let{x:i,y:a}=gN({clientX:o,clientY:r},t),l=15/t.zoom.value;if(mN(Qv(i,a),e,n))return!1;let[s,d,c]=$g(e,n);if(i>=s&&i<=c&&a>=d-t2&&a<=d)return!1;let{x:m,y:p}=o2(e,t,n);return!(o>=m-l&&o<=m+jg+Xg*2+l&&r>=p-l&&r<=p+l+Xg*2+bN)};import{jsx as TN}from"react/jsx-runtime";var Jg=G({name:"hyperlink",label:(e,n)=>qg(i2(e),n),icon:Xl,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:IN.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[a2.CTRL_OR_CMD]&&e.key===a2.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return TN($,{type:"toggle",icon:Xl,"aria-label":f(qg(i2(e),n)),title:`${vN(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${B("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as l2,arrayToMap as ef,randomId as SN}from"@excalidraw/common";import{elementsAreInSameGroup as CN,getNonDeletedElements as s2,newElementWith as c2,selectGroupsFromGivenElements as d2}from"@excalidraw/element";import{CaptureUpdateAction as m2}from"@excalidraw/element";var Qg=e=>e.every(n=>!n.locked),Ls=G({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Qg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Qg(t)?so:_o},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Qg(r),a=ef(r),l=r.length>1&&CN(r),d=r.length===1||l?null:SN(),c={...n.lockedMultiSelections};if(i)c={...n.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete c[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?d&&(y=[...y,d]):y=y.filter(x=>!n.lockedMultiSelections[x]),c2(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=ef(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:d2(s2(E),n),b=i?d||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:c,activeLockedId:b},captureUpdate:m2.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===l2.L&&e[l2.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),p2=G({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:_o,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(l=>l.locked),o=e.map(l=>{if(l.locked){let s=l.groupIds.filter(d=>!n.lockedMultiSelections[d]);return c2(l,{locked:!1,groupIds:l.groupIds.length!==s.length?s:l.groupIds})}return l}),r=ef(o),i=t.map(l=>r.get(l.id)||l),a=s2(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(l=>[l.id,!0])),selectedGroupIds:d2(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:m2.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as z8,isLinearElement as G8,isLineElement as Oa}from"@excalidraw/element";import{arrayToMap as H8,invariant as $2}from"@excalidraw/common";import{toggleLinePolygonState as U8,CaptureUpdateAction as j2}from"@excalidraw/element";import{getSizeFromPoints as pCe,randomInteger as F8,getUpdatedTimestamp as O8}from"@excalidraw/common";import{simplify as E8}from"points-on-curve";import{getStroke as b8,getStrokePoints as XSe}from"perfect-freehand";function tt([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function La([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function lt([e,n,t],o){return[e*o,n*o,t*o]}function bi([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function kt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function u2(e,n,t){return tt(e,lt(La(n,e),t))}function tf(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function nf(e){return Math.atan2(Math.sin(e),Math.cos(e))}function of([e,n]){return Math.sqrt(e**2+n**2)}function Ei([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function h2(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Ei(e[t-1],e[t]);return n+=Ei(e[e.length-2],e[e.length-1]),n}var PN=(e,n,t)=>Math.max(n,Math.min(t,e));function g2(e,n,t){let o=Ei(n,t);if(o===0)return Ei(e,n);let r=PN(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return Ei(i,e)}function Ds(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,l],s,d)=>{let c=g2(s,t,o);return c>a?[c,d]:[a,l]},[0,-1]);if(r>=n){let a=e[i];return[...Ds([t,...e.slice(1,i),a],n).slice(0,-1),a,...Ds([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var Sr=class Sr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},Sr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=u2(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),h2(this.tailPoints)>Sr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=Ds(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let C=t[0],k=this.getSize(n,C[2],0,o,0);if(k<.5)return[];let M=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)M.push(tt(C,lt(kt([1,0,0],_),k)));return M.push(tt(C,lt([1,0,0],this.getSize(n,C[2],0,o,0)))),M}if(o===2){let C=t[0],k=t[1],M=this.getSize(n,C[2],0,o,0),_=this.getSize(n,k[2],0,o,0);if(M<.5||_<.5)return[];let L=[],R=tf(C,[C[0],C[1]-100,C[2]],k);for(let z=R;z<=Math.PI+R;z+=Math.PI/16)L.push(tt(C,lt(kt([1,0,0],z),M)));for(let z=Math.PI+R;z<=Math.PI*2+R;z+=Math.PI/16)L.push(tt(k,lt(kt([1,0,0],z),_)));return L.push(L[0]),L}let r=[],i=[],a=0,l=0,s=0,d=0;for(let C=1;C<o-1;C++){let k=t[C-1],M=t[C],_=t[C+1],L=M[2],R=Ei(k,M);d+=R,a=l+(R-l)*.2;let z=this.getSize(n,L,C,o,d);if(z===0){s=C+1;continue}let K=bi(La(k,M)),U=bi(La(_,M)),D=kt(K,Math.PI/2),H=kt(K,-Math.PI/2),F=kt(U,Math.PI/2),J=kt(U,-Math.PI/2),re=tt(M,lt(D,z)),O=tt(M,lt(H,z)),V=tt(M,lt(F,z)),ce=tt(M,lt(J,z)),pe=tt(D,J),Be=tt(H,F),Ee=tt(M,lt(of(pe)===0?K:bi(pe),z)),He=tt(M,lt(of(Be)===0?U:bi(Be),z)),se=nf(tf(M,k,_)),ke=Sr.constants.cornerDetectionMaxAngle/180*Math.PI*Sr.constants.cornerDetectionVariance(a);if(Math.abs(se)<ke){let Me=Math.abs(nf(Math.PI-se));if(Me===0)continue;if(se<0){i.push(O,He);for(let xe=0;xe<=Me;xe+=Me/4)r.push(tt(M,kt(lt(D,z),xe)));for(let xe=Me;xe>=0;xe-=Me/4)i.push(tt(M,kt(lt(D,z),xe)));i.push(He,V)}else{r.push(re,Ee);for(let xe=0;xe<=Me;xe+=Me/4)i.push(tt(M,kt(lt(D,-z),-xe)));for(let xe=Me;xe>=0;xe-=Me/4)r.push(tt(M,kt(lt(D,-z),-xe)));r.push(Ee,ce)}}else r.push(Ee),i.push(He);l=a}if(s>=o-2){if(this.options.keepHead){let C=t[o-1],k=[];for(let M=0;M<=Math.PI*2;M+=Math.PI/16)k.push(tt(C,lt(kt([1,0,0],M),this.options.size)));return k.push(tt(C,lt([1,0,0],this.options.size))),k}return[]}let c=t[s],m=t[s+1],p=t[o-2],u=t[o-1],E=bi(La(m,c)),g=bi(La(p,u)),b=kt(E,-Math.PI/2),w=kt(g,Math.PI/2),y=this.getSize(n,c[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,d),T=[];if(y>.1){for(let C=0;C<=Math.PI;C+=Math.PI/16)x.unshift(tt(c,kt(lt(b,y),-C)));x.unshift(tt(c,lt(b,-y)))}else x.push(c);for(let C=0;C<=Math.PI*3;C+=Math.PI/16)T.push(tt(u,kt(lt(w,-I),-C)));let P=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&P.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?Ds(P,this.options.simplify):P}};v(Sr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(Sr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Da=Sr;import{pointsOnBezierCurves as Wme}from"points-on-curve";import{invariant as Yme}from"@excalidraw/common";import{curve as Xme,lineSegment as Zme,pointFrom as $me,pointDistance as jme,pointFromArray as qme,pointFromVector as Jme,pointRotateRads as Qme,polygon as epe,polygonFromPoints as tpe,PRECISION as npe,segmentsIntersectAt as ope,vector as rpe,vectorAdd as ipe,vectorFromPoint as ape,vectorScale as lpe}from"@excalidraw/math";import{getElementAbsoluteCoords as cpe}from"@excalidraw/element";var rf=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as x8,pointDistance as W2,pointRotateRads as qSe}from"@excalidraw/math";import{ROUGHNESS as y8,THEME as Tf,isTransparent as Ys,assertNever as w8,COLOR_PALETTE as v8,LINE_POLYGON_POINT_MERGE_DISTANCE as QSe,applyDarkModeFilter as Ks,DEFAULT_STROKE_STREAMLINE as I8}from"@excalidraw/common";import{RoughGenerator as T8}from"roughjs/bin/generator";import rSe from"roughjs/bin/rough";import{isRightAngleRads as aSe,lineSegment as lSe,pointFrom as sSe,pointRotateRads as cSe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as mSe,DEFAULT_REDUCED_GLOBAL_ALPHA as pSe,ELEMENT_READY_TO_ERASE_OPACITY as uSe,FRAME_STYLE as hSe,DARK_THEME_FILTER as gSe,MIME_TYPES as U2,THEME as fSe,distance as ESe,getFontString as bSe,isRTL as xSe,getVerticalOffset as ySe,invariant as wSe,applyDarkModeFilter as vSe,isSafari as ISe}from"@excalidraw/common";import PTe from"roughjs/bin/rough";import{arrayToMap as MTe,invariant as H2,rescalePoints as ATe,sizeOf as LTe}from"@excalidraw/common";import{degreesToRadians as yf,lineSegment as _Te,pointFrom as Mt,pointFromArray as d8,pointRotateRads as Fa}from"@excalidraw/math";import{pointsOnBezierCurves as BTe}from"points-on-curve";import{pointCenter as YIe,pointFrom as KIe,pointRotateRads as XIe,pointsEqual as ZIe,pointDistance as $Ie,vectorFromPoint as jIe,curveLength as qIe,curvePointAtLength as JIe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as tTe,KEYS as nTe,shouldRotateWithDiscreteAngle as oTe,getGridPoint as rTe,invariant as iTe,isShallowEqual as aTe,getFeatureFlag as lTe}from"@excalidraw/common";import{arrayToMap as aIe,getFeatureFlag as lIe,getGridPoint as sIe,invariant as cIe,isTransparent as dIe}from"@excalidraw/common";import{PRECISION as pIe,clamp as uIe,lineSegment as hIe,pointDistance as gIe,pointDistanceSq as fIe,pointFrom as EIe,pointFromArray as bIe,pointFromVector as xIe,pointRotateRads as yIe,pointsEqual as wIe,vectorFromPoint as vIe,vectorNormalize as IIe,vectorScale as TIe}from"@excalidraw/math";import{invariant as P2e,isTransparent as k2e}from"@excalidraw/common";import{curveIntersectLineSegment as A2e,isPointWithinBounds as L2e,lineSegment as D2e,lineSegmentIntersectionPoints as _2e,pointFrom as R2e,pointFromVector as N2e,pointRotateRads as B2e,pointsEqual as F2e,vectorFromPoint as O2e,vectorNormalize as z2e,vectorScale as G2e}from"@excalidraw/math";import{ellipse as U2e,ellipseSegmentInterceptPoints as W2e}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as LN,DEFAULT_PROPORTIONAL_RADIUS as sf,invariant as ype,LINE_CONFIRM_THRESHOLD as DN,ROUNDNESS as cf}from"@excalidraw/common";import{bezierEquation as vpe,curve as Ipe,curveCatmullRomCubicApproxPoints as Tpe,curveOffsetPoints as Spe,lineSegment as Cpe,lineSegmentIntersectionPoints as Ppe,pointDistance as _N,pointFrom as kpe,pointFromArray as Mpe,pointFromVector as Ape,pointRotateRads as Lpe,pointTranslate as Dpe,rectangle as _pe,vectorFromPoint as Rpe,vectorNormalize as Npe,vectorScale as Bpe}from"@excalidraw/math";import{ROUNDNESS as upe,assertNever as hpe}from"@excalidraw/common";import{pointsEqual as fpe}from"@excalidraw/math";var f2=e=>!!e&&e.type==="embeddable",af=e=>!!e&&e.type==="iframe",lf=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),yn=e=>e!=null&&e.type==="text";var bo=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var wn=e=>e!=null&&MN(e.type);var Un=e=>e!=null&&e.type==="arrow",Wn=e=>Un(e)&&e.elbowed;var MN=e=>e==="arrow"||e==="line";var Ho=e=>e!==null&&"containerId"in e&&e.containerId!==null&&yn(e);var _a=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return _N(t,o)<=DN/n}return!1},_s=(e,n)=>{if(n.roundness?.type===cf.PROPORTIONAL_RADIUS||n.roundness?.type===cf.LEGACY)return e*sf;if(n.roundness?.type===cf.ADAPTIVE_RADIUS){let t=n.roundness?.value??LN,o=t/sf;return e<=o?e*sf:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as a2e,ARROW_LABEL_WIDTH_FRACTION as l2e,BOUND_TEXT_PADDING as s2e,DEFAULT_FONT_SIZE as c2e,TEXT_ALIGN as d2e,VERTICAL_ALIGN as m2e,getFontString as p2e,isProdEnv as u2e,invariant as h2e}from"@excalidraw/common";import{pointFrom as f2e,pointRotateRads as E2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as jpe,DEFAULT_FONT_SIZE as qpe,DEFAULT_FONT_FAMILY as Jpe,getFontString as Qpe,isTestEnv as eue,normalizeEOL as tue}from"@excalidraw/common";var nue="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as cue,isTestEnv as due}from"@excalidraw/common";import{toIterable as Qwe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as gue,viewportCoordsToSceneCoords as fue}from"@excalidraw/common";import{normalizeRadians as bue,radiansBetweenAngles as xue,radiansDifference as yue}from"@excalidraw/math";import{pointsEqual as vue}from"@excalidraw/math";import{arrayToMap as ahe,isShallowEqual as FN}from"@excalidraw/common";import{arrayToMap as Gue}from"@excalidraw/common";import{isPointWithinBounds as Uue,pointFrom as Wue,segmentsIntersectAt as Vue}from"@excalidraw/math";import{arrayToMap as kue}from"@excalidraw/common";import{validateOrderKey as Aue,generateNKeysBetween as Lue}from"@excalidraw/fractional-indexing";var df=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var hhe=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),Os=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){xi(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Ho(i)&&xi(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{bo(a)&&df(e,a.id).forEach(l=>!o.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var pf=(e,n)=>FN(n.selectedElementIds,e)?n.selectedElementIds:e;var ON=function(){let e=null,n=null,t=null,o=(i,a,l,s)=>{if(t!==void 0&&a===n&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let d={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let E=u.indexOf(l.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];d[E]=!0}}let c={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>d[g]);return E&&(p[u.id]=!0,Array.isArray(c[E])?c[E].push(u.id):c[E]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&d[p]&&(d[p]=!1);return n=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:pf({...l.selectedElementIds,...m},s)},t},r=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Os(a,i);return d.length?o(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:pf(i.selectedElementIds,l)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Dhe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as kge,VERTICAL_ALIGN as Mge}from"@excalidraw/common";import{pointDistance as Lge,pointFromVector as Dge,pointsEqual as _ge,vector as Rge,vectorDot as Nge,vectorFromPoint as Bge,vectorNormalize as Fge,vectorScale as Oge}from"@excalidraw/math";import{invariant as Vhe,isDevEnv as Yhe,isTestEnv as Khe}from"@excalidraw/common";import{pointFrom as Zhe,pointFromVector as $he,pointRotateRads as jhe,pointScaleFromOrigin as qhe,pointsEqual as Jhe,triangleIncludesPoint as Qhe,vectorCross as ege,vectorFromPoint as HN,vectorScale as tge}from"@excalidraw/math";var Hs=[1,0],Om=[0,1],Us=[-1,0],zm=[0,-1],Gm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Hs:n<=-r?Us:t>o?Om:zm},S2=(e,n)=>Gm(HN(e,n)),Hm=(e,n)=>Um(S2(e,n)),Gs=(e,n)=>e[0]===n[0]&&e[1]===n[1],Um=e=>Gs(e,Hs)||Gs(e,Us);import{DEFAULT_ELEMENT_PROPS as age,DEFAULT_FONT_FAMILY as lge,DEFAULT_FONT_SIZE as sge,DEFAULT_TEXT_ALIGN as cge,DEFAULT_VERTICAL_ALIGN as dge,DEFAULT_STROKE_STREAMLINE as mge,VERTICAL_ALIGN as pge,randomInteger as uge,randomId as hge,getFontString as gge,getUpdatedTimestamp as fge,getLineHeight as Ege}from"@excalidraw/common";import{pointsOnBezierCurves as lfe,simplify as sfe}from"points-on-curve";import{curveToBezier as dfe}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as pfe,lineSegment as ufe,lineSegmentIntersectionPoints as hfe,pointDistance as gfe,pointFrom as ffe,pointRotateRads as Efe,polygonArea as bfe,polygonIncludesPoint as xfe,polygonIncludesPointNonZero as yfe,polygonSignedArea as wfe}from"@excalidraw/math";import{isOpaqueColor as Ife,isTransparent as Tfe}from"@excalidraw/common";var M2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as $ge,distanceToLineSegment as jge,pointRotateRads as qge}from"@excalidraw/math";import{ellipse as Qge,ellipseDistanceFromPoint as efe}from"@excalidraw/math/ellipse";import{pointFrom as Ofe,pointCenter as zfe,pointRotateRads as Gfe,vectorFromPoint as Hfe,vectorNormalize as Ufe,vectorSubtract as Wfe,vectorAdd as Vfe,vectorScale as Yfe,pointFromVector as Kfe,clamp as Xfe,isCloseTo as Zfe}from"@excalidraw/math";import{arrayToMap as Ibe,arrayToObject as Tbe,assertNever as Sbe,isDevEnv as Cbe,isShallowEqual as Pbe,isTestEnv as kbe,randomInteger as Mbe}from"@excalidraw/common";import{assertNever as AEe,COLOR_PALETTE as LEe,isDevEnv as DEe,isTestEnv as _Ee,randomId as REe,Emitter as NEe,toIterable as BEe}from"@excalidraw/common";import{ORIG_ID as lEe,randomId as sEe,randomInteger as cEe,arrayToMap as dEe,castArray as mEe,findLastIndex as pEe,getUpdatedTimestamp as uEe,isTestEnv as hEe}from"@excalidraw/common";import{arrayToMap as Qfe}from"@excalidraw/common";import VN from"lodash.throttle";import{randomInteger as qEe,arrayToMap as JEe,toBrandedType as QEe,isDevEnv as D2,isTestEnv as _2,toArray as ebe}from"@excalidraw/common";import{isNonDeletedElement as nbe}from"@excalidraw/element";import{isFrameLikeElement as rbe}from"@excalidraw/element";import{getElementsInGroup as abe}from"@excalidraw/element";import{syncInvalidIndices as sbe,syncMovedIndices as cbe,validateFractionalIndices as YN}from"@excalidraw/element";import{getSelectedElements as mbe}from"@excalidraw/element";import{mutateElement as ube}from"@excalidraw/element";var hbe=VN(e=>{(D2()||_2()||window?.DEBUG_FRACTIONAL_INDICES)&&YN(e,{shouldThrow:D2()||_2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as exe,getGridPoint as txe,getFontString as nxe,DRAGGING_THRESHOLD as oxe}from"@excalidraw/common";import{clamp as hxe,pointDistance as gxe,pointFrom as fxe,pointScaleFromOrigin as Exe,pointsEqual as bxe,pointTranslate as xxe,vector as yxe,vectorCross as wxe,vectorFromPoint as vxe,vectorScale as Ixe}from"@excalidraw/math";import{BinaryHeap as Sxe,invariant as Cxe,isAnyTrue as Pxe,getSizeFromPoints as kxe,isDevEnv as Mxe,arrayToMap as Axe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as Vxe,normalizeLink as Yxe}from"@excalidraw/common";import{FONT_FAMILY as jxe,VERTICAL_ALIGN as qxe,escapeDoubleQuotes as Jxe,getFontString as Qxe}from"@excalidraw/common";import{invariant as s1e,toBrandedType as c1e}from"@excalidraw/common";import{clamp as m1e,pointFrom as p1e}from"@excalidraw/math";import{pointDistance as H1e,pointFrom as U1e}from"@excalidraw/math";import{invariant as V1e}from"@excalidraw/common";import{arrayToMap as C1e,findIndex as P1e,findLastIndex as k1e}from"@excalidraw/common";import{isFiniteNumber as A1e}from"@excalidraw/math";import{decodeAnimated as e0e}from"@discourse/gif";var a8="gif.worker.js";var n0e=new URL(a8,import.meta.url).toString();import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as s0e,MIME_TYPES as c0e,SVG_NS as d0e}from"@excalidraw/common";import{rgbaToThumbHash as p0e,thumbHashToRGBA as u0e}from"thumbhash";import{pointCenter as D0e,normalizeRadians as _0e,pointFrom as R0e,pointRotateRads as N0e}from"@excalidraw/math";import{MIN_FONT_SIZE as F0e,SHIFT_LOCKING_ANGLE as O0e,rescalePoints as z0e,getFontString as G0e}from"@excalidraw/common";import{pointFrom as uye,pointOnLineSegment as hye,pointRotateRads as gye}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Eye}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as eye}from"@excalidraw/common";import{pointFrom as nye,pointRotateRads as oye}from"@excalidraw/math";import{KEYS as Yn}from"@excalidraw/common";var kye=[{icon:id,value:"selection",key:Yn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:qi,value:"rectangle",key:Yn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ji,value:"diamond",key:Yn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Qi,value:"ellipse",key:Yn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:ad,value:"arrow",key:Yn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:lr,value:"line",key:Yn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:co,value:"freedraw",key:[Yn.P,Yn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Bn,value:"text",key:Yn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:qr,value:"image",key:[Yn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:ld,value:"eraser",key:Yn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as Gye}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as Uye,DEFAULT_FONT_SIZE as Wye,TEXT_ALIGN as Vye,VERTICAL_ALIGN as Yye,getSizeFromPoints as Kye,randomId as Xye,arrayToMap as Zye,assertNever as $ye,cloneJSON as jye,getFontString as qye,isDevEnv as Jye,toBrandedType as Qye,getLineHeight as ewe}from"@excalidraw/common";import{getBoundsFromPoints as Iwe,getElementAbsoluteCoords as Twe}from"@excalidraw/element/bounds";import{newArrowElement as Cwe,newElement as Pwe,newLinearElement as kwe}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Awe,getStrokeWidthByKey as Lwe,ROUNDNESS as Dwe}from"@excalidraw/common";import{convexHull as Rwe,distanceToLineSegment as Nwe,elongation as Bwe,kurtosis as Fwe,lineSegment as Owe,orientPrincipalAxes as zwe,pointFrom as Gwe,polygonArea as Hwe,principalAxes as Uwe,principalCoords as Wwe,skewness as Vwe}from"@excalidraw/math";var Zwe=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var xi=e=>!e.isDeleted;var n8=10/1.5;var Rm=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var m8=20,p8=15,u8=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 p8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return m8;default:return 15}},h8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},zt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=rf(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,l=i[a].data;H2(l.length===6,"Op data length is not 6");let s=Mt(l[4],l[5]),d=Mt(l[2],l[3]),c=Mt(l[0],l[1]),m=i[a-1],p=Mt(0,0);if(m.op==="move"){let F=d8(m.data);H2(F!=null,"Op data is not a point"),p=F}else m.op==="bcurveTo"&&(p=Mt(m.data[4],m.data[5]));let u=(F,J)=>Math.pow(1-F,3)*s[J]+3*F*Math.pow(1-F,2)*d[J]+3*Math.pow(F,2)*(1-F)*c[J]+p[J]*Math.pow(F,3),[E,g]=t==="start"?p:s,[b,w]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-w),x=(E-b)/y,I=(g-w)/y,T=u8(o),P=0;{let[F,J]=t==="end"?e.points[e.points.length-1]:e.points[0],[re,O]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];P=Math.hypot(F-re,J-O)}let k=Math.min(T,P*(o==="diamond"||o==="diamond_outline"?.25:.5)),M=E-x*k*r,_=g-I*k*r,L=M-x*k,R=_-I*k;if(o==="circle"||o==="circle_outline"){let F=Math.hypot(R-_,L-M)+e.strokeWidth-2;return[M,_,F]}let z=h8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[F,J]=Fa(Mt(M,_),Mt(L,R),yf(-z)),[re,O]=Fa(Mt(M,_),Mt(L,R),yf(z));return[L,R,F,J,re,O]}let[K,U]=Fa(Mt(L,R),Mt(M,_),-z*Math.PI/180),[D,H]=Fa(Mt(L,R),Mt(M,_),yf(z));if(o==="diamond"||o==="diamond_outline"){let F,J;if(t==="start"){let[re,O]=e.points.length>1?e.points[1]:[0,0];[F,J]=Fa(Mt(M+k*2,_),Mt(M,_),Math.atan2(O-_,re-M))}else{let[re,O]=e.points.length>1?e.points[e.points.length-2]:[0,0];[F,J]=Fa(Mt(M-k*2,_),Mt(M,_),Math.atan2(_-O,M-re))}return[M,_,K,U,F,J,D,H]}return[M,_,K,U,D,H]};var g8=typeof document<"u"?document.createElement("img"):{src:""};g8.src=`data:${U2.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 f8=typeof document<"u"?document.createElement("img"):{src:""};f8.src=`data:${U2.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 wf=new WeakMap;var Zt=class Zt{};v(Zt,"rg",new T8),v(Zt,"cache",new WeakMap),v(Zt,"get",(n,t)=>{let o=Zt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Zt,"delete",n=>{Zt.cache.delete(n),wf.delete(n)}),v(Zt,"destroy",()=>{Zt.cache=new WeakMap}),v(Zt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Zt.get(n,t?t.theme:null);if(o!==void 0)return o;wf.delete(n);let r=P8(n,Zt.rg,t||{isExporting:!1,canvasBackgroundColor:v8.white,embedsValidationStatus:null,theme:Tf.LIGHT});return t?.isExporting||Zt.cache.set(n,{shape:r,theme:t?.theme||Tf.LIGHT}),r});var Ba=Zt,S8=e=>[8,8+e],X2=e=>[1.5,6+e];function C8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&M2(e.type)||wn(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Wo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?S8(e.strokeWidth):e.strokeStyle==="dotted"?X2(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:C8(e),stroke:Ks(e.strokeColor,t),preserveVertices:n||e.roughness<y8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Ys(e.backgroundColor)?void 0:Ks(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return _a(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Ks(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},V2=(e,n,t)=>lf(e)&&(n||f2(e)&&t?.get(e.id)!==!0)&&Ys(e.backgroundColor)&&Ys(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:af(e)?{...e,strokeColor:Ys(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Ys(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Vs=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Vm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,l,s]=n;return[e.line(i,a,o,r,t),e.line(l,s,o,r,t)]},wi=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=X2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},vf=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,l,s]=o,d={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete d.strokeLineDash,[e.circle(a,l,s*i,d)]},Y2=(e,n,t,o,r,i,a,l)=>{if(o===null)return[];let s=Ks(e.strokeColor,l),d=Ks(a,l),c=-.25,m=.8;switch(o){case"circle":case"circle_outline":return vf(r,i,s,zt(e,n,t,o),o==="circle_outline"?d:s);case"triangle":case"triangle_outline":{let p=zt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y]=p,x={...i,fill:o==="triangle_outline"?d:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=zt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y,x,I]=p,T={...i,fill:o==="diamond_outline"?d:s,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[x,I],[u,E]],T)]}case"cardinality_one":return Vs(r,zt(e,n,t,o),wi(e,i));case"cardinality_many":return Vm(r,zt(e,n,t,o),wi(e,i));case"cardinality_one_or_many":{let p=wi(e,i);return[...Vm(r,zt(e,n,t,"cardinality_many"),p),...Vs(r,zt(e,n,t,"cardinality_one",c),p)]}case"cardinality_exactly_one":{let p=wi(e,i);return[...Vs(r,zt(e,n,t,"cardinality_one",-.5),p),...Vs(r,zt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=wi(e,i);return[...vf(r,i,s,zt(e,n,t,"circle_outline",1.5),d,m),...Vs(r,zt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=wi(e,i);return[...Vm(r,zt(e,n,t,"cardinality_many"),p),...vf(r,i,s,zt(e,n,t,"circle_outline",1.5),d,m)]}case"bar":case"arrow":default:return Vm(r,zt(e,n,t,o),wi(e,i))}};var P8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Tf.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let l;if(e.roundness){let s=e.width,d=e.height,c=_s(Math.min(s,d),e);l=n.path(`M ${c} 0 L ${s-c} 0 Q ${s} 0, ${s} ${c} L ${s} ${d-c} Q ${s} ${d}, ${s-c} ${d} L ${c} ${d} Q 0 ${d}, 0 ${d-c} L 0 ${c} Q 0 0, ${c} 0`,Wo(V2(e,t,r),!0,a))}else l=n.rectangle(0,0,e.width,e.height,Wo(V2(e,t,r),!1,a));return l}case"diamond":{let l,[s,d,c,m,p,u,E,g]=Rm(e);if(e.roundness){let b=_s(Math.abs(s-E),e),w=_s(Math.abs(m-d),e);l=n.path(`M ${s+b} ${d+w} L ${c-b} ${m-w}
|
|
5
|
+
C ${c} ${m}, ${c} ${m}, ${c-b} ${m+w}
|
|
6
|
+
L ${p+b} ${u-w}
|
|
7
|
+
C ${p} ${u}, ${p} ${u}, ${p-b} ${u-w}
|
|
8
8
|
L ${E+b} ${g+w}
|
|
9
9
|
C ${E} ${g}, ${E} ${g}, ${E+b} ${g-w}
|
|
10
10
|
L ${s-b} ${d+w}
|
|
11
|
-
C ${s} ${d}, ${s} ${d}, ${s+b} ${d+w}`,Ro(e,!0,a))}else l=n.polygon([[s,d],[c,p],[m,u],[E,g]],Ro(e,!1,a));return l}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Ro(e,!1,a));case"line":case"arrow":{let l,s=Ro(e,!1,a),d=e.points.length?e.points:[ZN(0,0)];if(On(e)?d.every(c=>Math.abs(c[0])<=1e6&&Math.abs(c[1])<=1e6)?l=[n.path(o8(d,16),Ro(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(d)),l=[]):e.roundness?l=[n.curve(d,s)]:s.fill?l=[n.polygon(d,s)]:l=[n.linearPath(d,s)],e.type==="arrow"){let{startArrowhead:c=null,endArrowhead:p="arrow"}=e;if(c!==null){let m=P2(e,l,"start",c,n,s,o,a);l.push(...m)}if(p!==null){let m=P2(e,l,"end",p,n,s,o,a);l.push(...m)}}return l}case"freedraw":{let l=[];if(Sa(e.points)){let s=KN(e.points,.75);l.push(n.curve(s,{...Ro(e,!1,a),stroke:"none"}))}return l.push(r8(e)),l}case"frame":case"magicframe":case"text":case"image":return null;default:return jN(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},o8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=Dm(l,i),d=Dm(a,l),c=Math.min(n,S2(e[r],a)/2,S2(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c]),t.push(e[r]),d?a[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var r8=e=>m8(c8(e)),pf={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},i8={SIZE_FACTOR:1.4},A2=e=>e.strokeOptions?.streamline??JN,a8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return XN(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*pf.SIZE_FACTOR,thinning:pf.THINNING,smoothing:pf.SMOOTHING,streamline:A2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},l8=e=>new Ta({size:e.strokeWidth*i8.SIZE_FACTOR,streamline:A2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),s8=e=>{let n=l8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},c8=e=>e.strokeOptions?.variability==="constant"?s8(e):a8(e);var k2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],d8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,m8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,k2(o,i[0]),"L",i[0],"Z"):t.push(o,k2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(d8,"$1")};var gi=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??p8(),updated:u8()}};import{jsx as _2}from"react/jsx-runtime";var La=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&g8(r[0])&&!h8(r[0]))},perform(e,n,t,o){L2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);L2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:D2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return _2($,{type:"button",icon:P0,title:r,"aria-label":r,onClick:()=>n(null)})}}),GSe=O({name:"togglePolygon",icon:Ku,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Aa(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>Aa(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(s=>!Aa(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=f8(i);return{elements:e.map(s=>!l.has(s.id)||!Aa(s)?s:gi(s,{backgroundColor:a?s.backgroundColor:"transparent",...E8(s,a)})),appState:n,captureUpdate:D2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Aa(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Aa(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return _2($,{type:"toggle",icon:Ku,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as R2,CANVAS_SEARCH_TAB as N2,CLASSES as b8,DEFAULT_SIDEBAR as B2}from"@excalidraw/common";import{CaptureUpdateAction as x8}from"@excalidraw/element";var Gs=O({name:"searchMenu",icon:ao,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===B2.name&&n.openSidebar.tab===N2){let r=o.excalidrawContainerValue.container?.querySelector(`.${b8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:B2.name,tab:N2},openDialog:null},captureUpdate:x8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[R2.CTRL_OR_CMD]&&e.key===R2.F});import{isImageElement as y8}from"@excalidraw/element";import{CaptureUpdateAction as w8}from"@excalidraw/element";import{jsx as v8}from"react/jsx-runtime";var hf=O({name:"cropEditor",label:"helpDialog.cropStart",icon:fh,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:w8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&y8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return v8($,{type:"button",icon:fh,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as I8}from"@excalidraw/element";import{mutateElement as T8}from"@excalidraw/element";import{newFrameElement as S8}from"@excalidraw/element";import{isFrameLikeElement as Bm}from"@excalidraw/element";import{addElementsToFrame as C8,removeAllElementsFromFrame as P8}from"@excalidraw/element";import{getFrameChildren as k8}from"@excalidraw/element";import{getElementsInGroup as M8}from"@excalidraw/element";import{getCommonBounds as A8}from"@excalidraw/element";import{CaptureUpdateAction as Da}from"@excalidraw/element";var F2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Bm(t[0])},O2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Bm(r)){let i=k8(I8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:Da.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Da.EVENTUALLY}},predicate:(e,n,t,o)=>F2(n,o)}),z2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Bm(r)?{elements:P8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Da.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Da.EVENTUALLY}},predicate:(e,n,t,o)=>F2(n,o)}),jCe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:Da.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),G2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=de(e,n);return r.length>0&&!r.some(i=>Bm(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,l,s,d]=A8(r,i),c=16,p=S8({x:a-c,y:l-c,width:s-a+c*2,height:d-l+c*2});if(n.editingGroupId){let u=M8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);T8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:C8([...o.scene.getElementsIncludingDeleted(),p],r,p),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:Da.IMMEDIATELY}}});import{KEYS as Ra,matchKey as Ef,arrayToMap as H2,MOBILE_ACTION_BUTTON_BG as U2}from"@excalidraw/common";import{CaptureUpdateAction as ff}from"@excalidraw/element";import{orderByFractionalIndex as F8}from"@excalidraw/element";import{Emitter as L8}from"@excalidraw/common";import{CaptureUpdateAction as D8,StoreChange as _8,StoreDelta as R8}from"@excalidraw/element";var _a=class extends R8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},Ei=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},Hs=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new L8);v(this,"undoStack",[]);v(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(n){if(n.isEmpty()||n instanceof _a)return;let t=_a.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=D8.IMMEDIATELY,l=this.store.snapshot,s=n,d=t,c=!1;for(;i;){try{[s,d,c]=i.applyTo(s,d,l);let p=l.elements,m=l.maybeClone(a,s,d),u=_8.create(l,m),E=_a.applyLatestChanges(i,p,s);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),l=m}finally{r(i)}if(c)break;i=o()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new Ei(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=_a.inverse(t);return n.push(o)}};import{useEffect as N8,useState as B8}from"react";var gf=(e,n)=>{let[t,o]=B8(n);return N8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as K2}from"react/jsx-runtime";var W2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:ff.EVENTUALLY};let[r,i]=o,a=F8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:ff.NEVER}}return{captureUpdate:ff.EVENTUALLY}},V2=e=>({name:"undo",label:"buttons.undo",icon:ju,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>W2(r,t,()=>e.undo(H2(n),t)),keyTest:n=>n[Ra.CTRL_OR_CMD]&&Ef(n,Ra.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=gf(e.onHistoryChangedEmitter,new Ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return K2($,{type:"button",icon:ju,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?U2:{}}})}}),Y2=e=>({name:"redo",label:"buttons.redo",icon:qu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>W2(r,t,()=>e.redo(H2(n),t)),keyTest:n=>n[Ra.CTRL_OR_CMD]&&n.shiftKey&&Ef(n,Ra.Z)||n[Ra.CTRL_OR_CMD]&&!n.shiftKey&&Ef(n,Ra.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=gf(e.onHistoryChangedEmitter,new Ei(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return K2($,{type:"button",icon:qu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?U2:{}}})}});import{getFontString as O8}from"@excalidraw/common";import{getTextAnchorRatios as z8,isExcalidrawElement as G8,isNonDeletedElement as H8,newElementWith as U8,updateBoundElements as W8}from"@excalidraw/element";import{measureText as V8}from"@excalidraw/element";import{isTextElement as bf}from"@excalidraw/element";import{CaptureUpdateAction as Y8}from"@excalidraw/element";var xf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&bf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=G8(t)&&bf(t)?t:r[0],a=e.find(c=>c.id===i?.id);if(!a||!bf(a))return!1;let l=V8(a.originalText,O8(a),a.lineHeight),s=z8(a),d=U8(a,{autoResize:!0,width:l.width,height:l.height,x:a.x+(a.width-l.width)*s.x,y:a.y+(a.height-l.height)*s.y,text:a.originalText});return H8(d)&&W8(d,o.scene,{changedElements:new Map([[d.id,d]])}),{appState:n,elements:e.map(c=>c.id===d.id?d:c),captureUpdate:Y8.IMMEDIATELY}}});import{CODES as K8,KEYS as X8}from"@excalidraw/common";import Z8 from"clsx";import{CaptureUpdateAction as $8}from"@excalidraw/element";import{jsx as j8}from"react/jsx-runtime";var Na=O({name:"viewMode",label:"labels.viewMode",icon:Jr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:$8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[X8.CTRL_OR_CMD]&&e.altKey&&!e.shiftKey&&e.code===K8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return j8($,{type:"button",icon:t.viewModeEnabled?yh:Jr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:Z8({enabled:t.viewModeEnabled})})}});import{isPromiseLike as q8}from"@excalidraw/common";import{jsx as J8}from"react/jsx-runtime";var yf=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ye(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Fm=class{constructor(n,t,o,r){v(this,"actions",{});v(this,"updater");v(this,"getAppState");v(this,"getElementsIncludingDeleted");v(this,"app");v(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);v(this,"isActionEnabledByCanvasOptions",n=>{let t=this.app.props.UIOptions.canvasActions;return n.name==="saveFileToDisk"?!!(t.export&&typeof t.export=="object"&&t.export.saveFileToDisk):n.name in t?!!t[n.name]:!0});v(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=l=>{this.isActionBlockedByViewportTransition(r)||(yf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,l),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),l,this.app)))};return J8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});v(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});v(this,"isActionAvailableForUI",n=>{let t=this.getAppState();return this.isActionEnabledByCanvasOptions(n)&&this.isActionEnabled(n)&&(!t.viewModeEnabled||n.viewMode===!0)&&(this.app.isInteractionEnabled()||this.app.isNavigationEnabled()&&n.navigation===!0)&&!this.isActionBlockedByViewportTransition(n)});this.updater=i=>{if(q8(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return yf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,l,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();yf(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var wf=e=>{let n=Array.from(e.values());return{x:X2(n,t=>t.x)/n.length,y:X2(n,t=>t.y)/n.length}},vf=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),X2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as vr,rangeInclusive as xn,rangeIntersection as Om,rangesOverlap as zm}from"@excalidraw/math";import{TOOL_TYPE as bi,KEYS as Z2}from"@excalidraw/common";import{getCommonBounds as If,getDraggedElementsBounds as Tf,getElementAbsoluteCoords as Q8}from"@excalidraw/element";import{isBoundToContainer as J2}from"@excalidraw/element";import{getMaximumGroups as Q2}from"@excalidraw/element";import{getSelectedElements as e7,getVisibleAndNonSelectedElements as eI}from"@excalidraw/element";var t7=8,$2=99999,Gm=e=>t7/e,zt=class zt{};v(zt,"referenceSnapPoints",null),v(zt,"visibleGaps",null),v(zt,"setReferenceSnapPoints",n=>{zt.referenceSnapPoints=n}),v(zt,"getReferenceSnapPoints",()=>zt.referenceSnapPoints),v(zt,"setVisibleGaps",n=>{zt.visibleGaps=n}),v(zt,"getVisibleGaps",()=>zt.visibleGaps),v(zt,"destroy",()=>{zt.referenceSnapPoints=null,zt.visibleGaps=null});var yn=zt,Ir=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,No=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[Z2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[Z2.CTRL_OR_CMD]&&!Ir(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},n7=(e,n,t=.01)=>Math.abs(e-n)<=t,Us=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,c,p,m]=Q8(a,n);r&&(l+=r.x,d+=r.x,p+=r.x,s+=r.y,c+=r.y,m+=r.y);let u=(d-l)/2,E=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=vr(X(l,s+E),X(p,m),a.angle),b=vr(X(l+u,s),X(p,m),a.angle),w=vr(X(d,s+E),X(p,m),a.angle),y=vr(X(l+u,c),X(p,m),a.angle),x=X(p,m);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=vr(X(l,s),X(p,m),a.angle),b=vr(X(d,s),X(p,m),a.angle),w=vr(X(l,c),X(p,m),a.angle),y=vr(X(d,c),X(p,m),a.angle),x=X(p,m);i=t?[g,b,w,y]:[g,b,w,y,x]}}else if(e.length>1){let[a,l,s,d]=Tf(e,r??{x:0,y:0}),c=s-a,p=d-l,m=X(a,l),u=X(s,l),E=X(a,d),g=X(s,d),b=X(a+c/2,l+p/2);i=t?[m,u,E,g]:[m,u,E,g,b]}return i.map(a=>X(qe(a[0]),qe(a[1])))},tI=(e,n,t,o)=>eI(e,n,t,o),nI=(e,n,t,o)=>{let r=tI(e,n,t,o),i=Q2(r,o).filter(p=>!(p.length===1&&J2(p[0]))).map(p=>If(p).map(m=>qe(m))),a=i.sort((p,m)=>p[0]-m[0]),l=[],s=0;e:for(let p=0;p<a.length;p++){let m=a[p];for(let u=p+1;u<a.length;u++){if(++s>$2)break e;let E=a[u],[,g,b,w]=m,[y,x,,I]=E;b<y&&zm(xn(g,w),xn(x,I))&&l.push({startBounds:m,endBounds:E,startSide:[X(b,g),X(b,w)],endSide:[X(y,x),X(y,I)],length:y-b,overlap:Om(xn(g,w),xn(x,I))})}}let d=i.sort((p,m)=>p[1]-m[1]),c=[];s=0;e:for(let p=0;p<d.length;p++){let m=d[p];for(let u=p+1;u<d.length;u++){if(++s>$2)break e;let E=d[u],[g,,b,w]=m,[y,x,I]=E;w<x&&zm(xn(g,b),xn(y,I))&&c.push({startBounds:m,endBounds:E,startSide:[X(g,w),X(b,w)],endSide:[X(y,x),X(I,x)],length:x-w,overlap:Om(xn(g,b),xn(y,I))})}}return{horizontalGaps:l,verticalGaps:c}},j2=(e,n,t,o,r,i,a)=>{if(!No({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let l=yn.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[c,p,m,u]=Tf(e,n).map(b=>qe(b)),E=(c+m)/2,g=(p+u)/2;for(let b of s){if(!zm(xn(p,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=qe(w-E);if(b.length>m-c&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:b,offset:y};r.push(_);continue}let[,,I]=b.endBounds,T=c-I,C=qe(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,M=P-m,L=qe(M-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of d){if(!zm(xn(c,m),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=qe(w-g);if(b.length>u-p&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:b,offset:y};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=qe(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,M=qe(p-P),L=b.length-M;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},oI=(e,n,t,o)=>{let r=tI(e,n,t,o);return Q2(r,o).filter(i=>!(i.length===1&&J2(i[0]))).flatMap(i=>Us(i,o))},Ba=(e,n,t,o,r,i,a)=>{if(!No({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let l=yn.getReferenceSnapPoints();if(l)for(let s of n)for(let d of l){let c=d[0]-s[0],p=d[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(r.length=0),r.push({type:"point",points:[s,d],offset:c}),a.x=Math.abs(c)),Math.abs(p)<=a.y&&(Math.abs(p)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:p}),a.y=Math.abs(p))}},rI=(e,n,t,o,r)=>{let i=t.state,a=e7(e,i);if(!No({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=qe(n.x),n.y=qe(n.y);let l=[],s=[],d=Gm(i.zoom.value),c={x:d,y:d},p=Us(a,r,{dragOffset:n});Ba(a,p,t,o,l,s,c),j2(a,n,t,o,l,s,c);let m={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:qe(n.x+m.x),y:qe(n.y+m.y)};Ba(a,Us(a,r,{dragOffset:u}),t,o,l,s,c),j2(a,u,t,o,l,s,c);let E=Sf(l,s),g=r7(a,u,[...l,...s].filter(b=>b.type==="gap"));return{snapOffset:m,snapLines:[...E,...g]}},qe=e=>Math.round(e*10**6)/10**6,q2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},Sf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=qe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(qe(a[0]),qe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=qe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(qe(a[0]),qe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:q2(i.map(a=>X(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:q2(i.map(a=>X(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},o7=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[qe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},r7=(e,n,t)=>{let[o,r,i,a]=Tf(e,n),l=[];for(let s of t){let[d,c,p,m]=s.gap.startBounds,[u,E,g,b]=s.gap.endBounds,w=Om(xn(r,a),s.gap.overlap),y=Om(xn(o,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(s.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(s.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,s.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(p,x),X(u,x)]},{type:"gap",direction:"horizontal",points:[X(g,x),X(o,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(i,x),X(d,x)]},{type:"gap",direction:"horizontal",points:[X(p,x),X(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,c)]},{type:"gap",direction:"vertical",points:[X(x,m),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,m),X(x,E)]},{type:"gap",direction:"vertical",points:[X(x,b),X(x,r)]})}break}}}return o7(l.map(s=>({...s,points:s.points.map(d=>X(qe(d[0]),qe(d[1])))})))},Cf=(e,n,t,o,r,i)=>{if(!No({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!n7(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=If(n);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(d+=r.y));let c=[];if(i)switch(i){case"e":{c.push(X(s,l),X(s,d));break}case"w":{c.push(X(a,l),X(a,d));break}case"n":{c.push(X(a,l),X(s,l));break}case"s":{c.push(X(a,d),X(s,d));break}case"ne":{c.push(X(s,l));break}case"nw":{c.push(X(a,l));break}case"se":{c.push(X(s,d));break}case"sw":{c.push(X(a,d));break}}let p=Gm(t.state.zoom.value),m={x:p,y:p},u=[],E=[];Ba(n,c,t,o,u,E,m);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};m.x=0,m.y=0,u.length=0,E.length=0;let[b,w,y,x]=If(e).map(C=>qe(C)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];Ba(e,I,t,o,u,E,m);let T=Sf(u,E);return{snapOffset:g,snapLines:T}},iI=(e,n,t,o,r,i)=>{if(!No({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],l=Gm(n.state.zoom.value),s={x:l,y:l},d=[],c=[];Ba([e],a,n,t,d,c,s);let p={x:d[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,d.length=0,c.length=0;let m=Us([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ba([e],m,n,t,d,c,s);let u=Sf(d,c);return{snapOffset:p,snapLines:u}},aI=(e,n,t,o,r)=>{if(!No({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=eI(e,[],n.state,r),a=Gm(n.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let c of i){let p=Us([c],r);for(let m of p){let u=m[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[m,X(m[0],t.y)],direction:"vertical"}),l.x=u);let E=m[1]-t.y;Math.abs(E)<=Math.abs(l.y)&&(Math.abs(E)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[m,X(t.x,m[1])],direction:"horizontal"}),l.y=E)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},lI=e=>e===bi.rectangle||e===bi.ellipse||e===bi.diamond||e===bi.frame||e===bi.magicframe||e===bi.image||e===bi.text;import{getCommonFrameId as i7,getFrameChildrenInsertionIndex as a7,isElementInViewport as l7}from"@excalidraw/element";import{arrayToMap as s7,memoize as c7,toBrandedType as d7}from"@excalidraw/common";var Ws=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",c7(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s,editingTextElement:d,newElement:c})=>{let p=this.scene.getNonDeletedElements(),{elementsMap:m,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:p,editingTextElement:d,newElement:c}),E=this.getVisibleCanvasElements({elementsMap:m,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s});return{elementsMap:m,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));v(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&i7(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s}){let d=[];for(let c of n.values())l7(c,s,l,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&d.push(c);return d}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=d7(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=s7(t),i=n.filter(l=>!r.has(l.id)),a=a7(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Lx.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as g7,easeOut as dI}from"@excalidraw/common";import{SVG_NS as cI,getSvgPathFromStroke as u7,sceneCoordsToViewportCoords as h7}from"@excalidraw/common";import{version as m7}from"react";import{unstable_batchedUpdates as sI}from"react-dom";import{throttleRAF as p7}from"@excalidraw/common";var Je=e=>n=>{sI(e,n)},Hm=e=>p7(n=>{sI(e,n)}),Fa=(()=>{let e;try{let t=m7.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var he=class he{static start(n,t){if(he.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};he.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw he.animations.get(n)===o&&(he.animations.delete(n),he.cancelScheduledFrameIfIdle()),i}if(he.animations.get(n)===o){if(!r){he.animations.delete(n),he.cancelScheduledFrameIfIdle();return}o.state=r,he.scheduleNextFrame()}}static scheduleNextFrame(){he.scheduledFrame||(Fa()?he.scheduledFrame={id:requestAnimationFrame(he.tick),type:"raf"}:he.scheduledFrame={id:setTimeout(he.tick,0),type:"timeout"})}static cancelScheduledFrame(){he.scheduledFrame&&(he.scheduledFrame.type==="raf"?cancelAnimationFrame(he.scheduledFrame.id):clearTimeout(he.scheduledFrame.id),he.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return he.animations.size>0?!1:(he.cancelScheduledFrame(),!0)}static tick(){if(he.scheduledFrame=null,he.animations.size>0){let n=[...he.animations];for(let[t,o]of n){if(he.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(he.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(he.animations.delete(t),he.cancelScheduledFrameIfIdle())return}}if(he.cancelScheduledFrameIfIdle())return;he.scheduleNextFrame()}}static running(n){return he.animations.has(n)}static cancel(n){he.animations.delete(n),he.cancelScheduledFrameIfIdle()}static reset(){he.animations.clear(),he.cancelScheduledFrame()}};v(he,"scheduledFrame",null),v(he,"animations",new Map);var mt=he;var Um=class Um{constructor(n,t){this.app=n;this.options=t;v(this,"currentTrail");v(this,"pastTrails",[]);v(this,"container");v(this,"trailElement");v(this,"trailAnimation");v(this,"key");this.key=`animated-trail-${Um.counter++}`,this.trailElement=document.createElementNS(cI,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(cI,"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(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),mt.running(this.key)||mt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){mt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Ta(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,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 n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let l=h7({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return u7(r,!0)}};v(Um,"counter",0);var Hn=Um;var Wm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Hn(n,{...this.getTrailOptions(),fill:()=>g7})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(dI(i),dI(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Hn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||ci(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",l=r.hasCurrentTrail;i&&!l&&r.startPath(o.pointer.x,o.pointer.y);let s=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&s&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&l&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as f7}from"@excalidraw/common";import{pointFrom as Vs,pointRotateRads as Vm}from"@excalidraw/math";var E7=12,Pf=16,b7=10,x7=Pf+2,y7=.8,kf=e=>f7*2/e,Mf=(e,n,t)=>{let o=kf(n);if(t!=="desktop"||Pf>(e.height+o*2)*n*y7)return null;let r=E7/n,i=Pf/n,a=Vs(e.x+e.width/2,e.y+e.height/2),l=Vm(Vs(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:l,start:Vm(Vs(l[0],l[1]-i/2),l,e.angle),end:Vm(Vs(l[0],l[1]+i/2),l,e.angle),hitboxWidth:b7/n,hitboxHeight:x7/n}},mI=(e,n,t,o)=>{let r=Mf(n,t,o);if(!r)return!1;let i=Vm(Vs(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as Af,KEYS as Ys,CLASSES as Lf,POINTER_BUTTON as w7,THEME as v7,isWritableElement as I7,getFontString as pI,getFontFamilyString as uI,isTestEnv as hI,MIME_TYPES as Df,applyDarkModeFilter as T7,isRTL as S7,getViewpointFlipSign as gI}from"@excalidraw/common";import{pointFrom as fI,pointRotateRads as C7}from"@excalidraw/math";import{getTextFromElements as P7,originalContainerCache as k7,updateBoundElements as EI,updateOriginalContainerCache as bI}from"@excalidraw/element";import{LinearElementEditor as M7}from"@excalidraw/element/linearElementEditor";import{bumpVersion as A7}from"@excalidraw/element";import{getBoundTextElementId as L7,getContainerElement as _f,getTextElementAngle as D7,redrawTextBoundingBox as _7,getBoundTextMaxHeight as R7,getBoundTextMaxWidth as xI,computeContainerDimensionForBoundText as yI,computeBoundTextPosition as N7,getBoundTextElement as B7}from"@excalidraw/element";import{getTextWidth as F7}from"@excalidraw/element";import{getLineHeightInPx as O7}from"@excalidraw/element";import{getLineWidth as z7}from"@excalidraw/element";import{normalizeText as wI}from"@excalidraw/element";import{wrapText as G7}from"@excalidraw/element";import{getWrappedTextLines as H7}from"@excalidraw/element";import{isArrowElement as Ym,isBoundToContainer as U7,isTextElement as vI}from"@excalidraw/element";var W7=(e,n,t,o,r,i)=>{let{zoom:a}=o,l=180*t/Math.PI,s=e*(a.value-1)/2,d=n*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),n>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value*gI(o.viewpointFlip.horizontal)}, ${a.value*gI(o.viewpointFlip.vertical)}) rotate(${l}deg)`},V7=(e,n)=>{let t=e.lastIndexOf(`
|
|
11
|
+
C ${s} ${d}, ${s} ${d}, ${s+b} ${d+w}`,Wo(e,!0,a))}else l=n.polygon([[s,d],[c,m],[p,u],[E,g]],Wo(e,!1,a));return l}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Wo(e,!1,a));case"line":case"arrow":{let l,s=Wo(e,!1,a),d=e.points.length?e.points:[x8(0,0)];if(Wn(e)?d.every(c=>Math.abs(c[0])<=1e6&&Math.abs(c[1])<=1e6)?l=[n.path(k8(d,16),Wo(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(d)),l=[]):e.roundness?l=[n.curve(d,s)]:s.fill?l=[n.polygon(d,s)]:l=[n.linearPath(d,s)],e.type==="arrow"){let{startArrowhead:c=null,endArrowhead:m="arrow"}=e;if(c!==null){let p=Y2(e,l,"start",c,n,s,o,a);l.push(...p)}if(m!==null){let p=Y2(e,l,"end",m,n,s,o,a);l.push(...p)}}return l}case"freedraw":{let l=[];if(_a(e.points)){let s=E8(e.points,.75);l.push(n.curve(s,{...Wo(e,!1,a),stroke:"none"}))}return l.push(M8(e)),l}case"frame":case"magicframe":case"text":case"image":return null;default:return w8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},k8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=Hm(l,i),d=Hm(a,l),c=Math.min(n,W2(e[r],a)/2,W2(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c]),t.push(e[r]),d?a[0]<l[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var M8=e=>B8(R8(e)),If={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},A8={SIZE_FACTOR:1.4},Z2=e=>e.strokeOptions?.streamline??I8,L8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return b8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*If.SIZE_FACTOR,thinning:If.THINNING,smoothing:If.SMOOTHING,streamline:Z2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},D8=e=>new Da({size:e.strokeWidth*A8.SIZE_FACTOR,streamline:Z2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),_8=e=>{let n=D8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},R8=e=>e.strokeOptions?.variability==="constant"?_8(e):L8(e);var K2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],N8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,B8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,K2(o,i[0]),"L",i[0],"Z"):t.push(o,K2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(N8,"$1")};var yi=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??F8(),updated:O8()}};import{jsx as q2}from"react/jsx-runtime";var za=G({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&G8(r[0])&&!z8(r[0]))},perform(e,n,t,o){$2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);$2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:j2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return q2($,{type:"button",icon:z0,title:r,"aria-label":r,onClick:()=>n(null)})}}),CCe=G({name:"togglePolygon",icon:eh,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Oa(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>Oa(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(s=>!Oa(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=H8(i);return{elements:e.map(s=>!l.has(s.id)||!Oa(s)?s:yi(s,{backgroundColor:a?s.backgroundColor:"transparent",...U8(s,a)})),appState:n,captureUpdate:j2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Oa(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Oa(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return q2($,{type:"toggle",icon:eh,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as J2,CANVAS_SEARCH_TAB as Q2,CLASSES as W8,DEFAULT_SIDEBAR as eI}from"@excalidraw/common";import{CaptureUpdateAction as V8}from"@excalidraw/element";var Xs=G({name:"searchMenu",icon:hn,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===eI.name&&n.openSidebar.tab===Q2){let r=o.excalidrawContainerValue.container?.querySelector(`.${W8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:eI.name,tab:Q2},openDialog:null},captureUpdate:V8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[J2.CTRL_OR_CMD]&&e.key===J2.F});import{isImageElement as Y8}from"@excalidraw/element";import{CaptureUpdateAction as K8}from"@excalidraw/element";import{jsx as X8}from"react/jsx-runtime";var Sf=G({name:"cropEditor",label:"helpDialog.cropStart",icon:Th,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:K8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&Y8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return X8($,{type:"button",icon:Th,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as Z8}from"@excalidraw/element";import{mutateElement as $8}from"@excalidraw/element";import{newFrameElement as j8}from"@excalidraw/element";import{isFrameLikeElement as Ym}from"@excalidraw/element";import{addElementsToFrame as q8,removeAllElementsFromFrame as J8}from"@excalidraw/element";import{getFrameChildren as Q8}from"@excalidraw/element";import{getElementsInGroup as e7}from"@excalidraw/element";import{getCommonBounds as t7}from"@excalidraw/element";import{CaptureUpdateAction as Ga}from"@excalidraw/element";var tI=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Ym(t[0])},nI=G({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Ym(r)){let i=Q8(Z8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:Ga.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Ga.EVENTUALLY}},predicate:(e,n,t,o)=>tI(n,o)}),oI=G({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Ym(r)?{elements:J8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Ga.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Ga.EVENTUALLY}},predicate:(e,n,t,o)=>tI(n,o)}),BPe=G({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:Ga.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),rI=G({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=de(e,n);return r.length>0&&!r.some(i=>Ym(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,l,s,d]=t7(r,i),c=16,m=j8({x:a-c,y:l-c,width:s-a+c*2,height:d-l+c*2});if(n.editingGroupId){let u=e7(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);$8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:q8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Ga.IMMEDIATELY}}});import{KEYS as Ua,matchKey as kf,arrayToMap as iI,MOBILE_ACTION_BUTTON_BG as aI}from"@excalidraw/common";import{CaptureUpdateAction as Pf}from"@excalidraw/element";import{orderByFractionalIndex as s7}from"@excalidraw/element";import{Emitter as n7}from"@excalidraw/common";import{CaptureUpdateAction as o7,StoreChange as r7,StoreDelta as i7}from"@excalidraw/element";var Ha=class extends i7{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},vi=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},Zs=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new n7);v(this,"undoStack",[]);v(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(n){if(n.isEmpty()||n instanceof Ha)return;let t=Ha.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new vi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=o7.IMMEDIATELY,l=this.store.snapshot,s=n,d=t,c=!1;for(;i;){try{[s,d,c]=i.applyTo(s,d,l);let m=l.elements,p=l.maybeClone(a,s,d),u=r7.create(l,p),E=Ha.applyLatestChanges(i,m,s);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),l=p}finally{r(i)}if(c)break;i=o()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new vi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=Ha.inverse(t);return n.push(o)}};import{useEffect as a7,useState as l7}from"react";var Cf=(e,n)=>{let[t,o]=l7(n);return a7(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as dI}from"react/jsx-runtime";var lI=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Pf.EVENTUALLY};let[r,i]=o,a=s7(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Pf.NEVER}}return{captureUpdate:Pf.EVENTUALLY}},sI=e=>({name:"undo",label:"buttons.undo",icon:rh,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>lI(r,t,()=>e.undo(iI(n),t)),keyTest:n=>n[Ua.CTRL_OR_CMD]&&kf(n,Ua.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Cf(e.onHistoryChangedEmitter,new vi(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return dI($,{type:"button",icon:rh,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?aI:{}}})}}),cI=e=>({name:"redo",label:"buttons.redo",icon:ih,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>lI(r,t,()=>e.redo(iI(n),t)),keyTest:n=>n[Ua.CTRL_OR_CMD]&&n.shiftKey&&kf(n,Ua.Z)||n[Ua.CTRL_OR_CMD]&&!n.shiftKey&&kf(n,Ua.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Cf(e.onHistoryChangedEmitter,new vi(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return dI($,{type:"button",icon:ih,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?aI:{}}})}});import{getFontString as c7}from"@excalidraw/common";import{getTextAnchorRatios as d7,isExcalidrawElement as m7,isNonDeletedElement as p7,newElementWith as u7,updateBoundElements as h7}from"@excalidraw/element";import{measureText as g7}from"@excalidraw/element";import{isTextElement as Mf}from"@excalidraw/element";import{CaptureUpdateAction as f7}from"@excalidraw/element";var Af=G({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&Mf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=m7(t)&&Mf(t)?t:r[0],a=e.find(c=>c.id===i?.id);if(!a||!Mf(a))return!1;let l=g7(a.originalText,c7(a),a.lineHeight),s=d7(a),d=u7(a,{autoResize:!0,width:l.width,height:l.height,x:a.x+(a.width-l.width)*s.x,y:a.y+(a.height-l.height)*s.y,text:a.originalText});return p7(d)&&h7(d,o.scene,{changedElements:new Map([[d.id,d]])}),{appState:n,elements:e.map(c=>c.id===d.id?d:c),captureUpdate:f7.IMMEDIATELY}}});import{CODES as E7,KEYS as b7}from"@excalidraw/common";import x7 from"clsx";import{CaptureUpdateAction as y7}from"@excalidraw/element";import{jsx as w7}from"react/jsx-runtime";var Wa=G({name:"viewMode",label:"labels.viewMode",icon:ni,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:y7.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[b7.CTRL_OR_CMD]&&e.altKey&&!e.shiftKey&&e.code===E7.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return w7($,{type:"button",icon:t.viewModeEnabled?kh:ni,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:x7({enabled:t.viewModeEnabled})})}});import{isPromiseLike as v7}from"@excalidraw/common";import{jsx as I7}from"react/jsx-runtime";var Lf=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ye(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Km=class{constructor(n,t,o,r){v(this,"actions",{});v(this,"updater");v(this,"getAppState");v(this,"getElementsIncludingDeleted");v(this,"app");v(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);v(this,"isActionEnabledByCanvasOptions",n=>{let t=this.app.props.UIOptions.canvasActions;return n.name==="saveFileToDisk"?!!(t.export&&typeof t.export=="object"&&t.export.saveFileToDisk):n.name in t?!!t[n.name]:!0});v(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=l=>{this.isActionBlockedByViewportTransition(r)||(Lf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,l),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),l,this.app)))};return I7(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});v(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});v(this,"isActionAvailableForUI",n=>{let t=this.getAppState();return this.isActionEnabledByCanvasOptions(n)&&this.isActionEnabled(n)&&(!t.viewModeEnabled||n.viewMode===!0)&&(this.app.isInteractionEnabled()||this.app.isNavigationEnabled()&&n.navigation===!0)&&!this.isActionBlockedByViewportTransition(n)});this.updater=i=>{if(v7(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Lf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,l,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();Lf(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Df=e=>{let n=Array.from(e.values());return{x:mI(n,t=>t.x)/n.length,y:mI(n,t=>t.y)/n.length}},_f=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),mI=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as Cr,rangeInclusive as vn,rangeIntersection as Xm,rangesOverlap as Zm}from"@excalidraw/math";import{TOOL_TYPE as Ii,KEYS as pI}from"@excalidraw/common";import{getCommonBounds as Rf,getDraggedElementsBounds as Nf,getElementAbsoluteCoords as T7}from"@excalidraw/element";import{isBoundToContainer as fI}from"@excalidraw/element";import{getMaximumGroups as EI}from"@excalidraw/element";import{getSelectedElements as S7,getVisibleAndNonSelectedElements as bI}from"@excalidraw/element";var C7=8,uI=99999,$m=e=>C7/e,Gt=class Gt{};v(Gt,"referenceSnapPoints",null),v(Gt,"visibleGaps",null),v(Gt,"setReferenceSnapPoints",n=>{Gt.referenceSnapPoints=n}),v(Gt,"getReferenceSnapPoints",()=>Gt.referenceSnapPoints),v(Gt,"setVisibleGaps",n=>{Gt.visibleGaps=n}),v(Gt,"getVisibleGaps",()=>Gt.visibleGaps),v(Gt,"destroy",()=>{Gt.referenceSnapPoints=null,Gt.visibleGaps=null});var In=Gt,Pr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Vo=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[pI.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[pI.CTRL_OR_CMD]&&!Pr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},P7=(e,n,t=.01)=>Math.abs(e-n)<=t,$s=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,c,m,p]=T7(a,n);r&&(l+=r.x,d+=r.x,m+=r.x,s+=r.y,c+=r.y,p+=r.y);let u=(d-l)/2,E=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=Cr(X(l,s+E),X(m,p),a.angle),b=Cr(X(l+u,s),X(m,p),a.angle),w=Cr(X(d,s+E),X(m,p),a.angle),y=Cr(X(l+u,c),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=Cr(X(l,s),X(m,p),a.angle),b=Cr(X(d,s),X(m,p),a.angle),w=Cr(X(l,c),X(m,p),a.angle),y=Cr(X(d,c),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}}else if(e.length>1){let[a,l,s,d]=Nf(e,r??{x:0,y:0}),c=s-a,m=d-l,p=X(a,l),u=X(s,l),E=X(a,d),g=X(s,d),b=X(a+c/2,l+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(qe(a[0]),qe(a[1])))},xI=(e,n,t,o)=>bI(e,n,t,o),yI=(e,n,t,o)=>{let r=xI(e,n,t,o),i=EI(r,o).filter(m=>!(m.length===1&&fI(m[0]))).map(m=>Rf(m).map(p=>qe(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>uI)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Zm(vn(g,w),vn(x,I))&&l.push({startBounds:p,endBounds:E,startSide:[X(b,g),X(b,w)],endSide:[X(y,x),X(y,I)],length:y-b,overlap:Xm(vn(g,w),vn(x,I))})}}let d=i.sort((m,p)=>m[1]-p[1]),c=[];s=0;e:for(let m=0;m<d.length;m++){let p=d[m];for(let u=m+1;u<d.length;u++){if(++s>uI)break e;let E=d[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Zm(vn(g,b),vn(y,I))&&c.push({startBounds:p,endBounds:E,startSide:[X(g,w),X(b,w)],endSide:[X(y,x),X(I,x)],length:x-w,overlap:Xm(vn(g,b),vn(y,I))})}}return{horizontalGaps:l,verticalGaps:c}},hI=(e,n,t,o,r,i,a)=>{if(!Vo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let l=In.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[c,m,p,u]=Nf(e,n).map(b=>qe(b)),E=(c+p)/2,g=(m+u)/2;for(let b of s){if(!Zm(vn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=qe(w-E);if(b.length>p-c&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:b,offset:y};r.push(_);continue}let[,,I]=b.endBounds,T=c-I,P=qe(b.length-T);if(Math.abs(P)<=a.x){Math.abs(P)<a.x&&(r.length=0),a.x=Math.abs(P);let _={type:"gap",direction:"side_right",gap:b,offset:P};r.push(_);continue}let[C,,,]=b.startBounds,k=C-p,M=qe(k-b.length);if(Math.abs(M)<=a.x){Math.abs(M)<a.x&&(r.length=0),a.x=Math.abs(M);let _={type:"gap",direction:"side_left",gap:b,offset:M};r.push(_);continue}}for(let b of d){if(!Zm(vn(c,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=qe(w-g);if(b.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:b,offset:y};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,P=qe(T-b.length);if(Math.abs(P)<=a.y){Math.abs(P)<a.y&&(i.length=0),a.y=Math.abs(P);let _={type:"gap",direction:"side_top",gap:b,offset:P};i.push(_);continue}let[,,,C]=b.endBounds,k=qe(m-C),M=b.length-k;if(Math.abs(M)<=a.y){Math.abs(M)<a.y&&(i.length=0),a.y=Math.abs(M);let _={type:"gap",direction:"side_bottom",gap:b,offset:M};i.push(_);continue}}}},wI=(e,n,t,o)=>{let r=xI(e,n,t,o);return EI(r,o).filter(i=>!(i.length===1&&fI(i[0]))).flatMap(i=>$s(i,o))},Va=(e,n,t,o,r,i,a)=>{if(!Vo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let l=In.getReferenceSnapPoints();if(l)for(let s of n)for(let d of l){let c=d[0]-s[0],m=d[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(r.length=0),r.push({type:"point",points:[s,d],offset:c}),a.x=Math.abs(c)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:m}),a.y=Math.abs(m))}},vI=(e,n,t,o,r)=>{let i=t.state,a=S7(e,i);if(!Vo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=qe(n.x),n.y=qe(n.y);let l=[],s=[],d=$m(i.zoom.value),c={x:d,y:d},m=$s(a,r,{dragOffset:n});Va(a,m,t,o,l,s,c),hI(a,n,t,o,l,s,c);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:qe(n.x+p.x),y:qe(n.y+p.y)};Va(a,$s(a,r,{dragOffset:u}),t,o,l,s,c),hI(a,u,t,o,l,s,c);let E=Bf(l,s),g=M7(a,u,[...l,...s].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},qe=e=>Math.round(e*10**6)/10**6,gI=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},Bf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=qe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(qe(a[0]),qe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=qe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(qe(a[0]),qe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:gI(i.map(a=>X(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:gI(i.map(a=>X(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},k7=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[qe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},M7=(e,n,t)=>{let[o,r,i,a]=Nf(e,n),l=[];for(let s of t){let[d,c,m,p]=s.gap.startBounds,[u,E,g,b]=s.gap.endBounds,w=Xm(vn(r,a),s.gap.overlap),y=Xm(vn(o,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(s.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(s.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,s.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]},{type:"gap",direction:"horizontal",points:[X(g,x),X(o,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[X(i,x),X(d,x)]},{type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,c)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]},{type:"gap",direction:"vertical",points:[X(x,b),X(x,r)]})}break}}}return k7(l.map(s=>({...s,points:s.points.map(d=>X(qe(d[0]),qe(d[1])))})))},Ff=(e,n,t,o,r,i)=>{if(!Vo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!P7(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=Rf(n);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(d+=r.y));let c=[];if(i)switch(i){case"e":{c.push(X(s,l),X(s,d));break}case"w":{c.push(X(a,l),X(a,d));break}case"n":{c.push(X(a,l),X(s,l));break}case"s":{c.push(X(a,d),X(s,d));break}case"ne":{c.push(X(s,l));break}case"nw":{c.push(X(a,l));break}case"se":{c.push(X(s,d));break}case"sw":{c.push(X(a,d));break}}let m=$m(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Va(n,c,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,w,y,x]=Rf(e).map(P=>qe(P)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];Va(e,I,t,o,u,E,p);let T=Bf(u,E);return{snapOffset:g,snapLines:T}},II=(e,n,t,o,r,i)=>{if(!Vo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],l=$m(n.state.zoom.value),s={x:l,y:l},d=[],c=[];Va([e],a,n,t,d,c,s);let m={x:d[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,d.length=0,c.length=0;let p=$s([e],i,{boundingBoxCorners:!0,omitCenter:!0});Va([e],p,n,t,d,c,s);let u=Bf(d,c);return{snapOffset:m,snapLines:u}},TI=(e,n,t,o,r)=>{if(!Vo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=bI(e,[],n.state,r),a=$m(n.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let c of i){let m=$s([c],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,X(p[0],t.y)],direction:"vertical"}),l.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(l.y)&&(Math.abs(E)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,X(t.x,p[1])],direction:"horizontal"}),l.y=E)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},SI=e=>e===Ii.rectangle||e===Ii.ellipse||e===Ii.diamond||e===Ii.frame||e===Ii.magicframe||e===Ii.image||e===Ii.text;import{getCommonFrameId as A7,getFrameChildrenInsertionIndex as L7,isElementInViewport as D7}from"@excalidraw/element";import{arrayToMap as _7,memoize as R7,toBrandedType as N7}from"@excalidraw/common";var js=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",R7(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s,editingTextElement:d,newElement:c})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:d,newElement:c}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));v(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&A7(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:l,width:s}){let d=[];for(let c of n.values())D7(c,s,l,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&d.push(c);return d}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=N7(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=_7(t),i=n.filter(l=>!r.has(l.id)),a=L7(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Ux.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as G7,easeOut as kI}from"@excalidraw/common";import{SVG_NS as PI,getSvgPathFromStroke as O7,sceneCoordsToViewportCoords as z7}from"@excalidraw/common";import{version as B7}from"react";import{unstable_batchedUpdates as CI}from"react-dom";import{throttleRAF as F7}from"@excalidraw/common";var Je=e=>n=>{CI(e,n)},jm=e=>F7(n=>{CI(e,n)}),Ya=(()=>{let e;try{let t=B7.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var ge=class ge{static start(n,t){if(ge.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};ge.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw ge.animations.get(n)===o&&(ge.animations.delete(n),ge.cancelScheduledFrameIfIdle()),i}if(ge.animations.get(n)===o){if(!r){ge.animations.delete(n),ge.cancelScheduledFrameIfIdle();return}o.state=r,ge.scheduleNextFrame()}}static scheduleNextFrame(){ge.scheduledFrame||(Ya()?ge.scheduledFrame={id:requestAnimationFrame(ge.tick),type:"raf"}:ge.scheduledFrame={id:setTimeout(ge.tick,0),type:"timeout"})}static cancelScheduledFrame(){ge.scheduledFrame&&(ge.scheduledFrame.type==="raf"?cancelAnimationFrame(ge.scheduledFrame.id):clearTimeout(ge.scheduledFrame.id),ge.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return ge.animations.size>0?!1:(ge.cancelScheduledFrame(),!0)}static tick(){if(ge.scheduledFrame=null,ge.animations.size>0){let n=[...ge.animations];for(let[t,o]of n){if(ge.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(ge.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(ge.animations.delete(t),ge.cancelScheduledFrameIfIdle())return}}if(ge.cancelScheduledFrameIfIdle())return;ge.scheduleNextFrame()}}static running(n){return ge.animations.has(n)}static cancel(n){ge.animations.delete(n),ge.cancelScheduledFrameIfIdle()}static reset(){ge.animations.clear(),ge.cancelScheduledFrame()}};v(ge,"scheduledFrame",null),v(ge,"animations",new Map);var pt=ge;var qm=class qm{constructor(n,t){this.app=n;this.options=t;v(this,"currentTrail");v(this,"pastTrails",[]);v(this,"container");v(this,"trailElement");v(this,"trailAnimation");v(this,"key");this.key=`animated-trail-${qm.counter++}`,this.trailElement=document.createElementNS(PI,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(PI,"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(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),pt.running(this.key)||pt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){pt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Da(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,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 n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let l=z7({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return O7(r,!0)}};v(qm,"counter",0);var Kn=qm;var Jm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Kn(n,{...this.getTrailOptions(),fill:()=>G7})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(kI(i),kI(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new Kn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||hi(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",l=r.hasCurrentTrail;i&&!l&&r.startPath(o.pointer.x,o.pointer.y);let s=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&s&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&l&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as H7}from"@excalidraw/common";import{pointFrom as qs,pointRotateRads as Qm}from"@excalidraw/math";var U7=12,Of=16,W7=10,V7=Of+2,Y7=.8,zf=e=>H7*2/e,Gf=(e,n,t)=>{let o=zf(n);if(t!=="desktop"||Of>(e.height+o*2)*n*Y7)return null;let r=U7/n,i=Of/n,a=qs(e.x+e.width/2,e.y+e.height/2),l=Qm(qs(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:l,start:Qm(qs(l[0],l[1]-i/2),l,e.angle),end:Qm(qs(l[0],l[1]+i/2),l,e.angle),hitboxWidth:W7/n,hitboxHeight:V7/n}},MI=(e,n,t,o)=>{let r=Gf(n,t,o);if(!r)return!1;let i=Qm(qs(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as Hf,KEYS as Js,CLASSES as Uf,POINTER_BUTTON as K7,THEME as X7,isWritableElement as Z7,getFontString as AI,getFontFamilyString as LI,isTestEnv as DI,MIME_TYPES as Wf,applyDarkModeFilter as $7,isRTL as j7,getViewpointFlipSign as _I}from"@excalidraw/common";import{pointFrom as RI,pointRotateRads as q7}from"@excalidraw/math";import{getTextFromElements as J7,originalContainerCache as Q7,updateBoundElements as NI,updateOriginalContainerCache as BI}from"@excalidraw/element";import{LinearElementEditor as eB}from"@excalidraw/element/linearElementEditor";import{bumpVersion as tB}from"@excalidraw/element";import{getBoundTextElementId as nB,getContainerElement as Vf,getTextElementAngle as oB,redrawTextBoundingBox as rB,getBoundTextMaxHeight as iB,getBoundTextMaxWidth as FI,computeContainerDimensionForBoundText as OI,computeBoundTextPosition as aB,getBoundTextElement as lB}from"@excalidraw/element";import{getTextWidth as sB}from"@excalidraw/element";import{getLineHeightInPx as cB}from"@excalidraw/element";import{getLineWidth as dB}from"@excalidraw/element";import{normalizeText as zI}from"@excalidraw/element";import{wrapText as mB}from"@excalidraw/element";import{getWrappedTextLines as pB}from"@excalidraw/element";import{isArrowElement as ep,isBoundToContainer as uB,isTextElement as GI}from"@excalidraw/element";var hB=(e,n,t,o,r,i)=>{let{zoom:a}=o,l=180*t/Math.PI,s=e*(a.value-1)/2,d=n*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),n>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value*_I(o.viewpointFlip.horizontal)}, ${a.value*_I(o.viewpointFlip.vertical)}) rotate(${l}deg)`},gB=(e,n)=>{let t=e.lastIndexOf(`
|
|
12
12
|
`,Math.max(0,n-1))+1,o=e.indexOf(`
|
|
13
|
-
`,n),r=e.slice(t,o===-1?e.length:o);return
|
|
14
|
-
`).reduce((Ee,He,se,Pe)=>Ee.concat(se?Ee[se-1]+Pe[se-1].length+1:F),[]).reverse()},M=F=>{F.target instanceof HTMLCanvasElement&&(F.preventDefault(),F.stopPropagation())},L=!1,_=()=>{if(oe)return;oe=!0,k();let F=a.scene.getElement(o.id);if(!F)return;let V=_f(F,a.scene.getNonDeletedElementsMap());if(V){if(u.value.trim()){let ce=L7(V);!ce||ce!==o.id?a.scene.mutateElement(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:o.id})}):Ym(V)&&A7(V)}else a.scene.mutateElement(V,{boundElements:V.boundElements?.filter(ce=>!vI(ce))});_7(F,V,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,le&&le.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",K),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),W(),G(),u.remove()},D=F=>{window.removeEventListener("pointerup",D);let V=F?.target,ce=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),fe=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content"),Be=(V instanceof HTMLElement||V instanceof SVGElement)&&(!!V.closest(`.${Lf.SHAPE_ACTIONS_MENU}`)||!!V.closest(".compact-shape-actions-island"));setTimeout(()=>{Be||ce||fe||(u.onblur=_,u.focus(),w&&(u.setSelectionRange(w.start,w.end),w=null))})},B=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},K=F=>{let V=F?.target;if(F.button===w7.WHEEL){V instanceof HTMLTextAreaElement&&(F.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(F)),B();return}let ce=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),fe=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content");(F.target instanceof HTMLElement||F.target instanceof SVGElement)&&(F.target.closest(`.${Lf.SHAPE_ACTIONS_MENU}, .${Lf.ZOOM_ACTIONS}`)||F.target.closest(".compact-shape-actions-island"))&&!I7(F.target)||ce||fe?B():F.target instanceof HTMLCanvasElement&&!hI()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(F=>{a.state.theme!==p&&m()}),U=a.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=a.onScrollChangeEmitter.on(()=>{m()}),G=a.onStateChange("viewpointFlip",()=>{m()}),oe=!1;l&&!w&&u.select(),D();let le=null;return r&&"ResizeObserver"in window?(le=new window.ResizeObserver(()=>{m()}),le.observe(r)):window.addEventListener("resize",m),u.onpointerdown=F=>F.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",K,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Km}from"@excalidraw/common";import{getCommonBounds as X7}from"@excalidraw/element";var xi=4,po=6,TI="rgba(0,0,0,0.3)",SI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=X7(e),s=n/o.zoom.value,d=t/o.zoom.value,c={top:parseInt(Km("sat"))||0,bottom:parseInt(Km("sab"))||0,left:parseInt(Km("sal"))||0,right:parseInt(Km("sar"))||0},p=to().rtl,m=-o.scrollX+c.left,u=-o.scrollY+c.top,E=m+s-c.right,g=u+d-c.bottom,b=Math.min(r,m),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(l,g),I=a-r,T=l-i,C=y-b,P=x-w,M=Math.max(xi*2,c.left+c.right)+po*2,L=n*(s/C)-M,_=Math.max(xi*2,c.top+c.bottom)+po*2,k=t*(d/P)-_,D=C>I?C*o.zoom.value/(L+M):n/(L+M),B=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:m===b&&E===y?null:{x:Math.max(c.left,xi)+po+(m-b)/C*n,y:t-po-Math.max(xi,c.bottom),width:L,height:po,deltaMultiplier:D},vertical:u===w&&g===x?null:{x:p?Math.max(c.left,xi):n-po-Math.max(c.right,xi),y:Math.max(c.top,xi)+po+(u-w)/P*t,width:po,height:k,deltaMultiplier:B}}},Rf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as pB}from"@excalidraw/math";import{getElementLineSegments as uB}from"@excalidraw/element";import{LinearElementEditor as hB}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as gB,isLinearElement as fB}from"@excalidraw/element";import{getFrameChildren as EB}from"@excalidraw/element";import{selectGroupsForSelectedElements as bB}from"@excalidraw/element";import{arrayToMap as xB,easeOut as DI,isShallowEqual as yB}from"@excalidraw/common";import{simplify as Z7}from"points-on-curve";import{polygonFromPoints as $7,lineSegment as Zm,pointFrom as Oa,pointOnLineSegment as j7,polygonIncludesPointNonZero as q7,PRECISION as Xm}from"@excalidraw/math";import{boundsContainBounds as PI,computeBoundTextPosition as J7,doBoundsIntersect as Q7,elementOverlapsWithFrame as eB,getBoundTextElement as kI,getContainingFrame as tB,getElementBounds as MI,intersectElementWithLineSegment as nB,isBoundToContainer as AI,pointInsideBoundsInclusive as oB}from"@excalidraw/element";var LI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l,mode:s="contain"}=e,d=n;l&&(d=Z7(n,l));let c=t.filter(g=>!g.locked&&!AI(g));a.clear(),i.clear();let p=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),m=$7(d),u=[p[0]-Xm,p[1]-Xm,p[2]+Xm,p[3]+Xm];for(let g of c){let b=MI(g,o),w=rB(g,b,o),y=iB(b,w);if(Q7(p,y)&&!i.has(g.id)&&!a.has(g.id)){if(s==="contain"&&!PI(u,y))continue;let x=aB(g,o,r,w),I=cB(m,x,y,s);s==="contain"?I&&!CI(d,g,o,w)&&a.add(g.id):I?a.add(g.id):CI(d,g,o,w)&&i.add(g.id)}}return{selectedElementIds:s==="contain"?sB([...a],o):[...i,...a]}},rB=(e,n,t)=>{let o=tB(e,t);if(!o)return null;let r=MI(o,t);return PI(r,n)?null:eB(e,o,t)?r:null},iB=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,aB=(e,n,t,o)=>{let r=t.get(e.id)??[],i=kI(e,n),a=i?t.get(i.id):null,l=a?.length?[...r,...a]:r;return o?lB(l,o):l},lB=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[l,s],[d,c]]of e){let p=d-l,m=c-s,u=0,E=1,g=!0;for(let[b,w]of[[-p,l-t],[p,r-l],[-m,s-o],[m,i-s]]){if(b===0){if(w<0){g=!1;break}continue}let y=w/b;if(b<0){if(y>E){g=!1;break}u=Math.max(u,y)}else{if(y<u){g=!1;break}E=Math.min(E,y)}}g&&a.push(Zm(Oa(l+u*p,s+u*m),Oa(l+E*p,s+E*m)))}return a},sB=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||AI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(l=>o.has(l))})},cB=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>q7(a,e)||o==="contain"&&mB(a,e);return n.length===0?dB(t)[r](i):n[r](a=>a[r](i))},dB=([e,n,t,o])=>[Oa(e,n),Oa(t,n),Oa(t,o),Oa(e,o)],mB=(e,n)=>n.some((t,o)=>o>0&&j7(e,Zm(n[o-1],t))),CI=(e,n,t,o)=>{let r=e.slice(1).map((l,s)=>Zm(e[s],l)).concat([Zm(e[e.length-1],e[0])]),i=kI(n,t),a=(l,s)=>{let d=nB(l,t,s,0,!o);return o?d.some(c=>oB(c,o)):d.length>0};return r.some(l=>a(n,l)||!!i&&a({...i,...J7(n,i,t)},l))};var $m=class extends Hn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),l=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(DI(l),DI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});v(this,"intersectedElements",new Set);v(this,"enclosedElements",new Set);v(this,"elementsSegments",null);v(this,"canvasTranslate",null);v(this,"keepPreviousSelection",!1);v(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(o.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&gB(d)){let c=EB(this.app.scene.getNonDeletedElementsMap(),d.id);for(let p of c)delete r[p.id]}}let i=bB({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&fB(this.app.scene.getNonDeletedElement(a[0]))?new hB(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});v(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});v(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>pB(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!yB(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=xB(this.app.visibleElements);for(let i of this.app.visibleElements){let a=uB(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=LI({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,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),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 wB,easeOut as _I,THEME as vB}from"@excalidraw/common";import{computeBoundTextPosition as IB,doBoundsIntersect as TB,getBoundTextElement as SB,getElementBounds as CB,getElementLineSegments as PB,getFreedrawOutlineAsSegments as kB,getFreedrawOutlinePoints as MB,intersectElementWithLineSegment as RI,isArrowElement as AB,isFreeDrawElement as NI,isLineElement as LB,isPointInElement as DB}from"@excalidraw/element";import{lineSegment as _B,lineSegmentsDistance as BI,pointFrom as UI,polygon as RB,polygonIncludesPointNonZero as NB}from"@excalidraw/math";import{getElementsInGroup as FI}from"@excalidraw/element";import{shouldTestInside as BB}from"@excalidraw/element";import{hasBoundTextElement as OI,isBoundToContainer as zI}from"@excalidraw/element";import{getBoundTextElementId as GI}from"@excalidraw/element";var jm=class extends Hn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),l=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(_I(l),_I(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===vB.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});v(this,"elementsToErase",new Set);v(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(l=>UI(l[0],l[1]))||[];if(o.length<2)return[];let r=_B(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=wB(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(HI(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let c=FI(this.app.scene.getNonDeletedElementsMap(),d);for(let p of c)this.elementsToErase.delete(p.id);this.groupsToErase.delete(d)}if(zI(l)&&this.elementsToErase.delete(l.containerId),OI(l)){let c=GI(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&HI(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let c=FI(this.app.scene.getNonDeletedElementsMap(),d);for(let p of c)this.elementsToErase.add(p.id);this.groupsToErase.add(d)}if(OI(l)){let c=GI(l);c&&this.elementsToErase.add(c)}zI(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},HI=(e,n,t,o)=>{let r=e[1],i=NI(n)?15:n.strokeWidth/2,a=[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],l=CB(n,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!TB(a,s))return!1;if(BB(n)&&DB(r,n,t))return!0;if(NI(n)){let c=MB(n),p=kB(n,c,t),m=Math.max(2.25,5/o);for(let E of p)if(BI(E,e)<=m)return!0;let u=RB(...c.map(([E,g])=>UI(n.x+E,n.y+g)));return!!NB(e[0],u)}let d=SB(n,t);if(AB(n)||LB(n)&&!n.polygon){let c=Math.max(n.strokeWidth,n.strokeWidth*2/o),p=PB(n,t);for(let m of p)if(BI(m,e)<=c)return!0;return!1}return RI(n,t,e,0,!0).length>0||!!d&&RI({...d,...IB(n,d,t)},t,e,0,!0).length>0};import{isDevEnv as JB}from"@excalidraw/common";import{newElement as QB}from"@excalidraw/element";import{COLOR_PALETTE as FB,DEFAULT_FONT_FAMILY as OB,DEFAULT_FONT_SIZE as zB,VERTICAL_ALIGN as GB}from"@excalidraw/common";var WI=44,VI=22,YI=66,KI=48,Ks=14,XI=304,ZI=320,Nf=5.87,$I=28,jI=4,qI=2,Bf=10,JI=10,QI=8,uo=12,za=256,yi=10,Ff=4,Ga=uo*2,Of=uo*2,eT=100,tT=140,Xs=.35,nT=uo/2,Tr=20,qm=uo*2,zf=uo,Ue={fillStyle:"hachure",fontFamily:OB,fontSize:zB,opacity:100,roughness:1,strokeColor:FB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:GB.MIDDLE,locked:!1};import{pointFrom as Ha}from"@excalidraw/math";import{COLOR_PALETTE as lT,DEFAULT_CHART_COLOR_INDEX as HB,FONT_FAMILY as Uf,FONT_SIZES as Jm,ROUNDNESS as oT,DEFAULT_FONT_SIZE as UB,getAllColorsSpecificShade as WB,getFontString as Wf,getLineHeight as Vf,ROUGHNESS as rT}from"@excalidraw/common";import{getApproxMinLineWidth as Yf,measureText as Sr,newElement as Hf,newLinearElement as Gf,newTextElement as Ua,wrapText as sT}from"@excalidraw/element";var wi=WB(HB),VB=e=>e.labels?.length??e.series[0]?.values.length??0,Wa=(e,n)=>{if(!e)return!1;let t=VB(e);return t<2?!1:n==="radar"?t>=3:!0},iT=(e,n)=>{let t=n<=1?0:Math.min(YI,(n-1)*VI);return e+t},Qm=(e,n)=>{if(e==="line"){let o=iT(KI,n);return{slotWidth:o,gap:Ks,chartHeight:ZI,xLabelMaxWidth:o+Ks*3+Bf}}let t=iT(WI,n);return{slotWidth:t,gap:Ks,chartHeight:XI,xLabelMaxWidth:t+Ks*3+Bf}},Va=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},cT=()=>{let e=za+Of*2,n=za+Of*2;return{chartWidth:e,chartHeight:n}},YB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Ya=(e,n)=>{if(e<=0||wi.length===0)return[];let t=wi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(l,s)=>s).filter(l=>l!==o));for(;r.length<i;){let l=-1,s=-1,d=-1;for(let c of a){let p=r.map(E=>YB(c,E,t)),m=Math.min(...p),u=p.reduce((E,g)=>E+g,0)/p.length;(m>s||m===s&&u>d)&&(l=c,s=m,d=u)}r.push(l),a.delete(l)}return Array.from({length:e},(l,s)=>wi[r[s%r.length]])},Ka=e=>{if(wi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*wi.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%wi.length},Xa=e=>wi[e],dT=(e,n)=>{let t=e.flatMap(l=>l.values.map(s=>Math.max(0,s))),o=t.filter(l=>l>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=eT;return{renderSteps:!1,normalize:(l,s)=>{let d=Math.max(0,l);return a?Math.log10(d+1)/Math.log10(r+1):d/r}}},KB=e=>/\s/.test(e.trim()),ep=(e,n,t)=>KB(e)?sT(e,n,t):e,mT=(e,n,t,o,r,i)=>{let a=Uf.Excalifont,l=Jm.sm,s=Vf(a),d=Wf({fontFamily:a,fontSize:l}),c=Math.min(tT,r*(e.length>8?.56:.72)),p=Yf(d,s),m=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>Sr(z,d,s).width)),x=Math.max(p,c,y),I=ep(g,d,x),T=Sr(I,d,s),C=Math.cos(w),P=Math.sin(w),M=C>Xs?"left":C<-Xs?"right":"center",L=M==="center"?T.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(T.height/2),k=Ga+_+nT,D=t+C*(r+k),B=o+P*(r+k),K=P>Xs?uo/3:P<-Xs?-uo/3:0;return Ua({backgroundColor:i,...Ue,text:I,originalText:g,x:D,y:B+K,fontFamily:a,fontSize:l,lineHeight:s,textAlign:M,verticalAlign:"middle"})}),u=Math.min(...m.map(g=>g.y)),E=Math.max(...m.map(g=>g.y+g.height));return{axisLabels:m,axisLabelTopY:u,axisLabelBottomY:E}},Za=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Uf["Lilita One"],l=Jm.lg,s=Vf(a),d=Wf({fontFamily:a,fontSize:l}),c=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=ep(C,d,za),M=Sr(P,d,s),L=Tr+zf+M.width;return{label:C,displayLabel:P,color:n[T],width:L,height:M.height}}),p=Math.max(Tr/2,...c.map(I=>I.height/2)),m=Math.max(r,o+p+Ga),u=qm,E=Tr*.6,g=c.reduce((I,T)=>I+T.width,0)+qm*Math.max(0,c.length-1),b=g+u*2,w=p*2+E*2,y=[];y.push(Hf({...Ue,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:lT.black,x:t-b/2,y:m-w/2,width:b,height:w,roughness:rT.architect,roundness:{type:oT.PROPORTIONAL_RADIUS}}));let x=t-g/2;return c.forEach(I=>{y.push(Hf({...Ue,backgroundColor:I.color,type:"rectangle",x,y:m-Tr/2,width:Tr,height:Tr,fillStyle:"solid",strokeColor:I.color,roughness:rT.architect,roundness:{type:oT.PROPORTIONAL_RADIUS}})),y.push(Ua({...Ue,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+Tr+zf,y:m,fontFamily:a,fontSize:l,lineHeight:s,textAlign:"left",verticalAlign:"middle"})),x+=I.width+qm}),y},XB=(e,n,t,o)=>{if(Sr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(Sr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},ZB=(e,n,t,o)=>{if(Sr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>Sr(a,t,o).width>n)&&n>=Yf(t,o)?{wrapped:!0,text:sT(e,t,n)}:{wrapped:!1,text:XB(e,n,t,o)}},pT=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},aT=e=>e.includes("..."),$B=(e,n,t,o,r)=>{let i=Math.max($I,Math.ceil(Yf(o,r))),a=Math.max(i,Math.floor(n)),l=[];for(let u=a;u>=i;u-=4)l.push(u);l[l.length-1]!==i&&l.push(i);let s=u=>{let E=aT(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
|
|
15
|
-
`).length;return{ellipsified:E,visibleChars:g,lineCount:b}},d=(u,E)=>{let g=s(u),b=s(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},c=null,
|
|
13
|
+
`,n),r=e.slice(t,o===-1?e.length:o);return j7(r)?"rtl":"ltr"},fB=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},EB=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=fB(e),a=document.createElement("div"),l=document.createTextNode(e),s=document.createRange(),d=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(l),document.body.append(a);try{for(let u of i){s.setStart(l,u),s.setEnd(l,u);let E=s.getBoundingClientRect();if(!Number.isFinite(E.left))return null;d.push(E.left)}}catch{return null}finally{a.remove()}let c=Math.min(...d),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(d[u]-c-r);E<p&&(p=E,m=i[u])}return m},HI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:l=!0,initialCaretSceneCoords:s=null})=>{let d=null,c=(O,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let ce=V.style.fontFamily.replace(/"/g,"");return LI({fontFamily:O.fontFamily})!==ce||`${O.fontSize}px`!==V.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let O=a.state,V=a.scene.getElement(o.id);if(!V)return;let{textAlign:ce,verticalAlign:pe}=V,Be=a.scene.getNonDeletedElementsMap();if(V&&GI(V)){let Ee=V.x,He=V.y,se=Vf(V,a.scene.getNonDeletedElementsMap()),ke=V.width,Me=V.height,xe=V.width,Et=V.height;if(se&&V.containerId){if(ep(se)){let dn=eB.getBoundTextElementPosition(se,V,Be);Ee=dn.x,He=dn.y}let or=c(V,u),Mo;if(or?Mo=BI(se.id,se.height):(Mo=Q7[se.id],Mo||(Mo=BI(se.id,se.height))),xe=FI(se,V),Et=iB(se,V),!ep(se)&&Me>Et){let dn=OI(Me,se.type);a.scene.mutateElement(se,{height:dn}),NI(se,a.scene);return}else if(!ep(se)&&se.height>Mo.height&&Me<Et){let dn=OI(Me,se.type);a.scene.mutateElement(se,{height:dn}),NI(se,a.scene)}else{let{x:dn,y:rr}=aB(se,V,Be);Ee=dn,He=rr}}let[en,Fe]=t(Ee,He);se?ke+=.5:(xe=(O.viewpointFlip.horizontal?en-8:O.width-8-en)/O.zoom.value,ke=Math.min(ke,xe)),Me*=1.05;let st=AI(V),Yt=oB(V,se),nr=(O.viewpointFlip.vertical?Fe:O.height-Fe)/O.zoom.value;Object.assign(u.style,{font:st,lineHeight:V.lineHeight,width:`${ke}px`,height:`${Me}px`,left:`${en}px`,top:`${Fe}px`,transform:hB(ke,Me,Yt,O,xe,nr),textAlign:ce,verticalAlign:pe,color:$7(V.strokeColor,O.theme===X7.DARK),opacity:V.opacity/100,maxHeight:`${nr}px`}),d={angle:Yt,font:st,height:V.height,lineHeightPx:cB(V.fontSize,V.lineHeight),textAlign:ce,width:V.width,x:Ee,y:He},u.scrollTop=0,DI()&&(u.style.fontFamily=LI(V)),a.scene.mutateElement(V,{x:Ee,y:He})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(uB(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!s||!d)return null;let O=d,V=RI(O.x+O.width/2,O.y+O.height/2),[ce,pe]=q7(RI(s.x,s.y),V,-O.angle),Be=ce-O.x,Ee=pe-O.y,He=pB(u.value,O.font,E==="pre-wrap"?O.width:1/0),se=Math.max(0,Math.min(He.length-1,Math.floor(Ee/O.lineHeightPx))),ke=He[se],Me=gB(u.value,ke.start),xe=dB(ke.text,O.font),Et=O.textAlign==="center"?(O.width-xe)/2:O.textAlign==="right"?O.width-xe:0,en=Be-Et;if(!ke.text)return ke.start;let Fe=EB({text:ke.text,font:O.font,lineHeightPx:O.lineHeightPx,direction:Me,targetX:en});return ke.start+(Fe||0)},w=(()=>{let O=b();return O===null?null:{start:O,end:O}})();e&&(u.onpaste=async O=>{let V=Qw(O),ce=null;if(V.has(Wf.excalidrawClipboard)||V.has(Wf.excalidraw)){O.preventDefault(),ce=await yr(O);try{let se=await Is(ce);if(se.elements){let ke=J7(se.elements);if(ke){let{selectionStart:Me,selectionEnd:xe,value:Et}=u;u.value=Et.slice(0,Me)+ke+Et.slice(xe);let en=Me+ke.length;u.selectionStart=u.selectionEnd=en,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ce=ce||await yr(O);let pe=ce.findByType(Wf.text);if(!pe)return;let Be=zI(pe.value);if(!Be)return;let Ee=Vf(o,a.scene.getNonDeletedElementsMap()),He=AI({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(Ee){let se=lB(Ee,a.scene.getNonDeletedElementsMap()),ke=mB(`${u.value}${Be}`,He,FI(Ee,se)),Me=sB(ke,He);u.style.width=`${Me}px`}},u.oninput=()=>{let O=zI(u.value);if(u.value!==O){let V=u.selectionStart;u.value=O,u.selectionStart=V,u.selectionEnd=V}e(u.value)}),u.onkeydown=O=>{if(!O.shiftKey&&em.keyTest(O))O.preventDefault(),a.actionManager.executeAction(em),p();else if(!O.shiftKey&&tm.keyTest(O))O.preventDefault(),a.actionManager.executeAction(tm),p();else if(!O.shiftKey&&nm.keyTest(O))O.preventDefault(),a.actionManager.executeAction(nm),p();else if(ug.keyTest(O))a.actionManager.executeAction(ug);else if(hg.keyTest(O))a.actionManager.executeAction(hg);else if(O.key===Js.ESCAPE)O.preventDefault(),M=!0,_();else if(pi.keyTest(O))O.preventDefault(),_(),a.actionManager.executeAction(pi);else if(O.key===Js.ENTER&&O[Js.CTRL_OR_CMD]){if(O.preventDefault(),O.isComposing||O.keyCode===229)return;M=!0,_()}else if(O.key===Js.TAB||O[Js.CTRL_OR_CMD]&&(O.code===Hf.BRACKET_LEFT||O.code===Hf.BRACKET_RIGHT)){if(O.preventDefault(),O.isComposing)return;O.shiftKey||O.code===Hf.BRACKET_LEFT?P():T(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:O,selectionEnd:V}=u,ce=C(),pe=u.value;ce.forEach(Be=>{let Ee=pe.slice(0,Be),He=pe.slice(Be);pe=`${Ee}${x}${He}`}),u.value=pe,u.selectionStart=O+y,u.selectionEnd=V+y*ce.length},P=()=>{let{selectionStart:O,selectionEnd:V}=u,ce=C(),pe=[],Be=u.value;ce.forEach(Ee=>{let He=Be.slice(Ee,Ee+y).match(I);if(He){let se=Be.slice(0,Ee),ke=Be.slice(Ee+He[0].length);Be=`${se}${ke}`,pe.push(Ee)}}),u.value=Be,pe.length&&(O>pe[pe.length-1]?u.selectionStart=Math.max(O-y,pe[pe.length-1]):u.selectionStart=O,u.selectionEnd=Math.max(u.selectionStart,V-y*pe.length))},C=()=>{let{selectionStart:O,selectionEnd:V,value:ce}=u,pe=ce.slice(0,O).match(/[^\n]*$/)[0].length;return O=O-pe,ce.slice(O,V).split(`
|
|
14
|
+
`).reduce((Ee,He,se,ke)=>Ee.concat(se?Ee[se-1]+ke[se-1].length+1:O),[]).reverse()},k=O=>{O.target instanceof HTMLCanvasElement&&(O.preventDefault(),O.stopPropagation())},M=!1,_=()=>{if(J)return;J=!0,L();let O=a.scene.getElement(o.id);if(!O)return;let V=Vf(O,a.scene.getNonDeletedElementsMap());if(V){if(u.value.trim()){let ce=nB(V);!ce||ce!==o.id?a.scene.mutateElement(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:o.id})}):ep(V)&&tB(V)}else a.scene.mutateElement(V,{boundElements:V.boundElements?.filter(ce=>!GI(ce))});rB(O,V,a.scene)}n({viaKeyboard:M,nextOriginalText:u.value})},L=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",k,!0),window.removeEventListener("pointerdown",K),window.removeEventListener("pointerup",R),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),D(),U(),H(),F(),u.remove()},R=O=>{window.removeEventListener("pointerup",R);let V=O?.target,ce=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),pe=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content"),Be=(V instanceof HTMLElement||V instanceof SVGElement)&&(!!V.closest(`.${Uf.SHAPE_ACTIONS_MENU}`)||!!V.closest(".compact-shape-actions-island"));setTimeout(()=>{Be||ce||pe||(u.onblur=_,u.focus(),w&&(u.setSelectionRange(w.start,w.end),w=null))})},z=()=>{u.onblur=null,window.addEventListener("pointerup",R),window.addEventListener("blur",_)},K=O=>{let V=O?.target;if(O.button===K7.WHEEL){V instanceof HTMLTextAreaElement&&(O.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(O)),z();return}let ce=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),pe=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content");(O.target instanceof HTMLElement||O.target instanceof SVGElement)&&(O.target.closest(`.${Uf.SHAPE_ACTIONS_MENU}, .${Uf.ZOOM_ACTIONS}`)||O.target.closest(".compact-shape-actions-island"))&&!Z7(O.target)||ce||pe?z():O.target instanceof HTMLCanvasElement&&!DI()&&requestAnimationFrame(()=>{_()})},U=a.onChangeEmitter.on(O=>{a.state.theme!==m&&p()}),D=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),H=a.onScrollChangeEmitter.on(()=>{p()}),F=a.onStateChange("viewpointFlip",()=>{p()}),J=!1;l&&!w&&u.select(),R();let re=null;return r&&"ResizeObserver"in window?(re=new window.ResizeObserver(()=>{p()}),re.observe(r)):window.addEventListener("resize",p),u.onpointerdown=O=>O.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",K,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as tp}from"@excalidraw/common";import{getCommonBounds as bB}from"@excalidraw/element";var Ti=4,xo=6,UI="rgba(0,0,0,0.3)",WI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=bB(e),s=n/o.zoom.value,d=t/o.zoom.value,c={top:parseInt(tp("sat"))||0,bottom:parseInt(tp("sab"))||0,left:parseInt(tp("sal"))||0,right:parseInt(tp("sar"))||0},m=lo().rtl,p=-o.scrollX+c.left,u=-o.scrollY+c.top,E=p+s-c.right,g=u+d-c.bottom,b=Math.min(r,p),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(l,g),I=a-r,T=l-i,P=y-b,C=x-w,k=Math.max(Ti*2,c.left+c.right)+xo*2,M=n*(s/P)-k,_=Math.max(Ti*2,c.top+c.bottom)+xo*2,L=t*(d/C)-_,R=P>I?P*o.zoom.value/(M+k):n/(M+k),z=C>T?C*o.zoom.value/(L+_):t/(L+_);return{horizontal:p===b&&E===y?null:{x:Math.max(c.left,Ti)+xo+(p-b)/P*n,y:t-xo-Math.max(Ti,c.bottom),width:M,height:xo,deltaMultiplier:R},vertical:u===w&&g===x?null:{x:m?Math.max(c.left,Ti):n-xo-Math.max(c.right,Ti),y:Math.max(c.top,Ti)+xo+(u-w)/C*t,width:xo,height:L,deltaMultiplier:z}}},Yf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as FB}from"@excalidraw/math";import{getElementLineSegments as OB}from"@excalidraw/element";import{LinearElementEditor as zB}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as GB,isLinearElement as HB}from"@excalidraw/element";import{getFrameChildren as UB}from"@excalidraw/element";import{selectGroupsForSelectedElements as WB}from"@excalidraw/element";import{arrayToMap as VB,easeOut as jI,isShallowEqual as YB}from"@excalidraw/common";import{simplify as xB}from"points-on-curve";import{polygonFromPoints as yB,lineSegment as op,pointFrom as Ka,pointOnLineSegment as wB,polygonIncludesPointNonZero as vB,PRECISION as np}from"@excalidraw/math";import{boundsContainBounds as YI,computeBoundTextPosition as IB,doBoundsIntersect as TB,elementOverlapsWithFrame as SB,getBoundTextElement as KI,getContainingFrame as CB,getElementBounds as XI,intersectElementWithLineSegment as PB,isBoundToContainer as ZI,pointInsideBoundsInclusive as kB}from"@excalidraw/element";var $I=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l,mode:s="contain"}=e,d=n;l&&(d=xB(n,l));let c=t.filter(g=>!g.locked&&!ZI(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=yB(d),u=[m[0]-np,m[1]-np,m[2]+np,m[3]+np];for(let g of c){let b=XI(g,o),w=MB(g,b,o),y=AB(b,w);if(TB(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(s==="contain"&&!YI(u,y))continue;let x=LB(g,o,r,w),I=RB(p,x,y,s);s==="contain"?I&&!VI(d,g,o,w)&&a.add(g.id):I?a.add(g.id):VI(d,g,o,w)&&i.add(g.id)}}return{selectedElementIds:s==="contain"?_B([...a],o):[...i,...a]}},MB=(e,n,t)=>{let o=CB(e,t);if(!o)return null;let r=XI(o,t);return YI(r,n)?null:SB(e,o,t)?r:null},AB=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,LB=(e,n,t,o)=>{let r=t.get(e.id)??[],i=KI(e,n),a=i?t.get(i.id):null,l=a?.length?[...r,...a]:r;return o?DB(l,o):l},DB=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[l,s],[d,c]]of e){let m=d-l,p=c-s,u=0,E=1,g=!0;for(let[b,w]of[[-m,l-t],[m,r-l],[-p,s-o],[p,i-s]]){if(b===0){if(w<0){g=!1;break}continue}let y=w/b;if(b<0){if(y>E){g=!1;break}u=Math.max(u,y)}else{if(y<u){g=!1;break}E=Math.min(E,y)}}g&&a.push(op(Ka(l+u*m,s+u*p),Ka(l+E*m,s+E*p)))}return a},_B=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||ZI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(l=>o.has(l))})},RB=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>vB(a,e)||o==="contain"&&BB(a,e);return n.length===0?NB(t)[r](i):n[r](a=>a[r](i))},NB=([e,n,t,o])=>[Ka(e,n),Ka(t,n),Ka(t,o),Ka(e,o)],BB=(e,n)=>n.some((t,o)=>o>0&&wB(e,op(n[o-1],t))),VI=(e,n,t,o)=>{let r=e.slice(1).map((l,s)=>op(e[s],l)).concat([op(e[e.length-1],e[0])]),i=KI(n,t),a=(l,s)=>{let d=PB(l,t,s,0,!o);return o?d.some(c=>kB(c,o)):d.length>0};return r.some(l=>a(n,l)||!!i&&a({...i,...IB(n,i,t)},l))};var rp=class extends Kn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),l=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(jI(l),jI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});v(this,"intersectedElements",new Set);v(this,"enclosedElements",new Set);v(this,"elementsSegments",null);v(this,"canvasTranslate",null);v(this,"keepPreviousSelection",!1);v(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(o.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&GB(d)){let c=UB(this.app.scene.getNonDeletedElementsMap(),d.id);for(let m of c)delete r[m.id]}}let i=WB({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&HB(this.app.scene.getNonDeletedElement(a[0]))?new zB(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});v(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});v(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>FB(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!YB(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=VB(this.app.visibleElements);for(let i of this.app.visibleElements){let a=OB(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=$I({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,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),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 KB,easeOut as qI,THEME as XB}from"@excalidraw/common";import{computeBoundTextPosition as ZB,doBoundsIntersect as $B,getBoundTextElement as jB,getElementBounds as qB,getElementLineSegments as JB,getFreedrawOutlineAsSegments as QB,getFreedrawOutlinePoints as eF,intersectElementWithLineSegment as JI,isArrowElement as tF,isFreeDrawElement as QI,isLineElement as nF,isPointInElement as oF}from"@excalidraw/element";import{lineSegment as rF,lineSegmentsDistance as eT,pointFrom as aT,polygon as iF,polygonIncludesPointNonZero as aF}from"@excalidraw/math";import{getElementsInGroup as tT}from"@excalidraw/element";import{shouldTestInside as lF}from"@excalidraw/element";import{hasBoundTextElement as nT,isBoundToContainer as oT}from"@excalidraw/element";import{getBoundTextElementId as rT}from"@excalidraw/element";var ip=class extends Kn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),l=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(qI(l),qI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===XB.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});v(this,"elementsToErase",new Set);v(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(l=>aT(l[0],l[1]))||[];if(o.length<2)return[];let r=rF(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=KB(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(iT(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let c=tT(this.app.scene.getNonDeletedElementsMap(),d);for(let m of c)this.elementsToErase.delete(m.id);this.groupsToErase.delete(d)}if(oT(l)&&this.elementsToErase.delete(l.containerId),nT(l)){let c=rT(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&iT(r,l,a,this.app.state.zoom.value)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let c=tT(this.app.scene.getNonDeletedElementsMap(),d);for(let m of c)this.elementsToErase.add(m.id);this.groupsToErase.add(d)}if(nT(l)){let c=rT(l);c&&this.elementsToErase.add(c)}oT(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},iT=(e,n,t,o)=>{let r=e[1],i=QI(n)?15:n.strokeWidth/2,a=[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],l=qB(n,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!$B(a,s))return!1;if(lF(n)&&oF(r,n,t))return!0;if(QI(n)){let c=eF(n),m=QB(n,c,t),p=Math.max(2.25,5/o);for(let E of m)if(eT(E,e)<=p)return!0;let u=iF(...c.map(([E,g])=>aT(n.x+E,n.y+g)));return!!aF(e[0],u)}let d=jB(n,t);if(tF(n)||nF(n)&&!n.polygon){let c=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=JB(n,t);for(let p of m)if(eT(p,e)<=c)return!0;return!1}return JI(n,t,e,0,!0).length>0||!!d&&JI({...d,...ZB(n,d,t)},t,e,0,!0).length>0};import{isDevEnv as IF}from"@excalidraw/common";import{newElement as TF}from"@excalidraw/element";import{COLOR_PALETTE as sF,DEFAULT_FONT_FAMILY as cF,DEFAULT_FONT_SIZE as dF,VERTICAL_ALIGN as mF}from"@excalidraw/common";var lT=44,sT=22,cT=66,dT=48,Qs=14,mT=304,pT=320,Kf=5.87,uT=28,hT=4,gT=2,Xf=10,fT=10,ET=8,yo=12,Xa=256,Si=10,Zf=4,Za=yo*2,$f=yo*2,bT=100,xT=140,ec=.35,yT=yo/2,kr=20,ap=yo*2,jf=yo,Ue={fillStyle:"hachure",fontFamily:cF,fontSize:dF,opacity:100,roughness:1,strokeColor:sF.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:mF.MIDDLE,locked:!1};import{pointFrom as $a}from"@excalidraw/math";import{COLOR_PALETTE as ST,DEFAULT_CHART_COLOR_INDEX as pF,FONT_FAMILY as Qf,FONT_SIZES as lp,ROUNDNESS as wT,DEFAULT_FONT_SIZE as uF,getAllColorsSpecificShade as hF,getFontString as eE,getLineHeight as tE,ROUGHNESS as vT}from"@excalidraw/common";import{getApproxMinLineWidth as nE,measureText as Mr,newElement as Jf,newLinearElement as qf,newTextElement as ja,wrapText as CT}from"@excalidraw/element";var Ci=hF(pF),gF=e=>e.labels?.length??e.series[0]?.values.length??0,qa=(e,n)=>{if(!e)return!1;let t=gF(e);return t<2?!1:n==="radar"?t>=3:!0},IT=(e,n)=>{let t=n<=1?0:Math.min(cT,(n-1)*sT);return e+t},sp=(e,n)=>{if(e==="line"){let o=IT(dT,n);return{slotWidth:o,gap:Qs,chartHeight:pT,xLabelMaxWidth:o+Qs*3+Xf}}let t=IT(lT,n);return{slotWidth:t,gap:Qs,chartHeight:mT,xLabelMaxWidth:t+Qs*3+Xf}},Ja=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},PT=()=>{let e=Xa+$f*2,n=Xa+$f*2;return{chartWidth:e,chartHeight:n}},fF=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Qa=(e,n)=>{if(e<=0||Ci.length===0)return[];let t=Ci.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(l,s)=>s).filter(l=>l!==o));for(;r.length<i;){let l=-1,s=-1,d=-1;for(let c of a){let m=r.map(E=>fF(c,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>s||p===s&&u>d)&&(l=c,s=p,d=u)}r.push(l),a.delete(l)}return Array.from({length:e},(l,s)=>Ci[r[s%r.length]])},el=e=>{if(Ci.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*Ci.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%Ci.length},tl=e=>Ci[e],kT=(e,n)=>{let t=e.flatMap(l=>l.values.map(s=>Math.max(0,s))),o=t.filter(l=>l>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=bT;return{renderSteps:!1,normalize:(l,s)=>{let d=Math.max(0,l);return a?Math.log10(d+1)/Math.log10(r+1):d/r}}},EF=e=>/\s/.test(e.trim()),cp=(e,n,t)=>EF(e)?CT(e,n,t):e,MT=(e,n,t,o,r,i)=>{let a=Qf.Excalifont,l=lp.sm,s=tE(a),d=eE({fontFamily:a,fontSize:l}),c=Math.min(xT,r*(e.length>8?.56:.72)),m=nE(d,s),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(U=>Mr(U,d,s).width)),x=Math.max(m,c,y),I=cp(g,d,x),T=Mr(I,d,s),P=Math.cos(w),C=Math.sin(w),k=P>ec?"left":P<-ec?"right":"center",M=k==="center"?T.width/2:0,_=Math.abs(P)*M+Math.abs(C)*(T.height/2),L=Za+_+yT,R=t+P*(r+L),z=o+C*(r+L),K=C>ec?yo/3:C<-ec?-yo/3:0;return ja({backgroundColor:i,...Ue,text:I,originalText:g,x:R,y:z+K,fontFamily:a,fontSize:l,lineHeight:s,textAlign:k,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},nl=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Qf["Lilita One"],l=lp.lg,s=tE(a),d=eE({fontFamily:a,fontSize:l}),c=e.map((I,T)=>{let P=I.title?.trim()||`Series ${T+1}`,C=cp(P,d,Xa),k=Mr(C,d,s),M=kr+jf+k.width;return{label:P,displayLabel:C,color:n[T],width:M,height:k.height}}),m=Math.max(kr/2,...c.map(I=>I.height/2)),p=Math.max(r,o+m+Za),u=ap,E=kr*.6,g=c.reduce((I,T)=>I+T.width,0)+ap*Math.max(0,c.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Jf({...Ue,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:ST.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:vT.architect,roundness:{type:wT.PROPORTIONAL_RADIUS}}));let x=t-g/2;return c.forEach(I=>{y.push(Jf({...Ue,backgroundColor:I.color,type:"rectangle",x,y:p-kr/2,width:kr,height:kr,fillStyle:"solid",strokeColor:I.color,roughness:vT.architect,roundness:{type:wT.PROPORTIONAL_RADIUS}})),y.push(ja({...Ue,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+kr+jf,y:p,fontFamily:a,fontSize:l,lineHeight:s,textAlign:"left",verticalAlign:"middle"})),x+=I.width+ap}),y},bF=(e,n,t,o)=>{if(Mr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(Mr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},xF=(e,n,t,o)=>{if(Mr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>Mr(a,t,o).width>n)&&n>=nE(t,o)?{wrapped:!0,text:CT(e,t,n)}:{wrapped:!1,text:bF(e,n,t,o)}},AT=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},TT=e=>e.includes("..."),yF=(e,n,t,o,r)=>{let i=Math.max(uT,Math.ceil(nE(o,r))),a=Math.max(i,Math.floor(n)),l=[];for(let u=a;u>=i;u-=4)l.push(u);l[l.length-1]!==i&&l.push(i);let s=u=>{let E=TT(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
|
|
15
|
+
`).length;return{ellipsified:E,visibleChars:g,lineCount:b}},d=(u,E)=>{let g=s(u),b=s(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},c=null,m=null,p=null;for(let u of l){let{wrapped:E,text:g}=xF(e,u,o,r),b=Mr(g,o,r),w=AT(b.width,b.height,Kf),y={originalText:e,text:g,metrics:b,rotatedWidth:w.width,rotatedHeight:w.height,wrapped:E},x=w.width-t;if(x<=0){(!c||d(y,c))&&(c=y);continue}(!m||x<m.overflow||x===m.overflow&&d(y,m.spec))&&(m={overflow:x,spec:y}),!TT(y.text)&&(!p||x<p.overflow||x===p.overflow&&d(y,p.spec))&&(p={overflow:x,spec:y})}return c||(p&&m&&p.overflow<=m.overflow+ET?p.spec:m.spec)},dp=e=>{if(e.type!=="text")return e.y+e.height;let n=AT(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},tc=(e,n,t,o,r)=>{let i=Ue.fontFamily,a=lp.sm,l=tE(i),s=eE({fontFamily:i,fontSize:a}),d=Math.max(1,r.slotWidth+r.gap-hT*2+fT),c=t;return e.labels?.map((m,p)=>{let u=yF(m,r.xLabelMaxWidth,d,s,l),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=c+gT+(u.rotatedHeight-u.metrics.height)/2;return ja({backgroundColor:o,...Ue,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:Kf,fontSize:a,lineHeight:l,textAlign:"center",verticalAlign:"top"})})||[]},wF=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=ja({backgroundColor:o,...Ue,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),l=ja({backgroundColor:o,...Ue,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,l]},vF=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Ja(e,r),l=qf({backgroundColor:o,...Ue,type:"line",x:n,y:t,width:i,points:[$a(0,0),$a(i,0)]}),s=qf({backgroundColor:o,...Ue,type:"line",x:n,y:t,height:a,points:[$a(0,0),$a(0,-a)]}),d=qf({backgroundColor:o,...Ue,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:Si,points:[$a(0,0),$a(i,0)]});return[l,s,d]},mp=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:l,chartHeight:s}=Ja(e,r),d=e.title?ja({backgroundColor:o,...Ue,text:e.title,x:n+l/2,y:t-r.chartHeight-r.gap*2-uF,roundness:null,textAlign:"center",fontSize:lp.xl,fontFamily:Qf["Lilita One"]}):null,c=a?Jf({backgroundColor:o,...Ue,type:"rectangle",x:n,y:t-s,width:l,height:s,strokeColor:ST.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...d?[d]:[],...tc(e,n,t,o,r),...wF(e,n,t,o,r,i),...vF(e,n,t,o,r)]};var LT=(e,n,t,o)=>{let r=e.series,i=sp("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),l=el(o),s=tl(l),d=Qa(r.length,l),c=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-c*(r.length-1))/r.length):i.slotWidth,p=r.length*m+c*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((P,C)=>{let M=Math.max(0,P.values[T]??0)/a*i.chartHeight,_=r.length>1?d[C]:s;return TF({backgroundColor:_,...Ue,type:"rectangle",fillStyle:r.length>1?"solid":Ue.fillStyle,strokeColor:r.length>1?_:Ue.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+C*(m+c),y:t-M-i.gap,width:m,height:M})})),g=mp(e,n,t,s,i,a,IF()),b=tc(e,n,t,s,i),w=Math.max(t+i.gap/2,...b.map(I=>dp(I))),{chartWidth:y}=Ja(e,i),x=nl(r,d,n+y/2,w,t+i.gap*5,s);return[...g,...E,...x]};import{pointFrom as oE}from"@excalidraw/math";import{isDevEnv as SF}from"@excalidraw/common";import{newElement as CF,newLinearElement as DT}from"@excalidraw/element";var _T=(e,n,t,o)=>{let r=e.series,i=sp("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),l=el(o),s=tl(l),d=Qa(r.length,l),c=r.map((x,I)=>{let T=x.values.map((_,L)=>oE(L*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),P=Math.max(...T.map(_=>_[0])),C=Math.max(...T.map(_=>_[1])),k=Math.min(...T.map(_=>_[0])),M=Math.min(...T.map(_=>_[1]));return DT({backgroundColor:"transparent",...Ue,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:C-M,width:P-k,strokeColor:d[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,P)=>{let C=P*(i.slotWidth+i.gap)+i.gap/2,k=-(T/a)*i.chartHeight+i.gap/2;return CF({backgroundColor:d[I],...Ue,fillStyle:"solid",strokeColor:d[I],strokeWidth:2,type:"ellipse",x:n+C+i.slotWidth/2,y:t+k-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,P=x/a*i.chartHeight+i.gap/2+i.gap;return DT({backgroundColor:s,...Ue,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-P,height:P,strokeStyle:"dotted",opacity:Si,points:[oE(0,0),oE(0,P)]})}),E=mp(e,n,t,s,i,a,SF()),g=tc(e,n,t,s,i),b=Math.max(t+i.gap/2,...g.map(x=>dp(x))),{chartWidth:w}=Ja(e,i),y=nl(r,d,n+w/2,b,t+i.gap*5,s);return[...E,...c,...u,...m,...y]};var Xn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},PF=(e,n)=>e.slice(1).every(t=>Xn(t[n])!==null),RT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Xn(m)===null),l=a?e.slice(1):e;if(l.length<1)return{ok:!1,reason:"No data rows"};if(l.some(m=>m.slice(1).some(p=>Xn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>l.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=l.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Xn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let c=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:l.map(g=>Xn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:l.map(m=>m[0]),series:c}}}if(n===1){if(!PF(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Xn(e[0][0])===null,l=a?e[0][0]:null,s=(a?e.slice(1):e).map(d=>Xn(d[0]));return s.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:l,labels:null,series:[{title:l,values:s}]}}}let t=Xn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Xn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Xn(a[1]))}]}}},pp=e=>{let n=l=>e.replace(/\r\n?/g,`
|
|
16
16
|
`).split(`
|
|
17
|
-
`).filter(s=>s.trim().length>0).map(s=>s.split(l).map(d=>d.trim())),t=[" ",",",";"].map(l=>{let s=n(l),d=s[0]?.length??0,c=s.length>0&&s.every(p=>p.length===d);return{delimiter:l,parsed:s,numCols:d,isConsistent:c}}),r=(t.find(l=>l.isConsistent&&l.numCols>1)??t.find(l=>l.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(l=>l.length===i)?fT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as $a}from"@excalidraw/math";import{FONT_FAMILY as oF,FONT_SIZES as rF,getFontString as iF,getLineHeight as aF,ROUGHNESS as ET}from"@excalidraw/common";import{measureText as lF,newLinearElement as Xf,newTextElement as sF}from"@excalidraw/element";var bT=(e,n,t,o)=>{if(!Wa(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:l}=dT(i,r.length),s=Ka(o),d=Xa(s),c=Ya(i.length,s),{chartWidth:p,chartHeight:m}=cT(),u=n+p/2,E=t-m/2,g=za/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=mT(r,b,u,E,g,d),I=oF["Lilita One"],T=rF.xl,C=aF(I),P=iF({fontFamily:I,fontSize:T}),M=e.title?ep(e.title,P,p+Ga*2):null,L=M?lF(M,P,C):null,_=M?sF({backgroundColor:d,...Ue,text:M,originalText:e.title??M,x:n+p/2,y:y-Ga-L.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=l?Array.from({length:Ff},(z,U)=>{let W=(U+1)/Ff,G=g*W,oe=b.map(le=>$a(Math.cos(le)*G,Math.sin(le)*G));return oe.push($a(oe[0][0],oe[0][1])),Xf({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:ET.architect,opacity:yi,polygon:!0,points:oe})}):[],D=b.map(z=>{let U=Math.cos(z)*g,W=Math.sin(z)*g;return Xf({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(W),strokeStyle:"solid",roughness:ET.architect,opacity:yi,points:[$a(0,0),$a(U,W)]})}),B=i.map((z,U)=>{let W=b.map((G,oe)=>{let le=z.values[oe]??0,F=a(le,oe)*g;return $a(Math.cos(G)*F,Math.sin(G)*F)});return W.push($a(W[0][0],W[0][1])),Xf({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:c[U],strokeWidth:2,polygon:!0,points:W})}),K=Za(i,c,u,x,t+uo*5,d);return[..._?[_]:[],...w,...k,...D,...B,...K]};var Zf=(e,n,t,o,r)=>e==="line"?gT(n,t,o,r):e==="radar"?bT(n,t,o,r):uT(n,t,o,r);import{isDarwin as xT}from"@excalidraw/common";var yT={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],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+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[xT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[xT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],flipViewpointHorizontal:[N("Shift+R")],flipViewpointVertical:[N("Alt+Shift+R")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+A")],toolLock:[N("Q")]},Qe=(e,n=0)=>{let t=yT[e];return t&&t.length>0?t[n]||t[0]:""},wT=e=>{if(Object.prototype.hasOwnProperty.call(yT,e))return Qe(e)||void 0};import{clamp as rp,pointFrom as ja,pointsEqual as gF,bezierEquation as LT,pointRotateRads as ip,pointDistance as fF}from"@excalidraw/math";import{arrayToMap as EF,BIND_MODE_TIMEOUT as $s,DEFAULT_TRANSFORM_HANDLE_SPACING as DT,FRAME_STYLE as vn,getFeatureFlag as bF,invariant as CT,shouldRotateWithDiscreteAngle as _T,THEME as Bo}from"@excalidraw/common";import{deconstructDiamondElement as Qf,deconstructRectanguloidElement as RT,elementCenterPoint as qa,getDiamondBaseCorners as xF,FOCUS_POINT_SIZE as yF,getOmitSidesForEditorInterface as $f,getTransformHandles as wF,getTransformHandlesFromCoords as vF,hasBoundingBox as IF,hitElementItself as TF,isArrowElement as NT,isBindableElement as BT,isElbowArrow as Ja,isFrameLikeElement as Qa,isImageElement as ap,isLinearElement as SF,isLineElement as CF,maxBindingDistance_simple as PF,isTextElement as kF,LinearElementEditor as In,getActiveTextElement as MF,getElementsInGroup as eE,getSelectedGroupIds as AF,isSelectedViaGroup as LF,selectGroupsFromGivenElements as DF}from"@excalidraw/element";import{renderSelectionElement as _F}from"@excalidraw/element";import{getCommonBounds as tE,getElementAbsoluteCoords as qs}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as PT,isFocusPointVisible as RF}from"@excalidraw/element";import{pointFrom as Lt}from"@excalidraw/math";import{THEME as cF}from"@excalidraw/common";var dF="#ff6b6b",mF="#ff0000",vT=1,IT=2,TT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===cF.LIGHT||n.zenModeEnabled?dF:mF,o=(n.zenModeEnabled?vT*1.5:vT)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,uF(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,hF(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,pF(r,e,n));e.restore()},pF=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];wn(o,r,n)}for(let o of e.points)ST(o,t,n)},uF=(e,n,t)=>{ST(e.points[0],t,n),t.zenModeEnabled||wn(e.points[0],e.points[1],n)},ST=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?IT*1.5:IT)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},wn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},hF=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||wn(Lt(e[0],e[1]-i),Lt(e[0],e[1]+i),r),wn(Lt(s[0]-l,s[1]-a),Lt(s[0]-l,s[1]+a),r),wn(Lt(s[0]+l,s[1]-a),Lt(s[0]+l,s[1]+a),r),o.zenModeEnabled||(wn(Lt(n[0],n[1]-i),Lt(n[0],n[1]+i),r),wn(e,n,r))}else{let s=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||wn(Lt(e[0]-i,e[1]),Lt(e[0]+i,e[1]),r),wn(Lt(s[0]-a,s[1]-l),Lt(s[0]+a,s[1]-l),r),wn(Lt(s[0]-a,s[1]+l),Lt(s[0]+a,s[1]+l),r),o.zenModeEnabled||(wn(Lt(n[0]-i,n[1]),Lt(n[0]+i,n[1]),r),wn(e,n,r))}};var NF=(e,n)=>{CT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;CT(t,"midPointCoords is null"),lp(t,e,n)},BF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=In.getElement(o,t);if(!i)return;let a=In.getPointAtIndexGlobalCoordinates(i,r,t);lp(a,e,n)},lp=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",Al(n,e[0],e[1],In.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},FF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!NT(i)||i.isDeleted)return;let a=r==="label"?In.getBoundTextElementCenter(i,t):In.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);lp(a,e,n)},jf=(e,n,t,o,r,i,a)=>{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)"),Al(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},OF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Qa(a)&&(e.translate(a.x,a.y),e.beginPath(),vn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,vn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=vn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===Bo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",vn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,vn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let l=qa(n.element,t);switch(e.translate(l[0],l[1]),e.rotate(n.element.angle),e.translate(-l[0],-l[1]),e.translate(n.element.x,n.element.y),e.lineWidth=rp(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Bo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[s,d]=Qf(n.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[p,m,u,E]=c;e.beginPath(),e.moveTo(p[0]-n.element.x,p[1]-n.element.y),e.bezierCurveTo(m[0]-n.element.x,m[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[s,d]=RT(n.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[p,m,u,E]=c;e.beginPath(),e.moveTo(p[0]-n.element.x,p[1]-n.element.y),e.bezierCurveTo(m[0]-n.element.x,m[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(Qa(n.element)||BT(n.element))){let l=o.selectedLinearElement,s=l?.elementId&&In.getElement(l?.elementId,t),d=r&&TF({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=s&&Ja(s)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!d||c){e.save();let p=qa(n.element,t),m;if(n.element.type==="diamond"){let b=qa(n.element,t);m=xF(n.element).map(w=>{let y=LT(w,.5),x=ip(y,b,n.element.angle);return ja(x[0],x[1])})}else m=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(w=>{let y=ja(w.x+n.element.x,w.y+n.element.y),x=ip(y,p,n.element.angle);return ja(x[0],x[1])});let u=r&&m.reduce((b,w,y)=>{let x=fF(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=PF(o.zoom)+n.element.strokeWidth/2;m.forEach((b,w)=>{let y=(!d||c)&&u?.idx===w&&u.distance<=g,x=!y&&(c||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Bo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===Bo.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},zF=(e,n,t,o,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=$s-(a?.runtime??(l?0:$s)),d=rp(1/$s*s,1e-4,1),c=t.strokeWidth/2,p=t.frameId&&o.get(t.frameId);switch(p&&Qa(p)&&(n.translate(p.x,p.y),n.beginPath(),vn.radius&&n.roundRect?n.roundRect(-1,-1,p.width+1,p.height+1,vn.radius/r.zoom.value):n.rect(-1,-1,p.width+1,p.height+1),n.clip(),n.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=vn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===Bo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,vn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,vn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=qa(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-c,t.y+r.scrollY-c),n.lineWidth=rp(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Bo.DARK?`rgba(3, 93, 161, ${d/2})`:`rgba(106, 189, 252, ${d/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+c*2)/2,(t.height+c*2)/2,(t.width+c*2)/2,(t.height+c*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=Qf(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,T[0]-t.x+c,T[1]-t.y+c,C[0]-t.x+c,C[1]-t.y+c),n.stroke()})}break;default:{let[b,w]=RT(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,T[0]-t.x+c,T[1]-t.y+c,C[0]-t.x+c,C[1]-t.y+c),n.stroke()})}break}n.restore();break}if(!l||(a?.runtime??0)>$s)return;let m=.5*(Math.min(t.width,t.height)/2);if(!Qa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/$s*s;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,m,m,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,m*(1-d),m*(1-d),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!_T(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,w;if(t.type==="diamond"){let[,y]=Qf(t),x=qa(t,o);w=y.map(I=>{let T=LT(I,.5),C=ip(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=qa(t,o);w=[{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(I=>{let T=ja(I.x+t.x,I.y+t.y),C=ip(T,y,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}w.forEach(y=>{n.clearRect(y.x-b,y.y-b,b*2,b*2)}),n.fillStyle=r.theme===Bo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,w.forEach(y=>{n.beginPath(),n.arc(y.x,y.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},GF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(bF("COMPLEX_BINDINGS"))return zF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let l=e.lastPointerMoveCoords?ja(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,s=!!e.lastPointerMoveEvent&&_T(e.lastPointerMoveEvent);OF(n,t,o,r,l,s),n.restore()},FT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:c,dashed:p,activeEmbeddable:m}=t,u=a-r,E=l-i,b=(t.padding??DT*2)/n.zoom.value,w=8/n.zoom.value,y=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(m?4:1)/n.zoom.value;let x=s.length;for(let I=0;I<x;++I)e.strokeStyle=s[I],p&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*I,Ll(e,r-b,i-b,u+b*2,E+b*2,d,c,o);e.restore()},HF=(e,n,t,o)=>{let[r,i,a,l]=qs(t,o),s=a-r,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=vn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),Ll(e,r,i,s,d,r+s/2,i+d/2,t.angle,!1,vn.radius/n.zoom.value),e.restore()},kT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[p,m,u,E]=tE(c);return{angle:0,x1:p,x2:u,y1:m,y2:E,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:m+(E-m)/2,activeEmbeddable:!1}},d=c=>{let p=eE(t,c);return s(p)};Object.entries(DF(l,n)).filter(([c,p])=>p).map(([c,p])=>c).map(c=>d(c)).concat(a.map(c=>s([c]))).forEach(c=>FT(e,n,c))},qf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=In.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=In,a=n.selectedLinearElement?.isEditing?i:i/2,l=Ja(t),s=CF(t);if(r.forEach((d,c)=>{if(l&&c!==0&&c!==r.length-1)return;let p=c>0&&(c!==r.length-1||!s||!t.polygon)&&gF(d,c===r.length-1?r[0]:r[c-1],2/n.zoom.value),m=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!m&&c===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(m=!0),jf(e,n,d,a,m,!1,p)}),Ja(t)){let d=t.fixedSegments?.map(c=>c.index)||[];r.slice(0,-1).forEach((c,p)=>{In.isSegmentTooShort(t,r[p+1],r[p],p,n.zoom,o)||jf(e,n,ja((c[0]+r[p+1][0])/2,(c[1]+r[p+1][1])/2),i/2,!1,!d.includes(p+1),!1)})}else In.getEditorMidPoints(t,o,n).filter((c,p,m)=>c!==null&&!(Ja(t)&&(p===0||p===m.length-1))).forEach(c=>{(n.selectedLinearElement?.isEditing||r.length===2)&&jf(e,n,c,i/2,!1,!0,!1)});e.restore()},UF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},WF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Al(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},MT=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!BT(a)||a.isDeleted)return;let l=PT(i.fixedPoint,a,r);if(!RF(l,e,a,r,n,t))return;let s=n.selectedLinearElement,d=!!s?.isDragging,c=t==="start"?0:e.points.length-1,p=!!s?.selectedPointsIndices?.includes(c);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&lp(l,o,n),!(p&&d)){let m=PT(i.fixedPoint,a,r),u=s?.hoveredFocusPointBinding===t,E=In.getPointAtIndexGlobalCoordinates(e,c,r);UF(o,n,E,m),WF(o,n,m,yF/1.5,u)}},AT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[l,s,d,c]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?Al(e,l+d/2,s+c/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,c,2/t.zoom.value),e.fill(),e.stroke()):Ll(e,l,s,d,c,l+d/2,s+c/2,r,!0),e.restore()}})},VF=(e,n,t,o,r)=>{let[i,a,,,l,s]=qs(o,r),d=3,c=20,p=d/t.zoom.value,m=p/2,u=l-i+p,E=s-a+p,g=Math.min(c/t.zoom.value,u),b=Math.min(c/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=p,[[[-u,-E],[0,m],[g,m],[m,0],[m,b]],[[u-m,-E],[m,m],[-g+m,m],[0,0],[0,b]],[[-u,E],[0,-m],[g,-m],[m,0],[m,-b]],[[u-m,E],[m,-m],[-g+m,-m],[0,0],[0,-b]]].forEach(y=>{let[[x,I],[T,C],[P,M],[L,_],[k,D]]=y;e.save(),e.translate(l,s),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+M),e.stroke(),e.beginPath(),e.moveTo(x+L,I+_),e.lineTo(x+k,I+D),e.stroke(),e.restore()}),e.restore()},YF=(e,n,t,o)=>{n.save();let r=kf(t.zoom.value),i=e.width+r*2,a=e.height+r*2,l=e.x+e.width/2,s=e.y+e.height/2,d=-(e.width/2+r),c=-(e.height/2+r);n.translate(l+t.scrollX,s+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(d,c,i,a),n.restore()},KF=(e,n,t,o,r)=>{let i=Mf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},XF=(e,n,t,o,r,i)=>{for(let a of n){if(!ap(a)||!a.fileId)continue;let l=o.imageStatus.get(a.fileId);if(!!l?.downloadError){let c=js(a,t,r,"center");c&&zT(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,r,l?.downloadError??void 0)}else{let c=o.imageLoadingProgress.get(a.fileId);if(c!==void 0){let p=js(a,t,r,"center");p&&OT(e,p.centerX+r.scrollX,p.centerY+r.scrollY,p.radius,p.lineWidth,c,r,i)}}let d=l?.uploadProgress;if(d){let c=js(a,t,r,"top-right");c&&$F(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,c.lineWidth,d,r,i)}}},js=(e,n,t,o)=>{if(!ap(e))return null;let[r,i,a,l]=qs(e,n),s=t.zoom.value,d=Math.min(a-r,l-i)*s,c=Math.min(o==="center"?14:11.7,d/(o==="center"?4:4.62))/s,p=Math.min((o==="center"?3:2.6)/s,c/2);if(c<=0||p<=0)return null;if(o==="top-right"){let m=6/s;return{centerX:a-m-c,centerY:i+m+c,radius:c,lineWidth:p}}return{centerX:(r+a)/2,centerY:(i+l)/2,radius:c,lineWidth:p}},OT=(e,n,t,o,r,i,a,l,s)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=s?.trackColor??(a.theme===Bo.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=s?.color??l,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*rp(i,0,1)),e.stroke()),e.restore()},Jf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,ZF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},$F=(e,n,t,o,r,i,a,l)=>{let s=i.state??"uploading",d=i.color??Jf("--color-primary",l),c=i.color??Jf("--color-warning-darkest","#ec8b14");if(s==="failed"){zT(e,n,t,o,a,{color:i.color??Jf("--color-danger","#e03131")});return}if(s==="uploading"&&OT(e,n,t,o,r,i.progress??0,a,l,{color:d,trackColor:i.trackColor}),ZF(e,n,t-o*.02,o*1.125,{color:s==="error"?c:d,lineWidth:Math.max(r*.75,1/a.zoom.value)}),s==="error"){e.save(),e.strokeStyle=c,e.fillStyle=c,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let p=o*.18,m=t-o*.09;e.moveTo(n-p,m-p),e.lineTo(n+p,m+p),e.moveTo(n+p,m-p),e.lineTo(n-p,m+p),e.stroke(),e.restore()}else s==="pending"&&(e.save(),e.strokeStyle=d,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},zT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",l=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},jF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:d,animationState:c,deltaTime:p})=>{if(n===null)return{};let[m,u]=Uc(n,a),E=c,g=Wc({canvas:n,scale:a,normalizedWidth:m,normalizedHeight:u});g.save(),Vc(g,l);let b;if(o.forEach(C=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&qf(g,l,b,t),l.selectionElement&&!l.isCropping)try{_F(l.selectionElement,g,l,s.selectionColor)}catch(C){console.error(C)}let w=MF(r,l);if(w&&!w.autoResize&&KF(w,g,l,s.selectionColor,d.formFactor),l.editingTextElement){let C=i.get(l.editingTextElement.id);C&&!C.autoResize&&YF(C,g,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?E={...c,bindingHighlight:GF(e,g,l.suggestedBinding,i,l,p,c?.bindingHighlight)}:E={...c,bindingHighlight:void 0},l.hoveredArrowTextAnchor&&FF(g,l,i),l.frameToHighlight&&HF(g,l,l.frameToHighlight,t),l.elementsToHighlight&&kT(g,l,l.elementsToHighlight),l.activeLockedId){let C=i.get(l.activeLockedId),P=C?[C]:eE(i,l.activeLockedId);kT(g,l,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>Qa(C));r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&qf(g,l,r[0],t);let x=l.selectedLinearElement,I=x&&In.getElement(x.elementId,i);if(I&&(l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?NF(g,l):(Ja(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&BF(g,l,t)),NT(I)&&(MT({arrow:I,elementsMap:i,appState:l,context:g,type:"start"}),MT({arrow:I,elementsMap:i,appState:l,context:g,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let C=IF(r,l,d),P=r.length===1&&SF(r[0]);P&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&qf(g,l,r[0],t);let M=s.selectionColor||"#000";if(C){let L=EF(r),_=[];for(let D of t.values()){let B=[],K=s.remoteSelectedElementIds.get(D.id);if(P&&Ja(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!LF(l,D)&&B.push(M),K&&B.push(...K.map(z=>ci(z,l.collaborators.get(z))))),B.length){let[z,U,W,G,oe,le]=qs(D,t,!0);_.push({angle:D.angle,x1:z,y1:U,x2:W,y2:G,selectionColors:D.locked?["#ced4da"]:B,dashed:!!K||D.locked,cx:oe,cy:le,activeEmbeddable:l.activeEmbeddable?.element===D&&l.activeEmbeddable.state==="active",padding:D.id===l.croppingElementId||ap(D)?0:void 0})}}let k=D=>{let B=eE(t,D),[K,z,U,W]=tE(B);_.push({angle:0,x1:K,x2:U,y1:z,y2:W,selectionColors:B.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:K+(U-K)/2,cy:z+(W-z)/2,activeEmbeddable:!1})};for(let D of AF(l))k(D);l.editingGroupId&&k(l.editingGroupId),_.forEach(D=>FT(g,l,D))}if(g.save(),g.translate(l.scrollX,l.scrollY),r.length===1){g.fillStyle="#fff";let L=wF(r[0],l.zoom,t,"mouse",$f(d));if(!l.viewModeEnabled&&C&&!kF(l.editingTextElement)&&!l.croppingElementId&&AT(g,s,l,L,r[0].angle),l.croppingElementId&&!l.isCropping){let _=t.get(l.croppingElementId);_&&ap(_)&&VF(g,s,l,_,t)}}else if(r.length>1&&!l.isRotating&&!r.some(L=>L.locked)){let L=DT*2/l.zoom.value;g.fillStyle="#fff";let[_,k,D,B]=tE(r,t),K=g.getLineDash();g.setLineDash([2/l.zoom.value]);let z=g.lineWidth;g.lineWidth=1/l.zoom.value,g.strokeStyle=M,Ll(g,_-L,k-L,D-_+L*2,B-k+L*2,(_+D)/2,(k+B)/2,0),g.lineWidth=z,g.setLineDash(K);let U=vF([_,k,D,B,(_+D)/2,(k+B)/2],0,l.zoom,"mouse",y?{...$f(d),rotation:!0}:$f(d));r.some(W=>!W.locked)&&AT(g,s,l,U,0)}g.restore()}l.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let L=t.get(C);if(L){let[_,k,,,D,B]=qs(L,t,!0);g.save(),l.theme===Bo.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let K=Qa(L)?l.zoom.value:1;g.translate(l.scrollX,l.scrollY),g.translate(D,B),g.rotate(L.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/K-D,k+z.offsetY/K-B,z.width/K,z.height/K)}),g.restore()}}),TT(g,l),XF(g,o,t,e,l,s.selectionColor),g.restore(),$w({context:g,renderConfig:s,appState:l,normalizedWidth:m,normalizedHeight:u});let T;return s.renderScrollbars&&(T=SI(t,m,u,l),g.save(),g.fillStyle=TI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Em(g,C.x,C.y,C.width,C.height,po/2)}),g.restore()),{scrollBars:T,animationState:E}},nE=e=>{let n=jF(e);return e.callback(n),n};import{useEffect as tc,useMemo as GT,useRef as lE,useState as qF}from"react";import{bumpVersion as Js,getLinearElementSubType as tl,mutateElement as sE,updateElbowArrowPoints as JF}from"@excalidraw/element";import{pointFrom as cp,pointRotateRads as QF}from"@excalidraw/math";import{hasBoundTextElement as eO,isArrowBoundToElement as tO,isArrowElement as nO,isElbowArrow as oO,isLinearElement as pE,isUsingAdaptiveRadius as rO}from"@excalidraw/element";import{getCommonBoundingBox as iO,getElementAbsoluteCoords as aO}from"@excalidraw/element";import{getBoundTextElement as YT,getBoundTextMaxHeight as lO,getBoundTextMaxWidth as sO,redrawTextBoundingBox as cO}from"@excalidraw/element";import{wrapText as dO}from"@excalidraw/element";import{assertNever as mO,CLASSES as pO,getFontString as oE,isProdEnv as uO,mapFind as hO,reduceToCommonValue as gO,ROUNDNESS as rE,sceneCoordsToViewportCoords as fO,updateActiveTool as HT}from"@excalidraw/common";import{measureText as UT}from"@excalidraw/element";import{LinearElementEditor as EO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as iE,newElement as bO,newLinearElement as xO}from"@excalidraw/element";import{ShapeCache as yO}from"@excalidraw/element";import{updateBindings as wO}from"@excalidraw/element";import{jsx as mE}from"react/jsx-runtime";var vO=8,IO=10,Qs=["rectangle","diamond","ellipse"],ec=["line","sharpArrow","curvedArrow","elbowArrow"],TO=new Set(Qs),SO=new Set(ec),nl=e=>TO.has(e),dp=e=>e==="arrow"||SO.has(e),ho=et(null),nc=new Map,oc=new Map,CO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=lE(null);return tc(()=>{if(n.length===0){e.updateEditorAtom(ho,null);return}let o=mp(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ho,null),t.current=null)},[n,e]),tc(()=>()=>{nc.clear(),oc.clear()},[]),mE(PO,{app:e,elements:n})},PO=({app:e,elements:n})=>{let t=mp(n),o=GT(()=>t==="generic"?XT(n):[],[t,n]),r=GT(()=>t==="linear"?dE(n):[],[t,n]),i=t==="generic"?o.every(p=>p.type===o[0].type):t==="linear"?r.every(p=>tl(p)===tl(r[0])):!1,[a,l]=qF({x:0,y:0}),s=lE(""),d=lE(null);tc(()=>{let p=[...o,...r].sort((b,w)=>b.id.localeCompare(w.id)),m=`
|
|
18
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(b=>b.id).join(",")}`;if(m===s.current)return;s.current=m;let u;if(p.length===1){let[b,,,w,y,x]=aO(p[0],e.scene.getNonDeletedElementsMap());u=QF(cp(b,w),cp(y,x),p[0].angle)}else{let{minX:b,maxY:w}=iO(p);u=cp(b,w)}let{x:E,y:g}=fO({sceneX:u[0],sceneY:u[1]},e.state);l({x:E,y:g})},[o,r,e.scene,e.state]),tc(()=>{for(let p of r){let m=cE(p.id,DO(p));oc.has(m)||oc.set(m,p)}},[r]),tc(()=>{for(let p of o)if(!nc.has(p.id)){let m=YT(p,e.scene.getNonDeletedElementsMap());m&&nc.set(p.id,{fontSize:m.fontSize})}},[o,e.scene]);let c=t==="linear"?[["line",Qo],["sharpArrow",nr],["curvedArrow",rr],["elbowArrow",or]]:t==="generic"?[["rectangle",Yi],["diamond",Ki],["ellipse",Xi]]:[];return mE("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(IO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-vO}px`,zIndex:2},className:pO.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([p,m])=>{let u=i&&(t==="generic"&&o[0].type===p||t==="linear"&&tl(r[0])===p);return mE($,{type:"toggle",icon:m,checked:u,title:p,"aria-label":p,"data-testid":`toolbar-${p}`,onSelect:()=>{u||(e.state.activeTool.type!==p&&Ye("convertElementType",p,"ui"),uE(e,{conversionType:t,nextType:p}),d.current?.focus())}},`${n[0].id}${n[0].version}_${p}`)})})},kO=(e,n,t)=>{let o=sO(e,n),r=lO(e,n),i=dO(n.text,oE(n),o),a=UT(i,oE(n),n.lineHeight),l=n.fontSize;for(;(a.width>o||a.height>r)&&l>0;){l-=1;let s={...n,fontSize:l};a=UT(n.text,oE(s),n.lineHeight)}sE(n,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),cO(n,e,t)},uE=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let l=XT(r),d=l.every(c=>c.type===l[0].type)?Qs.indexOf(l[0].type):-1;if(t=t??Qs[(d+Qs.length+a)%Qs.length],t&&nl(t)){let c={};for(let m of l){let u=VT(m,t,e);c[u.id]=u}let p=[];for(let m of e.scene.getElementsIncludingDeleted())c[m.id]?p.push(c[m.id]):p.push(m);e.scene.replaceAllElements(p);for(let m of Object.values(c)){let u=YT(m,e.scene.getNonDeletedElementsMap());u&&(nc.get(m.id)&&sE(u,e.scene.getNonDeletedElementsMap(),{fontSize:nc.get(m.id)?.fontSize??u.fontSize}),kO(m,u,e.scene))}e.setState(m=>({selectedElementIds:i,activeTool:HT(m,{type:"selection"})}))}}if(n==="linear"){let l=dE(r);if(!t){let d=gO(l,tl),c=d?ec.indexOf(d):-1;t=ec[(c+ec.length+a)%ec.length]}if(dp(t)){let d=[],c=e.scene.getElementsMapIncludingDeleted();for(let p of l){let m=oc.get(cE(p.id,t));if(m&&tl(m)===t)c.set(m.id,m),d.push(m);else{let u=VT(p,t,e);c.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(c);for(let p of d)if(pE(p))if(oO(p)){let m=MO(p);if(m.length<2)continue;let u=[];for(let g=1;g<m.length-2;g++)u.push({start:m[g],end:m[g+1],index:g+1});let E=JF(p,e.scene.getNonDeletedElementsMap(),{points:m,fixedSegments:u});sE(p,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let m=hO(["line","sharpArrow","curvedArrow"],u=>oc.get(cE(p.id,u)));if(m){let u=m.points;e.scene.mutateElement(p,{points:u})}}}let s=dE(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new EO(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:HT(d,{type:"selection"})}))}return!0},mp=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(nl(t.type))return"generic";KT(t)&&(n=!0)}return n?"linear":null},KT=e=>pE(e)&&(!nO(e)||!tO(e)&&!eO(e)),cE=(e,n)=>`${e}:${n}`,XT=e=>e.filter(n=>nl(n.type)),dE=e=>e.filter(n=>KT(n)),sp=20,el=(e,n)=>e[0]===n[0],aE=(e,n)=>e[1]===n[1],WT=(e,n)=>el(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),MO=e=>{let n=[e.points[0]],t=AO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<sp?l[0]=a[0]:Math.abs(l[1]-a[1])<sp&&(l[1]=a[1]),el(a,l)||aE(a,l)||n.push(cp(a[0],l[1])),n.push(l)}let o=[n[0]];for(let i=1;i<n.length-1;++i)el(n[i-1],n[i])&&el(n[i],n[i+1])||aE(n[i-1],n[i])&&aE(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],l=o[i],s=o[i+1],d=el(a,l),c=el(l,s);if(d!==c){let p=WT(a,l),m=WT(l,s);if(p<sp||m<sp){if(m<p)d?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(o[o.length-1]),r},AO=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},VT=(e,n,t)=>{if(!LO(e.type,n)){if(!uO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(yO.delete(e),nl(n)){let o=Js(bO({...e,type:n,roundness:e.roundness?{type:rO(n)?rE.ADAPTIVE_RADIUS:rE.PROPORTIONAL_RADIUS}:e.roundness}));return wO(o,t.scene,t.state),o}if(dp(n))switch(n){case"line":return Js(xO({...e,type:"line"}));case"sharpArrow":return Js(iE({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Js(iE({...e,type:"arrow",elbowed:!1,roundness:{type:rE.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Js(iE({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return mO(n,`unhandled conversion type: ${n}`),e},LO=(e,n)=>!!(nl(e)&&nl(n)||dp(e)&&dp(n)),DO=e=>pE(e)?tl(e):e.type,ZT=CO;import{bindBindingElementToFixedPoint as _O,dragNewTextElement as RO,getBoundTextElement as NO,getEndpointBoundTextDragAnchor as BO,getTextBindingForArrowEndpoint as FO,getUnboundArrowEndpointAtPoint as OO,isArrowElement as zO,isBindingEnabled as GO,isEndpointBoundText as HO,isTextElement as UO}from"@excalidraw/element";import{pointFrom as WO}from"@excalidraw/math";var pp=class{constructor(n){this.app=n;v(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});v(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!GO(this.app.state))return null;let o=OO(WO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!zO(r)||NO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return FO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){_O(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!UO(n)||!HO(n,this.app.scene.getNonDeletedElementsMap())?!1:(RO({newElement:n,...BO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as VO,BUCKET_FILL_BACKGROUND_PICKS as YO,COLOR_PALETTE as jT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as KO,getSizeFromPoints as XO,isTransparent as ZO,THEME as $O}from"@excalidraw/common";import{pointFrom as $T}from"@excalidraw/math";import{computeBucketFillPolygon as jO,isBucketFillCompatible as qO,isFrameLikeElement as JO,isRestylableFill as QO,newLinearElement as e9,ShapeCache as t9}from"@excalidraw/element";var hE=YO.filter(e=>e!==jT.white),up=class{constructor(n){this.app=n;v(this,"temporaryEyeDropper",null);v(this,"pending",null);v(this,"handlePointerDown",n=>{this.pending=n});v(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});v(this,"cancel",()=>{this.pending=null});v(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=hE.indexOf(n),o=hE[(t+1)%hE.length];this.app.actionManager.executeAction(Hd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Tt.get(Yt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Hd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Yt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Tt.get(Yt)===n&&this.app.updateEditorAtom(Yt,null)});v(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),t9.delete(n),this.app.scheduleCapture())});v(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=$T(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),l=jO({point:i,elements:o,elementsMap:r});if(!l.ok){if(a&&qO(a)){this.restyle(a);return}l.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(l.reason==="open_region"||l.reason==="too_small"||l.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&QO({hitElement:a,scenePoints:l.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:d}=XO(l.scenePoints),[c,p]=l.scenePoints[0],m=l.scenePoints.map(y=>$T(y[0]-c,y[1]-p)),u=l.ownerId?r.get(l.ownerId):null,E=u?JO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:l.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=e9({type:"line",x:c,y:p,width:s,height:d,points:m,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),w=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===l.insertion.elementId);this.app.scene.insertElementsAtIndex([b],w<0?null:l.insertion.placement==="above"?w+1:w),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>ZO(n)?jT.green[KO]:VO(n,t===$O.DARK))}};import{CURSOR_TYPE as rc,MIME_TYPES as gp,THEME as qT}from"@excalidraw/common";var JT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',n9='<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"/>',QT='<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"/>',o9=`data:${gp.svg},${encodeURIComponent(`${JT}${QT}</svg>`)}`,r9=`data:${gp.svg},${encodeURIComponent(`${JT}${n9}${QT}</svg>`)}`,i9=e=>{let n=$u.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${gp.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},hp=class{constructor(n){this.app=n;v(this,"toolCursorMemo",null);v(this,"eraserCanvasCache",null);v(this,"eraserPreviewDataURL",null);v(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});v(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(rc.GRAB):this.clear():this.applyForTool()});v(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(kl({activeTool:n}))this.set(rc.GRAB);else if(dn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(rc.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${i9(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===qT.LIGHT?o9:r9;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(rc.AUTO):this.set(rc.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});v(this,"clear",()=>{this.set("")});v(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===qT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(gp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as d9}from"@excalidraw/common";import{bindBindingElement as m9,convertToShape as p9,convertToShapeHandlePointerMoveFromPointerDown as u9,getHoveredElementForBinding as eS,isBindingElement as h9,isLineElement as g9,LinearElementEditor as gE,maxBindingDistance_simple as tS,newArrowElement as f9,updateBoundPoint as E9}from"@excalidraw/element";import{getStrokeWidthByKey as a9,THEME as l9}from"@excalidraw/common";import{clamp as s9,pointFrom as c9}from"@excalidraw/math";var fp=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Hn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===l9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>s9(a9("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>c9(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Ep=class{constructor(n){this.app=n;v(this,"trail");v(this,"gestureInProgress",!1);v(this,"stop",()=>{this.trail.stop()});v(this,"hasPendingGesture",()=>this.gestureInProgress);v(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(xt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>u9(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=tS(t.state.zoom),a=["start","end"].map(c=>{let p=gE.getPointAtIndexGlobalCoordinates(n,c==="start"?0:-1,o);return{startOrEnd:c,globalPoint:p,target:eS(p,r,o,i)}}),l=!!a[0].target&&a[0].target===a[1].target,s=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:c,globalPoint:p,target:m}of a)m&&m9(n,m,l?"inside":"orbit",c,t.scene,p,t.state.isBindingEnabled,s);if(l)return;let d=new Map;for(let{startOrEnd:c,target:p}of a){if(!p)continue;let m=E9(n,c==="start"?"startBinding":"endBinding",c==="start"?n.startBinding:n.endBinding,p,o);m&&d.set(c==="start"?0:n.points.length-1,{point:m})}d.size&&gE.movePoints(n,t.scene,d)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=tS(t.state.zoom),[a,l]=[0,-1].map(s=>eS(gE.getPointAtIndexGlobalCoordinates(n,s,o),r,o,i));return!a&&!l||a===l?null:f9({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});v(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||p9(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:d9(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&g9(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&h9(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new fp(n)}};import{isArrowKey as b9,KEYS as vi}from"@excalidraw/common";import{makeNextSelectedElementIds as x9,CaptureUpdateAction as y9,FlowChartCreator as w9,FlowChartNavigator as v9,getSelectedElements as nS,isFlowchartNodeElement as I9}from"@excalidraw/element";var bp=class e{constructor(n){this.app=n;v(this,"creator",new w9);v(this,"navigator",new v9);v(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});v(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===vi.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!b9(n.key))return{type:"none"};if(n[vi.CTRL_OR_CMD]&&!n.shiftKey){let a=nS(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&I9(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),l=nS(a,r.state);if(l.length===1)return{type:"navigating",nodeId:o.exploreByDirection(l[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[vi.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:x9({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:y9.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case vi.ARROW_UP:return"up";case vi.ARROW_DOWN:return"down";case vi.ARROW_RIGHT:return"right";case vi.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as oS,hasPlayableGif as T9,isInitializedImageElement as S9,newElementWith as rS,ShapeCache as C9}from"@excalidraw/element";import{MIME_TYPES as iS}from"@excalidraw/common";var xp=class{constructor(n){this.app=n;v(this,"playbackRaf",null);v(this,"runtimeState",new Map);v(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});v(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);v(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});v(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||T9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==iS.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:iS.gif,gifDecodeStatus:"pending"});let r=rS(n,{fileId:o,gifPlayback:oS({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});v(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:rS(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:oS(t)}));v(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});v(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!S9(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),l=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,l);let s=l.frameIndex,d=i.delays[s]??100;n-l.lastFrameTime>=d/a&&(l.frameIndex=(s+1)%i.frames.length,l.lastFrameTime=n,C9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as P9,easeOut as mS,isBounds as k9}from"@excalidraw/common";import{clamp as pS}from"@excalidraw/math";import{getCommonBounds as aS,getElementsInGroup as M9,isElementLink as A9,isExcalidrawElement as L9,parseElementLinkFromURL as D9}from"@excalidraw/element";var yp="animateScrollToContent",ol="animateScrollConstraintsSnapBack",lS=500,_9=250,R9=200,fE=302,sS={full:216,compact:64},N9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},B9=(e,n)=>{let t=n.get(e);return t?[t]:M9(n,e)},cS=(e,n,t)=>{if(typeof e=="string"){let a=A9(e),l=a?"link":"element",s=a?D9(e):e,d=s?B9(s,n):[];return d.length?{bounds:aS(d,n),type:l}:{bounds:null,type:l}}if(k9(e))return{bounds:e,type:"area"};if(N9(e)&&!L9(e)){let a=e.width??t.width,l=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+l],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,l)=>{if(l&&!l.isDeleted){let s=n.get(l.id);s&&a.push(s)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:aS(r,n),type:"element"}},F9=e=>e===!1?0:e===!0||e==null?Ou:Math.max(e,0),O9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Wr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},dS=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=O9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[l,s,d,c]=n,p={x:l,y:s,width:d-l,height:c-s,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:F9(r.overscroll),offsets:o};return{...Jn({...e,...a,scrollConstraints:p}),scrollConstraints:p}},z9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},G9=e=>e===!1?null:e===!0||e==null?lS:e.duration??lS,H9=(e,n,t,o,r)=>{mt.start(yp,({deltaTime:i,state:a})=>{let l=(a?.elapsed??0)+i,s=Math.min(l/t,1),d=mS(pS(s,0,1));return s<1?(o({...z9({from:e,target:n,factor:d}),shouldCacheIgnoreZoom:!0}),{elapsed:l}):(r(),null)})},U9=(e,n,t=_9)=>{let o=Jn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||mt.running(yp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;mt.start(ol,({deltaTime:a,state:l})=>{let s=(l?.elapsed??0)+a,d=Math.min(s/t,1),c=1-mS(pS(d,0,1));return n(p=>{if(!p.scrollConstraints)return null;let m=Jn(p),u=m.zoom.value;return{scrollX:m.scrollX+r*c/u,scrollY:m.scrollY+i*c/u,zoom:m.zoom}}),d<1?{elapsed:s}:null})},wp=class{constructor(n,t){this.app=n;this.dependencies=t;v(this,"lastPosition",{x:0,y:0});v(this,"activeTransition",null);v(this,"uiLastMeasured",new Map);v(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});v(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});v(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=to().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g=u.closest("[data-ui-layout-region]")?.getBoundingClientRect(),b=Math.max(E.left,o.left,g?.left??-1/0),w=Math.max(E.top,o.top,g?.top??-1/0),y=Math.min(E.right,o.right,g?.right??1/0),x=Math.min(E.bottom,o.bottom,g?.bottom??1/0);if(y<=b||x<=w)continue;let I={top:w-o.top,right:y-o.left,bottom:x-o.top,left:b-o.left,width:y-b},T=u.dataset.viewportUiName;switch(T&&a.add(T),u.dataset.viewportUi){case"top":i.top=Math.max(i.top,I.bottom),T&&I.bottom>0&&this.uiLastMeasured.set(T,{side:"top",offset:I.bottom});break;case"bottom":{let C=this.app.state.height-I.top;i.bottom=Math.max(i.bottom,C),T&&C>0&&this.uiLastMeasured.set(T,{side:"bottom",offset:C})}break;case"side":{let[C,P]=I.left+I.width/2<this.app.state.width/2?["left",I.right]:["right",this.app.state.width-I.left];i[C]=Math.max(i[C],P),T&&P>0&&this.uiLastMeasured.set(T,{side:C,offset:P});break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:w}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],w)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?sS.compact:sS.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:fE})}let l=n?.padding??24,s=n?.paddingTop??l,d=(r?n?.paddingLeft:n?.paddingRight)??l,c=n?.paddingBottom??l,p=(r?n?.paddingRight:n?.paddingLeft)??l,m={top:i.top+s,right:i.right+d,bottom:i.bottom+c,left:i.left+p};return{top:n?.top??m.top,right:(r?n?.left:n?.right)??m.right,bottom:n?.bottom??m.bottom,left:(r?n?.right:n?.left)??m.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=cS(n.target,t,o);return r?dS(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),mt.cancel(ol),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,l=this.resolveOffsets(n.offsets),{bounds:s,type:d}=cS(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!s){d==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let c=dS(this.app.state,s,{fit:o,offsets:l,lock:r,viewportZoomFactor:a}),p=G9(i),m={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),mt.cancel(ol),this.snapBackDebounced.cancel(),p===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let u={target:c};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),H9(m,c,p,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||mt.cancel(ol),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),Jn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Jn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||U9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",P9(this.snapBack,R9));v(this,"cancelTransition",()=>{this.activeTransition=null,mt.cancel(yp)});v(this,"destroy",()=>{this.cancelTransition(),mt.cancel(ol),this.snapBackDebounced.cancel()})}get isAnimating(){return mt.running(yp)||mt.running(ol)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import vp from"react";var W9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,V9=/{{([\w-]+)}}/,Y9=/<([\w-]+)>/,K9=/<\/([\w-]+)>/,X9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(W9).filter(Boolean).forEach(o=>{let r=o.match(Y9),i=o.match(K9),a=o.match(V9);if(r!==null){let l=r[1];n.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),d=vp.createElement(vp.Fragment,{},...s.children),c=n[s.name];typeof c=="function"&&t[t.length-1].children.push(c(d))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let l=a[1];n.hasOwnProperty(l)?t[t.length-1].children.push(n[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},Z9=({i18nKey:e,children:n,...t})=>{let{t:o}=_e();return vp.createElement(vp.Fragment,{},...X9(o(e),t))},Ii=Z9;import{jsx as Tn,jsxs as uS}from"react/jsx-runtime";var $9=()=>uS("div",{"data-testid":"brave-measure-text-error",children:[Tn("p",{children:Tn(Ii,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Tn("span",{style:{fontWeight:600},children:e})})}),Tn("p",{children:Tn(Ii,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Tn("span",{style:{fontWeight:600},children:e})})}),Tn("p",{children:Tn(Ii,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Tn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Tn("p",{children:Tn(Ii,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Tn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>uS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),hS=$9;import nz from"clsx";import oz from"react";import{useLayoutEffect as j9,useRef as gS,useEffect as fS}from"react";import{unstable_batchedUpdates as q9}from"react-dom";import{KEYS as J9,queryFocusableElements as Q9}from"@excalidraw/common";import{clamp as ES}from"@excalidraw/math";import ez from"clsx";import{jsx as tz}from"react/jsx-runtime";var Cr=10,bS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:l})=>{let s=gS(null);fS(()=>{let c=s.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=m=>{if(m.key===J9.TAB){let u=Q9(c),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===c?(m.shiftKey?u[u.length-1]?.focus():u[0].focus(),m.preventDefault(),m.stopImmediatePropagation()):g===0&&m.shiftKey?(u[u.length-1]?.focus(),m.preventDefault(),m.stopImmediatePropagation()):g===u.length-1&&!m.shiftKey&&(u[0]?.focus(),m.preventDefault(),m.stopImmediatePropagation())}};return c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let d=gS(null);return j9(()=>{if(r&&s.current&&t!=null&&n!=null){let c=s.current,{width:p,height:m}=c.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===n)return;d.current={top:t,left:n};let u=Math.max(0,i-Cr*2);p>=u?(c.style.width=`${u}px`,c.style.left=`${Cr}px`,c.style.overflowX="scroll"):c.style.left=`${ES(n,Cr,i-Cr-p)}px`;let E=Math.max(0,a-Cr*2);m>=E?(c.style.height=`${E}px`,c.style.top=`${Cr}px`,c.style.overflowY="scroll"):c.style.top=`${ES(t,Cr,a-Cr-m)}px`}},[t,n,r,i,a]),fS(()=>{if(o){let c=p=>{s.current?.contains(p.target)||q9(()=>o(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[o]),tz("div",{className:ez("popover",l),ref:s,tabIndex:-1,children:e})};import{jsx as Fo,jsxs as yS}from"react/jsx-runtime";var We="separator",xS=e=>"onSelect"in e,wS=oz.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=nn(),a=Qi(),l=n.reduce((s,d)=>d?d===We||xS(d)?(s.push(d),s):((!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s):s,[]);return Fo(bS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Fo("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===We)return!l[d-1]||l[d-1]===We?null:Fo("hr",{className:"context-menu-item-separator"},d);if(xS(s))return Fo("li",{"data-testid":s.key,onClick:()=>{r(()=>{s.onSelect()})},children:yS("button",{type:"button",className:"context-menu-item",children:[Fo("div",{className:"context-menu-item__label",children:s.label}),Fo("kbd",{className:"context-menu-item__shortcut"})]})},s.key);let c=s.name,p="";return s.label&&(typeof s.label=="function"?p=f(s.label(a,i,e.app)):p=f(s.label)),Fo("li",{"data-testid":c,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:yS("button",{type:"button",className:nz("context-menu-item",{dangerous:c==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Fo("div",{className:"context-menu-item__label",children:p}),Fo("kbd",{className:"context-menu-item__shortcut",children:c?Qe(c):""})]})},d)})})})});import{useId as rz}from"react";import iz from"clsx";import{Fragment as az,jsx as ic,jsxs as vS}from"react/jsx-runtime";var Ip=({border:e,style:n})=>ic("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),Tp=({label:e,border:n})=>{let t=rz(),o=vS(az,{children:[e.icon&&ic("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return vS("div",{className:iz("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&ic("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),ic("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&ic("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:mn})]})};import lu from"clsx";import MV from"react";import{CLASSES as AV,TOOL_TYPE as jk,arrayToMap as LV,isShallowEqual as su}from"@excalidraw/common";import{mutateElement as DV,ShapeCache as _V}from"@excalidraw/element";import{showSelectedShapeActions as RV}from"@excalidraw/element";import{createIsolation as lz}from"jotai-scope";import EE from"react";import Oo from"tunnel-rat";var bE=EE.createContext(null),ut=()=>EE.useContext(bE),sz=lz(),IS=()=>EE.useMemo(()=>({MainMenuTunnel:Oo(),WelcomeScreenMenuHintTunnel:Oo(),WelcomeScreenToolbarHintTunnel:Oo(),WelcomeScreenHelpHintTunnel:Oo(),WelcomeScreenCenterTunnel:Oo(),FooterCenterTunnel:Oo(),DefaultSidebarTriggerTunnel:Oo(),DefaultSidebarTabTriggersTunnel:Oo(),OverwriteConfirmDialogTunnel:Oo(),tunnelsJotai:sz}),[]);import kr from"clsx";import{useRef as Ez}from"react";import{Popover as Pr}from"radix-ui";import{CLASSES as RS}from"@excalidraw/common";import{isArrowElement as _S}from"@excalidraw/element";import{forwardRef as TS}from"react";import SS from"clsx";import{jsx as CS}from"react/jsx-runtime";var cz=TS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>CS("div",{className:SS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),dz=TS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>CS("div",{className:SS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),an={Row:cz,Col:dz};import{isTransparent as PS}from"@excalidraw/common";import{shouldAllowVerticalAlign as mz,suppportsHorizontalAlign as pz,hasBoundTextElement as kS,isElbowArrow as uz,isImageElement as MS,isLinearElement as hz,isTextElement as gz,hasStrokeColor as AS,toolIsArrow as fz}from"@excalidraw/element";var LS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return AS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>AS(o.type))},DS=(e,n)=>jo(e.activeTool.type)||n.some(t=>jo(t.type)),Sp=(e,n,t,o)=>{let r=e.activeTool.type,i=c=>c(r)||n.some(p=>c(p.type)),a=n.length===1,l=n.length===2&&(kS(n[0])||kS(n[1])),s=!!(e.editingTextElement||e.newElement),d=n.length>0;return{hasSelection:d,showExtraActions:d&&!s,strokeColor:LS(e,n),backgroundColor:DS(e,n),fill:r==="bucketfill"||jo(r)&&!PS(e.currentItemBackgroundColor)||n.some(c=>jo(c.type)&&!PS(c.backgroundColor)),strokeWidth:i(Ix),freedrawMode:i(Tx),strokeStyle:i(zu),sloppiness:i(zu),roundness:i(Sx),arrowType:i(fz),arrowheads:i(Pl),text:r==="text"||n.some(gz),textAlign:r==="text"||pz(n,t),verticalAlign:mz(n,t),opacity:r!=="autoshape"||d,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(c=>c.type==="freedraw")||de(t,e).some(c=>c.type==="freedraw"),align:!l&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(MS)&&dt(e,o),link:a||l,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&MS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&hz(n[0])&&!uz(n[0])}};import{Fragment as ln,jsx as J,jsxs as Ae}from"react/jsx-runtime";var xE=kr([RS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),NS=({renderAction:e})=>Ae("fieldset",{children:[J("legend",{children:f("labels.layers")}),Ae("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),BS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Ae("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Ae("div",{className:"align-fieldset-header",children:[J("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Ae("div",{className:"buttonList",children:[o?Ae(ln,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ae(ln,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),J("div",{style:{flexBasis:"100%",height:0}}),Ae("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Ae(ln,{children:[J("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},FS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Fi(n,e),i=Sp(e,r,n,o);return e.activeTool.type==="bucketfill"?Ae("div",{className:"selected-shape-actions",children:[J("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ae("div",{className:"selected-shape-actions",children:[J("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&J("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&J(ln,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&J(ln,{children:t("changeSloppiness")}),i.roundness&&J(ln,{children:t("changeRoundness")}),i.arrowType&&J(ln,{children:t("changeArrowType")}),i.text&&Ae(ln,{children:[J("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&J(ln,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&J(NS,{renderAction:t}),i.align&&J(BS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Ae("fieldset",{children:[J("legend",{children:f("labels.actions")}),Ae("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},OS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||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 i?J("div",{className:"compact-action-item",children:Ae(Pr.Root,{open:a,onOpenChange:l=>{t(l?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[J(Pr.Trigger,{asChild:!0,children:J("button",{type:"button",className:kr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:L0})}),a&&J(Po,{className:xE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ae("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&J(ln,{children:n("changeStrokeStyle")}),o.sloppiness&&J(ln,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},zS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let l=e.openPopup==="compactArrowProperties";return J("div",{className:"compact-action-item",children:Ae(Pr.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[J(Pr.Trigger,{asChild:!0,children:J("button",{type:"button",className:kr("compact-action-button properties-trigger",{active:l}),title:f("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=Et(o,a,d=>_S(d)?d.elbowed?"elbow":d.roundness?"round":"sharp":null,d=>_S(d),d=>d?null:e.currentItemArrowType);return s==="elbow"?or:s==="round"?rr:nr})()})}),l&&J(Po,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},GS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=ey(),l=e.openPopup==="compactTextProperties";return J("div",{className:"compact-action-item",children:Ae(Pr.Root,{open:l,onOpenChange:s=>{s?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[J(Pr.Trigger,{asChild:!0,children:J("button",{type:"button",className:kr("compact-action-button properties-trigger",{active:l}),title:f("labels.textAlign"),onClick:s=>{s.preventDefault(),s.stopPropagation(),l?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:o1})}),e.openPopup==="compactTextProperties"&&J(Po,{className:xE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ae("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},HS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let l=e.openPopup==="compactOtherProperties";return t.showExtraActions?J("div",{className:"compact-action-item",children:Ae(Pr.Root,{open:l,onOpenChange:s=>{o(s?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[J(Pr.Trigger,{asChild:!0,children:J("button",{type:"button",className:kr("compact-action-button properties-trigger",{active:l}),title:f("labels.actions"),onClick:s=>{s.preventDefault(),s.stopPropagation(),o({openPopup:l?null:"compactOtherProperties"})},children:jx})}),l&&J(Po,{className:xE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ae("div",{className:"selected-shape-actions",children:[t.layers&&J(NS,{renderAction:n}),t.align&&J(BS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Ae("fieldset",{children:[J("legend",{children:f("labels.actions")}),Ae("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},bz=({renderAction:e,predicates:n})=>n.lineEditor?J("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,US=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Fi(n,e),a=Sp(e,i,n,o),{container:l}=Te();return Ae("div",{className:"compact-shape-actions",children:[a.strokeColor&&J("div",{className:kr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&J("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&J("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),J(OS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:l}),J(zS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:l,app:o}),a.lineEditor&&J("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Ae(ln,{children:[J("div",{className:"compact-action-item",children:t("changeFontFamily")}),J(GS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:l})]}),a.showExtraActions&&J("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&J("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),J(HS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:l})]})},WS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r,showUndo:i=!0,showRedo:a=!0})=>{let l=Fi(n,e),s=Sp(e,l,n,o),{container:d}=Te(),c=Ez(null),p=c.current?.getBoundingClientRect()?.width??0,m=7+Number(i)+Number(a),u=6,E=32,g=m*E+(m-1)*u,b=E+u,w=p>=g+b,y=p>=g+2*b;return Ae(Ke,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:E*1.35,alignItems:"center",gap:u,pointerEvents:"none"},ref:c,children:[Ae("div",{className:"mobile-shape-actions__primary",children:[s.strokeColor&&J("div",{className:kr("compact-action-item"),children:t("changeStrokeColor")}),s.backgroundColor&&J("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),J(OS,{appState:e,renderAction:t,setAppState:r,predicates:s,container:d}),J(zS,{appState:e,renderAction:t,setAppState:r,targetElements:l,predicates:s,container:d,app:o}),J(bz,{renderAction:t,predicates:s}),s.text&&Ae(ln,{children:[J("div",{className:"compact-action-item",children:t("changeFontFamily")}),J(GS,{appState:e,renderAction:t,setAppState:r,predicates:s,container:d})]}),J(HS,{appState:e,renderAction:t,predicates:s,setAppState:r,container:d,showDuplicate:!y,showDelete:!w})]}),Ae("div",{style:{display:"flex",flexDirection:"row",gap:u},children:[i&&J("div",{className:"compact-action-item",children:t("undo")}),a&&J("div",{className:"compact-action-item",children:t("redo")}),y&&J("div",{className:"compact-action-item",children:t("duplicateSelection")}),w&&J("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},VS=({renderAction:e})=>J(an.Col,{gap:1,className:RS.ZOOM_ACTIONS,children:Ae(an.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})});var YS=({showExitZenModeBtn:e})=>J("button",{type:"button",className:kr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import xz from"clsx";import{useState as yz,useEffect as wz}from"react";import{THEME as vz}from"@excalidraw/common";import{jsx as yE,jsxs as Iz}from"react/jsx-runtime";var Cp=({delay:e,theme:n})=>{let[t,o]=yz(!!e);return wz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:Iz("div",{className:xz("LoadingMessage",{"LoadingMessage--dark":n===vz.DARK}),children:[yE("div",{children:yE(Co,{})}),yE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Mp,useEffect as hC}from"react";import qz from"clsx";import{KEYS as TE,capitalizeString as gC}from"@excalidraw/common";import uC from"react";import{DropdownMenu as Xz}from"radix-ui";import{CLASSES as Zz}from"@excalidraw/common";import Tz from"clsx";import{useCallback as Sz,useEffect as Cz,useRef as Pz}from"react";import{CLASSES as kz,EVENT as KS,KEYS as Mz}from"@excalidraw/common";import{DropdownMenu as XS}from"radix-ui";import{jsx as ac}from"react/jsx-runtime";var ZS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let l=me(),{container:s}=Te(),d=Pz(null),c=Ji({onClickOutside:n});qi(d,Sz(m=>{d.current?.closest(`.${kz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),Cz(()=>{if(!r)return;let m=E=>{E.key===Mz.ESCAPE&&(E.preventDefault(),E.stopImmediatePropagation(),c.onClickOutside?.())},u={capture:!0};return document.addEventListener(KS.KEYDOWN,m,u),()=>{document.removeEventListener(KS.KEYDOWN,m,u)}},[c,r]);let p=Tz(`dropdown-menu ${t}`,{"dropdown-menu--mobile":l.formFactor==="phone"}).trim();return ac(Vh.Provider,{value:{onSelect:o},children:ac(XS.Portal,{container:s,children:ac(XS.Content,{ref:d,className:p,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:l.formFactor==="phone"?ac(an.Col,{className:"dropdown-menu-container",children:e}):ac(Ke,{className:"dropdown-menu-container",padding:2,children:e})})})})};ZS.displayName="DropdownMenuContent";var $S=ZS;import{jsx as Lz}from"react/jsx-runtime";var Az=({children:e,className:n="",selected:t,...o})=>Lz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),jS=Az;import{DropdownMenu as Dz}from"radix-ui";import{jsx as wE}from"react/jsx-runtime";var qS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let d=Md(r);return wE(Dz.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:wE("a",{...s,href:t,target:"_blank",rel:`noopener ${l}`,className:sr(i,a),title:s.title??s["aria-label"],children:wE(cr,{icon:e,shortcut:n,children:o})})})},rl=qS;qS.displayName="DropdownMenuItemLink";import{jsx as _z}from"react/jsx-runtime";var JS=()=>_z("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),QS=JS;JS.displayName="DropdownMenuSeparator";import{DropdownMenu as Gz}from"radix-ui";import Rz from"clsx";import{DropdownMenu as Nz}from"radix-ui";import{useCallback as Bz,useState as eC}from"react";import{jsx as IE}from"react/jsx-runtime";var vE=-4,Fz=4,tC=({children:e,className:n})=>{let t=me(),o=Rz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=Bz(d=>{if(d){let p=d.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let m=d.getBoundingClientRect().width,E=window.innerWidth-p.right;E<m+20&&(a(E-m+vE),s(vE+8))}}},[]),[i,a]=eC(Fz),[l,s]=eC(vE);return IE(Nz.SubContent,{className:o,sideOffset:i,alignOffset:l,collisionPadding:8,ref:r,children:t.formFactor==="phone"?IE(an.Col,{className:"dropdown-menu-container",children:e}):IE(Ke,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},nC=tC;tC.displayName="DropdownMenuSubContent";import{DropdownMenu as Oz}from"radix-ui";import{jsx as oC,jsxs as zz}from"react/jsx-runtime";var rC=({children:e,icon:n,shortcut:t,className:o})=>zz(Oz.SubTrigger,{className:`${sr(o)} dropdown-menu__submenu-trigger`,children:[oC(cr,{icon:n,shortcut:t,children:e}),oC("div",{className:"dropdown-menu__submenu-trigger-icon",children:R0})]}),iC=rC;rC.displayName="DropdownMenuSubTrigger";import aC from"react";var Pp=e=>n=>{let t=aC.Children.toArray(n).find(o=>aC.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},lC=Pp("DropdownMenuTrigger"),sC=Pp("DropdownMenuContent"),cC=Pp("DropdownMenuSubTrigger"),dC=Pp("DropdownMenuSubContent");import{jsxs as Hz}from"react/jsx-runtime";var kp=({children:e})=>{let n=cC(e),t=dC(e);return Hz(Gz.Sub,{children:[n,t]})};kp.Trigger=iC;kp.Content=nC;kp.displayName="DropdownMenuSub";var Mr=kp;import Uz from"clsx";import{DropdownMenu as Wz}from"radix-ui";import{jsx as Vz}from"react/jsx-runtime";var mC=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=me(),a=Uz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return Vz(Wz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},pC=mC;mC.displayName="DropdownMenuTrigger";import{jsx as Kz}from"react/jsx-runtime";var Yz=e=>Kz(tn,{...e,icon:e.checked?ed:ld}),go=Yz;import{jsx as jz,jsxs as $z}from"react/jsx-runtime";var Wn=({children:e,open:n})=>{let t=lC(e),o=sC(e),r=o&&uC.isValidElement(o)?uC.cloneElement(o,{open:n}):o;return jz(Xz.Root,{open:n,modal:!1,children:$z("div",{className:Zz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Wn.Trigger=pC;Wn.Content=$S;Wn.Item=tn;Wn.ItemCheckbox=go;Wn.ItemLink=rl;Wn.ItemCustom=jS;Wn.Group=jl;Wn.Separator=QS;Wn.Sub=Mr;var pe=Wn;Wn.displayName="DropdownMenu";import{Fragment as SE,jsx as Ge,jsxs as il}from"react/jsx-runtime";var Jz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Bt))return null;let t=f("buttons.objectsSnapMode");return Ge($,{type:"toggle",icon:tr,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Bt,"ui")})},Qz=({app:e})=>Ge($,{type:"button",icon:jr,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),fC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,l]=Mp(!1),[s,d]=Mp("rectangle"),[c,p]=Mp("arrow");hC(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&d(o.type)},[o.type]),hC(()=>{(o.type==="arrow"||o.type==="line")&&p(o.type)},[o.type]);let m=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",w=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Me[G].icon,title:gC(f(`toolBar.${G}`)),fillable:Me[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:Me[G].icon,title:gC(f(`toolBar.${G}`)),fillable:Me[G].fillable})),[x,I]=Mp(0),T=32,C=6,P=7,M=P*T+(P-1)*C,L=T+C,_=x>=M+1*L,k=i&&x>=M+(r?3:2)*L,D=x>=M+3*L,B=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||D&&G==="frame")),K=r&&hr.includes(o.type),z=K||B.includes(o.type),U=z?K?Me[o.type].icon:o.type==="text"?_n:o.type==="image"?Xr:o.type==="frame"?ro:o.type==="embeddable"?er:o.type==="laser"?io:o.type==="bucketfill"?oo:Rl:Rl,W={app:e,activeTool:o,hideShortcut:!0};return il("div",{className:"mobile-toolbar",ref:G=>{if(G){let oe=G.closest('[data-ui-layout-item="toolbar"]'),le=G.closest(".App-toolbar"),F=oe?.getBoundingClientRect().width??G.getBoundingClientRect().width,V=le?Number.parseFloat(getComputedStyle(le).maxWidth):Number.POSITIVE_INFINITY,ce=le?Number.parseFloat(getComputedStyle(le).paddingLeft)+Number.parseFloat(getComputedStyle(le).paddingRight):0;I(Math.max(0,Math.min(F,Number.isFinite(V)?V:F)-ce))}},children:[Ge(Qd,{...W}),Ge(ri,{...W,setAppState:t}),r?Ge(as,{...W}):Ge(ma,{...W}),Ge(cs,{...W}),!r&&Ge(ca,{app:e,options:w,activeTool:o,defaultOption:s,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(d(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===s)||w[0]}),!r&&Ge(ca,{app:e,options:y,activeTool:o,defaultOption:c,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(p(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===c)||y[0]}),_&&Ge(ls,{...W}),r&&k&&Ge(Qz,{app:e}),k&&Ge(ss,{...W}),!r&&D&&Ge(fw,{...W,hideShortcut:!0}),il(pe,{open:a,children:[Ge(pe.Trigger,{className:qz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{l(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),il(pe.Content,{onClickOutside:()=>l(!1),onSelect:()=>l(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&hr.map(G=>Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Me[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Jd(G),disabled:ot(e,G),children:f(`toolBar.${G}`)},G)),!r&&Ge("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Bt)&&Ge(pe.Item,{onSelect:()=>n.executeAction(Bt,"ui"),icon:tr,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Qe("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&il(SE,{children:[r&&Ge("div",{className:"App-toolbar__dropdown-divider"}),Ge(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Jo:So,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:TE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:_n,shortcut:TE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:ot(e,"text"),children:f("toolBar.text")}),i&&!k&&Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Xr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:ot(e,"image"),children:f("toolBar.image")}),!r&&!D&&Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:ro,shortcut:TE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,disabled:ot(e,"frame"),children:f("toolBar.frame")}),!r&&il(SE,{children:[Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:er,"data-testid":"toolbar-embeddable",selected:g,disabled:ot(e,"embeddable"),children:f("toolBar.embeddable")}),Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:qr,shortcut:Lo("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:ot(e,"autoshape"),children:f("toolBar.autoshape")}),Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:io,"data-testid":"toolbar-laser",selected:E,disabled:ot(e,"laser"),children:f("toolBar.laser")}),Ge(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:oo,"data-testid":"toolbar-bucketfill",selected:b,disabled:ot(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&il(SE,{children:[Ge("div",{className:"App-toolbar__divider"}),Ge(Jz,{actionManager:n,app:e})]})]})};import eG from"clsx";import{jsx as tG}from"react/jsx-runtime";var Ar=e=>e.penDetected?tG($,{className:eG("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:n1,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{jsx as lc,jsxs as Ap}from"react/jsx-runtime";var nG=({item:e,api:n,appState:t,editorInterface:o,region:r,orientation:i})=>{let a=ur("zoom");return e.render({api:n,appState:t,editorInterface:o,region:r,orientation:i,zoom:a})},EC=["topLeft","topCenter","topRight","middleLeft","middleRight","bottomLeft","bottomCenter","bottomRight"],bC=e=>e.startsWith("middle")?"vertical":"horizontal",xC=e=>e.startsWith("middle")?"side":e.startsWith("top")?"top":"bottom",Lp=({items:e,layout:n,app:t,appState:o,editorInterface:r,className:i,legacyBottomCenter:a,legacyBottomLeft:l})=>{let s=new Map;EC.forEach(g=>s.set(g,[]));let d=e.flatMap((g,b)=>{let w=n?.items?.[g.id]??{};if(w.visible===!1||g.content==null)return[];let y=w.region??g.defaultRegion,x=w.orientation&&w.orientation!=="auto"?w.orientation:g.defaultOrientation&&g.defaultOrientation!=="auto"?g.defaultOrientation:bC(y);return[{id:g.id,region:y,orientation:x,order:w.order??g.defaultOrder??b,content:g.content,islandGroup:g.islandGroup}]}),c=(n?.customItems??[]).flatMap((g,b)=>{if(g.visible===!1)return[];let w=g.region,y=g.orientation&&g.orientation!=="auto"?g.orientation:bC(w);return[{id:`custom:${g.id}`,region:w,orientation:y,order:g.order??1e3+b,content:lc(nG,{item:g,api:t.api,appState:o,editorInterface:r,region:w,orientation:y})}]}),p=a==null?[]:[{id:"legacyFooterCenter",region:"bottomCenter",orientation:"horizontal",order:999,content:a}],m=[...d,...c,...p].sort((g,b)=>g.order-b.order||g.id.localeCompare(b.id)),u=g=>lc("div",{className:"ui-layout__item","data-ui-layout-item":g.id,"data-ui-orientation":g.orientation,"data-viewport-ui":xC(g.region),"data-viewport-ui-name":g.id==="stylesPanel"?"stylesPanel":void 0,children:g.content},g.id);EC.forEach(g=>{let b=m.filter(y=>y.region===g),w=s.get(g);for(let y=0;y<b.length;){let x=b[y],I=x.islandGroup;if(!I){w?.push(u(x)),y++;continue}let T=[x],C=y+1;for(;C<b.length;){let P=b[C];if(P.islandGroup?.id!==I.id||P.orientation!==x.orientation)break;T.push(P),C++}w?.push(lc(Ke,{className:`ui-layout__island-group ${I.className}`,padding:I.padding,"data-viewport-ui":xC(g),style:{display:"flex",alignItems:"center",gap:`${I.gap}px`},children:T.map(u)},`island-group:${I.id}:${g}:${x.id}`)),y=C}}),l!=null&&s.get("bottomLeft")?.unshift(lc("div",{className:"ui-layout__legacy-bottom-left",children:l},"legacy-bottom-left"));let E=g=>lc("div",{className:`ui-layout__region ui-layout__region--${g}`,"data-ui-layout-region":g,style:r.formFactor==="phone"&&g==="bottomLeft"?{alignItems:"center"}:void 0,children:s.get(g)},g);return Ap("div",{className:i?`ui-layout ${i}`:"ui-layout",children:[Ap("div",{className:"ui-layout__row ui-layout__row--top",children:[E("topLeft"),E("topCenter"),E("topRight")]}),Ap("div",{className:"ui-layout__row ui-layout__row--middle",children:[E("middleLeft"),E("middleRight")]}),Ap("div",{className:"ui-layout__row ui-layout__row--bottom",children:[E("bottomLeft"),E("bottomCenter"),E("bottomRight")]})]})},Dp=(e,n)=>n.formFactor==="phone"?e?.mobile:n.formFactor==="tablet"?e?.tablet:e?.desktop;import{Fragment as rG,jsx as yt,jsxs as iG}from"react/jsx-runtime";var oG=450,yC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:l,defaultUIEnabled:s,scrollBackToContentUIEnabled:d,app:c,onPenModeToggle:p,uiLayout:m})=>{let{WelcomeScreenCenterTunnel:u,MainMenuTunnel:E,DefaultSidebarTriggerTunnel:g}=ut(),b=d&&e.scrolledOutside,w=s,y=s&&(!e.viewModeEnabled||w),x=b&&!e.openMenu&&!e.openSidebar?yt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(K=>({...Bi(n,K)}))},children:f("buttons.scrollBackToContent")}):null,I=c.props.viewportStatusFrame?.label,T=I?yt(Tp,{label:I,border:c.props.viewportStatusFrame?.border}):null,C=c.editorInterface,P=Dp(m,C),M=i?.(!0,e),L=M!=null,_=P?.items?.undo!==void 0,k=P?.items?.redo!==void 0,D=e.openDialog?.name==="elementLinkSelector",B=[{id:"hostTopLeftUI",defaultRegion:"topLeft",defaultOrder:-10,content:!D&&r?.(!0,e)},{id:"mainMenu",defaultRegion:"topLeft",content:D?null:yt(E.Out,{})},{id:"hostTopRightUI",defaultRegion:"topRight",defaultOrder:-10,content:D?null:M},{id:"penMode",defaultRegion:"topRight",content:!D&&!L&&!e.viewModeEnabled&&s?yt(Ar,{checked:e.penMode,onChange:()=>p(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}):null},{id:"sidebarTrigger",defaultRegion:"topRight",content:!D&&!L&&!e.viewModeEnabled?yt(g.Out,{}):null},{id:"viewMode",defaultRegion:"bottomLeft",defaultOrder:0,islandGroup:{id:"mobileCanvasActions",className:"mobile-canvas-actions",padding:0,gap:6},content:w&&!e.viewModeOnly?yt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}):null},{id:"smartZoom",defaultRegion:"bottomLeft",defaultOrder:1,islandGroup:{id:"mobileCanvasActions",className:"mobile-canvas-actions",padding:0,gap:6},content:w?yt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")}):null},{id:"stylesPanel",defaultRegion:"bottomLeft",defaultOrder:2,content:s&&!e.viewModeEnabled?yt(WS,{appState:e,elementsMap:c.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:c,setAppState:o,showUndo:!_,showRedo:!k}):null},{id:"undo",defaultRegion:"bottomLeft",content:_&&P?.items?.undo?.visible!==!1&&s&&!e.viewModeEnabled?yt("div",{className:"undo-button-container",children:t.renderAction("undo")}):null},{id:"redo",defaultRegion:"bottomLeft",content:k&&P?.items?.redo?.visible!==!1&&s&&!e.viewModeEnabled?yt("div",{className:"redo-button-container",children:t.renderAction("redo")}):null},{id:"toolbar",defaultRegion:"bottomLeft",defaultOrder:10,content:s&&!e.viewModeEnabled&&!D?yt(Ke,{className:"App-toolbar",padding:1,style:{justifyContent:"flex-start",maxWidth:oG,width:"fit-content"},children:yt(fC,{app:c,actionManager:t,setAppState:o})}):null}];return iG(rG,{children:[a(),yt("div",{className:"App-welcome-screen",children:l&&yt(u.Out,{})}),(y||P!==void 0||r||i)&&yt(Lp,{items:B,layout:P,app:c,appState:e,editorInterface:C,className:"ui-layout--mobile",legacyBottomLeft:y&&x?yt("div",{className:"floating-status-stack",children:x}):null}),!y&&x&&yt("div",{className:"floating-status-stack",children:x}),T&&yt("div",{className:"viewport-status-frame__badge-row",children:T})]})};import PC,{useLayoutEffect as kC,useRef as MC,useState as AC}from"react";import{newTextElement as LC}from"@excalidraw/element";import pG from"clsx";import{useEffect as uG,useState as hG}from"react";import{KEYS as gG,queryFocusableElements as SC}from"@excalidraw/common";import{useCallback as aG,useState as lG}from"react";var wC=()=>{let[e,n]=lG(null),t=aG(o=>n(o),[]);return[e,t]};import vC from"clsx";import{useRef as sG}from"react";import{createPortal as cG}from"react-dom";import{KEYS as dG}from"@excalidraw/common";import{jsx as IC,jsxs as mG}from"react/jsx-runtime";var TC=e=>{let{closeOnClickOutside:n=!0}=e,t=bd({className:vC("excalidraw-modal-container",e.portalContainerClassName)}),o=sG(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===dG.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return cG(mG("div",{className:vC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[IC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),IC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as _p,jsxs as CC}from"react/jsx-runtime";function fG(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Sn=e=>{let[n,t]=wC(),[o]=hG(document.activeElement),{id:r}=Te(),i=me().formFactor==="phone";uG(()=>{if(!n)return;let s=SC(n);setTimeout(()=>{s.length>0&&e.autofocus!==!1&&(s[1]||s[0]).focus()});let d=c=>{if(c.key===gG.TAB){let p=SC(n),{activeElement:m}=document,u=p.findIndex(E=>E===m);u===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):u===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return n.addEventListener("keydown",d),()=>n.removeEventListener("keydown",d)},[n,e.autofocus]);let a=ze(),l=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return _p(TC,{className:pG("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:fG(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:CC(Ke,{ref:t,children:[e.title&&CC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[_p("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&_p("button",{className:"Dialog__close",onClick:l,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:mn}),_p("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as zo,jsxs as Rp}from"react/jsx-runtime";var EG=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},bG=e=>{let n=MC(null),[t,o]=AC(null),{theme:r}=ye();kC(()=>{if(!e.spreadsheet){o(null);return}let a=Zf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let l,s=n.current;return(async()=>(l=await Vr(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),l.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(l)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=EG(e.chartType);return Rp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[zo("div",{className:"ChartPreview__canvas",ref:n}),zo("div",{className:"ChartPreview__label",children:i})]})},xG=e=>{let n=MC(null),{theme:t}=ye();return kC(()=>{if(!e.rawText)return;let o=LC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Vr([o],{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]),Rp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[zo("div",{className:"ChartPreview__canvas",ref:n}),zo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},DC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=ft(),[i,a]=AC(Math.random()),l=PC.useCallback(()=>{a(Math.random())},[]),s=PC.useCallback(()=>{t&&t()},[t]),d=(p,m)=>{o(m),Ye("paste","chart",p),t(),r()},c=p=>{let m=LC({text:p,x:0,y:0});o([m]),Ye("paste","chart","plaintext"),t(),r()};return zo(Sn,{size:"regular",onCloseRequest:s,title:Rp("div",{className:"PasteChartDialog__title",children:[zo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),zo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:l,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),l())},children:oo})]}),className:"PasteChartDialog",autofocus:!1,children:Rp("div",{className:"container",children:[["bar","line","radar"].map(p=>Wa(e,p)?zo(bG,{chartType:p,spreadsheet:e,colorSeed:i,onClick:d},p):null),n&&zo(xG,{rawText:n,onClick:c})]})})};import{Fragment as yG,jsx as _C,jsxs as wG}from"react/jsx-runtime";var CE=({heading:e,children:n,...t})=>{let{id:o}=Te(),r=_C("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return _C("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):wG(yG,{children:[r,n]})})};import{Popover as al}from"radix-ui";import RC from"clsx";import Np,{useLayoutEffect as vG}from"react";import{supportsResizeObserver as IG,isShallowEqual as TG}from"@excalidraw/common";import{Fragment as ME,jsx as wt,jsxs as ll}from"react/jsx-runtime";var SG=4,CG=8,PE=38,NC=21,PG=({shouldWrap:e,children:n,username:t})=>e?wt(bt,{label:t||"Unknown user",children:n}):wt(ME,{children:n}),kE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return wt(PG,{username:n.username,shouldWrap:r,children:l},t)},kG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Bp=Np.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=nt(),{container:a}=Te(),l=typeof r=="function"?r(!!n):r,s=Array.from(t,([P,M])=>({...M,socketId:P})).filter(P=>P.username?.trim()),d=s.find(P=>P.isCurrentUser),c=s.filter(P=>!P.isCurrentUser),[p,m]=Np.useState(""),u=s.filter(P=>P.username?.toLowerCase().includes(p)),E=Np.useRef(null);vG(()=>{if(E.current){let P=L=>{b(L)};if(P(E.current.clientWidth),!IG)return;let M=new ResizeObserver(L=>{for(let _ of L){let{width:k}=_.contentRect;P(k)}});return M.observe(E.current),()=>{M.disconnect()}}},[]);let[g,b]=Np.useState(SG*PE),w=d?g-NC:g,y=Math.max(1,Math.min(8,Math.floor(w/PE))),x=d?Math.max(0,y-1):y,I=c.slice(0,x),T=d?[...I,d]:I,C=T.map(P=>{let M=kE({actionManager:i,collaborator:P,socketId:P.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:P.socketId===o});return P.isCurrentUser?ll(al.Root,{children:[wt(al.Trigger,{asChild:!0,children:ll("div",{className:"UserList__pill",children:[M,wt("div",{className:"UserList__pill-chevron",children:_0})]})}),wt(al.Portal,{container:a,children:wt(al.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:ll(Ke,{padding:2,children:[s.length>=CG&&wt(Pd,{placeholder:f("quickSearch.placeholder"),onChange:m}),wt(kd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:u.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),u.map(L=>kE({actionManager:i,collaborator:L,socketId:L.socketId,withName:!0,isBeingFollowed:L.socketId===o}))]:[]}),l&&ll(ME,{children:[wt("div",{className:"UserList__menu-divider"}),wt(al.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:l})})]}),wt(al.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})})]},P.socketId):M});return n?ll("div",{className:RC("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(P=>kE({actionManager:i,collaborator:P,socketId:P.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:P.socketId===o}))}),l&&ll(ME,{children:[wt("div",{className:"UserList__menu-divider"}),l]})]}):wt("div",{className:"UserList__wrapper",ref:E,children:wt("div",{className:RC("UserList",e),style:{"--max-avatars":T.length+(d?NC/PE:0)},children:C})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!TG(r,i,kG))return!1}return!0});import{composeEventHandlers as FG}from"@excalidraw/common";import{useLayoutEffect as MG,useRef as AG}from"react";import{jsx as LG}from"react/jsx-runtime";var Ti=(e,n)=>{let t=et(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=ut(),[,a]=i(t),l=AG({preferHost:!1,counter:0});return MG(()=>{let s=l.current;return a(d=>{let c=d+1;return s.counter=c,c}),()=>{a(d=>{let c=d-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:LG(n,{...r})};return o.displayName=e,o};var DE={};KA(DE,{ChangeCanvasBackground:()=>KC,Export:()=>XC,Help:()=>VC,LiveCollaborationTrigger:()=>$C,LoadScene:()=>GC,Preferences:()=>fo,PreferencesToggleGridModeItem:()=>LE,SaveAsImage:()=>UC,SaveToActiveFile:()=>HC,SearchMenu:()=>WC,Socials:()=>ZC,ToggleTheme:()=>YC});import NG from"clsx";import{THEME as cc}from"@excalidraw/common";var AE=et({active:!1});async function BC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Tt.set(AE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import DG from"clsx";import{jsx as FC,jsxs as _G}from"react/jsx-runtime";var Fp=function({onChange:e,value:n,choices:t,name:o}){return FC("div",{className:"RadioGroup",children:t.map(r=>_G("div",{className:DG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[FC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as RG,jsx as sc,jsxs as OC}from"react/jsx-runtime";var zC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let l=me();return OC(RG,{children:[OC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&sc("div",{className:"dropdown-menu-item__icon",children:a}),sc("label",{className:"dropdown-menu-item__text",children:sc(ql,{children:r})}),sc(Fp,{name:i,value:e,onChange:t,choices:o})]}),n&&l.formFactor!=="phone"&&sc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};zC.displayName="DropdownMenuItemContentRadio";var Op=zC;import{Fragment as oP,jsx as be,jsxs as dc}from"react/jsx-runtime";var GC=()=>{let{t:e}=_e(),n=nt(),t=Qi();return n.isActionEnabled(ua)?be(tn,{icon:td,onSelect:async()=>{(!t.length||await BC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:be(Ii,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>be("strong",{children:r}),br:()=>be("br",{})})}))&&n.executeAction(ua)},"data-testid":"load-button",shortcut:Qe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};GC.displayName="LoadScene";var HC=()=>{let{t:e}=_e(),n=nt();return n.isActionEnabled(li)?be(tn,{shortcut:Qe("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(li),icon:d1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};HC.displayName="SaveToActiveFile";var UC=()=>{let e=ze(),{t:n}=_e();return be(tn,{icon:u1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Qe("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};UC.displayName="SaveAsImage";var WC=e=>{let{t:n}=_e(),t=nt();return be(tn,{icon:ao,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Gs)},shortcut:Qe("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};WC.displayName="SearchMenu";var VC=()=>{let{t:e}=_e(),n=nt();return be(tn,{"data-testid":"help-menu-item",icon:Zi,onSelect:()=>n.executeAction(si),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};VC.displayName="Help";var YC=e=>{let{t:n}=_e(),t=ye(),o=nt(),r=Qe("toggleTheme"),i=on();return o.isActionEnabled(Zd)?e?.allowSystemTheme?be(Op,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:cc.LIGHT,label:Fl,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:cc.DARK,label:Bl,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:S0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):be(tn,{onSelect:a=>{a.preventDefault(),o.executeAction(Zd)},icon:t.theme===cc.DARK?Fl:Bl,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===cc.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===cc.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};YC.displayName="ToggleTheme";var KC=()=>{let{t:e}=_e(),n=ye(),t=nt(),o=on();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:dc("div",{style:{marginTop:"0.75rem"},children:[be("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),be("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};KC.displayName="ChangeCanvasBackground";var XC=()=>{let{t:e}=_e(),n=ze();return be(tn,{icon:Ol,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};XC.displayName="Export";var ZC=()=>{let{t:e}=_e();return dc(oP,{children:[be(rl,{icon:l1,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),be(rl,{icon:c1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),be(rl,{icon:s1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};ZC.displayName="Socials";var $C=({onSelect:e,isCollaborating:n})=>{let{t}=_e();return be(tn,{"data-testid":"collab-button",icon:nd,className:NG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};$C.displayName="LiveCollaborationTrigger";var jC=()=>{let{t:e}=_e(),n=ft(),t=ye();return be(go,{checked:t.activeTool.locked,shortcut:Qe("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},qC=()=>{let{t:e}=_e(),n=ye(),t=ze();return be(Op,{name:"boxSelectionMode",icon:ld,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},JC=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(go,{checked:t.objectsSnapModeEnabled,shortcut:Qe("objectsSnapMode"),onSelect:o=>{n.executeAction(Bt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},QC=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(go,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(ys),o.preventDefault()},children:e("labels.arrowBinding")})},eP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(go,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ws),o.preventDefault()},children:e("labels.midpointSnapping")})},LE=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(go,{checked:t.gridModeEnabled,shortcut:Qe("gridMode"),onSelect:o=>{n.executeAction(ya),o.preventDefault()},children:e("labels.toggleGrid")})},tP=()=>{let{t:e}=_e(),n=nt(),t=ye();return t.viewModeOnly?null:be(go,{checked:t.viewModeEnabled,shortcut:Qe("viewMode"),onSelect:o=>{n.executeAction(Na),o.preventDefault()},children:e("labels.viewMode")})},BG=()=>{let{t:e}=_e(),n=ft(),t=me();if(t.formFactor!=="desktop")return null;let o=e("labels.preferences_myocDesktopUIDescription");return be(Op,{name:"myocDesktopUIMode",value:t.desktopUIMode,onChange:r=>n.setDesktopUIMode(r),choices:[{value:"full",label:e("labels.preferences_myocDesktopUIFull"),ariaLabel:`${e("labels.preferences_myocDesktopUIFull")}. ${o}`},{value:"compact",label:e("labels.preferences_myocDesktopUICompact"),ariaLabel:`${e("labels.preferences_myocDesktopUICompact")}. ${o}`}],children:be("span",{title:o,children:e("labels.preferences_myocDesktopUISize")})})},nP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(go,{checked:t.stats.open,shortcut:Qe("stats"),onSelect:o=>{n.executeAction(yr),o.preventDefault()},children:e("stats.fullTitle")})},fo=({children:e,additionalItems:n})=>{let{t}=_e();return dc(Mr,{children:[be(Mr.Trigger,{icon:N0,children:t("labels.preferences")}),dc(Mr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||dc(oP,{children:[be(BG,{}),be(qC,{}),be(jC,{}),be(JC,{}),be(LE,{}),be(tP,{}),be(nP,{}),be(QC,{}),be(eP,{})]}),n]})]})};fo.ToggleToolLock=jC;fo.BoxSelectionMode=qC;fo.ToggleSnapMode=JC;fo.ToggleArrowBinding=QC;fo.ToggleMidpointSnapping=eP;fo.ToggleGridMode=LE;fo.ToggleViewMode=tP;fo.ToggleElementProperties=nP;fo.displayName="Preferences";import{jsx as zp,jsxs as _E}from"react/jsx-runtime";var OG=Object.assign(Ti("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=ut(),o=me(),r=ye(),i=on(),a=ze();return zp(t.In,{children:_E(pe,{open:r.openMenu==="canvas",children:[zp(pe.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:i1}),_E(pe.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:FG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&_E("fieldset",{className:"UserList-Wrapper",children:[zp("legend",{children:f("labels.collaborators")}),zp(Bp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:pe.Trigger,Item:pe.Item,ItemLink:pe.ItemLink,ItemCustom:pe.ItemCustom,Group:pe.Group,Separator:pe.Separator,Sub:Mr,DefaultItems:DE}),Gt=OG;import zG from"clsx";import{forwardRef as GG,useState as HG}from"react";import{isPromiseLike as UG}from"@excalidraw/common";import{jsx as Gp,jsxs as WG}from"react/jsx-runtime";var Lr=GG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d,disabled:c},p)=>{let[m,u]=HG(!1),E=async b=>{let w=t?.(b);if(UG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof zc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=m?"loading":d;return i=g==="success"?"success":i,Gp("button",{className:zG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:E,type:"button","aria-label":o,ref:p,disabled:c||g==="loading"||g==="success",children:WG("div",{className:"ExcButton__contents",children:[g==="loading"?Gp(Co,{className:"ExcButton__statusIcon"}):g==="success"&&Gp("div",{className:"ExcButton__statusIcon",children:h0}),n&&Gp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as sl,jsxs as KG}from"react/jsx-runtime";var Hp=({title:e,children:n,actionLabel:t,onClick:o})=>KG("div",{className:"OverwriteConfirm__Actions__Action",children:[sl("h4",{children:e}),sl("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),sl(Lr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),VG=()=>{let{t:e}=_e(),n=nt(),t=ze();return sl(Hp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(pm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},YG=()=>{let{t:e}=_e(),n=nt();return sl(Hp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(bs,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},RE=Object.assign(({children:e})=>sl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:VG,SaveToDisk:YG});import{jsx as Dr,jsxs as rP}from"react/jsx-runtime";var Up=Object.assign(Ti("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=ut(),[t,o]=$e(AE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Dr(n.In,{children:Dr(Sn,{onCloseRequest:r,title:!1,size:916,children:rP("div",{className:"OverwriteConfirm",children:[Dr("h3",{children:t.title}),rP("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Dr("div",{className:"OverwriteConfirm__Description__icon",children:g0}),Dr("div",{children:t.description}),Dr("div",{className:"OverwriteConfirm__Description__spacer"}),Dr(Lr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Dr(RE,{children:e})]})})})}),{Actions:RE,Action:Hp});import{round as ZP}from"@excalidraw/math";import dU from"clsx";import mU from"lodash.throttle";import{useEffect as $P,useMemo as ZE,useState as pU,memo as uU}from"react";import{STATS_PANELS as qp}from"@excalidraw/common";import{getCommonBounds as hU}from"@excalidraw/element";import{getUncroppedWidthAndHeight as gU}from"@excalidraw/element";import{isImageElement as $E}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as fU}from"@excalidraw/element";import{elementsAreInSameGroup as EU}from"@excalidraw/element";import{degreesToRadians as pP,radiansToDegrees as fP}from"@excalidraw/math";import{getBoundTextElement as uP}from"@excalidraw/element";import{isArrowElement as hP,isElbowArrow as aH}from"@excalidraw/element";import{updateBindings as gP}from"@excalidraw/element";import eH from"clsx";import{useEffect as dP,useRef as Vp,useState as tH}from"react";import{EVENT as ml,KEYS as nH,cloneJSON as NE}from"@excalidraw/common";import{deepCopyElement as oH}from"@excalidraw/element";import{CaptureUpdateAction as mP}from"@excalidraw/element";import{pointFrom as _r,pointRotateRads as Wp}from"@excalidraw/math";import{getBoundTextElement as XG,getNonDeletedElements as ZG,isBindingElement as $G,unbindBindingElement as iP}from"@excalidraw/element";import{isFrameLikeElement as sP}from"@excalidraw/element";import{getSelectedGroupIds as jG,getElementsInGroup as qG,isInGroup as JG}from"@excalidraw/element";import{getFrameChildren as QG}from"@excalidraw/element";import{updateBindings as aP}from"@excalidraw/element";import{DRAGGING_THRESHOLD as lP}from"@excalidraw/common";var cP=.01,mc=10,Zt=(e,n)=>!(n==="angle"&&sP(e)),je=(e,n)=>{let t=e+n/2;return t-t%n},cl=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var Si=(e,n,t,o,r,i,a=!0)=>{if($G(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<lP&&Math.abs(n-t.y)<lP)return;iP(t,"start",o),iP(t,"end",o)}let l=o.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[d,c]=[t.x+t.width/2,t.y+t.height/2],[p,m]=Wp(_r(t.x,t.y),_r(d,c),t.angle),u=e-p,E=n-m,[g,b]=Wp(_r(e,n),_r(d+u,c+E),-t.angle);o.mutateElement(s,{x:g,y:b},{informMutation:a,isDragging:!1}),aP(s,o,r);let w=XG(t,i);if(w){let y=l.get(w.id);y&&o.mutateElement(y,{x:w.x+u,y:w.y+E},{informMutation:a,isDragging:!1})}if(sP(t)){let y=QG(i,t.id);y.forEach(x=>{let I=l.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=Wp(_r(x.x,x.y),_r(T,C),x.angle),L=Math.round(P+u),_=Math.round(M+E),[k,D]=Wp(_r(L,_),_r(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:D},{informMutation:a,isDragging:!1}),aP(I,o,r,{simultaneouslyUpdated:ZG(y)})})}},dl=(e,n)=>{let o=jG(n).map(r=>qG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!JG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as BE,jsxs as iH}from"react/jsx-runtime";var rH=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:c=1,dragFinishedCallback:p})=>{let m=ft(),u=ze(),E=Vp(null),g=Vp(null),[b,w]=tH(o.toString()),y=Vp(null);y.current||(y.current={originalAppState:NE(d),originalElements:r,lastUpdatedValue:b,updatePending:!1}),dP(()=>{let T=o.toString();w(T),y.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let M=Number(T);if(isNaN(M)){w(o.toString());return}let L=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=cP)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:m.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:L,property:l,originalAppState:P,setInputValue:k=>w(String(k)),app:m,setAppState:u}),m.syncActionResult({captureUpdate:mP.IMMEDIATELY}))},I=Vp({});return I.current.handleInputValue=x,dP(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(ml.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(ml.POINTER_UP,C.onPointerUp,!1)}},[i]),i?iH("div",{className:eH("drag-input-container",!i&&"disabled"),"data-testid":e,children:[BE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,M=m.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,oH(U)),z),new Map),L=r.map(z=>M.get(z.id)),_=NE(d),k=0,D=0,B=z=>{if(P&&M!==null&&L!==null){let U=z.clientX-P.x;U!==0&&(D+=U,Math.abs(D)>=c&&(D=Math.sign(D)*Math.floor(Math.abs(D)/c),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:W=>w(String(W)),app:m,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},K=()=>{window.removeEventListener(ml.POINTER_MOVE,B,!1),m.syncActionResult({captureUpdate:mP.IMMEDIATELY}),p?.({app:m,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ml.POINTER_UP,K,!1)};I.current.onPointerMove=B,I.current.onPointerUp=K,window.addEventListener(ml.POINTER_MOVE,B,!1),window.addEventListener(ml.POINTER_UP,K,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?BE(Dd,{icon:n}):e}),BE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===nH.ENTER&&(x(C.value,r,d),m.focusContainer())}},ref:E,value:b,onChange:T=>{y.current.updatePending=!0,w(T.target.value)},onFocus:T=>{T.target.select(),y.current.originalElements=r,y.current.originalAppState=NE(d)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},vt=rH;import{jsx as dH}from"react/jsx-runtime";var lH=15,sH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=n[0];if(l&&!aH(l)){let s=a.get(l.id);if(!s)return;if(o!==void 0){let E=pP(o);r.mutateElement(s,{angle:E}),gP(s,r,i.state);let g=uP(s,a);g&&!hP(s)&&r.mutateElement(g,{angle:E});return}let d=Math.round(fP(l.angle)*100)/100,c=Math.round(e),p=(d+c)%360;t&&(p=je(p,lH)),p=p<0?p+360:p;let m=pP(p);r.mutateElement(s,{angle:m}),gP(s,r,i.state);let u=uP(s,a);u&&!hP(s)&&r.mutateElement(u,{angle:m})}},cH=({element:e,scene:n,appState:t,property:o})=>dH(vt,{label:"A",icon:rd,value:Math.round(fP(e.angle)%360*100)/100,elements:[e],dragInputCallback:sH,editable:Zt(e,"angle"),scene:n,appState:t,property:o}),EP=cH;import{jsx as pH}from"react/jsx-runtime";var bP=5,mH=({property:e,scene:n,appState:t,setAppState:o})=>pH(vt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{o(s=>{let d;return r?d=r:i&&(d=a?je(s.gridStep+bP*Math.sign(i),bP):s.gridStep+i),d?(d=wx(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),xP=mH;import{clamp as Yp,round as FE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Kp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as yP,getNonDeletedElements as uH,getUncroppedWidthAndHeight as IP}from"@excalidraw/element";import{resizeSingleElement as wP}from"@excalidraw/element";import{isImageElement as TP}from"@excalidraw/element";import{isFrameLikeElement as OE}from"@excalidraw/element";import{getElementsInResizingFrame as zE}from"@excalidraw/element";import{replaceAllElementsInFrame as SP}from"@excalidraw/element";import{jsx as bH}from"react/jsx-runtime";var vP=10,hH=e=>e.type==="image",gH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:c,setAppState:p})=>{let m=d.getNonDeletedElementsMap(),u=n[0],E=m.get(u.id);if(u&&E){let g=o||hH(u),b=u.width/u.height;if(l.croppingElementId===u.id){let w=m.get(u.id);if(!w||!TP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:C,height:P}=IP(w),M=y.naturalWidth/C,L=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=T?y.height+y.y:y.naturalHeight-y.y,D=yP*M,B=yP*L;if(i!==void 0){if(a==="width"){let G=i*M,oe=Yp(G,D,_);x={...x,width:oe,x:I?y.x+y.width-oe:y.x}}else if(a==="height"){let G=i*L,oe=Yp(G,B,k);x={...x,height:oe,y:T?y.y+y.height-oe:y.y}}d.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let K=a==="width"?s:0,z=a==="height"?s:0,U=Yp(y.width+K,D,_),W=Yp(y.height+z,D,k);x={...y,x:I?y.x+y.width-U:y.x,y:T?y.y+y.height-W:y.y,width:U,height:W},d.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:g?i*b:u.width,Kp),y=Math.max(a==="height"?i:g?i/b:u.height,Kp);if(wP(w,y,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),OE(E)){let x=zE(d.getElementsIncludingDeleted(),E,l,d.getNonDeletedElementsMap()),I=SP(d.getElementsIncludingDeleted(),x,E);d.replaceAllElements(I)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,u.width+w);a==="width"&&(r?x=je(x,vP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=je(I,vP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Kp,I),x=Math.max(Kp,x),wP(x,I,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),OE(E)){let T=uH(zE(d.getElementsIncludingDeleted(),E,l,d.getNonDeletedElementsMap()));p({elementsToHighlight:T})}}}},fH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&OE(a)){let l=zE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),s=SP(n.scene.getElementsIncludingDeleted(),l,a);n.scene.replaceAllElements(s),e({elementsToHighlight:null})}},EH=({property:e,element:n,scene:t,appState:o})=>{let r=FE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&TP(n)&&n.crop){let{width:i,height:a}=IP(n);if(e==="width"){let l=i/n.crop.naturalWidth;r=FE(n.crop.width*l,2)}if(e==="height"){let l=a/n.crop.naturalHeight;r=FE(n.crop.height*l,2)}}return bH(vt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:gH,value:r,editable:Zt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:fH})},GE=EH;import{getBoundTextElement as xH,redrawTextBoundingBox as yH}from"@excalidraw/element";import{hasBoundTextElement as wH,isTextElement as PP}from"@excalidraw/element";import{jsx as SH}from"react/jsx-runtime";var CP=4,vH=4,IH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let l=i.get(a.id);if(!l||!PP(l))return;let s;if(o!==void 0)s=Math.max(Math.round(o),CP);else if(a.type==="text"){let d=Math.round(a.fontSize),c=Math.round(e);s=Math.max(d+c,CP),t&&(s=je(s,vH))}s&&(r.mutateElement(l,{fontSize:s}),yH(l,r.getContainerElement(l),r))}},TH=({element:e,scene:n,appState:t,property:o})=>{let r=PP(e)?e:wH(e)?xH(e,n.getNonDeletedElementsMap()):null;return r?SH(vt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:IH,icon:$r,appState:t,scene:n,property:o}):null},kP=TH;import{degreesToRadians as MP,radiansToDegrees as DP}from"@excalidraw/math";import{getBoundTextElement as AP}from"@excalidraw/element";import{isArrowElement as LP}from"@excalidraw/element";import{isInGroup as HE}from"@excalidraw/element";import{jsx as MH}from"react/jsx-runtime";var CH=15,PH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=n.map(d=>a.get(d.id)).filter(d=>d&&!HE(d)&&Zt(d,r)),s=n.filter(d=>!HE(d)&&Zt(d,r));if(o!==void 0){let d=MP(o);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:d});let p=AP(c,a);p&&!LP(c)&&i.mutateElement(p,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let c=l[d];if(!c)continue;let p=s[d],m=Math.round(DP(p.angle)*100)/100,u=Math.round(e),E=(m+u)%360;t&&(E=je(E,CH)),E=E<0?E+360:E;let g=MP(E);i.mutateElement(c,{angle:g});let b=AP(c,a);b&&!LP(c)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},kH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(s=>!HE(s)&&Zt(s,"angle")),i=r.map(s=>Math.round(DP(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Zt(s,"angle"));return MH(vt,{label:"A",icon:rd,value:a,elements:e,dragInputCallback:PH,editable:l,appState:t,scene:n,property:o})},_P=kH;import{pointFrom as FP}from"@excalidraw/math";import{useMemo as LH}from"react";import{MIN_WIDTH_OR_HEIGHT as Rr}from"@excalidraw/common";import{getElementsInResizingFrame as UE,getNonDeletedElements as DH,isFrameLikeElement as WE,replaceAllElementsInFrame as GP,updateBoundElements as _H}from"@excalidraw/element";import{rescalePointsInElement as RH,resizeSingleElement as OP}from"@excalidraw/element";import{getBoundTextElement as NH,handleBindTextResize as BH}from"@excalidraw/element";import{isTextElement as HP}from"@excalidraw/element";import{MIME_TYPES as Ci}from"@excalidraw/common";import{getNonDeletedElements as RP}from"@excalidraw/element";var Xp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let l=RP(Yr(e,null,{deleteInvisibleElements:!0})),s=zi(n,null),{exportBackground:d,viewBackgroundColor:c}=s;return Yc(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(p,m)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(p,m),b=o<g?o/g:n?.exportScale??1;return u.width=p*b,u.height=m*b,{canvas:u,scale:b}}let E=r?.(p,m)||{width:p,height:m};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},NP=async e=>{let{mimeType:n=Ci.png,quality:t}=e;n===Ci.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Ci.png}" mimeType`),n==="image/jpg"&&(n=Ci.jpg),n===Ci.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Ci.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Xp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===Ci.png&&e.appState?.exportEmbedScene&&(a=await _x({blob:a,metadata:Ml(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},BP=async({elements:e,appState:n=qo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let s=RP(Yr(e,null,{deleteInvisibleElements:!0})),c={...zi(n,null),exportPadding:o};return Vr(s,c,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},AH=async e=>{if(e.type==="svg"){let n=await BP(e);await lo(n.outerHTML)}else if(e.type==="png")await dm(NP(e));else if(e.type==="json")await lm(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as z8e}from"@excalidraw/element";import{getCommonBounds as Zp}from"@excalidraw/element";import{jsx as UH}from"react/jsx-runtime";var pl=10,FH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,l=o.height*t,s=e+r*t,d=n+i*t;return{width:a,height:l,x:s,y:d,...RH(o,a,l,!1),...HP(o)?{fontSize:o.fontSize*t}:{}}},OH=(e,n,t,o,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=FH(e,n,o,i);l.mutateElement(r,d);let c=NH(i,a);if(c){let p=c.fontSize*o;_H(r,l);let m=s.get(c.id);m&&HP(m)&&(l.mutateElement(m,{fontSize:p}),BH(r,l,t==="width"?"e":"s",!0))}},zP=(e,n,t,o,r,i,a,l,s,d)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let c=n/t;for(let p=0;p<l.length;p++){let m=l[p],u=a[p];OH(r[0],r[1],i,c,u,m,s,d)}},zH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let c=a.getNonDeletedElementsMap(),p=dl(n,o);if(i!==void 0){for(let g of p){let b=cl(g,c,t);if(b.length>1){let w=b.map(D=>D.latest),y=b.map(D=>D.original),[x,I,T,C]=Zp(y),P=T-x,M=C-I,L=P/M,_=Math.max(Rr,l==="width"?Math.max(0,i):P),k=Math.max(Rr,l==="height"?Math.max(0,i):M);zP(_,k,M,L,FP(x,I),l,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Zt(y,l)){let I=l==="width"?Math.max(0,i):y.width;l==="width"&&(r?I=je(I,pl):I=Math.round(I));let T=l==="height"?Math.max(0,i):y.height;if(l==="height"&&(r?T=je(T,pl):T=Math.round(T)),I=Math.max(Rr,I),T=Math.max(Rr,T),OP(I,T,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),WE(y)){let C=UE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=GP(a.getElementsIncludingDeleted(),C,y);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let m=l==="width"?e:0,u=l==="height"?e:0,E=[];for(let g of p){let b=cl(g,c,t);if(b.length>1){let w=b.map(D=>D.latest),y=b.map(D=>D.original),[x,I,T,C]=Zp(y),P=T-x,M=C-I,L=P/M,_=Math.max(0,P+m);l==="width"&&(r?_=je(_,pl):_=Math.round(_));let k=Math.max(0,M+u);l==="height"&&(r?k=je(k,pl):k=Math.round(k)),_=Math.max(Rr,_),k=Math.max(Rr,k),zP(_,k,M,L,FP(x,I),l,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Zt(y,l)){let I=Math.max(0,x.width+m);l==="width"&&(r?I=je(I,pl):I=Math.round(I));let T=Math.max(0,x.height+u);if(l==="height"&&(r?T=je(T,pl):T=Math.round(T)),I=Math.max(Rr,I),T=Math.max(Rr,T),OP(I,T,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),WE(y)){let C=DH(UE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}s({elementsToHighlight:E}),a.triggerUpdate()},GH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&WE(a)){let l=UE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),s=GP(n.scene.getElementsIncludingDeleted(),l,a);n.scene.replaceAllElements(s),e({elementsToHighlight:null})}},HH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=LH(()=>o.map(d=>{let c=cl(d,t);if(c.length>1){let[m,u,E,g]=Zp(c.map(b=>b.latest));return Math.round((e==="width"?E-m:g-u)*100)/100}let[p]=c;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,o,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return UH(vt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:zH,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:GH})},VE=HH;import{getBoundTextElement as WH,redrawTextBoundingBox as UP}from"@excalidraw/element";import{hasBoundTextElement as VH,isTextElement as YH}from"@excalidraw/element";import{isInGroup as KH}from"@excalidraw/element";import{jsx as qH}from"react/jsx-runtime";var WP=4,XH=4,ZH=(e,n)=>e.reduce((t,o)=>{if(!o||KH(o))return t;if(YH(o))return t.push(o),t;if(VH(o)){let r=WH(o,n);if(r)return t.push(r),t}return t},[]),$H=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(s=>i.get(s.id)),l;if(o){l=Math.max(Math.round(o),WP);for(let s of a)r.mutateElement(s,{fontSize:l}),UP(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=n;for(let d=0;d<a.length;d++){let c=a[d],p=s[d],m=Math.round(p.fontSize),u=Math.round(e),E=Math.max(m+u,WP);t&&(E=je(E,XH)),r.mutateElement(c,{fontSize:E}),UP(c,r.getContainerElement(c),r)}r.triggerUpdate()}},jH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=ZH(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return qH(vt,{label:"F",icon:$r,elements:i,dragInputCallback:$H,value:l,editable:s,scene:n,property:o,appState:t})},VP=jH;import{pointFrom as Nr,pointRotateRads as $p}from"@excalidraw/math";import{useMemo as JH}from"react";import{isTextElement as QH}from"@excalidraw/element";import{getCommonBounds as YE}from"@excalidraw/element";import{jsx as rU}from"react/jsx-runtime";var eU=(e,n,t,o,r,i,a)=>{for(let l=0;l<o.length;l++){let s=o[l],[d,c]=[s.x+s.width/2,s.y+s.height/2],[p,m]=$p(Nr(s.x,s.y),Nr(d,c),s.angle),u=e==="x"?Math.round(p+n):p,E=e==="y"?Math.round(m+t):m;Si(u,E,s,i,a,r,!1)}},tU=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=YE(t),d=e-l,c=n-s;for(let p=0;p<t.length;p++){let m=t[p],u=a.get(m.id);if(u&&(!QH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=$p(Nr(u.x,u.y),Nr(E,g),u.angle);Si(b+d,w+c,m,r,i,o,!1)}}},nU=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let d=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of dl(n,l)){let E=cl(u,d,t);if(E.length>1){let[g,b,,]=YE(E.map(x=>x.latest));tU(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,s.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Zt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=$p(Nr(g.x,g.y),Nr(w,y),g.angle);Si(i==="x"?r:x,i==="y"?r:I,g,a,s.state,t,!1)}}}a.triggerUpdate();return}let c=o?je(e,mc):e;eU(i,i==="x"?c:0,i==="y"?c:0,n,t,a,s.state),a.triggerUpdate()},oU=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=JH(()=>o.map(s=>{let d=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(d.length>1){let[g,b]=YE(d);return Math.round((e==="x"?g:b)*100)/100}let[c]=d,[p,m]=[c.x+c.width/2,c.y+c.height/2],[u,E]=$p(Nr(c.x,c.y),Nr(p,m),c.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return rU(vt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:nU,value:l,property:e,scene:r,appState:i})},KE=oU;import{clamp as pc,pointFrom as jp,pointRotateRads as KP,round as YP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as iU,getUncroppedWidthAndHeight as aU}from"@excalidraw/element";import{isImageElement as XP}from"@excalidraw/element";import{jsx as cU}from"react/jsx-runtime";var lU=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:d})=>{let c=l.getNonDeletedElementsMap(),p=t[0],[m,u]=[p.x+p.width/2,p.y+p.height/2],[E,g]=KP(jp(p.x,p.y),jp(m,u),p.angle);if(s.croppingElementId===p.id){let I=c.get(p.id);if(!I||!XP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:L,height:_}=aU(I);if(i!==void 0){if(a==="x"){let B=i*(T.naturalWidth/L);P?C={...T,x:pc(T.naturalWidth-B-T.width,0,T.naturalWidth-T.width)}:C={...T,x:pc(i*(T.naturalWidth/L),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:pc(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),l.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(M?-1:1);C={...T,x:pc(T.x+k,0,T.naturalWidth-T.width),y:pc(T.y+D,0,T.naturalHeight-T.height)},l.mutateElement(I,{crop:C});return}if(i!==void 0){Si(a==="x"?i:E,a==="y"?i:g,p,l,d.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?je(p.x+b,mc):E+b):E,x=a==="y"?Math.round(r?je(p.y+w,mc):g+w):g;Si(y,x,p,l,d.state,o)},sU=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=KP(jp(n.x,n.y),jp(n.x+n.width/2,n.y+n.height/2),n.angle),a=YP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&XP(n)&&n.crop){let l=iU(n);l&&(a=YP(e==="x"?l.x:l.y,2))}return cU(vt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:lU,scene:t,value:a,property:e,appState:o})},XE=sU;import{Fragment as jE,jsx as re,jsxs as $t}from"react/jsx-runtime";var bU=50,uc=e=>{let n=nn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=Ir(e.app);return re(xU,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Xe=({children:e,columns:n=1,heading:t,style:o,...r})=>re("div",{className:dU("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Xe.displayName="StatsRow";var Jp=({children:e,order:n,style:t,...o})=>re("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Jp.displayName="StatsRows";uc.StatsRow=Xe;uc.StatsRows=Jp;var xU=uU(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),c=ze(),p=o.length===1?o[0]:null,m=o.length>1?o:null,u=r.croppingElementId&&$E(p),E=u?gU(p):null,[g,b]=pU({width:0,height:0}),w=ZE(()=>mU(I=>{let T=hU(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},bU),[]);$P(()=>{w(s)},[i,s,w]),$P(()=>()=>w.cancel(),[w]);let y=ZE(()=>dl(o,r),[o,r]),x=ZE(()=>fU(o),[o]);return re("div",{className:"exc-stats",children:$t(Ke,{padding:3,children:[$t("div",{className:"title",children:[re("h2",{children:f("stats.title")}),re("div",{className:"close",onClick:n,children:mn})]}),$t(es,{label:re("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&qp.generalStats),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^qp.generalStats}})),children:[$t(Jp,{children:[re(Xe,{heading:!0,children:f("stats.scene")}),$t(Xe,{columns:2,children:[re("div",{children:f("stats.shapes")}),re("div",{children:s.length})]}),$t(Xe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:g.width})]}),$t(Xe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:g.height})]}),a&&$t(jE,{children:[re(Xe,{heading:!0,children:"Canvas"}),re(Xe,{children:re(xP,{property:"gridStep",scene:l,appState:r,setAppState:c})})]})]}),t?.(s,r)]}),!x&&o.length>0&&re("div",{id:"elementStats",style:{marginTop:12},children:re(es,{label:re("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&qp.elementProperties),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^qp.elementProperties}})),children:$t(Jp,{children:[p&&$t(jE,{children:[u&&re(Xe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&$E(p)&&E&&$t(Xe,{columns:2,children:[re("div",{children:f("stats.width")}),re("div",{children:ZP(E.width,2)})]}),r.croppingElementId&&$E(p)&&E&&$t(Xe,{columns:2,children:[re("div",{children:f("stats.height")}),re("div",{children:ZP(E.height,2)})]}),re(Xe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):p.type==="magicframe"?f("element.frame"):f(`element.${p.type}`)}),re(Xe,{children:re(XE,{element:p,property:"x",elementsMap:d,scene:l,appState:r})}),re(Xe,{children:re(XE,{element:p,property:"y",elementsMap:d,scene:l,appState:r})}),re(Xe,{children:re(GE,{property:"width",element:p,scene:l,appState:r})}),re(Xe,{children:re(GE,{property:"height",element:p,scene:l,appState:r})}),re(Xe,{children:re(EP,{property:"angle",element:p,scene:l,appState:r})}),re(Xe,{children:re(kP,{property:"fontSize",element:p,scene:l,appState:r})})]}),m&&$t(jE,{children:[EU(m)&&re(Xe,{heading:!0,children:f("element.group")}),$t(Xe,{columns:2,style:{margin:"0.3125rem 0"},children:[re("div",{children:f("stats.shapes")}),re("div",{children:o.length})]}),re(Xe,{children:re(KE,{property:"x",elements:m,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),re(Xe,{children:re(KE,{property:"y",elements:m,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),re(Xe,{children:re(VE,{property:"width",elements:m,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),re(Xe,{children:re(VE,{property:"height",elements:m,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),re(Xe,{children:re(_P,{property:"angle",elements:m,scene:l,appState:r})}),re(Xe,{children:re(VP,{property:"fontSize",elements:m,scene:l,appState:r,elementsMap:d})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as LU,useEffect as qP,useState as JP}from"react";import{normalizeLink as DU,KEYS as eb}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as _U,getLinkIdAndTypeFromSelection as RU}from"@excalidraw/element";import yU from"clsx";import{jsx as Qp,jsxs as vU}from"react/jsx-runtime";var wU=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return vU("button",{className:yU("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:n,...l,children:[o&&Qp("div",{style:a?{visibility:"hidden"}:{},children:o}),Qp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Qp("div",{style:{position:"absolute",inset:0},children:Qp(Co,{})})]})},qE=wU;import JE from"clsx";import{forwardRef as CU,useRef as PU,useImperativeHandle as kU,useLayoutEffect as MU,useState as AU}from"react";import IU from"clsx";import{composeEventHandlers as TU}from"@excalidraw/common";import{jsx as SU}from"react/jsx-runtime";var Cn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>SU("button",{onClick:TU(i.onClick,a=>{n()}),type:e,className:IU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as QE,jsxs as jP}from"react/jsx-runtime";var eu=CU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,type:c,...p},m)=>{let u=PU(null);kU(m,()=>u.current),MU(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=AU(!1);return jP("div",{className:JE("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,n&&QE("div",{className:"ExcTextField__label",children:n}),jP("div",{className:JE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[QE("input",{className:JE({"is-redacted":"value"in p&&p.value&&l&&!E}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:c}),l&&QE(Cn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?f0:Jr})]})]})});import{jsx as ul,jsxs as tu}from"react/jsx-runtime";var NU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=_U})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=JP(a),[d,c]=JP(!1);qP(()=>{let m=de(i,t),u=a;if(m.length>0&&r){let E=RU(m,t);E&&(u=DU(r(E.id,E.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let p=LU(()=>{if(l&&l!==i.get(e)?.link){let m=i.get(e);m&&o.mutateElement(m,{link:l})}if(!l&&d&&e){let m=i.get(e);m&&o.mutateElement(m,{link:null})}n?.()},[e,l,i,d,o,n]);return qP(()=>{let m=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===eb.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===eb.ESCAPE&&n?.()};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[t,n,p]),tu("div",{className:"ElementLinkDialog",children:[tu("div",{className:"ElementLinkDialog__header",children:[ul("h2",{children:f("elementLink.title")}),ul("p",{children:f("elementLink.desc")})]}),tu("div",{className:"ElementLinkDialog__input",children:[ul(eu,{value:l??"",onChange:m=>{d||c(!0),s(m)},onKeyDown:m=>{m.key===eb.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&ul($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:Zr})]}),tu("div",{className:"ElementLinkDialog__actions",children:[ul(qE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),ul(qE,{label:f("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},QP=NU;import BU,{useState as FU}from"react";import{Fragment as OU,jsx as tb}from"react/jsx-runtime";var ek=({children:e,onClose:n})=>{let[t,o]=FU(!!e),{container:r}=Te(),i=BU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return tb(OU,{children:t&&tb(Sn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:tb("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import nb from"clsx";import Vn from"react";import{MIME_TYPES as tk,sceneCoordsToViewportCoords as ob}from"@excalidraw/common";import{getCommonBounds as rk,isInitializedImageElement as nk,ShapeCache as zU}from"@excalidraw/element";import{Fragment as YU,jsx as Ht,jsxs as Pi}from"react/jsx-runtime";var GU=Ht("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:Ht("path",{d:"M8 5v14l11 -7z"})}),HU=Pi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[Ht("path",{d:"M8 5v14"}),Ht("path",{d:"M16 5v14"})]}),UU=76,ik=4,hc=UU+ik,ok=8,ki=8,WU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+ki),window.innerWidth-t-ki)},VU=(e,n)=>{let[,,t,o]=rk([e]),r=ob({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},ak=({app:e,files:n,setAppState:t})=>{let o=nn(),[,r]=Vn.useReducer(T=>T+1,0),[i,a]=Vn.useState(0),[l,s]=Vn.useState(!1),d=Vn.useRef(null),c=Vn.useRef(null),p=Vn.useRef(null),m=Vn.useRef(null),u=Vn.useRef(null),E=Vn.useRef(!1),[g,b]=Vn.useState(null);Vn.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?d.current:c.current,P=T==="gifSpeedPicker"?p.current:m.current;if(!C||!P)return;let M=C.getBoundingClientRect(),L=P.getBoundingClientRect(),_=WU(M.left+M.width/2,L.width),k=T==="gifSpeedPicker"?Math.max(ki,M.top-L.height-ki):Math.min(window.innerHeight-L.height-ki,M.bottom+ki),D={left:_,top:Math.max(ki,k)};b(B=>B?.left===D.left&&B.top===D.top?B:D)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let w=(T,C)=>{zU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().flatMap(T=>{if(!nk(T)||n[T.fileId]?.mimeType!==tk.gif||e.imageCache.get(T.fileId)?.gifDecodeStatus!=="deferred")return[];let C=VU(T,o);return[Ht("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:C,onPointerDown:P=>P.stopPropagation(),children:Ht("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})},T.id)]}),x=e.scene.getSelectedElements(o);return Pi(YU,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!nk(T)||n[T.fileId]?.mimeType!==tk.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,L,_]=rk([T]),k=ob({sceneX:M,sceneY:_},o),B=ob({sceneX:L,sceneY:_},o).x-k.x,K=k.x-o.offsetLeft+B/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="pending")return null;let U=P?.frames.length??0;if(!P||U<2)return null;let W=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,oe=e.getGifPlaybackFrameIndex(T)??W.frameIndex,le=Math.min(Math.max(oe,0),U-1),F=Math.min(G.height-120,z+48),V=Math.max(12,z-52),ce=Z=>{let De=(Z+U)%U;e.setGifPlaybackFrameIndex(T,De),w(T,{...W,frameIndex:De,playing:!1})},fe=Z=>{Z.stopPropagation(),ce(le+(Z.deltaY<0?1:-1))},Be=Z=>{e.setGifPlaybackFrameIndex(T,le),w(T,{...W,frameIndex:le,playing:Z})},Ee=[.25,.5,.75,1,1.25,1.5,1.75,2,4],He=Z=>{let De=Ee.indexOf(Z);return De!==-1?De:Ee.reduce((Rt,Ni,Ru)=>Math.abs(Ni-Z)<Math.abs(Ee[Rt]-Z)?Ru:Rt,0)},se=Z=>{w(T,{...W,speed:Z})},Pe=Z=>{let De=He(W.speed);se(Ee[Math.min(Math.max(De+Z,0),Ee.length-1)])},ke=Number.isInteger(W.speed)?`${W.speed}`:`${W.speed}`,xe=U*hc-ik,gt=Math.min(Math.max(G.width*.9,1),xe),Qt=Math.max(xe-gt,0),Fe=Math.min(i,Qt),st=Math.max(Math.floor(Fe/hc)-ok,0),Vt=Math.ceil(gt/hc)+ok*2,Xo=Math.min(st+Vt,U),Zo=P.frames.slice(st,Xo),vo=Z=>{Z.pointerType!=="mouse"||Z.button!==0||(u.current={pointerId:Z.pointerId,startClientX:Z.clientX,startScrollLeft:Z.currentTarget.scrollLeft,didDrag:!1},Z.stopPropagation())},_t=Z=>{let De=u.current;if(!De||De.pointerId!==Z.pointerId)return;let Rt=Z.clientX-De.startClientX;!De.didDrag&&Math.abs(Rt)<=3||(De.didDrag||(De.didDrag=!0,Z.currentTarget.setPointerCapture?.(Z.pointerId),s(!0)),Z.currentTarget.scrollLeft=De.startScrollLeft-Rt,a(Z.currentTarget.scrollLeft),Z.preventDefault(),Z.stopPropagation())},Cl=Z=>{let De=u.current;!De||De.pointerId!==Z.pointerId||(E.current=De.didDrag,u.current=null,Z.currentTarget.hasPointerCapture?.(Z.pointerId)&&Z.currentTarget.releasePointerCapture(Z.pointerId),s(!1),Z.stopPropagation())},Oc=Z=>{let De=u.current;!De||De.pointerId!==Z.pointerId||(u.current=null,s(!1),Z.stopPropagation())},$o=Z=>{Z.pointerType!=="mouse"&&Z.stopPropagation()};return Pi("div",{className:"gif-playback-controls",style:{left:K,top:z},onPointerDown:Z=>Z.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&Ht("div",{className:"gif-speed-picker",ref:p,style:g??{left:K,top:V},children:Ee.map(Z=>{let De=Number.isInteger(Z)?`${Z}`:`${Z}`;return Pi("button",{type:"button",className:nb("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":Z===W.speed}),onClick:()=>se(Z),title:`${De}x`,children:["x",De]},Z)})}),Pi("div",{className:"gif-playback-controls__bar",children:[Pi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:d,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:Z=>{Z.stopPropagation(),Pe(Z.deltaY<0?1:-1)},title:"Speed",children:["x",ke]}),Ht("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>ce(le-1),onWheel:fe,title:"Previous frame",children:m0}),Ht("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Be(!W.playing),onWheel:fe,title:W.playing?"Pause":"Play",children:W.playing?HU:GU}),Ht("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>ce(le+1),onWheel:fe,title:"Next frame",children:p0}),Ht("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:c,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(le*hc-gt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:fe,title:"Frames",children:u0})]}),o.openPopup==="gifFrameGallery"&&Ht("div",{className:nb("gif-frame-gallery",{"gif-frame-gallery--dragging":l}),style:{...g??{left:K,top:F},width:gt},ref:Z=>{m.current=Z,Z&&Z.scrollLeft!==Fe&&(Z.scrollLeft=Fe)},onScroll:Z=>{a(Z.currentTarget.scrollLeft)},onPointerDownCapture:$o,onPointerMoveCapture:$o,onPointerUpCapture:$o,onPointerCancelCapture:$o,onPointerDown:vo,onPointerMove:_t,onPointerUp:Cl,onPointerCancel:Oc,onLostPointerCapture:Oc,onClickCapture:Z=>{if(E.current){E.current=!1,Z.preventDefault(),Z.stopPropagation();return}E.current=!1},onWheelCapture:Z=>{Z.stopPropagation(),Z.currentTarget.scrollLeft+=Z.deltaY,a(Z.currentTarget.scrollLeft)},children:Ht("div",{className:"gif-frame-gallery__spacer",style:{width:xe},children:Zo.map((Z,De)=>{let Rt=st+De;return Pi("button",{type:"button",className:nb("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Rt===le}),style:{left:Rt*hc},onClick:()=>ce(Rt),title:`Frame ${Rt+1}`,children:[Ht("canvas",{width:Z.width,height:Z.height,ref:Ni=>{Ni?.getContext("2d")?.drawImage(Z,0,0)}}),Ht("span",{children:Rt+1})]},Rt)})})})]})})()]})};import lk,{useMemo as QU}from"react";import sk from"clsx";import{isDarwin as ck,isFirefox as eW,isWindows as tW}from"@excalidraw/common";import{KEYS as hl}from"@excalidraw/common";import{SHAPES as nW}from"@excalidraw/element/shapes";import{isFirefox as KU,KEYS as rb}from"@excalidraw/common";import{SHAPES as XU}from"@excalidraw/element/shapes";import{Fragment as JU,jsx as Ve,jsxs as Mi}from"react/jsx-runtime";var ZU=e=>Mi(JU,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),ib=e=>Mi("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*$U(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var jU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),ht=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(qU,{children:jU(a)},a)));return Mi("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...$U(o,t?f("helpDialog.or"):null)]})]})},qU=e=>Ve("kbd",{className:"HelpDialog__key",...e});function ab(){return Mi(ZU,{title:f("helpDialog.shortcuts"),children:[Mi(ib,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(ht,{label:f("toolBar.hand"),shortcuts:[rb.H]}),XU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(ht,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(ht,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ve(ht,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),Mi(ib,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(ht,{label:f("helpDialog.smartZoom"),shortcuts:[rb.F]}),Ve(ht,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),Ve(ht,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),Ve(ht,{label:f("helpDialog.dragToZoom"),shortcuts:[`${rb.Z}+${f("helpDialog.drag")}`]}),Ve(ht,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),Mi(ib,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(ht,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ve(ht,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ve(ht,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(ht,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(gr||KU)&&Ve(ht,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ve(ht,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ve(ht,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ve(ht,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ve(ht,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ve(ht,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as mk,jsx as j,jsxs as Ai}from"react/jsx-runtime";var oW=e=>Ai(mk,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),lb=e=>Ai("div",{className:`HelpDialog__island ${e.className}`,children:[j("h4",{className:"HelpDialog__island-title",children:e.caption}),j("div",{className:"HelpDialog__island-content",children:e.children})]});function*rW(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var iW=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),Q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(aW,{children:iW(a)},a)));return Ai("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...rW(o,t?f("helpDialog.or"):null)]})]})},aW=e=>j("kbd",{className:"HelpDialog__key",...e}),dk=({onClose:e})=>{let[n,t]=lk.useState(!1),o=lk.useCallback(()=>{e&&e()},[e]),r=QU(()=>n?j("button",{className:sk("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:sk("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(mk,{children:j(Sn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ai(oW,{title:f("helpDialog.shortcuts"),children:[Ai(lb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(Q,{label:f("toolBar.hand"),shortcuts:[hl.H]}),nW.map(({value:i,key:a})=>j(Q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(Q,{label:f("toolBar.frame"),shortcuts:[hl.F]}),j(Q,{label:f("labels.eyeDropper"),shortcuts:[hl.I,"Shift+S","Shift+I"]}),j(Q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(Q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(Q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(Q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(Q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(Q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(Q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(Q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(Q,{label:f("toolBar.lock"),shortcuts:[hl.Q]}),j(Q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(Q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(Q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ai(lb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(Q,{label:f("helpDialog.smartZoom"),shortcuts:[hl.F]}),j(Q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${hl.Z}+${f("helpDialog.drag")}`]}),j(Q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(Q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(Q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(Q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(Q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(Q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(Q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(Q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(Q,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),j(Q,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),j(Q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(Q,{label:f("search.title"),shortcuts:[Qe("searchMenu")]})]}),Ai(lb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(Q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(Q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(Q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(Q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(Q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(Q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(Q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(Q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(Q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(Q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(gr||eW)&&j(Q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(Q,{label:f("labels.sendToBack"),shortcuts:[ck?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(Q,{label:f("labels.bringToFront"),shortcuts:[ck?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(Q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(Q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(Q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(Q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(Q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(Q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(Q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+A")]}),j(Q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(Q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(Q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(Q,{label:f("buttons.redo"),shortcuts:tW?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(Q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(Q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(Q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(Q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(Q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(Q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(Q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(Q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(Q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j(ab,{})})})};import{CANVAS_SEARCH_TAB as lW,DEFAULT_SIDEBAR as sW}from"@excalidraw/common";import{isArrowElement as cW,isFlowchartNodeElement as dW,isImageElement as pk,isLinearElement as uk,isLineElement as mW,isTextBindableContainer as pW,isTextElement as uW}from"@excalidraw/element";import{isNodeInFlowchart as hW}from"@excalidraw/element";import{jsx as sb}from"react/jsx-runtime";var ve=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,gW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===sW.name&&e.openSidebar.tab===lW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:ve("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(dn(e))return f("hints.eraserRevert",{shortcut:ve("Alt")});let d=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&d[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:ve("Ctrl"),shortcut_2:ve("Alt")});if(r.type==="arrow"||r.type==="line")return s?f("hints.linearElementMulti",{shortcut_1:ve("Escape"),shortcut_2:ve("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:ve("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&l==="mouse"&&d.length===1){let c=d[0];return uk(c)&&c.points.length===2?f("hints.lockAngle",{shortcut:ve("Shift")}):pk(c)?f("hints.resizeImage",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):f("hints.resize",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")})}if(a&&l==="mouse")return f("hints.rotate",{shortcut:ve("Shift")});if(d.length===1&&uW(d[0]))return f("hints.text_selected",{shortcut:ve("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:ve("Escape"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:ve("Enter"),shortcut_2:ve("Escape")});if(d.length===1&&pk(d[0]))return f("hints.enterCropEditor",{shortcut_1:ve("double click"),shortcut_2:ve("Enter")});if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:ve("CtrlOrCmd")});if(Ir(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:ve("CtrlOrCmd")});if(!d.length&&!n)return f("hints.canvasPanning",{shortcut_1:ve(f("keys.mmb")),shortcut_2:ve("Space")});if(d.length===1){if(uk(d[0]))return cW(d[0])&&e.selectedLinearElement?.elementId===d[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===d[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:ve("Delete"),shortcut_2:ve(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):mW(d[0])?f("hints.lineEditor_line_info",{shortcut:ve("Enter")}):f("hints.lineEditor_info",{shortcut_1:ve("CtrlOrCmd"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&pW(d[0])){let c=f("hints.bindTextToElement",{shortcut:ve("Enter")}),p=f("hints.createFlowchart",{shortcut:ve(["CtrlOrCmd","\u2191\u2193"])});return dW(d[0])?hW(d[0],o.scene.getNonDeletedElementsMap())?[c,p]:[c,p]:c}}}return null},gl=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let i=Hi(wa)?xv:e.viewModeEnabled?null:gW({appState:e,isMobile:n,editorInterface:t,app:o});if(!i)return null;let l=(Array.isArray(i)?i.map(s=>s.replace(/\. ?$/,"")).join(", "):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,d)=>{if(d%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return sb("kbd",{children:c?c[1]:s},d)}return s});return sb("div",{className:"HintViewer",children:sb("span",{children:l})})};import{useEffect as gk,useRef as fk,useState as Li}from"react";import{DEFAULT_EXPORT_PADDING as yW,EXPORT_IMAGE_TYPES as cb,isFirefox as wW,EXPORT_SCALES as vW,cloneJSON as Ek}from"@excalidraw/common";import{useCallback as fW,useRef as EW,useState as bW}from"react";var xW=2e3,hk=()=>{let[e,n]=bW(null),t=EW(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},xW)},r=fW(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ze,jsxs as Br}from"react/jsx-runtime";var IW=()=>Br("div",{children:[Ze("h3",{children:f("canvasError.cannotShowPreview")}),Ze("p",{children:Ze("span",{children:f("canvasError.canvasTooBig")})}),Br("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),TW=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let l=Oe(n,e),[s,d]=Li(i),[c,p]=Li(l),[m,u]=Li(e.exportBackground),[E,g]=Li(e.exportEmbedScene),[b,w]=Li(e.exportScale),y=fk(null),x=fk(0),[I,T]=Li(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=hk();gk(()=>{M()},[s,m,a,b,E,M]);let{exportedElements:L,exportingFrame:_}=ii(n,e,c);return gk(()=>{let k=y.current;if(!k)return;let D=k.offsetWidth,B=k.offsetHeight;if(!D)return;let K=++x.current,z=()=>K!==x.current;return Xp({elements:L,appState:{...e,name:s,exportBackground:m,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:yW,maxWidthOrHeight:Math.max(D,B),exportingFrame:_}).then(async U=>{if(!z()){try{await _l(U)}catch(W){throw W.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):W}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,L,_,s,m,a,b,E]),Br("div",{className:"ImageExportModal",children:[Ze("h3",{children:f("imageExportDialog.header")}),Br("div",{className:"ImageExportModal__preview",children:[Ze("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ze(IW,{})}),Ze("div",{className:"ImageExportModal__preview__filename",children:!Oi&&Ze("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:k=>{d(k.target.value),o.executeAction(fg,"ui",k.target.value)}})})]}),Br("div",{className:"ImageExportModal__settings",children:[Ze("h3",{children:f("imageExportDialog.header")}),l&&Ze(gc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ze(di,{name:"exportOnlySelected",checked:c,onChange:k=>{p(k)}})}),Ze(gc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ze(di,{name:"exportBackgroundSwitch",checked:m,onChange:k=>{u(k),o.executeAction(Eg,"ui",k)}})}),Ze(gc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ze(di,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Gw,"ui",k)}})}),Ze(gc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ze(di,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(pm,"ui",k)}})}),Ze(gc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ze(Fp,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(Ow,"ui",k)},choices:vW.map(k=>({value:k,label:`${k}\xD7`}))})}),Br("div",{className:"ImageExportModal__settings__buttons",children:[Ze(Lr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(cb.png,L,{exportingFrame:_}),icon:uh,children:f("imageExportDialog.button.exportToPng")}),Ze(Lr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(cb.svg,L,{exportingFrame:_}),icon:uh,children:f("imageExportDialog.button.exportToSvg")}),(gr||wW)&&Ze(Lr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(cb.clipboard,L,{exportingFrame:_}),C()},icon:s0,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},gc=({label:e,children:n,tooltip:t,name:o})=>Br("div",{className:"ImageExportModal__settings__setting",title:e,children:[Br("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ze(bt,{label:t,long:!0,children:d0})]}),Ze("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),bk=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Li(()=>({appStateSnapshot:Ek(n),elementsSnapshot:Ek(e)}));return Ze(Sn,{onCloseRequest:i,size:"wide",title:!1,children:Ze(TW,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import pV from"clsx";import{CANVAS_SEARCH_TAB as Fk,DEFAULT_SIDEBAR as uV}from"@excalidraw/common";import SW from"clsx";import CW from"lodash.debounce";import{Fragment as PW,memo as kW,useEffect as fc,useMemo as xk,useRef as db,useState as yk}from"react";import{CLASSES as MW,EVENT as AW,FONT_FAMILY as mb,FRAME_STYLE as pb,getLineHeight as LW}from"@excalidraw/common";import{getCommonBounds as DW,isElementCompletelyInViewport as _W}from"@excalidraw/element";import{measureText as Ec}from"@excalidraw/element";import{KEYS as fl,randomInteger as wk,addEventListener as RW,getFontString as nu}from"@excalidraw/common";import{newTextElement as NW}from"@excalidraw/element";import{isTextElement as Sk,isFrameLikeElement as ou}from"@excalidraw/element";import{getDefaultFrameName as Ck}from"@excalidraw/element/frame";import{Fragment as YW,jsx as It,jsxs as Yn}from"react/jsx-runtime";var BW=et(""),ub=et(null),FW=350,Pk=()=>{let e=ft(),n=ze(),t=db(null),[o,r]=$e(BW),i=o.trim(),[a,l]=yk(!1),[s,d]=yk({nonce:null,items:[]}),c=db(null),p=db(void 0),[m,u]=$e(ub),E=e.scene.getNonDeletedElementsMap();fc(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==p.current)&&(c.current=null,Tk(i,e,(x,I)=>{d({nonce:wk(),items:x}),c.current=i,p.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,p]);let g=()=>{s.items.length>0&&u(x=>x===null?0:(x+1)%s.items.length)},b=()=>{s.items.length>0&&u(x=>x===null?0:x-1<0?s.items.length-1:x-1)};fc(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:m!==null&&x.searchMatches?.matches[m]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===m?{...T,focus:!0}:{...T,focus:!1})}}:null)},[m,n]),fc(()=>{if(s.items.length>0&&m!==null){let x=s.items[m];if(x){let I=e.state.zoom.value,T=NW({text:x.searchQuery,x:x.element.x+(x.matchedLines[0]?.offsetX??0),y:x.element.y+(x.matchedLines[0]?.offsetY??0),width:x.matchedLines[0]?.width,height:x.matchedLines[0]?.height,fontSize:ou(x.element)?pb.nameFontSize:x.element.fontSize,fontFamily:ou(x.element)?mb.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!_W([T],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||M){let L=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:DW([T]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[m,s,e]),fc(()=>()=>{u(null),c.current=null,p.current=void 0,n({searchMatches:null}),l(!1)},[n,u]);let w=Ji({goToNextItem:g,goToPreviousItem:b,searchMatches:s});fc(()=>{let x=I=>{if(I.key===fl.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[fl.CTRL_OR_CMD]&&I.key===fl.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(I.key===fl.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===fl.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===fl.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return RW(window,AW.KEYDOWN,x,{capture:!0,passive:!1})},[n,w,e]);let y=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Yn("div",{className:"layer-ui__search",children:[Yn("div",{className:"layer-ui__search-header",children:[It(eu,{className:MW.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:ao,onChange:x=>{r(x),l(!0);let I=x.trim();Tk(I,e,(T,C)=>{d({nonce:wk(),items:T}),u(C),c.current=I,p.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0}),It(Cn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:mn})]}),Yn("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Yn(YW,{children:[m!==null&&m>-1?Yn("div",{children:[m+1," / ",y]}):It("div",{children:y}),Yn("div",{className:"result-nav",children:[It(Cn,{onSelect:()=>{g()},className:"result-nav-btn",children:ad}),It(Cn,{onSelect:()=>{b()},className:"result-nav-btn",children:M0})]})]}),s.items.length===0&&i&&c.current&&It("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),It(GW,{matches:s,onItemClick:u,focusIndex:m,searchQuery:i})]})},vk=e=>{let n=[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 It("div",{tabIndex:-1,className:SW("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:It("div",{className:"preview-text",children:n.flatMap((t,o)=>It(PW,{children:o===2?It("b",{children:t}):t},o))})})},OW=e=>{let n=xk(()=>e.matches.items.filter(o=>ou(o.element)),[e.matches]),t=xk(()=>e.matches.items.filter(o=>Sk(o.element)),[e.matches]);return Yn("div",{className:"layer-ui__search-results",children:[n.length>0&&Yn("div",{className:"layer-ui__search-result-container",children:[Yn("div",{className:"layer-ui__search-result-title",children:[It("div",{className:"title-icon",children:ro}),It("div",{children:f("search.frames")})]}),n.map((o,r)=>It(vk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&It("div",{className:"layer-ui__divider"})]}),t.length>0&&Yn("div",{className:"layer-ui__search-result-container",children:[Yn("div",{className:"layer-ui__search-result-title",children:[It("div",{className:"title-icon",children:_n}),It("div",{children:f("search.texts")})]}),t.map((o,r)=>It(vk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},zW=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,GW=kW(OW,zW),Ik=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;d=d.length>c?d.slice(-c):d;let p=e.slice(n+t.length),m=p.split(/\s+/),u=!p.startsWith(" "),E=u?6:5,g=(u?"":" ")+m.slice(0,E).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+g,moreBefore:s>0,moreAfter:m.length>E}},HW=(e,n)=>{let t=e.split(`
|
|
17
|
+
`).filter(s=>s.trim().length>0).map(s=>s.split(l).map(d=>d.trim())),t=[" ",",",";"].map(l=>{let s=n(l),d=s[0]?.length??0,c=s.length>0&&s.every(m=>m.length===d);return{delimiter:l,parsed:s,numCols:d,isConsistent:c}}),r=(t.find(l=>l.isConsistent&&l.numCols>1)??t.find(l=>l.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(l=>l.length===i)?RT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as ol}from"@excalidraw/math";import{FONT_FAMILY as kF,FONT_SIZES as MF,getFontString as AF,getLineHeight as LF,ROUGHNESS as NT}from"@excalidraw/common";import{measureText as DF,newLinearElement as rE,newTextElement as _F}from"@excalidraw/element";var BT=(e,n,t,o)=>{if(!qa(e,"radar"))return null;let r=e.labels??e.series[0].values.map((U,D)=>`Value ${D+1}`),i=e.series,{normalize:a,renderSteps:l}=kT(i,r.length),s=el(o),d=tl(s),c=Qa(i.length,s),{chartWidth:m,chartHeight:p}=PT(),u=n+m/2,E=t-p/2,g=Xa/2,b=r.map((U,D)=>-Math.PI/2+Math.PI*2*D/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=MT(r,b,u,E,g,d),I=kF["Lilita One"],T=MF.xl,P=LF(I),C=AF({fontFamily:I,fontSize:T}),k=e.title?cp(e.title,C,m+Za*2):null,M=k?DF(k,C,P):null,_=k?_F({backgroundColor:d,...Ue,text:k,originalText:e.title??k,x:n+m/2,y:y-Za-M.height/2,fontFamily:I,fontSize:T,lineHeight:P,textAlign:"center"}):null,L=l?Array.from({length:Zf},(U,D)=>{let H=(D+1)/Zf,F=g*H,J=b.map(re=>ol(Math.cos(re)*F,Math.sin(re)*F));return J.push(ol(J[0][0],J[0][1])),rE({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:F*2,height:F*2,strokeStyle:"solid",roughness:NT.architect,opacity:Si,polygon:!0,points:J})}):[],R=b.map(U=>{let D=Math.cos(U)*g,H=Math.sin(U)*g;return rE({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:Math.abs(D),height:Math.abs(H),strokeStyle:"solid",roughness:NT.architect,opacity:Si,points:[ol(0,0),ol(D,H)]})}),z=i.map((U,D)=>{let H=b.map((F,J)=>{let re=U.values[J]??0,O=a(re,J)*g;return ol(Math.cos(F)*O,Math.sin(F)*O)});return H.push(ol(H[0][0],H[0][1])),rE({backgroundColor:"transparent",...Ue,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:c[D],strokeWidth:2,polygon:!0,points:H})}),K=nl(i,c,u,x,t+yo*5,d);return[..._?[_]:[],...w,...L,...R,...z,...K]};var iE=(e,n,t,o,r)=>e==="line"?_T(n,t,o,r):e==="radar"?BT(n,t,o,r):LT(n,t,o,r);import{isDarwin as FT}from"@excalidraw/common";var OT={toggleTheme:[B("Shift+Alt+D")],saveScene:[B("CtrlOrCmd+S")],loadScene:[B("CtrlOrCmd+O")],imageExport:[B("CtrlOrCmd+Shift+E")],cut:[B("CtrlOrCmd+X")],copy:[B("CtrlOrCmd+C")],paste:[B("CtrlOrCmd+V")],copyStyles:[B("CtrlOrCmd+Alt+C")],pasteStyles:[B("CtrlOrCmd+Alt+V")],selectAll:[B("CtrlOrCmd+A")],deleteSelectedElements:[B("Delete")],duplicateSelection:[B("CtrlOrCmd+D"),B(`Alt+${f("helpDialog.drag")}`)],sendBackward:[B("CtrlOrCmd+[")],bringForward:[B("CtrlOrCmd+]")],sendToBack:[FT?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")],bringToFront:[FT?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")],copyAsPng:[B("Shift+Alt+C")],group:[B("CtrlOrCmd+G")],ungroup:[B("CtrlOrCmd+Shift+G")],gridMode:[B("CtrlOrCmd+'")],objectsSnapMode:[B("Alt+S")],stats:[B("Alt+/")],flipHorizontal:[B("Shift+H")],flipVertical:[B("Shift+V")],flipViewpointHorizontal:[B("Shift+R")],flipViewpointVertical:[B("Alt+Shift+R")],viewMode:[B("Alt+R")],hyperlink:[B("CtrlOrCmd+K")],toggleElementLock:[B("CtrlOrCmd+Shift+L")],resetZoom:[B("CtrlOrCmd+0")],zoomOut:[B("CtrlOrCmd+-")],zoomIn:[B("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[B("F")],saveFileToDisk:[B("CtrlOrCmd+S")],saveToActiveFile:[B("CtrlOrCmd+S")],toggleShortcuts:[B("?")],searchMenu:[B("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[B("Shift+A")],toolLock:[B("Q")]},Qe=(e,n=0)=>{let t=OT[e];return t&&t.length>0?t[n]||t[0]:""},zT=e=>{if(Object.prototype.hasOwnProperty.call(OT,e))return Qe(e)||void 0};import{clamp as up,pointFrom as rl,pointsEqual as GF,bezierEquation as $T,pointRotateRads as hp,pointDistance as HF}from"@excalidraw/math";import{arrayToMap as UF,BIND_MODE_TIMEOUT as nc,DEFAULT_TRANSFORM_HANDLE_SPACING as jT,FRAME_STYLE as Sn,getFeatureFlag as WF,invariant as VT,shouldRotateWithDiscreteAngle as qT,THEME as Yo}from"@excalidraw/common";import{deconstructDiamondElement as dE,deconstructRectanguloidElement as JT,elementCenterPoint as il,getDiamondBaseCorners as VF,FOCUS_POINT_SIZE as YF,getOmitSidesForEditorInterface as aE,getTransformHandles as KF,getTransformHandlesFromCoords as XF,hasBoundingBox as ZF,hitElementItself as $F,isArrowElement as QT,isBindableElement as eS,isElbowArrow as al,isFrameLikeElement as ll,isImageElement as gp,isLinearElement as jF,isLineElement as qF,maxBindingDistance_simple as JF,isTextElement as QF,LinearElementEditor as Cn,getActiveTextElement as eO,getElementsInGroup as mE,getSelectedGroupIds as tO,isSelectedViaGroup as nO,selectGroupsFromGivenElements as oO}from"@excalidraw/element";import{renderSelectionElement as rO}from"@excalidraw/element";import{getCommonBounds as pE,getElementAbsoluteCoords as rc}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as YT,isFocusPointVisible as iO}from"@excalidraw/element";import{pointFrom as Rt}from"@excalidraw/math";import{THEME as RF}from"@excalidraw/common";var NF="#ff6b6b",BF="#ff0000",GT=1,HT=2,UT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===RF.LIGHT||n.zenModeEnabled?NF:BF,o=(n.zenModeEnabled?GT*1.5:GT)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,OF(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,zF(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,FF(r,e,n));e.restore()},FF=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];Tn(o,r,n)}for(let o of e.points)WT(o,t,n)},OF=(e,n,t)=>{WT(e.points[0],t,n),t.zenModeEnabled||Tn(e.points[0],e.points[1],n)},WT=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?HT*1.5:HT)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},Tn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},zF=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||Tn(Rt(e[0],e[1]-i),Rt(e[0],e[1]+i),r),Tn(Rt(s[0]-l,s[1]-a),Rt(s[0]-l,s[1]+a),r),Tn(Rt(s[0]+l,s[1]-a),Rt(s[0]+l,s[1]+a),r),o.zenModeEnabled||(Tn(Rt(n[0],n[1]-i),Rt(n[0],n[1]+i),r),Tn(e,n,r))}else{let s=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||Tn(Rt(e[0]-i,e[1]),Rt(e[0]+i,e[1]),r),Tn(Rt(s[0]-a,s[1]-l),Rt(s[0]+a,s[1]-l),r),Tn(Rt(s[0]-a,s[1]+l),Rt(s[0]+a,s[1]+l),r),o.zenModeEnabled||(Tn(Rt(n[0]-i,n[1]),Rt(n[0]+i,n[1]),r),Tn(e,n,r))}};var aO=(e,n)=>{VT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;VT(t,"midPointCoords is null"),fp(t,e,n)},lO=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=Cn.getElement(o,t);if(!i)return;let a=Cn.getPointAtIndexGlobalCoordinates(i,r,t);fp(a,e,n)},fp=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",Ol(n,e[0],e[1],Cn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},sO=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!QT(i)||i.isDeleted)return;let a=r==="label"?Cn.getBoundTextElementCenter(i,t):Cn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);fp(a,e,n)},lE=(e,n,t,o,r,i,a)=>{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)"),Ol(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},cO=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&ll(a)&&(e.translate(a.x,a.y),e.beginPath(),Sn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,Sn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=Sn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===Yo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",Sn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,Sn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let l=il(n.element,t);switch(e.translate(l[0],l[1]),e.rotate(n.element.angle),e.translate(-l[0],-l[1]),e.translate(n.element.x,n.element.y),e.lineWidth=up(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Yo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[s,d]=dE(n.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[m,p,u,E]=c;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[s,d]=JT(n.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[m,p,u,E]=c;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(ll(n.element)||eS(n.element))){let l=o.selectedLinearElement,s=l?.elementId&&Cn.getElement(l?.elementId,t),d=r&&$F({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=s&&al(s)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!d||c){e.save();let m=il(n.element,t),p;if(n.element.type==="diamond"){let b=il(n.element,t);p=VF(n.element).map(w=>{let y=$T(w,.5),x=hp(y,b,n.element.angle);return rl(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(w=>{let y=rl(w.x+n.element.x,w.y+n.element.y),x=hp(y,m,n.element.angle);return rl(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=HF(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=JF(o.zoom)+n.element.strokeWidth/2;p.forEach((b,w)=>{let y=(!d||c)&&u?.idx===w&&u.distance<=g,x=!y&&(c||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Yo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===Yo.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},dO=(e,n,t,o,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=nc-(a?.runtime??(l?0:nc)),d=up(1/nc*s,1e-4,1),c=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&ll(m)&&(n.translate(m.x,m.y),n.beginPath(),Sn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,Sn.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=Sn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===Yo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,Sn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,Sn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=il(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-c,t.y+r.scrollY-c),n.lineWidth=up(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Yo.DARK?`rgba(3, 93, 161, ${d/2})`:`rgba(106, 189, 252, ${d/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+c*2)/2,(t.height+c*2)/2,(t.width+c*2)/2,(t.height+c*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=dE(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,T,P]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,T[0]-t.x+c,T[1]-t.y+c,P[0]-t.x+c,P[1]-t.y+c),n.stroke()})}break;default:{let[b,w]=JT(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,T,P]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,T[0]-t.x+c,T[1]-t.y+c,P[0]-t.x+c,P[1]-t.y+c),n.stroke()})}break}n.restore();break}if(!l||(a?.runtime??0)>nc)return;let p=.5*(Math.min(t.width,t.height)/2);if(!ll(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/nc*s;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-d),p*(1-d),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!qT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,w;if(t.type==="diamond"){let[,y]=dE(t),x=il(t,o);w=y.map(I=>{let T=$T(I,.5),P=hp(T,x,t.angle);return{x:P[0]-t.x,y:P[1]-t.y}})}else{let y=il(t,o);w=[{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(I=>{let T=rl(I.x+t.x,I.y+t.y),P=hp(T,y,t.angle);return{x:P[0]-t.x,y:P[1]-t.y}})}w.forEach(y=>{n.clearRect(y.x-b,y.y-b,b*2,b*2)}),n.fillStyle=r.theme===Yo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,w.forEach(y=>{n.beginPath(),n.arc(y.x,y.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},mO=(e,n,t,o,r,i,a)=>{if(t===null)return;if(WF("COMPLEX_BINDINGS"))return dO(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let l=e.lastPointerMoveCoords?rl(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,s=!!e.lastPointerMoveEvent&&qT(e.lastPointerMoveEvent);cO(n,t,o,r,l,s),n.restore()},tS=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:c,dashed:m,activeEmbeddable:p}=t,u=a-r,E=l-i,b=(t.padding??jT*2)/n.zoom.value,w=8/n.zoom.value,y=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=s.length;for(let I=0;I<x;++I)e.strokeStyle=s[I],m&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*I,zl(e,r-b,i-b,u+b*2,E+b*2,d,c,o);e.restore()},pO=(e,n,t,o)=>{let[r,i,a,l]=rc(t,o),s=a-r,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Sn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),zl(e,r,i,s,d,r+s/2,i+d/2,t.angle,!1,Sn.radius/n.zoom.value),e.restore()},KT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[m,p,u,E]=pE(c);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},d=c=>{let m=mE(t,c);return s(m)};Object.entries(oO(l,n)).filter(([c,m])=>m).map(([c,m])=>c).map(c=>d(c)).concat(a.map(c=>s([c]))).forEach(c=>tS(e,n,c))},sE=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=Cn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=Cn,a=n.selectedLinearElement?.isEditing?i:i/2,l=al(t),s=qF(t);if(r.forEach((d,c)=>{if(l&&c!==0&&c!==r.length-1)return;let m=c>0&&(c!==r.length-1||!s||!t.polygon)&&GF(d,c===r.length-1?r[0]:r[c-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!p&&c===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),lE(e,n,d,a,p,!1,m)}),al(t)){let d=t.fixedSegments?.map(c=>c.index)||[];r.slice(0,-1).forEach((c,m)=>{Cn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||lE(e,n,rl((c[0]+r[m+1][0])/2,(c[1]+r[m+1][1])/2),i/2,!1,!d.includes(m+1),!1)})}else Cn.getEditorMidPoints(t,o,n).filter((c,m,p)=>c!==null&&!(al(t)&&(m===0||m===p.length-1))).forEach(c=>{(n.selectedLinearElement?.isEditing||r.length===2)&&lE(e,n,c,i/2,!1,!0,!1)});e.restore()},uO=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},hO=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ol(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},XT=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!eS(a)||a.isDeleted)return;let l=YT(i.fixedPoint,a,r);if(!iO(l,e,a,r,n,t))return;let s=n.selectedLinearElement,d=!!s?.isDragging,c=t==="start"?0:e.points.length-1,m=!!s?.selectedPointsIndices?.includes(c);if(s?.hoveredFocusPointBinding===t&&!s.draggedFocusPointBinding&&fp(l,o,n),!(m&&d)){let p=YT(i.fixedPoint,a,r),u=s?.hoveredFocusPointBinding===t,E=Cn.getPointAtIndexGlobalCoordinates(e,c,r);uO(o,n,E,p),hO(o,n,p,YF/1.5,u)}},ZT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[l,s,d,c]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?Ol(e,l+d/2,s+c/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,c,2/t.zoom.value),e.fill(),e.stroke()):zl(e,l,s,d,c,l+d/2,s+c/2,r,!0),e.restore()}})},gO=(e,n,t,o,r)=>{let[i,a,,,l,s]=rc(o,r),d=3,c=20,m=d/t.zoom.value,p=m/2,u=l-i+m,E=s-a+m,g=Math.min(c/t.zoom.value,u),b=Math.min(c/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(y=>{let[[x,I],[T,P],[C,k],[M,_],[L,R]]=y;e.save(),e.translate(l,s),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+P),e.lineTo(x+C,I+k),e.stroke(),e.beginPath(),e.moveTo(x+M,I+_),e.lineTo(x+L,I+R),e.stroke(),e.restore()}),e.restore()},fO=(e,n,t,o)=>{n.save();let r=zf(t.zoom.value),i=e.width+r*2,a=e.height+r*2,l=e.x+e.width/2,s=e.y+e.height/2,d=-(e.width/2+r),c=-(e.height/2+r);n.translate(l+t.scrollX,s+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(d,c,i,a),n.restore()},EO=(e,n,t,o,r)=>{let i=Gf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},bO=(e,n,t,o,r,i)=>{for(let a of n){if(!gp(a)||!a.fileId)continue;let l=o.imageStatus.get(a.fileId);if(!!l?.downloadError){let c=oc(a,t,r,"center");c&&oS(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,r,l?.downloadError??void 0)}else{let c=o.imageLoadingProgress.get(a.fileId);if(c!==void 0){let m=oc(a,t,r,"center");m&&nS(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,c,r,i)}}let d=l?.uploadProgress;if(d){let c=oc(a,t,r,"top-right");c&&yO(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,c.lineWidth,d,r,i)}}},oc=(e,n,t,o)=>{if(!gp(e))return null;let[r,i,a,l]=rc(e,n),s=t.zoom.value,d=Math.min(a-r,l-i)*s,c=Math.min(o==="center"?14:11.7,d/(o==="center"?4:4.62))/s,m=Math.min((o==="center"?3:2.6)/s,c/2);if(c<=0||m<=0)return null;if(o==="top-right"){let p=6/s;return{centerX:a-p-c,centerY:i+p+c,radius:c,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+l)/2,radius:c,lineWidth:m}},nS=(e,n,t,o,r,i,a,l,s)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=s?.trackColor??(a.theme===Yo.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=s?.color??l,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*up(i,0,1)),e.stroke()),e.restore()},cE=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,xO=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},yO=(e,n,t,o,r,i,a,l)=>{let s=i.state??"uploading",d=i.color??cE("--color-primary",l),c=i.color??cE("--color-warning-darkest","#ec8b14");if(s==="failed"){oS(e,n,t,o,a,{color:i.color??cE("--color-danger","#e03131")});return}if(s==="uploading"&&nS(e,n,t,o,r,i.progress??0,a,l,{color:d,trackColor:i.trackColor}),xO(e,n,t-o*.02,o*1.125,{color:s==="error"?c:d,lineWidth:Math.max(r*.75,1/a.zoom.value)}),s==="error"){e.save(),e.strokeStyle=c,e.fillStyle=c,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else s==="pending"&&(e.save(),e.strokeStyle=d,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},oS=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",l=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},wO=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:d,animationState:c,deltaTime:m})=>{if(n===null)return{};let[p,u]=jc(n,a),E=c,g=qc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),Jc(g,l);let b;if(o.forEach(P=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===P.id&&P&&(b=P)}),b&&sE(g,l,b,t),l.selectionElement&&!l.isCropping)try{rO(l.selectionElement,g,l,s.selectionColor)}catch(P){console.error(P)}let w=eO(r,l);if(w&&!w.autoResize&&EO(w,g,l,s.selectionColor,d.formFactor),l.editingTextElement){let P=i.get(l.editingTextElement.id);P&&!P.autoResize&&fO(P,g,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?E={...c,bindingHighlight:mO(e,g,l.suggestedBinding,i,l,m,c?.bindingHighlight)}:E={...c,bindingHighlight:void 0},l.hoveredArrowTextAnchor&&sO(g,l,i),l.frameToHighlight&&pO(g,l,l.frameToHighlight,t),l.elementsToHighlight&&KT(g,l,l.elementsToHighlight),l.activeLockedId){let P=i.get(l.activeLockedId),C=P?[P]:mE(i,l.activeLockedId);KT(g,l,C,{colors:["#ced4da"],dashed:!0})}let y=r.some(P=>ll(P));r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&sE(g,l,r[0],t);let x=l.selectedLinearElement,I=x&&Cn.getElement(x.elementId,i);if(I&&(l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?aO(g,l):(al(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&lO(g,l,t)),QT(I)&&(XT({arrow:I,elementsMap:i,appState:l,context:g,type:"start"}),XT({arrow:I,elementsMap:i,appState:l,context:g,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let P=ZF(r,l,d),C=r.length===1&&jF(r[0]);C&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&sE(g,l,r[0],t);let k=s.selectionColor||"#000";if(P){let M=UF(r),_=[];for(let R of t.values()){let z=[],K=s.remoteSelectedElementIds.get(R.id);if(C&&al(R)&&(R.startBinding||R.endBinding)||(M.has(R.id)&&!nO(l,R)&&z.push(k),K&&z.push(...K.map(U=>hi(U,l.collaborators.get(U))))),z.length){let[U,D,H,F,J,re]=rc(R,t,!0);_.push({angle:R.angle,x1:U,y1:D,x2:H,y2:F,selectionColors:R.locked?["#ced4da"]:z,dashed:!!K||R.locked,cx:J,cy:re,activeEmbeddable:l.activeEmbeddable?.element===R&&l.activeEmbeddable.state==="active",padding:R.id===l.croppingElementId||gp(R)?0:void 0})}}let L=R=>{let z=mE(t,R),[K,U,D,H]=pE(z);_.push({angle:0,x1:K,x2:D,y1:U,y2:H,selectionColors:z.some(F=>F.locked)?["#ced4da"]:["#000"],dashed:!0,cx:K+(D-K)/2,cy:U+(H-U)/2,activeEmbeddable:!1})};for(let R of tO(l))L(R);l.editingGroupId&&L(l.editingGroupId),_.forEach(R=>tS(g,l,R))}if(g.save(),g.translate(l.scrollX,l.scrollY),r.length===1){g.fillStyle="#fff";let M=KF(r[0],l.zoom,t,"mouse",aE(d));if(!l.viewModeEnabled&&P&&!QF(l.editingTextElement)&&!l.croppingElementId&&ZT(g,s,l,M,r[0].angle),l.croppingElementId&&!l.isCropping){let _=t.get(l.croppingElementId);_&&gp(_)&&gO(g,s,l,_,t)}}else if(r.length>1&&!l.isRotating&&!r.some(M=>M.locked)){let M=jT*2/l.zoom.value;g.fillStyle="#fff";let[_,L,R,z]=pE(r,t),K=g.getLineDash();g.setLineDash([2/l.zoom.value]);let U=g.lineWidth;g.lineWidth=1/l.zoom.value,g.strokeStyle=k,zl(g,_-M,L-M,R-_+M*2,z-L+M*2,(_+R)/2,(L+z)/2,0),g.lineWidth=U,g.setLineDash(K);let D=XF([_,L,R,z,(_+R)/2,(L+z)/2],0,l.zoom,"mouse",y?{...aE(d),rotation:!0}:aE(d));r.some(H=>!H.locked)&&ZT(g,s,l,D,0)}g.restore()}l.searchMatches?.matches.forEach(({id:P,focus:C,matchedLines:k})=>{let M=t.get(P);if(M){let[_,L,,,R,z]=rc(M,t,!0);g.save(),l.theme===Yo.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 K=ll(M)?l.zoom.value:1;g.translate(l.scrollX,l.scrollY),g.translate(R,z),g.rotate(M.angle),k.forEach(U=>{(U.showOnCanvas||C)&&g.fillRect(_+U.offsetX/K-R,L+U.offsetY/K-z,U.width/K,U.height/K)}),g.restore()}}),UT(g,l),bO(g,o,t,e,l,s.selectionColor),g.restore(),uv({context:g,renderConfig:s,appState:l,normalizedWidth:p,normalizedHeight:u});let T;return s.renderScrollbars&&(T=WI(t,p,u,l),g.save(),g.fillStyle=UI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(P=>{P&&Cm(g,P.x,P.y,P.width,P.height,xo/2)}),g.restore()),{scrollBars:T,animationState:E}},uE=e=>{let n=wO(e);return e.callback(n),n};import{useEffect as sc,useMemo as rS,useRef as bE,useState as vO}from"react";import{bumpVersion as ic,getLinearElementSubType as cl,mutateElement as xE,updateElbowArrowPoints as IO}from"@excalidraw/element";import{pointFrom as bp,pointRotateRads as TO}from"@excalidraw/math";import{hasBoundTextElement as SO,isArrowBoundToElement as CO,isArrowElement as PO,isElbowArrow as kO,isLinearElement as IE,isUsingAdaptiveRadius as MO}from"@excalidraw/element";import{getCommonBoundingBox as AO,getElementAbsoluteCoords as LO}from"@excalidraw/element";import{getBoundTextElement as cS,getBoundTextMaxHeight as DO,getBoundTextMaxWidth as _O,redrawTextBoundingBox as RO}from"@excalidraw/element";import{wrapText as NO}from"@excalidraw/element";import{assertNever as BO,CLASSES as FO,getFontString as hE,isProdEnv as OO,mapFind as zO,reduceToCommonValue as GO,ROUNDNESS as gE,sceneCoordsToViewportCoords as HO,updateActiveTool as iS}from"@excalidraw/common";import{measureText as aS}from"@excalidraw/element";import{LinearElementEditor as UO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as fE,newElement as WO,newLinearElement as VO}from"@excalidraw/element";import{ShapeCache as YO}from"@excalidraw/element";import{updateBindings as KO}from"@excalidraw/element";import{jsx as vE}from"react/jsx-runtime";var XO=8,ZO=10,ac=["rectangle","diamond","ellipse"],lc=["line","sharpArrow","curvedArrow","elbowArrow"],$O=new Set(ac),jO=new Set(lc),dl=e=>$O.has(e),xp=e=>e==="arrow"||jO.has(e),wo=et(null),cc=new Map,dc=new Map,qO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=bE(null);return sc(()=>{if(n.length===0){e.updateEditorAtom(wo,null);return}let o=yp(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(wo,null),t.current=null)},[n,e]),sc(()=>()=>{cc.clear(),dc.clear()},[]),vE(JO,{app:e,elements:n})},JO=({app:e,elements:n})=>{let t=yp(n),o=rS(()=>t==="generic"?mS(n):[],[t,n]),r=rS(()=>t==="linear"?wE(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>cl(m)===cl(r[0])):!1,[a,l]=vO({x:0,y:0}),s=bE(""),d=bE(null);sc(()=>{let m=[...o,...r].sort((b,w)=>b.id.localeCompare(w.id)),p=`
|
|
18
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(m.length===1){let[b,,,w,y,x]=LO(m[0],e.scene.getNonDeletedElementsMap());u=TO(bp(b,w),bp(y,x),m[0].angle)}else{let{minX:b,maxY:w}=AO(m);u=bp(b,w)}let{x:E,y:g}=HO({sceneX:u[0],sceneY:u[1]},e.state);l({x:E,y:g})},[o,r,e.scene,e.state]),sc(()=>{for(let m of r){let p=yE(m.id,o9(m));dc.has(p)||dc.set(p,m)}},[r]),sc(()=>{for(let m of o)if(!cc.has(m.id)){let p=cS(m,e.scene.getNonDeletedElementsMap());p&&cc.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let c=t==="linear"?[["line",lr],["sharpArrow",dr],["curvedArrow",pr],["elbowArrow",mr]]:t==="generic"?[["rectangle",qi],["diamond",Ji],["ellipse",Qi]]:[];return vE("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(ZO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-XO}px`,zIndex:2},className:FO.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&cl(r[0])===m);return vE($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ye("convertElementType",m,"ui"),TE(e,{conversionType:t,nextType:m}),d.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},QO=(e,n,t)=>{let o=_O(e,n),r=DO(e,n),i=NO(n.text,hE(n),o),a=aS(i,hE(n),n.lineHeight),l=n.fontSize;for(;(a.width>o||a.height>r)&&l>0;){l-=1;let s={...n,fontSize:l};a=aS(n.text,hE(s),n.lineHeight)}xE(n,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),RO(n,e,t)},TE=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let l=mS(r),d=l.every(c=>c.type===l[0].type)?ac.indexOf(l[0].type):-1;if(t=t??ac[(d+ac.length+a)%ac.length],t&&dl(t)){let c={};for(let p of l){let u=sS(p,t,e);c[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?m.push(c[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(c)){let u=cS(p,e.scene.getNonDeletedElementsMap());u&&(cc.get(p.id)&&xE(u,e.scene.getNonDeletedElementsMap(),{fontSize:cc.get(p.id)?.fontSize??u.fontSize}),QO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:iS(p,{type:"selection"})}))}}if(n==="linear"){let l=wE(r);if(!t){let d=GO(l,cl),c=d?lc.indexOf(d):-1;t=lc[(c+lc.length+a)%lc.length]}if(xp(t)){let d=[],c=e.scene.getElementsMapIncludingDeleted();for(let m of l){let p=dc.get(yE(m.id,t));if(p&&cl(p)===t)c.set(p.id,p),d.push(p);else{let u=sS(m,t,e);c.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(c);for(let m of d)if(IE(m))if(kO(m)){let p=e9(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=IO(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});xE(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=zO(["line","sharpArrow","curvedArrow"],u=>dc.get(yE(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let s=wE(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new UO(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:iS(d,{type:"selection"})}))}return!0},yp=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(dl(t.type))return"generic";dS(t)&&(n=!0)}return n?"linear":null},dS=e=>IE(e)&&(!PO(e)||!CO(e)&&!SO(e)),yE=(e,n)=>`${e}:${n}`,mS=e=>e.filter(n=>dl(n.type)),wE=e=>e.filter(n=>dS(n)),Ep=20,sl=(e,n)=>e[0]===n[0],EE=(e,n)=>e[1]===n[1],lS=(e,n)=>sl(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),e9=e=>{let n=[e.points[0]],t=t9(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Ep?l[0]=a[0]:Math.abs(l[1]-a[1])<Ep&&(l[1]=a[1]),sl(a,l)||EE(a,l)||n.push(bp(a[0],l[1])),n.push(l)}let o=[n[0]];for(let i=1;i<n.length-1;++i)sl(n[i-1],n[i])&&sl(n[i],n[i+1])||EE(n[i-1],n[i])&&EE(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],l=o[i],s=o[i+1],d=sl(a,l),c=sl(l,s);if(d!==c){let m=lS(a,l),p=lS(l,s);if(m<Ep||p<Ep){if(p<m)d?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(o[o.length-1]),r},t9=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},sS=(e,n,t)=>{if(!n9(e.type,n)){if(!OO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(YO.delete(e),dl(n)){let o=ic(WO({...e,type:n,roundness:e.roundness?{type:MO(n)?gE.ADAPTIVE_RADIUS:gE.PROPORTIONAL_RADIUS}:e.roundness}));return KO(o,t.scene,t.state),o}if(xp(n))switch(n){case"line":return ic(VO({...e,type:"line"}));case"sharpArrow":return ic(fE({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ic(fE({...e,type:"arrow",elbowed:!1,roundness:{type:gE.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ic(fE({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return BO(n,`unhandled conversion type: ${n}`),e},n9=(e,n)=>!!(dl(e)&&dl(n)||xp(e)&&xp(n)),o9=e=>IE(e)?cl(e):e.type,pS=qO;import{bindBindingElementToFixedPoint as r9,dragNewTextElement as i9,getBoundTextElement as a9,getEndpointBoundTextDragAnchor as l9,getTextBindingForArrowEndpoint as s9,getUnboundArrowEndpointAtPoint as c9,isArrowElement as d9,isBindingEnabled as m9,isEndpointBoundText as p9,isTextElement as u9}from"@excalidraw/element";import{pointFrom as h9}from"@excalidraw/math";var wp=class{constructor(n){this.app=n;v(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});v(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!m9(this.app.state))return null;let o=c9(h9(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!d9(r)||a9(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return s9(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){r9(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!u9(n)||!p9(n,this.app.scene.getNonDeletedElementsMap())?!1:(i9({newElement:n,...l9(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as g9,BUCKET_FILL_BACKGROUND_PICKS as f9,COLOR_PALETTE as hS,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as E9,getSizeFromPoints as b9,isTransparent as x9,THEME as y9}from"@excalidraw/common";import{pointFrom as uS}from"@excalidraw/math";import{computeBucketFillPolygon as w9,isBucketFillCompatible as v9,isFrameLikeElement as I9,isRestylableFill as T9,newLinearElement as S9,ShapeCache as C9}from"@excalidraw/element";var SE=f9.filter(e=>e!==hS.white),vp=class{constructor(n){this.app=n;v(this,"temporaryEyeDropper",null);v(this,"pending",null);v(this,"handlePointerDown",n=>{this.pending=n});v(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});v(this,"cancel",()=>{this.pending=null});v(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=SE.indexOf(n),o=SE[(t+1)%SE.length];this.app.actionManager.executeAction(jd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Tt.get(Xt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(jd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Xt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Tt.get(Xt)===n&&this.app.updateEditorAtom(Xt,null)});v(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),C9.delete(n),this.app.scheduleCapture())});v(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=uS(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),l=w9({point:i,elements:o,elementsMap:r});if(!l.ok){if(a&&v9(a)){this.restyle(a);return}l.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(l.reason==="open_region"||l.reason==="too_small"||l.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&T9({hitElement:a,scenePoints:l.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:d}=b9(l.scenePoints),[c,m]=l.scenePoints[0],p=l.scenePoints.map(y=>uS(y[0]-c,y[1]-m)),u=l.ownerId?r.get(l.ownerId):null,E=u?I9(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:l.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=S9({type:"line",x:c,y:m,width:s,height:d,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),w=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===l.insertion.elementId);this.app.scene.insertElementsAtIndex([b],w<0?null:l.insertion.placement==="above"?w+1:w),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>x9(n)?hS.green[E9]:g9(n,t===y9.DARK))}};import{CURSOR_TYPE as mc,MIME_TYPES as Tp,THEME as gS}from"@excalidraw/common";var fS='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',P9='<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"/>',ES='<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"/>',k9=`data:${Tp.svg},${encodeURIComponent(`${fS}${ES}</svg>`)}`,M9=`data:${Tp.svg},${encodeURIComponent(`${fS}${P9}${ES}</svg>`)}`,A9=e=>{let n=oh.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Tp.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},Ip=class{constructor(n){this.app=n;v(this,"toolCursorMemo",null);v(this,"eraserCanvasCache",null);v(this,"eraserPreviewDataURL",null);v(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});v(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(mc.GRAB):this.clear():this.applyForTool()});v(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(Bl({activeTool:n}))this.set(mc.GRAB);else if(pn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(mc.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${A9(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===gS.LIGHT?k9:M9;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(mc.AUTO):this.set(mc.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});v(this,"clear",()=>{this.set("")});v(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===gS.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(Tp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as N9}from"@excalidraw/common";import{bindBindingElement as B9,convertToShape as F9,convertToShapeHandlePointerMoveFromPointerDown as O9,getHoveredElementForBinding as bS,isBindingElement as z9,isLineElement as G9,LinearElementEditor as CE,maxBindingDistance_simple as xS,newArrowElement as H9,updateBoundPoint as U9}from"@excalidraw/element";import{getStrokeWidthByKey as L9,THEME as D9}from"@excalidraw/common";import{clamp as _9,pointFrom as R9}from"@excalidraw/math";var Sp=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Kn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===D9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>_9(L9("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>R9(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Cp=class{constructor(n){this.app=n;v(this,"trail");v(this,"gestureInProgress",!1);v(this,"stop",()=>{this.trail.stop()});v(this,"hasPendingGesture",()=>this.gestureInProgress);v(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(xt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>O9(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=xS(t.state.zoom),a=["start","end"].map(c=>{let m=CE.getPointAtIndexGlobalCoordinates(n,c==="start"?0:-1,o);return{startOrEnd:c,globalPoint:m,target:bS(m,r,o,i)}}),l=!!a[0].target&&a[0].target===a[1].target,s=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:c,globalPoint:m,target:p}of a)p&&B9(n,p,l?"inside":"orbit",c,t.scene,m,t.state.isBindingEnabled,s);if(l)return;let d=new Map;for(let{startOrEnd:c,target:m}of a){if(!m)continue;let p=U9(n,c==="start"?"startBinding":"endBinding",c==="start"?n.startBinding:n.endBinding,m,o);p&&d.set(c==="start"?0:n.points.length-1,{point:p})}d.size&&CE.movePoints(n,t.scene,d)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=xS(t.state.zoom),[a,l]=[0,-1].map(s=>bS(CE.getPointAtIndexGlobalCoordinates(n,s,o),r,o,i));return!a&&!l||a===l?null:H9({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});v(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||F9(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:N9(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&G9(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&z9(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Sp(n)}};import{isArrowKey as W9,KEYS as Pi}from"@excalidraw/common";import{makeNextSelectedElementIds as V9,CaptureUpdateAction as Y9,FlowChartCreator as K9,FlowChartNavigator as X9,getSelectedElements as yS,isFlowchartNodeElement as Z9}from"@excalidraw/element";var Pp=class e{constructor(n){this.app=n;v(this,"creator",new K9);v(this,"navigator",new X9);v(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});v(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===Pi.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!W9(n.key))return{type:"none"};if(n[Pi.CTRL_OR_CMD]&&!n.shiftKey){let a=yS(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&Z9(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),l=yS(a,r.state);if(l.length===1)return{type:"navigating",nodeId:o.exploreByDirection(l[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[Pi.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:V9({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:Y9.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case Pi.ARROW_UP:return"up";case Pi.ARROW_DOWN:return"down";case Pi.ARROW_RIGHT:return"right";case Pi.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as wS,hasPlayableGif as $9,isInitializedImageElement as j9,newElementWith as vS,ShapeCache as q9}from"@excalidraw/element";import{MIME_TYPES as IS}from"@excalidraw/common";var kp=class{constructor(n){this.app=n;v(this,"playbackRaf",null);v(this,"runtimeState",new Map);v(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});v(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);v(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});v(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||$9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==IS.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:IS.gif,gifDecodeStatus:"pending"});let r=vS(n,{fileId:o,gifPlayback:wS({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});v(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:vS(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:wS(t)}));v(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});v(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!j9(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),l=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,l);let s=l.frameIndex,d=i.delays[s]??100;n-l.lastFrameTime>=d/a&&(l.frameIndex=(s+1)%i.frames.length,l.lastFrameTime=n,q9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as J9,easeOut as MS,isBounds as Q9}from"@excalidraw/common";import{clamp as AS}from"@excalidraw/math";import{getCommonBounds as TS,getElementsInGroup as ez,isElementLink as tz,isExcalidrawElement as nz,parseElementLinkFromURL as oz}from"@excalidraw/element";var Mp="animateScrollToContent",ml="animateScrollConstraintsSnapBack",SS=500,rz=250,iz=200,PE=302,CS={full:216,compact:64},az=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},lz=(e,n)=>{let t=n.get(e);return t?[t]:ez(n,e)},PS=(e,n,t)=>{if(typeof e=="string"){let a=tz(e),l=a?"link":"element",s=a?oz(e):e,d=s?lz(s,n):[];return d.length?{bounds:TS(d,n),type:l}:{bounds:null,type:l}}if(Q9(e))return{bounds:e,type:"area"};if(az(e)&&!nz(e)){let a=e.width??t.width,l=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+l],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,l)=>{if(l&&!l.isDeleted){let s=n.get(l.id);s&&a.push(s)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:TS(r,n),type:"element"}},sz=e=>e===!1?0:e===!0||e==null?Ku:Math.max(e,0),cz=(e,n,t="scale-down",o,r)=>{let{appState:i}=Xr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},kS=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=cz(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[l,s,d,c]=n,m={x:l,y:s,width:d-l,height:c-s,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:sz(r.overscroll),offsets:o};return{...oo({...e,...a,scrollConstraints:m}),scrollConstraints:m}},dz=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},mz=e=>e===!1?null:e===!0||e==null?SS:e.duration??SS,pz=(e,n,t,o,r)=>{pt.start(Mp,({deltaTime:i,state:a})=>{let l=(a?.elapsed??0)+i,s=Math.min(l/t,1),d=MS(AS(s,0,1));return s<1?(o({...dz({from:e,target:n,factor:d}),shouldCacheIgnoreZoom:!0}),{elapsed:l}):(r(),null)})},uz=(e,n,t=rz)=>{let o=oo(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||pt.running(Mp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;pt.start(ml,({deltaTime:a,state:l})=>{let s=(l?.elapsed??0)+a,d=Math.min(s/t,1),c=1-MS(AS(d,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=oo(m),u=p.zoom.value;return{scrollX:p.scrollX+r*c/u,scrollY:p.scrollY+i*c/u,zoom:p.zoom}}),d<1?{elapsed:s}:null})},Ap=class{constructor(n,t){this.app=n;this.dependencies=t;v(this,"lastPosition",{x:0,y:0});v(this,"activeTransition",null);v(this,"uiLastMeasured",new Map);v(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});v(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});v(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=lo().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g=u.closest("[data-ui-layout-region]")?.getBoundingClientRect(),b=Math.max(E.left,o.left,g?.left??-1/0),w=Math.max(E.top,o.top,g?.top??-1/0),y=Math.min(E.right,o.right,g?.right??1/0),x=Math.min(E.bottom,o.bottom,g?.bottom??1/0);if(y<=b||x<=w)continue;let I={top:w-o.top,right:y-o.left,bottom:x-o.top,left:b-o.left,width:y-b},T=u.dataset.viewportUiName;switch(T&&a.add(T),u.dataset.viewportUi){case"top":i.top=Math.max(i.top,I.bottom),T&&I.bottom>0&&this.uiLastMeasured.set(T,{side:"top",offset:I.bottom});break;case"bottom":{let P=this.app.state.height-I.top;i.bottom=Math.max(i.bottom,P),T&&P>0&&this.uiLastMeasured.set(T,{side:"bottom",offset:P})}break;case"side":{let[P,C]=I.left+I.width/2<this.app.state.width/2?["left",I.right]:["right",this.app.state.width-I.left];i[P]=Math.max(i[P],C),T&&C>0&&this.uiLastMeasured.set(T,{side:P,offset:C});break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:w}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],w)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?CS.compact:CS.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:PE})}let l=n?.padding??24,s=n?.paddingTop??l,d=(r?n?.paddingLeft:n?.paddingRight)??l,c=n?.paddingBottom??l,m=(r?n?.paddingRight:n?.paddingLeft)??l,p={top:i.top+s,right:i.right+d,bottom:i.bottom+c,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=PS(n.target,t,o);return r?kS(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),pt.cancel(ml),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,l=this.resolveOffsets(n.offsets),{bounds:s,type:d}=PS(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!s){d==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let c=kS(this.app.state,s,{fit:o,offsets:l,lock:r,viewportZoomFactor:a}),m=mz(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),pt.cancel(ml),this.snapBackDebounced.cancel(),m===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let u={target:c};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),pz(p,c,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||pt.cancel(ml),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),oo(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?oo(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||uz(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",J9(this.snapBack,iz));v(this,"cancelTransition",()=>{this.activeTransition=null,pt.cancel(Mp)});v(this,"destroy",()=>{this.cancelTransition(),pt.cancel(ml),this.snapBackDebounced.cancel()})}get isAnimating(){return pt.running(Mp)||pt.running(ml)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import Lp from"react";var hz=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,gz=/{{([\w-]+)}}/,fz=/<([\w-]+)>/,Ez=/<\/([\w-]+)>/,bz=(e,n)=>{let t=[{name:"",children:[]}];return e.split(hz).filter(Boolean).forEach(o=>{let r=o.match(fz),i=o.match(Ez),a=o.match(gz);if(r!==null){let l=r[1];n.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),d=Lp.createElement(Lp.Fragment,{},...s.children),c=n[s.name];typeof c=="function"&&t[t.length-1].children.push(c(d))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let l=a[1];n.hasOwnProperty(l)?t[t.length-1].children.push(n[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},xz=({i18nKey:e,children:n,...t})=>{let{t:o}=_e();return Lp.createElement(Lp.Fragment,{},...bz(o(e),t))},ki=xz;import{jsx as Pn,jsxs as LS}from"react/jsx-runtime";var yz=()=>LS("div",{"data-testid":"brave-measure-text-error",children:[Pn("p",{children:Pn(ki,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Pn("span",{style:{fontWeight:600},children:e})})}),Pn("p",{children:Pn(ki,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Pn("span",{style:{fontWeight:600},children:e})})}),Pn("p",{children:Pn(ki,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Pn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Pn("p",{children:Pn(ki,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Pn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>LS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),DS=yz;import Pz from"clsx";import kz from"react";import{useLayoutEffect as wz,useRef as _S,useEffect as RS}from"react";import{unstable_batchedUpdates as vz}from"react-dom";import{KEYS as Iz,queryFocusableElements as Tz}from"@excalidraw/common";import{clamp as NS}from"@excalidraw/math";import Sz from"clsx";import{jsx as Cz}from"react/jsx-runtime";var Ar=10,BS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:l})=>{let s=_S(null);RS(()=>{let c=s.current;if(!c)return;c.contains(document.activeElement)||c.focus();let m=p=>{if(p.key===Iz.TAB){let u=Tz(c),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===c?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return c.addEventListener("keydown",m),()=>c.removeEventListener("keydown",m)},[]);let d=_S(null);return wz(()=>{if(r&&s.current&&t!=null&&n!=null){let c=s.current,{width:m,height:p}=c.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===n)return;d.current={top:t,left:n};let u=Math.max(0,i-Ar*2);m>=u?(c.style.width=`${u}px`,c.style.left=`${Ar}px`,c.style.overflowX="scroll"):c.style.left=`${NS(n,Ar,i-Ar-m)}px`;let E=Math.max(0,a-Ar*2);p>=E?(c.style.height=`${E}px`,c.style.top=`${Ar}px`,c.style.overflowY="scroll"):c.style.top=`${NS(t,Ar,a-Ar-p)}px`}},[t,n,r,i,a]),RS(()=>{if(o){let c=m=>{s.current?.contains(m.target)||vz(()=>o(m))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[o]),Cz("div",{className:Sz("popover",l),ref:s,tabIndex:-1,children:e})};import{jsx as Ko,jsxs as OS}from"react/jsx-runtime";var We="separator",FS=e=>"onSelect"in e,zS=kz.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=on(),a=ia(),l=n.reduce((s,d)=>d?d===We||FS(d)?(s.push(d),s):((!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s):s,[]);return Ko(BS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Ko("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===We)return!l[d-1]||l[d-1]===We?null:Ko("hr",{className:"context-menu-item-separator"},d);if(FS(s))return Ko("li",{"data-testid":s.key,onClick:()=>{r(()=>{s.onSelect()})},children:OS("button",{type:"button",className:"context-menu-item",children:[Ko("div",{className:"context-menu-item__label",children:s.label}),Ko("kbd",{className:"context-menu-item__shortcut"})]})},s.key);let c=s.name,m="";return s.label&&(typeof s.label=="function"?m=f(s.label(a,i,e.app)):m=f(s.label)),Ko("li",{"data-testid":c,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:OS("button",{type:"button",className:Pz("context-menu-item",{dangerous:c==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ko("div",{className:"context-menu-item__label",children:m}),Ko("kbd",{className:"context-menu-item__shortcut",children:c?Qe(c):""})]})},d)})})})});import{useId as Mz}from"react";import Az from"clsx";import{Fragment as Lz,jsx as pc,jsxs as GS}from"react/jsx-runtime";var Dp=({border:e,style:n})=>pc("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),_p=({label:e,border:n})=>{let t=Mz(),o=GS(Lz,{children:[e.icon&&pc("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return GS("div",{className:Az("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&pc("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),pc("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&pc("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:un})]})};import fu from"clsx";import eY from"react";import{CLASSES as tY,TOOL_TYPE as hM,arrayToMap as nY,isShallowEqual as Eu}from"@excalidraw/common";import{mutateElement as oY,ShapeCache as rY}from"@excalidraw/element";import{showSelectedShapeActions as iY}from"@excalidraw/element";import{createIsolation as Dz}from"jotai-scope";import kE from"react";import Xo from"tunnel-rat";var ME=kE.createContext(null),gt=()=>kE.useContext(ME),_z=Dz(),HS=()=>kE.useMemo(()=>({MainMenuTunnel:Xo(),WelcomeScreenMenuHintTunnel:Xo(),WelcomeScreenToolbarHintTunnel:Xo(),WelcomeScreenHelpHintTunnel:Xo(),WelcomeScreenCenterTunnel:Xo(),FooterCenterTunnel:Xo(),DefaultSidebarTriggerTunnel:Xo(),DefaultSidebarTabTriggersTunnel:Xo(),OverwriteConfirmDialogTunnel:Xo(),tunnelsJotai:_z}),[]);import Dr from"clsx";import{useRef as Uz}from"react";import{Popover as Lr}from"radix-ui";import{CLASSES as JS}from"@excalidraw/common";import{isArrowElement as qS}from"@excalidraw/element";import{forwardRef as US}from"react";import WS from"clsx";import{jsx as VS}from"react/jsx-runtime";var Rz=US(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>VS("div",{className:WS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),Nz=US(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>VS("div",{className:WS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),an={Row:Rz,Col:Nz};import{isTransparent as YS}from"@excalidraw/common";import{shouldAllowVerticalAlign as Bz,suppportsHorizontalAlign as Fz,hasBoundTextElement as KS,isElbowArrow as Oz,isImageElement as XS,isLinearElement as zz,isTextElement as Gz,hasStrokeColor as ZS,toolIsArrow as Hz}from"@excalidraw/element";var $S=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return ZS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>ZS(o.type))},jS=(e,n)=>ir(e.activeTool.type)||n.some(t=>ir(t.type)),Rp=(e,n,t,o)=>{let r=e.activeTool.type,i=c=>c(r)||n.some(m=>c(m.type)),a=n.length===1,l=n.length===2&&(KS(n[0])||KS(n[1])),s=!!(e.editingTextElement||e.newElement),d=n.length>0;return{hasSelection:d,showExtraActions:d&&!s,strokeColor:$S(e,n),backgroundColor:jS(e,n),fill:r==="bucketfill"||ir(r)&&!YS(e.currentItemBackgroundColor)||n.some(c=>ir(c.type)&&!YS(c.backgroundColor)),strokeWidth:i(Rx),freedrawMode:i(Nx),strokeStyle:i(Xu),sloppiness:i(Xu),roundness:i(Bx),arrowType:i(Hz),arrowheads:i(Rl),text:r==="text"||n.some(Gz),textAlign:r==="text"||Fz(n,t),verticalAlign:Bz(n,t),opacity:r!=="autoshape"||d,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(c=>c.type==="freedraw")||de(t,e).some(c=>c.type==="freedraw"),align:!l&&mt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(XS)&&mt(e,o),link:a||l,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&XS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&zz(n[0])&&!Oz(n[0])}};import{Fragment as ln,jsx as Q,jsxs as Le}from"react/jsx-runtime";var AE=Dr([JS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),QS=({renderAction:e})=>Le("fieldset",{children:[Q("legend",{children:f("labels.layers")}),Le("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),eC=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Le("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Le("div",{className:"align-fieldset-header",children:[Q("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Le("div",{className:"buttonList",children:[o?Le(ln,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Le(ln,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),Q("div",{style:{flexBasis:"100%",height:0}}),Le("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Le(ln,{children:[Q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},tC=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Wi(n,e),i=Rp(e,r,n,o);return e.activeTool.type==="bucketfill"?Le("div",{className:"selected-shape-actions",children:[Q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Le("div",{className:"selected-shape-actions",children:[Q("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&Q("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&Q(ln,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&Q(ln,{children:t("changeSloppiness")}),i.roundness&&Q(ln,{children:t("changeRoundness")}),i.arrowType&&Q(ln,{children:t("changeArrowType")}),i.text&&Le(ln,{children:[Q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&Q(ln,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&Q(QS,{renderAction:t}),i.align&&Q(eC,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Le("fieldset",{children:[Q("legend",{children:f("labels.actions")}),Le("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},nC=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||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 i?Q("div",{className:"compact-action-item",children:Le(Lr.Root,{open:a,onOpenChange:l=>{t(l?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[Q(Lr.Trigger,{asChild:!0,children:Q("button",{type:"button",className:Dr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:W0})}),a&&Q(Fn,{className:AE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Le("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&Q(ln,{children:n("changeStrokeStyle")}),o.sloppiness&&Q(ln,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},oC=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let l=e.openPopup==="compactArrowProperties";return Q("div",{className:"compact-action-item",children:Le(Lr.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[Q(Lr.Trigger,{asChild:!0,children:Q("button",{type:"button",className:Dr("compact-action-button properties-trigger",{active:l}),title:f("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=ht(o,a,d=>qS(d)?d.elbowed?"elbow":d.roundness?"round":"sharp":null,d=>qS(d),d=>d?null:e.currentItemArrowType);return s==="elbow"?mr:s==="round"?pr:dr})()})}),l&&Q(Fn,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},rC=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=py(),l=e.openPopup==="compactTextProperties";return Q("div",{className:"compact-action-item",children:Le(Lr.Root,{open:l,onOpenChange:s=>{s?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[Q(Lr.Trigger,{asChild:!0,children:Q("button",{type:"button",className:Dr("compact-action-button properties-trigger",{active:l}),title:f("labels.textAlign"),onClick:s=>{s.preventDefault(),s.stopPropagation(),l?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:g1})}),e.openPopup==="compactTextProperties"&&Q(Fn,{className:AE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Le("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},iC=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let l=e.openPopup==="compactOtherProperties";return t.showExtraActions?Q("div",{className:"compact-action-item",children:Le(Lr.Root,{open:l,onOpenChange:s=>{o(s?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[Q(Lr.Trigger,{asChild:!0,children:Q("button",{type:"button",className:Dr("compact-action-button properties-trigger",{active:l}),title:f("labels.actions"),onClick:s=>{s.preventDefault(),s.stopPropagation(),o({openPopup:l?null:"compactOtherProperties"})},children:s1})}),l&&Q(Fn,{className:AE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Le("div",{className:"selected-shape-actions",children:[t.layers&&Q(QS,{renderAction:n}),t.align&&Q(eC,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Le("fieldset",{children:[Q("legend",{children:f("labels.actions")}),Le("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},Wz=({renderAction:e,predicates:n})=>n.lineEditor?Q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,aC=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Wi(n,e),a=Rp(e,i,n,o),{container:l}=we();return Le("div",{className:"compact-shape-actions",children:[a.strokeColor&&Q("div",{className:Dr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&Q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&Q("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),Q(nC,{appState:e,renderAction:t,setAppState:r,predicates:a,container:l}),Q(oC,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:l,app:o}),a.lineEditor&&Q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Le(ln,{children:[Q("div",{className:"compact-action-item",children:t("changeFontFamily")}),Q(rC,{appState:e,renderAction:t,setAppState:r,predicates:a,container:l})]}),a.showExtraActions&&Q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&Q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),Q(iC,{appState:e,renderAction:t,predicates:a,setAppState:r,container:l})]})},lC=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r,showUndo:i=!0,showRedo:a=!0})=>{let l=Wi(n,e),s=Rp(e,l,n,o),{container:d}=we(),c=Uz(null),m=c.current?.getBoundingClientRect()?.width??0,p=7+Number(i)+Number(a),u=6,E=32,g=p*E+(p-1)*u,b=E+u,w=m>=g+b,y=m>=g+2*b;return Le(Ke,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:E*1.35,alignItems:"center",gap:u,pointerEvents:"none"},ref:c,children:[Le("div",{className:"mobile-shape-actions__primary",children:[s.strokeColor&&Q("div",{className:Dr("compact-action-item"),children:t("changeStrokeColor")}),s.backgroundColor&&Q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),Q(nC,{appState:e,renderAction:t,setAppState:r,predicates:s,container:d}),Q(oC,{appState:e,renderAction:t,setAppState:r,targetElements:l,predicates:s,container:d,app:o}),Q(Wz,{renderAction:t,predicates:s}),s.text&&Le(ln,{children:[Q("div",{className:"compact-action-item",children:t("changeFontFamily")}),Q(rC,{appState:e,renderAction:t,setAppState:r,predicates:s,container:d})]}),Q(iC,{appState:e,renderAction:t,predicates:s,setAppState:r,container:d,showDuplicate:!y,showDelete:!w})]}),Le("div",{style:{display:"flex",flexDirection:"row",gap:u},children:[i&&Q("div",{className:"compact-action-item",children:t("undo")}),a&&Q("div",{className:"compact-action-item",children:t("redo")}),y&&Q("div",{className:"compact-action-item",children:t("duplicateSelection")}),w&&Q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},sC=({renderAction:e})=>Q(an.Col,{gap:1,className:JS.ZOOM_ACTIONS,children:Le(an.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})});var cC=({showExitZenModeBtn:e})=>Q("button",{type:"button",className:Dr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import Vz from"clsx";import{useState as Yz,useEffect as Kz}from"react";import{THEME as Xz}from"@excalidraw/common";import{jsx as LE,jsxs as Zz}from"react/jsx-runtime";var Np=({delay:e,theme:n})=>{let[t,o]=Yz(!!e);return Kz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:Zz("div",{className:Vz("LoadingMessage",{"LoadingMessage--dark":n===Xz.DARK}),children:[LE("div",{children:LE(Ro,{})}),LE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Op,useEffect as DC}from"react";import vG from"clsx";import{KEYS as NE,capitalizeString as _C}from"@excalidraw/common";import LC from"react";import{DropdownMenu as bG}from"radix-ui";import{CLASSES as xG}from"@excalidraw/common";import $z from"clsx";import{useCallback as jz,useEffect as qz,useRef as Jz}from"react";import{CLASSES as Qz,EVENT as dC,KEYS as eG}from"@excalidraw/common";import{DropdownMenu as mC}from"radix-ui";import{jsx as uc}from"react/jsx-runtime";var pC=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let l=me(),{container:s}=we(),d=Jz(null),c=ra({onClickOutside:n});oa(d,jz(p=>{d.current?.closest(`.${Qz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),qz(()=>{if(!r)return;let p=E=>{E.key===eG.ESCAPE&&(E.preventDefault(),E.stopImmediatePropagation(),c.onClickOutside?.())},u={capture:!0};return document.addEventListener(dC.KEYDOWN,p,u),()=>{document.removeEventListener(dC.KEYDOWN,p,u)}},[c,r]);let m=$z(`dropdown-menu ${t}`,{"dropdown-menu--mobile":l.formFactor==="phone"}).trim();return uc(Jh.Provider,{value:{onSelect:o},children:uc(mC.Portal,{container:s,children:uc(mC.Content,{ref:d,className:m,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:l.formFactor==="phone"?uc(an.Col,{className:"dropdown-menu-container",children:e}):uc(Ke,{className:"dropdown-menu-container",padding:2,children:e})})})})};pC.displayName="DropdownMenuContent";var uC=pC;import{jsx as nG}from"react/jsx-runtime";var tG=({children:e,className:n="",selected:t,...o})=>nG("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),hC=tG;import{DropdownMenu as oG}from"radix-ui";import{jsx as DE}from"react/jsx-runtime";var gC=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let d=Fd(r);return DE(oG.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:DE("a",{...s,href:t,target:"_blank",rel:`noopener ${l}`,className:Bo(i,a),title:s.title??s["aria-label"],children:DE(Fo,{icon:e,shortcut:n,children:o})})})},pl=gC;gC.displayName="DropdownMenuItemLink";import{jsx as rG}from"react/jsx-runtime";var fC=()=>rG("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),EC=fC;fC.displayName="DropdownMenuSeparator";import{DropdownMenu as mG}from"radix-ui";import iG from"clsx";import{DropdownMenu as aG}from"radix-ui";import{useCallback as lG,useState as bC}from"react";import{jsx as RE}from"react/jsx-runtime";var _E=-4,sG=4,xC=({children:e,className:n})=>{let t=me(),o=iG(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=lG(d=>{if(d){let m=d.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=d.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+_E),s(_E+8))}}},[]),[i,a]=bC(sG),[l,s]=bC(_E);return RE(aG.SubContent,{className:o,sideOffset:i,alignOffset:l,collisionPadding:8,ref:r,children:t.formFactor==="phone"?RE(an.Col,{className:"dropdown-menu-container",children:e}):RE(Ke,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},yC=xC;xC.displayName="DropdownMenuSubContent";import{DropdownMenu as cG}from"radix-ui";import{jsx as wC,jsxs as dG}from"react/jsx-runtime";var vC=({children:e,icon:n,shortcut:t,className:o})=>dG(cG.SubTrigger,{className:`${Bo(o)} dropdown-menu__submenu-trigger`,children:[wC(Fo,{icon:n,shortcut:t,children:e}),wC("div",{className:"dropdown-menu__submenu-trigger-icon",children:K0})]}),IC=vC;vC.displayName="DropdownMenuSubTrigger";import TC from"react";var Bp=e=>n=>{let t=TC.Children.toArray(n).find(o=>TC.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},SC=Bp("DropdownMenuTrigger"),CC=Bp("DropdownMenuContent"),PC=Bp("DropdownMenuSubTrigger"),kC=Bp("DropdownMenuSubContent");import{jsxs as pG}from"react/jsx-runtime";var Fp=({children:e})=>{let n=PC(e),t=kC(e);return pG(mG.Sub,{children:[n,t]})};Fp.Trigger=IC;Fp.Content=yC;Fp.displayName="DropdownMenuSub";var _r=Fp;import uG from"clsx";import{DropdownMenu as hG}from"radix-ui";import{jsx as gG}from"react/jsx-runtime";var MC=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=me(),a=uG(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return gG(hG.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},AC=MC;MC.displayName="DropdownMenuTrigger";import{jsx as EG}from"react/jsx-runtime";var fG=e=>EG(nn,{...e,icon:e.checked?sd:gd}),vo=fG;import{jsx as wG,jsxs as yG}from"react/jsx-runtime";var Zn=({children:e,open:n})=>{let t=SC(e),o=CC(e),r=o&&LC.isValidElement(o)?LC.cloneElement(o,{open:n}):o;return wG(bG.Root,{open:n,modal:!1,children:yG("div",{className:xG.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Zn.Trigger=AC;Zn.Content=uC;Zn.Item=nn;Zn.ItemCheckbox=vo;Zn.ItemLink=pl;Zn.ItemCustom=hC;Zn.Group=ri;Zn.Separator=EC;Zn.Sub=_r;var ue=Zn;Zn.displayName="DropdownMenu";import{Fragment as BE,jsx as Ge,jsxs as ul}from"react/jsx-runtime";var IG=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Ft))return null;let t=f("buttons.objectsSnapMode");return Ge($,{type:"toggle",icon:cr,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Ft,"ui")})},TG=({app:e})=>Ge($,{type:"button",icon:ei,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),RC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,l]=Op(!1),[s,d]=Op("rectangle"),[c,m]=Op("arrow");DC(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&d(o.type)},[o.type]),DC(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",w=["rectangle","diamond","ellipse"].map(F=>({type:F,icon:Ae[F].icon,title:_C(f(`toolBar.${F}`)),fillable:Ae[F].fillable})),y=["arrow","line"].map(F=>({type:F,icon:Ae[F].icon,title:_C(f(`toolBar.${F}`)),fillable:Ae[F].fillable})),[x,I]=Op(0),T=32,P=6,C=7,k=C*T+(C-1)*P,M=T+P,_=x>=k+1*M,L=i&&x>=k+(r?3:2)*M,R=x>=k+3*M,z=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(F=>!(_&&F==="text"||(!i||L)&&F==="image"||R&&F==="frame")),K=r&&br.includes(o.type),U=K||z.includes(o.type),D=U?K?Ae[o.type].icon:o.type==="text"?Bn:o.type==="image"?qr:o.type==="frame"?po:o.type==="embeddable"?sr:o.type==="laser"?uo:o.type==="bucketfill"?mo:Ul:Ul,H={app:e,activeTool:o,hideShortcut:!0};return ul("div",{className:"mobile-toolbar",ref:F=>{if(F){let J=F.closest('[data-ui-layout-item="toolbar"]'),re=F.closest(".App-toolbar"),O=J?.getBoundingClientRect().width??F.getBoundingClientRect().width,V=re?Number.parseFloat(getComputedStyle(re).maxWidth):Number.POSITIVE_INFINITY,ce=re?Number.parseFloat(getComputedStyle(re).paddingLeft)+Number.parseFloat(getComputedStyle(re).paddingRight):0;I(Math.max(0,Math.min(O,Number.isFinite(V)?V:O)-ce))}},children:[Ge(sm,{...H}),Ge(ci,{...H,setAppState:t}),r?Ge(us,{...H}):Ge(xa,{...H}),Ge(fs,{...H}),!r&&Ge(Ea,{app:e,options:w,activeTool:o,defaultOption:s,"data-testid":"toolbar-rectangle",onToolChange:F=>{(F==="rectangle"||F==="diamond"||F==="ellipse")&&(d(F),e.setActiveTool({type:F}))},displayedOption:w.find(F=>F.type===s)||w[0]}),!r&&Ge(Ea,{app:e,options:y,activeTool:o,defaultOption:c,"data-testid":"toolbar-arrow",onToolChange:F=>{(F==="arrow"||F==="line")&&(m(F),e.setActiveTool({type:F}))},displayedOption:y.find(F=>F.type===c)||y[0]}),_&&Ge(hs,{...H}),r&&L&&Ge(TG,{app:e}),L&&Ge(gs,{...H}),!r&&R&&Ge(Rw,{...H,hideShortcut:!0}),ul(ue,{open:a,children:[Ge(ue.Trigger,{className:vG("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":U||a}),onToggle:()=>{l(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:D}),ul(ue.Content,{onClickOutside:()=>l(!1),onSelect:()=>l(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&br.map(F=>Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:F}),icon:Ae[F].icon,"data-testid":`toolbar-${F}`,selected:o.type===F,shortcut:lm(F),disabled:ot(e,F),children:f(`toolBar.${F}`)},F)),!r&&Ge("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Ft)&&Ge(ue.Item,{onSelect:()=>n.executeAction(Ft,"ui"),icon:cr,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Qe("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&ul(BE,{children:[r&&Ge("div",{className:"App-toolbar__dropdown-divider"}),Ge(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?so:_o,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:NE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Bn,shortcut:NE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:ot(e,"text"),children:f("toolBar.text")}),i&&!L&&Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:qr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:ot(e,"image"),children:f("toolBar.image")}),!r&&!R&&Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:po,shortcut:NE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:ot(e,"frame"),children:f("toolBar.frame")}),!r&&ul(BE,{children:[Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:sr,"data-testid":"toolbar-embeddable",selected:g,disabled:ot(e,"embeddable"),children:f("toolBar.embeddable")}),Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:ti,shortcut:Go("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:ot(e,"autoshape"),children:f("toolBar.autoshape")}),Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:uo,"data-testid":"toolbar-laser",selected:E,disabled:ot(e,"laser"),children:f("toolBar.laser")}),Ge(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:mo,"data-testid":"toolbar-bucketfill",selected:b,disabled:ot(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&ul(BE,{children:[Ge("div",{className:"App-toolbar__divider"}),Ge(IG,{actionManager:n,app:e})]})]})};import SG from"clsx";import{jsx as CG}from"react/jsx-runtime";var Rr=e=>e.penDetected?CG($,{className:SG("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:h1,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{jsx as hc,jsxs as zp}from"react/jsx-runtime";var PG=({item:e,api:n,appState:t,editorInterface:o,region:r,orientation:i})=>{let a=Er("zoom");return e.render({api:n,appState:t,editorInterface:o,region:r,orientation:i,zoom:a})},NC=["topLeft","topCenter","topRight","middleLeft","middleRight","bottomLeft","bottomCenter","bottomRight"],BC=e=>e.startsWith("middle")?"vertical":"horizontal",FC=e=>e.startsWith("middle")?"side":e.startsWith("top")?"top":"bottom",Gp=({items:e,layout:n,app:t,appState:o,editorInterface:r,className:i,legacyBottomCenter:a,legacyBottomLeft:l})=>{let s=new Map;NC.forEach(g=>s.set(g,[]));let d=e.flatMap((g,b)=>{let w=n?.items?.[g.id]??{};if(w.visible===!1||g.content==null)return[];let y=w.region??g.defaultRegion,x=w.orientation&&w.orientation!=="auto"?w.orientation:g.defaultOrientation&&g.defaultOrientation!=="auto"?g.defaultOrientation:BC(y);return[{id:g.id,region:y,orientation:x,order:w.order??g.defaultOrder??b,content:g.content,islandGroup:g.islandGroup}]}),c=(n?.customItems??[]).flatMap((g,b)=>{if(g.visible===!1)return[];let w=g.region,y=g.orientation&&g.orientation!=="auto"?g.orientation:BC(w);return[{id:`custom:${g.id}`,region:w,orientation:y,order:g.order??1e3+b,content:hc(PG,{item:g,api:t.api,appState:o,editorInterface:r,region:w,orientation:y})}]}),m=a==null?[]:[{id:"legacyFooterCenter",region:"bottomCenter",orientation:"horizontal",order:999,content:a}],p=[...d,...c,...m].sort((g,b)=>g.order-b.order||g.id.localeCompare(b.id)),u=g=>hc("div",{className:"ui-layout__item","data-ui-layout-item":g.id,"data-ui-orientation":g.orientation,"data-viewport-ui":FC(g.region),"data-viewport-ui-name":g.id==="stylesPanel"?"stylesPanel":void 0,children:g.content},g.id);NC.forEach(g=>{let b=p.filter(y=>y.region===g),w=s.get(g);for(let y=0;y<b.length;){let x=b[y],I=x.islandGroup;if(!I){w?.push(u(x)),y++;continue}let T=[x],P=y+1;for(;P<b.length;){let C=b[P];if(C.islandGroup?.id!==I.id||C.orientation!==x.orientation)break;T.push(C),P++}w?.push(hc(Ke,{className:`ui-layout__island-group ${I.className}`,padding:I.padding,"data-viewport-ui":FC(g),style:{display:"flex",alignItems:"center",gap:`${I.gap}px`},children:T.map(u)},`island-group:${I.id}:${g}:${x.id}`)),y=P}}),l!=null&&s.get("bottomLeft")?.unshift(hc("div",{className:"ui-layout__legacy-bottom-left",children:l},"legacy-bottom-left"));let E=g=>hc("div",{className:`ui-layout__region ui-layout__region--${g}`,"data-ui-layout-region":g,style:r.formFactor==="phone"&&g==="bottomLeft"?{alignItems:"center"}:void 0,children:s.get(g)},g);return zp("div",{className:i?`ui-layout ${i}`:"ui-layout",children:[zp("div",{className:"ui-layout__row ui-layout__row--top",children:[E("topLeft"),E("topCenter"),E("topRight")]}),zp("div",{className:"ui-layout__row ui-layout__row--middle",children:[E("middleLeft"),E("middleRight")]}),zp("div",{className:"ui-layout__row ui-layout__row--bottom",children:[E("bottomLeft"),E("bottomCenter"),E("bottomRight")]})]})},Hp=(e,n)=>n.formFactor==="phone"?e?.mobile:n.formFactor==="tablet"?e?.tablet:e?.desktop;import{Fragment as MG,jsx as yt,jsxs as AG}from"react/jsx-runtime";var kG=450,OC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:l,defaultUIEnabled:s,scrollBackToContentUIEnabled:d,app:c,onPenModeToggle:m,uiLayout:p})=>{let{WelcomeScreenCenterTunnel:u,MainMenuTunnel:E,DefaultSidebarTriggerTunnel:g}=gt(),b=d&&e.scrolledOutside,w=s,y=s&&(!e.viewModeEnabled||w),x=b&&!e.openMenu&&!e.openSidebar?yt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(K=>({...Ui(n,K)}))},children:f("buttons.scrollBackToContent")}):null,I=c.props.viewportStatusFrame?.label,T=I?yt(_p,{label:I,border:c.props.viewportStatusFrame?.border}):null,P=c.editorInterface,C=Hp(p,P),k=i?.(!0,e),M=k!=null,_=C?.items?.undo!==void 0,L=C?.items?.redo!==void 0,R=e.openDialog?.name==="elementLinkSelector",z=[{id:"hostTopLeftUI",defaultRegion:"topLeft",defaultOrder:-10,content:!R&&r?.(!0,e)},{id:"mainMenu",defaultRegion:"topLeft",content:R?null:yt(E.Out,{})},{id:"hostTopRightUI",defaultRegion:"topRight",defaultOrder:-10,content:R?null:k},{id:"penMode",defaultRegion:"topRight",content:!R&&!M&&!e.viewModeEnabled&&s?yt(Rr,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}):null},{id:"sidebarTrigger",defaultRegion:"topRight",content:!R&&!M&&!e.viewModeEnabled?yt(g.Out,{}):null},{id:"viewMode",defaultRegion:"bottomLeft",defaultOrder:0,islandGroup:{id:"mobileCanvasActions",className:"mobile-canvas-actions",padding:0,gap:6},content:w&&!e.viewModeOnly?yt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}):null},{id:"smartZoom",defaultRegion:"bottomLeft",defaultOrder:1,islandGroup:{id:"mobileCanvasActions",className:"mobile-canvas-actions",padding:0,gap:6},content:w?yt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")}):null},{id:"stylesPanel",defaultRegion:"bottomLeft",defaultOrder:2,content:s&&!e.viewModeEnabled?yt(lC,{appState:e,elementsMap:c.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:c,setAppState:o,showUndo:!_,showRedo:!L}):null},{id:"undo",defaultRegion:"bottomLeft",content:_&&C?.items?.undo?.visible!==!1&&s&&!e.viewModeEnabled?yt("div",{className:"undo-button-container",children:t.renderAction("undo")}):null},{id:"redo",defaultRegion:"bottomLeft",content:L&&C?.items?.redo?.visible!==!1&&s&&!e.viewModeEnabled?yt("div",{className:"redo-button-container",children:t.renderAction("redo")}):null},{id:"toolbar",defaultRegion:"bottomLeft",defaultOrder:10,content:s&&!e.viewModeEnabled&&!R?yt(Ke,{className:"App-toolbar",padding:1,style:{justifyContent:"flex-start",maxWidth:kG,width:"fit-content"},children:yt(RC,{app:c,actionManager:t,setAppState:o})}):null}];return AG(MG,{children:[a(),yt("div",{className:"App-welcome-screen",children:l&&yt(u.Out,{})}),(y||C!==void 0||r||i)&&yt(Gp,{items:z,layout:C,app:c,appState:e,editorInterface:P,className:"ui-layout--mobile",legacyBottomLeft:y&&x?yt("div",{className:"floating-status-stack",children:x}):null}),!y&&x&&yt("div",{className:"floating-status-stack",children:x}),T&&yt("div",{className:"viewport-status-frame__badge-row",children:T})]})};import YC,{useLayoutEffect as KC,useRef as XC,useState as ZC}from"react";import{newTextElement as $C}from"@excalidraw/element";import FG from"clsx";import{useEffect as OG,useState as zG}from"react";import{KEYS as GG,queryFocusableElements as WC}from"@excalidraw/common";import{useCallback as LG,useState as DG}from"react";var zC=()=>{let[e,n]=DG(null),t=LG(o=>n(o),[]);return[e,t]};import GC from"clsx";import{useRef as _G}from"react";import{createPortal as RG}from"react-dom";import{KEYS as NG}from"@excalidraw/common";import{jsx as HC,jsxs as BG}from"react/jsx-runtime";var UC=e=>{let{closeOnClickOutside:n=!0}=e,t=Cd({className:GC("excalidraw-modal-container",e.portalContainerClassName)}),o=_G(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===NG.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return RG(BG("div",{className:GC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[HC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),HC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Up,jsxs as VC}from"react/jsx-runtime";function HG(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var kn=e=>{let[n,t]=zC(),[o]=zG(document.activeElement),{id:r}=we(),i=me().formFactor==="phone";OG(()=>{if(!n)return;let s=WC(n);setTimeout(()=>{s.length>0&&e.autofocus!==!1&&(s[1]||s[0]).focus()});let d=c=>{if(c.key===GG.TAB){let m=WC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&c.shiftKey?(m[m.length-1].focus(),c.preventDefault()):u===m.length-1&&!c.shiftKey&&(m[0].focus(),c.preventDefault())}};return n.addEventListener("keydown",d),()=>n.removeEventListener("keydown",d)},[n,e.autofocus]);let a=ze(),l=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return Up(UC,{className:FG("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:HG(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:VC(Ke,{ref:t,children:[e.title&&VC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[Up("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Up("button",{className:"Dialog__close",onClick:l,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:un}),Up("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Zo,jsxs as Wp}from"react/jsx-runtime";var UG=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},WG=e=>{let n=XC(null),[t,o]=ZC(null),{theme:r}=ye();KC(()=>{if(!e.spreadsheet){o(null);return}let a=iE(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let l,s=n.current;return(async()=>(l=await Zr(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),l.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(l)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=UG(e.chartType);return Wp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Zo("div",{className:"ChartPreview__canvas",ref:n}),Zo("div",{className:"ChartPreview__label",children:i})]})},VG=e=>{let n=XC(null),{theme:t}=ye();return KC(()=>{if(!e.rawText)return;let o=$C({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Zr([o],{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]),Wp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Zo("div",{className:"ChartPreview__canvas",ref:n}),Zo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},jC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=ct(),[i,a]=ZC(Math.random()),l=YC.useCallback(()=>{a(Math.random())},[]),s=YC.useCallback(()=>{t&&t()},[t]),d=(m,p)=>{o(p),Ye("paste","chart",m),t(),r()},c=m=>{let p=$C({text:m,x:0,y:0});o([p]),Ye("paste","chart","plaintext"),t(),r()};return Zo(kn,{size:"regular",onCloseRequest:s,title:Wp("div",{className:"PasteChartDialog__title",children:[Zo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Zo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:l,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),l())},children:mo})]}),className:"PasteChartDialog",autofocus:!1,children:Wp("div",{className:"container",children:[["bar","line","radar"].map(m=>qa(e,m)?Zo(WG,{chartType:m,spreadsheet:e,colorSeed:i,onClick:d},m):null),n&&Zo(VG,{rawText:n,onClick:c})]})})};import{Fragment as YG,jsx as qC,jsxs as KG}from"react/jsx-runtime";var FE=({heading:e,children:n,...t})=>{let{id:o}=we(),r=qC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return qC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):KG(YG,{children:[r,n]})})};import{Popover as hl}from"radix-ui";import JC from"clsx";import Vp,{useLayoutEffect as XG}from"react";import{supportsResizeObserver as ZG,isShallowEqual as $G}from"@excalidraw/common";import{Fragment as GE,jsx as wt,jsxs as gl}from"react/jsx-runtime";var jG=4,qG=8,OE=38,QC=21,JG=({shouldWrap:e,children:n,username:t})=>e?wt(bt,{label:t||"Unknown user",children:n}):wt(GE,{children:n}),zE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return wt(JG,{username:n.username,shouldWrap:r,children:l},t)},QG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Yp=Vp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=nt(),{container:a}=we(),l=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,k])=>({...k,socketId:C})).filter(C=>C.username?.trim()),d=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[m,p]=Vp.useState(""),u=s.filter(C=>C.username?.toLowerCase().includes(m)),E=Vp.useRef(null);XG(()=>{if(E.current){let C=M=>{b(M)};if(C(E.current.clientWidth),!ZG)return;let k=new ResizeObserver(M=>{for(let _ of M){let{width:L}=_.contentRect;C(L)}});return k.observe(E.current),()=>{k.disconnect()}}},[]);let[g,b]=Vp.useState(jG*OE),w=d?g-QC:g,y=Math.max(1,Math.min(8,Math.floor(w/OE))),x=d?Math.max(0,y-1):y,I=c.slice(0,x),T=d?[...I,d]:I,P=T.map(C=>{let k=zE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?gl(hl.Root,{children:[wt(hl.Trigger,{asChild:!0,children:gl("div",{className:"UserList__pill",children:[k,wt("div",{className:"UserList__pill-chevron",children:Y0})]})}),wt(hl.Portal,{container:a,children:wt(hl.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:gl(Ke,{padding:2,children:[s.length>=qG&&wt(Nd,{placeholder:f("quickSearch.placeholder"),onChange:p}),wt(Bd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:u.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),u.map(M=>zE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),l&&gl(GE,{children:[wt("div",{className:"UserList__menu-divider"}),wt(hl.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:l})})]}),wt(hl.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})})]},C.socketId):k});return n?gl("div",{className:JC("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>zE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),l&&gl(GE,{children:[wt("div",{className:"UserList__menu-divider"}),l]})]}):wt("div",{className:"UserList__wrapper",ref:E,children:wt("div",{className:JC("UserList",e),style:{"--max-avatars":T.length+(d?QC/OE:0)},children:P})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!$G(r,i,QG))return!1}return!0});import{composeEventHandlers as sH}from"@excalidraw/common";import{useLayoutEffect as eH,useRef as tH}from"react";import{jsx as nH}from"react/jsx-runtime";var Mi=(e,n)=>{let t=et(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=gt(),[,a]=i(t),l=tH({preferHost:!1,counter:0});return eH(()=>{let s=l.current;return a(d=>{let c=d+1;return s.counter=c,c}),()=>{a(d=>{let c=d-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:nH(n,{...r})};return o.displayName=e,o};var WE={};m3(WE,{ChangeCanvasBackground:()=>dP,Export:()=>mP,Help:()=>sP,LiveCollaborationTrigger:()=>uP,LoadScene:()=>rP,Preferences:()=>Io,PreferencesToggleGridModeItem:()=>UE,SaveAsImage:()=>aP,SaveToActiveFile:()=>iP,SearchMenu:()=>lP,Socials:()=>pP,ToggleTheme:()=>cP});import aH from"clsx";import{THEME as fc}from"@excalidraw/common";var HE=et({active:!1});async function eP({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Tt.set(HE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import oH from"clsx";import{jsx as tP,jsxs as rH}from"react/jsx-runtime";var Kp=function({onChange:e,value:n,choices:t,name:o}){return tP("div",{className:"RadioGroup",children:t.map(r=>rH("div",{className:oH("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[tP("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as iH,jsx as gc,jsxs as nP}from"react/jsx-runtime";var oP=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let l=me();return nP(iH,{children:[nP("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&gc("div",{className:"dropdown-menu-item__icon",children:a}),gc("label",{className:"dropdown-menu-item__text",children:gc(os,{children:r})}),gc(Kp,{name:i,value:e,onChange:t,choices:o})]}),n&&l.formFactor!=="phone"&&gc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};oP.displayName="DropdownMenuItemContentRadio";var Xp=oP;import{Fragment as wP,jsx as be,jsxs as Ec}from"react/jsx-runtime";var rP=()=>{let{t:e}=_e(),n=nt(),t=ia();return n.isActionEnabled(wa)?be(nn,{icon:cd,onSelect:async()=>{(!t.length||await eP({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:be(ki,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>be("strong",{children:r}),br:()=>be("br",{})})}))&&n.executeAction(wa)},"data-testid":"load-button",shortcut:Qe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};rP.displayName="LoadScene";var iP=()=>{let{t:e}=_e(),n=nt();return n.isActionEnabled(pi)?be(nn,{shortcut:Qe("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(pi),icon:v1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};iP.displayName="SaveToActiveFile";var aP=()=>{let e=ze(),{t:n}=_e();return be(nn,{icon:S1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Qe("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};aP.displayName="SaveAsImage";var lP=e=>{let{t:n}=_e(),t=nt();return be(nn,{icon:hn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Xs)},shortcut:Qe("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};lP.displayName="SearchMenu";var sP=()=>{let{t:e}=_e(),n=nt();return be(nn,{"data-testid":"help-menu-item",icon:ea,onSelect:()=>n.executeAction(ui),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};sP.displayName="Help";var cP=e=>{let{t:n}=_e(),t=ye(),o=nt(),r=Qe("toggleTheme"),i=St();return o.isActionEnabled(om)?e?.allowSystemTheme?be(Xp,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:fc.LIGHT,label:Yl,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:fc.DARK,label:Vl,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:F0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):be(nn,{onSelect:a=>{a.preventDefault(),o.executeAction(om)},icon:t.theme===fc.DARK?Yl:Vl,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===fc.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===fc.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};cP.displayName="ToggleTheme";var dP=()=>{let{t:e}=_e(),n=ye(),t=nt(),o=St();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Ec("div",{style:{marginTop:"0.75rem"},children:[be("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),be("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};dP.displayName="ChangeCanvasBackground";var mP=()=>{let{t:e}=_e(),n=ze();return be(nn,{icon:Kl,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};mP.displayName="Export";var pP=()=>{let{t:e}=_e();return Ec(wP,{children:[be(pl,{icon:x1,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),be(pl,{icon:w1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),be(pl,{icon:y1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};pP.displayName="Socials";var uP=({onSelect:e,isCollaborating:n})=>{let{t}=_e();return be(nn,{"data-testid":"collab-button",icon:dd,className:aH({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};uP.displayName="LiveCollaborationTrigger";var hP=()=>{let{t:e}=_e(),n=ct(),t=ye();return be(vo,{checked:t.activeTool.locked,shortcut:Qe("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},gP=()=>{let{t:e}=_e(),n=ye(),t=ze();return be(Xp,{name:"boxSelectionMode",icon:gd,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},fP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(vo,{checked:t.objectsSnapModeEnabled,shortcut:Qe("objectsSnapMode"),onSelect:o=>{n.executeAction(Ft),o.preventDefault()},children:e("buttons.objectsSnapMode")})},EP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(vo,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Ps),o.preventDefault()},children:e("labels.arrowBinding")})},bP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(vo,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ks),o.preventDefault()},children:e("labels.midpointSnapping")})},UE=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(vo,{checked:t.gridModeEnabled,shortcut:Qe("gridMode"),onSelect:o=>{n.executeAction(ka),o.preventDefault()},children:e("labels.toggleGrid")})},xP=()=>{let{t:e}=_e(),n=nt(),t=ye();return t.viewModeOnly?null:be(vo,{checked:t.viewModeEnabled,shortcut:Qe("viewMode"),onSelect:o=>{n.executeAction(Wa),o.preventDefault()},children:e("labels.viewMode")})},lH=()=>{let{t:e}=_e(),n=ct(),t=me();if(t.formFactor!=="desktop")return null;let o=e("labels.preferences_myocDesktopUIDescription");return be(Xp,{name:"myocDesktopUIMode",value:t.desktopUIMode,onChange:r=>n.setDesktopUIMode(r),choices:[{value:"full",label:e("labels.preferences_myocDesktopUIFull"),ariaLabel:`${e("labels.preferences_myocDesktopUIFull")}. ${o}`},{value:"compact",label:e("labels.preferences_myocDesktopUICompact"),ariaLabel:`${e("labels.preferences_myocDesktopUICompact")}. ${o}`}],children:be("span",{title:o,children:e("labels.preferences_myocDesktopUISize")})})},yP=()=>{let{t:e}=_e(),n=nt(),t=ye();return be(vo,{checked:t.stats.open,shortcut:Qe("stats"),onSelect:o=>{n.executeAction(Tr),o.preventDefault()},children:e("stats.fullTitle")})},Io=({children:e,additionalItems:n})=>{let{t}=_e();return Ec(_r,{children:[be(_r.Trigger,{icon:X0,children:t("labels.preferences")}),Ec(_r.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Ec(wP,{children:[be(lH,{}),be(gP,{}),be(hP,{}),be(fP,{}),be(UE,{}),be(xP,{}),be(yP,{}),be(EP,{}),be(bP,{})]}),n]})]})};Io.ToggleToolLock=hP;Io.BoxSelectionMode=gP;Io.ToggleSnapMode=fP;Io.ToggleArrowBinding=EP;Io.ToggleMidpointSnapping=bP;Io.ToggleGridMode=UE;Io.ToggleViewMode=xP;Io.ToggleElementProperties=yP;Io.displayName="Preferences";import{jsx as Zp,jsxs as VE}from"react/jsx-runtime";var cH=Object.assign(Mi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=gt(),o=me(),r=ye(),i=St(),a=ze();return Zp(t.In,{children:VE(ue,{open:r.openMenu==="canvas",children:[Zp(ue.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:E1}),VE(ue.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:sH(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&VE("fieldset",{className:"UserList-Wrapper",children:[Zp("legend",{children:f("labels.collaborators")}),Zp(Yp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ue.Trigger,Item:ue.Item,ItemLink:ue.ItemLink,ItemCustom:ue.ItemCustom,Group:ue.Group,Separator:ue.Separator,Sub:_r,DefaultItems:WE}),Ht=cH;import dH from"clsx";import{forwardRef as mH,useState as pH}from"react";import{isPromiseLike as uH}from"@excalidraw/common";import{jsx as $p,jsxs as hH}from"react/jsx-runtime";var Nr=mH(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d,disabled:c},m)=>{let[p,u]=pH(!1),E=async b=>{let w=t?.(b);if(uH(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Xc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":d;return i=g==="success"?"success":i,$p("button",{className:dH("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:E,type:"button","aria-label":o,ref:m,disabled:c||g==="loading"||g==="success",children:hH("div",{className:"ExcButton__contents",children:[g==="loading"?$p(Ro,{className:"ExcButton__statusIcon"}):g==="success"&&$p("div",{className:"ExcButton__statusIcon",children:C0}),n&&$p("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as fl,jsxs as EH}from"react/jsx-runtime";var jp=({title:e,children:n,actionLabel:t,onClick:o})=>EH("div",{className:"OverwriteConfirm__Actions__Action",children:[fl("h4",{children:e}),fl("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),fl(Nr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),gH=()=>{let{t:e}=_e(),n=nt(),t=ze();return fl(jp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(wm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},fH=()=>{let{t:e}=_e(),n=nt();return fl(jp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Ss,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},YE=Object.assign(({children:e})=>fl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:gH,SaveToDisk:fH});import{jsx as Br,jsxs as vP}from"react/jsx-runtime";var qp=Object.assign(Mi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=gt(),[t,o]=$e(HE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Br(n.In,{children:Br(kn,{onCloseRequest:r,title:!1,size:916,children:vP("div",{className:"OverwriteConfirm",children:[Br("h3",{children:t.title}),vP("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Br("div",{className:"OverwriteConfirm__Description__icon",children:P0}),Br("div",{children:t.description}),Br("div",{className:"OverwriteConfirm__Description__spacer"}),Br(Nr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Br(YE,{children:e})]})})})}),{Actions:YE,Action:jp});import{round as pk}from"@excalidraw/math";import NU from"clsx";import BU from"lodash.throttle";import{useEffect as uk,useMemo as ib,useState as FU,memo as OU}from"react";import{STATS_PANELS as au}from"@excalidraw/common";import{getCommonBounds as zU}from"@excalidraw/element";import{getUncroppedWidthAndHeight as GU}from"@excalidraw/element";import{isImageElement as ab}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as HU}from"@excalidraw/element";import{elementsAreInSameGroup as UU}from"@excalidraw/element";import{degreesToRadians as AP,radiansToDegrees as RP}from"@excalidraw/math";import{getBoundTextElement as LP}from"@excalidraw/element";import{isArrowElement as DP,isElbowArrow as LH}from"@excalidraw/element";import{updateBindings as _P}from"@excalidraw/element";import SH from"clsx";import{useEffect as kP,useRef as Qp,useState as CH}from"react";import{EVENT as xl,KEYS as PH,cloneJSON as KE}from"@excalidraw/common";import{deepCopyElement as kH}from"@excalidraw/element";import{CaptureUpdateAction as MP}from"@excalidraw/element";import{pointFrom as Fr,pointRotateRads as Jp}from"@excalidraw/math";import{getBoundTextElement as bH,getNonDeletedElements as xH,isBindingElement as yH,unbindBindingElement as IP}from"@excalidraw/element";import{isFrameLikeElement as CP}from"@excalidraw/element";import{getSelectedGroupIds as wH,getElementsInGroup as vH,isInGroup as IH}from"@excalidraw/element";import{getFrameChildren as TH}from"@excalidraw/element";import{updateBindings as TP}from"@excalidraw/element";import{DRAGGING_THRESHOLD as SP}from"@excalidraw/common";var PP=.01,bc=10,$t=(e,n)=>!(n==="angle"&&CP(e)),je=(e,n)=>{let t=e+n/2;return t-t%n},El=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var Ai=(e,n,t,o,r,i,a=!0)=>{if(yH(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<SP&&Math.abs(n-t.y)<SP)return;IP(t,"start",o),IP(t,"end",o)}let l=o.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[d,c]=[t.x+t.width/2,t.y+t.height/2],[m,p]=Jp(Fr(t.x,t.y),Fr(d,c),t.angle),u=e-m,E=n-p,[g,b]=Jp(Fr(e,n),Fr(d+u,c+E),-t.angle);o.mutateElement(s,{x:g,y:b},{informMutation:a,isDragging:!1}),TP(s,o,r);let w=bH(t,i);if(w){let y=l.get(w.id);y&&o.mutateElement(y,{x:w.x+u,y:w.y+E},{informMutation:a,isDragging:!1})}if(CP(t)){let y=TH(i,t.id);y.forEach(x=>{let I=l.get(x.id);if(!I)return;let[T,P]=[x.x+x.width/2,x.y+x.height/2],[C,k]=Jp(Fr(x.x,x.y),Fr(T,P),x.angle),M=Math.round(C+u),_=Math.round(k+E),[L,R]=Jp(Fr(M,_),Fr(T+u,P+E),-x.angle);o.mutateElement(I,{x:L,y:R},{informMutation:a,isDragging:!1}),TP(I,o,r,{simultaneouslyUpdated:xH(y)})})}},bl=(e,n)=>{let o=wH(n).map(r=>vH(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!IH(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as XE,jsxs as AH}from"react/jsx-runtime";var MH=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:c=1,dragFinishedCallback:m})=>{let p=ct(),u=ze(),E=Qp(null),g=Qp(null),[b,w]=CH(o.toString()),y=Qp(null);y.current||(y.current={originalAppState:KE(d),originalElements:r,lastUpdatedValue:b,updatePending:!1}),kP(()=>{let T=o.toString();w(T),y.current.lastUpdatedValue=T},[o]);let x=(T,P,C)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let k=Number(T);if(isNaN(k)){w(o.toString());return}let M=Number(k.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(M-_)>=PP)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:P,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:M,property:l,originalAppState:C,setInputValue:L=>w(String(L)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:MP.IMMEDIATELY}))},I=Qp({});return I.current.handleInputValue=x,kP(()=>{let T=E.current,P=I.current;return()=>{let C=T?.value;C&&P.handleInputValue?.(C,y.current.originalElements,y.current.originalAppState),window.removeEventListener(xl.POINTER_MOVE,P.onPointerMove,!1),window.removeEventListener(xl.POINTER_UP,P.onPointerUp,!1)}},[i]),i?AH("div",{className:SH("drag-input-container",!i&&"disabled"),"data-testid":e,children:[XE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let P=Number(E.current.value);isNaN(P)&&(P=0);let C=null,k=p.scene.getNonDeletedElements().reduce((U,D)=>(U.set(D.id,kH(D)),U),new Map),M=r.map(U=>k.get(U.id)),_=KE(d),L=0,R=0,z=U=>{if(C&&k!==null&&M!==null){let D=U.clientX-C.x;D!==0&&(R+=D,Math.abs(R)>=c&&(R=Math.sign(R)*Math.floor(Math.abs(R)/c),L+=R,t({accumulatedChange:L,instantChange:R,originalElements:M,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:U.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:H=>w(String(H)),app:p,setAppState:u}),R=0))}C={x:U.clientX,y:U.clientY}},K=()=>{window.removeEventListener(xl.POINTER_MOVE,z,!1),p.syncActionResult({captureUpdate:MP.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:M,originalAppState:_}),C=null,L=0,R=0,M=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(xl.POINTER_UP,K,!1)};I.current.onPointerMove=z,I.current.onPointerUp=K,window.addEventListener(xl.POINTER_MOVE,z,!1),window.addEventListener(xl.POINTER_UP,K,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?XE(Hd,{icon:n}):e}),XE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let P=T.target;P instanceof HTMLInputElement&&T.key===PH.ENTER&&(x(P.value,r,d),p.focusContainer())}},ref:E,value:b,onChange:T=>{y.current.updatePending=!0,w(T.target.value)},onFocus:T=>{T.target.select(),y.current.originalElements=r,y.current.originalAppState=KE(d)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},vt=MH;import{jsx as NH}from"react/jsx-runtime";var DH=15,_H=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=n[0];if(l&&!LH(l)){let s=a.get(l.id);if(!s)return;if(o!==void 0){let E=AP(o);r.mutateElement(s,{angle:E}),_P(s,r,i.state);let g=LP(s,a);g&&!DP(s)&&r.mutateElement(g,{angle:E});return}let d=Math.round(RP(l.angle)*100)/100,c=Math.round(e),m=(d+c)%360;t&&(m=je(m,DH)),m=m<0?m+360:m;let p=AP(m);r.mutateElement(s,{angle:p}),_P(s,r,i.state);let u=LP(s,a);u&&!DP(s)&&r.mutateElement(u,{angle:p})}},RH=({element:e,scene:n,appState:t,property:o})=>NH(vt,{label:"A",icon:pd,value:Math.round(RP(e.angle)%360*100)/100,elements:[e],dragInputCallback:_H,editable:$t(e,"angle"),scene:n,appState:t,property:o}),NP=RH;import{jsx as FH}from"react/jsx-runtime";var BP=5,BH=({property:e,scene:n,appState:t,setAppState:o})=>FH(vt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{o(s=>{let d;return r?d=r:i&&(d=a?je(s.gridStep+BP*Math.sign(i),BP):s.gridStep+i),d?(d=Dx(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),FP=BH;import{clamp as eu,round as ZE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as tu}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as OP,getNonDeletedElements as OH,getUncroppedWidthAndHeight as HP}from"@excalidraw/element";import{resizeSingleElement as zP}from"@excalidraw/element";import{isImageElement as UP}from"@excalidraw/element";import{isFrameLikeElement as $E}from"@excalidraw/element";import{getElementsInResizingFrame as jE}from"@excalidraw/element";import{replaceAllElementsInFrame as WP}from"@excalidraw/element";import{jsx as WH}from"react/jsx-runtime";var GP=10,zH=e=>e.type==="image",GH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:c,setAppState:m})=>{let p=d.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||zH(u),b=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!UP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:P,height:C}=HP(w),k=y.naturalWidth/P,M=y.naturalHeight/C,_=I?y.width+y.x:y.naturalWidth-y.x,L=T?y.height+y.y:y.naturalHeight-y.y,R=OP*k,z=OP*M;if(i!==void 0){if(a==="width"){let F=i*k,J=eu(F,R,_);x={...x,width:J,x:I?y.x+y.width-J:y.x}}else if(a==="height"){let F=i*M,J=eu(F,z,L);x={...x,height:J,y:T?y.y+y.height-J:y.y}}d.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/P),height:x.height/(y.naturalHeight/C)});return}let K=a==="width"?s:0,U=a==="height"?s:0,D=eu(y.width+K,R,_),H=eu(y.height+U,R,L);x={...y,x:I?y.x+y.width-D:y.x,y:T?y.y+y.height-H:y.y,width:D,height:H},d.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/P),height:x.height/(y.naturalHeight/C)});return}if(i!==void 0){let w=Math.max(a==="width"?i:g?i*b:u.width,tu),y=Math.max(a==="height"?i:g?i/b:u.height,tu);if(zP(w,y,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),$E(E)){let x=jE(d.getElementsIncludingDeleted(),E,l,d.getNonDeletedElementsMap()),I=WP(d.getElementsIncludingDeleted(),x,E);d.replaceAllElements(I)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,u.width+w);a==="width"&&(r?x=je(x,GP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=je(I,GP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(tu,I),x=Math.max(tu,x),zP(x,I,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),$E(E)){let T=OH(jE(d.getElementsIncludingDeleted(),E,l,d.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},HH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&$E(a)){let l=jE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),s=WP(n.scene.getElementsIncludingDeleted(),l,a);n.scene.replaceAllElements(s),e({elementsToHighlight:null})}},UH=({property:e,element:n,scene:t,appState:o})=>{let r=ZE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&UP(n)&&n.crop){let{width:i,height:a}=HP(n);if(e==="width"){let l=i/n.crop.naturalWidth;r=ZE(n.crop.width*l,2)}if(e==="height"){let l=a/n.crop.naturalHeight;r=ZE(n.crop.height*l,2)}}return WH(vt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:GH,value:r,editable:$t(n,e),scene:t,appState:o,property:e,dragFinishedCallback:HH})},qE=UH;import{getBoundTextElement as VH,redrawTextBoundingBox as YH}from"@excalidraw/element";import{hasBoundTextElement as KH,isTextElement as YP}from"@excalidraw/element";import{jsx as jH}from"react/jsx-runtime";var VP=4,XH=4,ZH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let l=i.get(a.id);if(!l||!YP(l))return;let s;if(o!==void 0)s=Math.max(Math.round(o),VP);else if(a.type==="text"){let d=Math.round(a.fontSize),c=Math.round(e);s=Math.max(d+c,VP),t&&(s=je(s,XH))}s&&(r.mutateElement(l,{fontSize:s}),YH(l,r.getContainerElement(l),r))}},$H=({element:e,scene:n,appState:t,property:o})=>{let r=YP(e)?e:KH(e)?VH(e,n.getNonDeletedElementsMap()):null;return r?jH(vt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:ZH,icon:Qr,appState:t,scene:n,property:o}):null},KP=$H;import{degreesToRadians as XP,radiansToDegrees as jP}from"@excalidraw/math";import{getBoundTextElement as ZP}from"@excalidraw/element";import{isArrowElement as $P}from"@excalidraw/element";import{isInGroup as JE}from"@excalidraw/element";import{jsx as eU}from"react/jsx-runtime";var qH=15,JH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=n.map(d=>a.get(d.id)).filter(d=>d&&!JE(d)&&$t(d,r)),s=n.filter(d=>!JE(d)&&$t(d,r));if(o!==void 0){let d=XP(o);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:d});let m=ZP(c,a);m&&!$P(c)&&i.mutateElement(m,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let c=l[d];if(!c)continue;let m=s[d],p=Math.round(jP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=je(E,qH)),E=E<0?E+360:E;let g=XP(E);i.mutateElement(c,{angle:g});let b=ZP(c,a);b&&!$P(c)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},QH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(s=>!JE(s)&&$t(s,"angle")),i=r.map(s=>Math.round(jP(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>$t(s,"angle"));return eU(vt,{label:"A",icon:pd,value:a,elements:e,dragInputCallback:JH,editable:l,appState:t,scene:n,property:o})},qP=QH;import{pointFrom as tk}from"@excalidraw/math";import{useMemo as nU}from"react";import{MIN_WIDTH_OR_HEIGHT as Or}from"@excalidraw/common";import{getElementsInResizingFrame as QE,getNonDeletedElements as oU,isFrameLikeElement as eb,replaceAllElementsInFrame as rk,updateBoundElements as rU}from"@excalidraw/element";import{rescalePointsInElement as iU,resizeSingleElement as nk}from"@excalidraw/element";import{getBoundTextElement as aU,handleBindTextResize as lU}from"@excalidraw/element";import{isTextElement as ik}from"@excalidraw/element";import{MIME_TYPES as Li}from"@excalidraw/common";import{getNonDeletedElements as JP}from"@excalidraw/element";var nu=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let l=JP($r(e,null,{deleteInvisibleElements:!0})),s=Yi(n,null),{exportBackground:d,viewBackgroundColor:c}=s;return Qc(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},QP=async e=>{let{mimeType:n=Li.png,quality:t}=e;n===Li.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Li.png}" mimeType`),n==="image/jpg"&&(n=Li.jpg),n===Li.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Li.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await nu(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===Li.png&&e.appState?.exportEmbedScene&&(a=await Vx({blob:a,metadata:Fl(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},ek=async({elements:e,appState:n=ar(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let s=JP($r(e,null,{deleteInvisibleElements:!0})),c={...Yi(n,null),exportPadding:o};return Zr(s,c,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},tU=async e=>{if(e.type==="svg"){let n=await ek(e);await go(n.outerHTML)}else if(e.type==="png")await xm(QP(e));else if(e.type==="json")await fm(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as S7e}from"@excalidraw/element";import{getCommonBounds as ou}from"@excalidraw/element";import{jsx as uU}from"react/jsx-runtime";var yl=10,sU=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,l=o.height*t,s=e+r*t,d=n+i*t;return{width:a,height:l,x:s,y:d,...iU(o,a,l,!1),...ik(o)?{fontSize:o.fontSize*t}:{}}},cU=(e,n,t,o,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=sU(e,n,o,i);l.mutateElement(r,d);let c=aU(i,a);if(c){let m=c.fontSize*o;rU(r,l);let p=s.get(c.id);p&&ik(p)&&(l.mutateElement(p,{fontSize:m}),lU(r,l,t==="width"?"e":"s",!0))}},ok=(e,n,t,o,r,i,a,l,s,d)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let c=n/t;for(let m=0;m<l.length;m++){let p=l[m],u=a[m];cU(r[0],r[1],i,c,u,p,s,d)}},dU=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let c=a.getNonDeletedElementsMap(),m=bl(n,o);if(i!==void 0){for(let g of m){let b=El(g,c,t);if(b.length>1){let w=b.map(R=>R.latest),y=b.map(R=>R.original),[x,I,T,P]=ou(y),C=T-x,k=P-I,M=C/k,_=Math.max(Or,l==="width"?Math.max(0,i):C),L=Math.max(Or,l==="height"?Math.max(0,i):k);ok(_,L,k,M,tk(x,I),l,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&$t(y,l)){let I=l==="width"?Math.max(0,i):y.width;l==="width"&&(r?I=je(I,yl):I=Math.round(I));let T=l==="height"?Math.max(0,i):y.height;if(l==="height"&&(r?T=je(T,yl):T=Math.round(T)),I=Math.max(Or,I),T=Math.max(Or,T),nk(I,T,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),eb(y)){let P=QE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),C=rk(a.getElementsIncludingDeleted(),P,y);a.replaceAllElements(C)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,E=[];for(let g of m){let b=El(g,c,t);if(b.length>1){let w=b.map(R=>R.latest),y=b.map(R=>R.original),[x,I,T,P]=ou(y),C=T-x,k=P-I,M=C/k,_=Math.max(0,C+p);l==="width"&&(r?_=je(_,yl):_=Math.round(_));let L=Math.max(0,k+u);l==="height"&&(r?L=je(L,yl):L=Math.round(L)),_=Math.max(Or,_),L=Math.max(Or,L),ok(_,L,k,M,tk(x,I),l,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&$t(y,l)){let I=Math.max(0,x.width+p);l==="width"&&(r?I=je(I,yl):I=Math.round(I));let T=Math.max(0,x.height+u);if(l==="height"&&(r?T=je(T,yl):T=Math.round(T)),I=Math.max(Or,I),T=Math.max(Or,T),nk(I,T,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),eb(y)){let P=oU(QE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...P)}}}}s({elementsToHighlight:E}),a.triggerUpdate()},mU=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&eb(a)){let l=QE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),s=rk(n.scene.getElementsIncludingDeleted(),l,a);n.scene.replaceAllElements(s),e({elementsToHighlight:null})}},pU=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=nU(()=>o.map(d=>{let c=El(d,t);if(c.length>1){let[p,u,E,g]=ou(c.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=c;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return uU(vt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:dU,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:mU})},tb=pU;import{getBoundTextElement as hU,redrawTextBoundingBox as ak}from"@excalidraw/element";import{hasBoundTextElement as gU,isTextElement as fU}from"@excalidraw/element";import{isInGroup as EU}from"@excalidraw/element";import{jsx as vU}from"react/jsx-runtime";var lk=4,bU=4,xU=(e,n)=>e.reduce((t,o)=>{if(!o||EU(o))return t;if(fU(o))return t.push(o),t;if(gU(o)){let r=hU(o,n);if(r)return t.push(r),t}return t},[]),yU=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(s=>i.get(s.id)),l;if(o){l=Math.max(Math.round(o),lk);for(let s of a)r.mutateElement(s,{fontSize:l}),ak(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=n;for(let d=0;d<a.length;d++){let c=a[d],m=s[d],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,lk);t&&(E=je(E,bU)),r.mutateElement(c,{fontSize:E}),ak(c,r.getContainerElement(c),r)}r.triggerUpdate()}},wU=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=xU(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return vU(vt,{label:"F",icon:Qr,elements:i,dragInputCallback:yU,value:l,editable:s,scene:n,property:o,appState:t})},sk=wU;import{pointFrom as zr,pointRotateRads as ru}from"@excalidraw/math";import{useMemo as IU}from"react";import{isTextElement as TU}from"@excalidraw/element";import{getCommonBounds as nb}from"@excalidraw/element";import{jsx as MU}from"react/jsx-runtime";var SU=(e,n,t,o,r,i,a)=>{for(let l=0;l<o.length;l++){let s=o[l],[d,c]=[s.x+s.width/2,s.y+s.height/2],[m,p]=ru(zr(s.x,s.y),zr(d,c),s.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;Ai(u,E,s,i,a,r,!1)}},CU=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=nb(t),d=e-l,c=n-s;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!TU(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=ru(zr(u.x,u.y),zr(E,g),u.angle);Ai(b+d,w+c,p,r,i,o,!1)}}},PU=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let d=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of bl(n,l)){let E=El(u,d,t);if(E.length>1){let[g,b,,]=nb(E.map(x=>x.latest));CU(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,s.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&$t(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=ru(zr(g.x,g.y),zr(w,y),g.angle);Ai(i==="x"?r:x,i==="y"?r:I,g,a,s.state,t,!1)}}}a.triggerUpdate();return}let c=o?je(e,bc):e;SU(i,i==="x"?c:0,i==="y"?c:0,n,t,a,s.state),a.triggerUpdate()},kU=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=IU(()=>o.map(s=>{let d=Object.keys(s).map(g=>t.get(g)).filter(g=>g!==void 0);if(d.length>1){let[g,b]=nb(d);return Math.round((e==="x"?g:b)*100)/100}let[c]=d,[m,p]=[c.x+c.width/2,c.y+c.height/2],[u,E]=ru(zr(c.x,c.y),zr(m,p),c.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return MU(vt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:PU,value:l,property:e,scene:r,appState:i})},ob=kU;import{clamp as xc,pointFrom as iu,pointRotateRads as dk,round as ck}from"@excalidraw/math";import{getFlipAdjustedCropPosition as AU,getUncroppedWidthAndHeight as LU}from"@excalidraw/element";import{isImageElement as mk}from"@excalidraw/element";import{jsx as RU}from"react/jsx-runtime";var DU=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:d})=>{let c=l.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=dk(iu(m.x,m.y),iu(p,u),m.angle);if(s.croppingElementId===m.id){let I=c.get(m.id);if(!I||!mk(I)||!I.crop)return;let T=I.crop,P=T,C=I.scale[0]===-1,k=I.scale[1]===-1,{width:M,height:_}=LU(I);if(i!==void 0){if(a==="x"){let z=i*(T.naturalWidth/M);C?P={...T,x:xc(T.naturalWidth-z-T.width,0,T.naturalWidth-T.width)}:P={...T,x:xc(i*(T.naturalWidth/M),0,T.naturalWidth-T.width)}}a==="y"&&(P={...T,y:xc(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),l.mutateElement(I,{crop:P});return}let L=(a==="x"?n:0)*(C?-1:1),R=(a==="y"?n:0)*(k?-1:1);P={...T,x:xc(T.x+L,0,T.naturalWidth-T.width),y:xc(T.y+R,0,T.naturalHeight-T.height)},l.mutateElement(I,{crop:P});return}if(i!==void 0){Ai(a==="x"?i:E,a==="y"?i:g,m,l,d.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?je(m.x+b,bc):E+b):E,x=a==="y"?Math.round(r?je(m.y+w,bc):g+w):g;Ai(y,x,m,l,d.state,o)},_U=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=dk(iu(n.x,n.y),iu(n.x+n.width/2,n.y+n.height/2),n.angle),a=ck(e==="x"?r:i,2);if(o.croppingElementId===n.id&&mk(n)&&n.crop){let l=AU(n);l&&(a=ck(e==="x"?l.x:l.y,2))}return RU(vt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:DU,scene:t,value:a,property:e,appState:o})},rb=_U;import{Fragment as lb,jsx as ie,jsxs as jt}from"react/jsx-runtime";var WU=50,yc=e=>{let n=on(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=Pr(e.app);return ie(VU,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Xe=({children:e,columns:n=1,heading:t,style:o,...r})=>ie("div",{className:NU("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Xe.displayName="StatsRow";var lu=({children:e,order:n,style:t,...o})=>ie("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});lu.displayName="StatsRows";yc.StatsRow=Xe;yc.StatsRows=lu;var VU=OU(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),c=ze(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&ab(m),E=u?GU(m):null,[g,b]=FU({width:0,height:0}),w=ib(()=>BU(I=>{let T=zU(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},WU),[]);uk(()=>{w(s)},[i,s,w]),uk(()=>()=>w.cancel(),[w]);let y=ib(()=>bl(o,r),[o,r]),x=ib(()=>HU(o),[o]);return ie("div",{className:"exc-stats",children:jt(Ke,{padding:3,children:[jt("div",{className:"title",children:[ie("h2",{children:f("stats.title")}),ie("div",{className:"close",onClick:n,children:un})]}),jt(ls,{label:ie("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&au.generalStats),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^au.generalStats}})),children:[jt(lu,{children:[ie(Xe,{heading:!0,children:f("stats.scene")}),jt(Xe,{columns:2,children:[ie("div",{children:f("stats.shapes")}),ie("div",{children:s.length})]}),jt(Xe,{columns:2,children:[ie("div",{children:f("stats.width")}),ie("div",{children:g.width})]}),jt(Xe,{columns:2,children:[ie("div",{children:f("stats.height")}),ie("div",{children:g.height})]}),a&&jt(lb,{children:[ie(Xe,{heading:!0,children:"Canvas"}),ie(Xe,{children:ie(FP,{property:"gridStep",scene:l,appState:r,setAppState:c})})]})]}),t?.(s,r)]}),!x&&o.length>0&&ie("div",{id:"elementStats",style:{marginTop:12},children:ie(ls,{label:ie("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&au.elementProperties),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^au.elementProperties}})),children:jt(lu,{children:[m&&jt(lb,{children:[u&&ie(Xe,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&ab(m)&&E&&jt(Xe,{columns:2,children:[ie("div",{children:f("stats.width")}),ie("div",{children:pk(E.width,2)})]}),r.croppingElementId&&ab(m)&&E&&jt(Xe,{columns:2,children:[ie("div",{children:f("stats.height")}),ie("div",{children:pk(E.height,2)})]}),ie(Xe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ie(Xe,{children:ie(rb,{element:m,property:"x",elementsMap:d,scene:l,appState:r})}),ie(Xe,{children:ie(rb,{element:m,property:"y",elementsMap:d,scene:l,appState:r})}),ie(Xe,{children:ie(qE,{property:"width",element:m,scene:l,appState:r})}),ie(Xe,{children:ie(qE,{property:"height",element:m,scene:l,appState:r})}),ie(Xe,{children:ie(NP,{property:"angle",element:m,scene:l,appState:r})}),ie(Xe,{children:ie(KP,{property:"fontSize",element:m,scene:l,appState:r})})]}),p&&jt(lb,{children:[UU(p)&&ie(Xe,{heading:!0,children:f("element.group")}),jt(Xe,{columns:2,style:{margin:"0.3125rem 0"},children:[ie("div",{children:f("stats.shapes")}),ie("div",{children:o.length})]}),ie(Xe,{children:ie(ob,{property:"x",elements:p,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),ie(Xe,{children:ie(ob,{property:"y",elements:p,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),ie(Xe,{children:ie(tb,{property:"width",elements:p,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),ie(Xe,{children:ie(tb,{property:"height",elements:p,elementsMap:d,atomicUnits:y,scene:l,appState:r})}),ie(Xe,{children:ie(qP,{property:"angle",elements:p,scene:l,appState:r})}),ie(Xe,{children:ie(sk,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:d})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as nW,useEffect as gk,useState as fk}from"react";import{normalizeLink as oW,KEYS as mb}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as rW,getLinkIdAndTypeFromSelection as iW}from"@excalidraw/element";import YU from"clsx";import{jsx as su,jsxs as XU}from"react/jsx-runtime";var KU=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return XU("button",{className:YU("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:n,...l,children:[o&&su("div",{style:a?{visibility:"hidden"}:{},children:o}),su("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&su("div",{style:{position:"absolute",inset:0},children:su(Ro,{})})]})},sb=KU;import cb from"clsx";import{forwardRef as qU,useRef as JU,useImperativeHandle as QU,useLayoutEffect as eW,useState as tW}from"react";import ZU from"clsx";import{composeEventHandlers as $U}from"@excalidraw/common";import{jsx as jU}from"react/jsx-runtime";var Mn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>jU("button",{onClick:$U(i.onClick,a=>{n()}),type:e,className:ZU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as db,jsxs as hk}from"react/jsx-runtime";var cu=qU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,type:c,...m},p)=>{let u=JU(null);QU(p,()=>u.current),eW(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=tW(!1);return hk("div",{className:cb("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,n&&db("div",{className:"ExcTextField__label",children:n}),hk("div",{className:cb("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[db("input",{className:cb({"is-redacted":"value"in m&&m.value&&l&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:c}),l&&db(Mn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?k0:ni})]})]})});import{jsx as wl,jsxs as du}from"react/jsx-runtime";var aW=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=rW})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=fk(a),[d,c]=fk(!1);gk(()=>{let p=de(i,t),u=a;if(p.length>0&&r){let E=iW(p,t);E&&(u=oW(r(E.id,E.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let m=nW(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,l,i,d,o,n]);return gk(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===mb.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===mb.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),du("div",{className:"ElementLinkDialog",children:[du("div",{className:"ElementLinkDialog__header",children:[wl("h2",{children:f("elementLink.title")}),wl("p",{children:f("elementLink.desc")})]}),du("div",{className:"ElementLinkDialog__input",children:[wl(cu,{value:l??"",onChange:p=>{d||c(!0),s(p)},onKeyDown:p=>{p.key===mb.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&wl($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:Jr})]}),du("div",{className:"ElementLinkDialog__actions",children:[wl(sb,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),wl(sb,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},Ek=aW;import lW,{useState as sW}from"react";import{Fragment as cW,jsx as pb}from"react/jsx-runtime";var bk=({children:e,onClose:n})=>{let[t,o]=sW(!!e),{container:r}=we(),i=lW.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return pb(cW,{children:t&&pb(kn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:pb("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import ub from"clsx";import $n from"react";import{MIME_TYPES as xk,sceneCoordsToViewportCoords as hb}from"@excalidraw/common";import{getCommonBounds as vk,isInitializedImageElement as yk,ShapeCache as dW}from"@excalidraw/element";import{Fragment as fW,jsx as Ut,jsxs as Di}from"react/jsx-runtime";var mW=Ut("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:Ut("path",{d:"M8 5v14l11 -7z"})}),pW=Di("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[Ut("path",{d:"M8 5v14"}),Ut("path",{d:"M16 5v14"})]}),uW=76,Ik=4,wc=uW+Ik,wk=8,_i=8,hW=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+_i),window.innerWidth-t-_i)},gW=(e,n)=>{let[,,t,o]=vk([e]),r=hb({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},Tk=({app:e,files:n,setAppState:t})=>{let o=on(),[,r]=$n.useReducer(T=>T+1,0),[i,a]=$n.useState(0),[l,s]=$n.useState(!1),d=$n.useRef(null),c=$n.useRef(null),m=$n.useRef(null),p=$n.useRef(null),u=$n.useRef(null),E=$n.useRef(!1),[g,b]=$n.useState(null);$n.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let P=T==="gifSpeedPicker"?d.current:c.current,C=T==="gifSpeedPicker"?m.current:p.current;if(!P||!C)return;let k=P.getBoundingClientRect(),M=C.getBoundingClientRect(),_=hW(k.left+k.width/2,M.width),L=T==="gifSpeedPicker"?Math.max(_i,k.top-M.height-_i):Math.min(window.innerHeight-M.height-_i,k.bottom+_i),R={left:_,top:Math.max(_i,L)};b(z=>z?.left===R.left&&z.top===R.top?z:R)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let w=(T,P)=>{dW.delete(T),e.scene.mutateElement(T,{gifPlayback:P}),e.scheduleUpdate(),t({}),r(),P.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().flatMap(T=>{if(!yk(T)||n[T.fileId]?.mimeType!==xk.gif||e.imageCache.get(T.fileId)?.gifDecodeStatus!=="deferred")return[];let P=gW(T,o);return[Ut("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:P,onPointerDown:C=>C.stopPropagation(),children:Ut("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})},T.id)]}),x=e.scene.getSelectedElements(o);return Di(fW,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!yk(T)||n[T.fileId]?.mimeType!==xk.gif)return null;let P=e.imageCache.get(T.fileId),C=P?.gif,[k,,M,_]=vk([T]),L=hb({sceneX:k,sceneY:_},o),z=hb({sceneX:M,sceneY:_},o).x-L.x,K=L.x-o.offsetLeft+z/2,U=Math.max(12,Math.min(o.height-86,L.y-o.offsetTop+16));if(P?.gifDecodeStatus==="pending")return null;let D=C?.frames.length??0;if(!C||D<2)return null;let H=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},F=e.state,J=e.getGifPlaybackFrameIndex(T)??H.frameIndex,re=Math.min(Math.max(J,0),D-1),O=Math.min(F.height-120,U+48),V=Math.max(12,U-52),ce=Z=>{let Te=(Z+D)%D;e.setGifPlaybackFrameIndex(T,Te),w(T,{...H,frameIndex:Te,playing:!1})},pe=Z=>{Z.stopPropagation(),ce(re+(Z.deltaY<0?1:-1))},Be=Z=>{e.setGifPlaybackFrameIndex(T,re),w(T,{...H,frameIndex:re,playing:Z})},Ee=[.25,.5,.75,1,1.25,1.5,1.75,2,4],He=Z=>{let Te=Ee.indexOf(Z);return Te!==-1?Te:Ee.reduce((Kt,Hi,Kc)=>Math.abs(Hi-Z)<Math.abs(Ee[Kt]-Z)?Kc:Kt,0)},se=Z=>{w(T,{...H,speed:Z})},ke=Z=>{let Te=He(H.speed);se(Ee[Math.min(Math.max(Te+Z,0),Ee.length-1)])},Me=Number.isInteger(H.speed)?`${H.speed}`:`${H.speed}`,xe=D*wc-Ik,Et=Math.min(Math.max(F.width*.9,1),xe),en=Math.max(xe-Et,0),Fe=Math.min(i,en),st=Math.max(Math.floor(Fe/wc)-wk,0),Yt=Math.ceil(Et/wc)+wk*2,nr=Math.min(st+Yt,D),or=C.frames.slice(st,nr),Mo=Z=>{Z.pointerType!=="mouse"||Z.button!==0||(u.current={pointerId:Z.pointerId,startClientX:Z.clientX,startScrollLeft:Z.currentTarget.scrollLeft,didDrag:!1},Z.stopPropagation())},dn=Z=>{let Te=u.current;if(!Te||Te.pointerId!==Z.pointerId)return;let Kt=Z.clientX-Te.startClientX;!Te.didDrag&&Math.abs(Kt)<=3||(Te.didDrag||(Te.didDrag=!0,Z.currentTarget.setPointerCapture?.(Z.pointerId),s(!0)),Z.currentTarget.scrollLeft=Te.startScrollLeft-Kt,a(Z.currentTarget.scrollLeft),Z.preventDefault(),Z.stopPropagation())},rr=Z=>{let Te=u.current;!Te||Te.pointerId!==Z.pointerId||(E.current=Te.didDrag,u.current=null,Z.currentTarget.hasPointerCapture?.(Z.pointerId)&&Z.currentTarget.releasePointerCapture(Z.pointerId),s(!1),Z.stopPropagation())},Yc=Z=>{let Te=u.current;!Te||Te.pointerId!==Z.pointerId||(u.current=null,s(!1),Z.stopPropagation())},Gi=Z=>{Z.pointerType!=="mouse"&&Z.stopPropagation()};return Di("div",{className:"gif-playback-controls",style:{left:K,top:U},onPointerDown:Z=>Z.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&Ut("div",{className:"gif-speed-picker",ref:m,style:g??{left:K,top:V},children:Ee.map(Z=>{let Te=Number.isInteger(Z)?`${Z}`:`${Z}`;return Di("button",{type:"button",className:ub("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":Z===H.speed}),onClick:()=>se(Z),title:`${Te}x`,children:["x",Te]},Z)})}),Di("div",{className:"gif-playback-controls__bar",children:[Di("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:d,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:Z=>{Z.stopPropagation(),ke(Z.deltaY<0?1:-1)},title:"Speed",children:["x",Me]}),Ut("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>ce(re-1),onWheel:pe,title:"Previous frame",children:I0}),Ut("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Be(!H.playing),onWheel:pe,title:H.playing?"Pause":"Play",children:H.playing?pW:mW}),Ut("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>ce(re+1),onWheel:pe,title:"Next frame",children:T0}),Ut("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:c,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(re*wc-Et/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:pe,title:"Frames",children:S0})]}),o.openPopup==="gifFrameGallery"&&Ut("div",{className:ub("gif-frame-gallery",{"gif-frame-gallery--dragging":l}),style:{...g??{left:K,top:O},width:Et},ref:Z=>{p.current=Z,Z&&Z.scrollLeft!==Fe&&(Z.scrollLeft=Fe)},onScroll:Z=>{a(Z.currentTarget.scrollLeft)},onPointerDownCapture:Gi,onPointerMoveCapture:Gi,onPointerUpCapture:Gi,onPointerCancelCapture:Gi,onPointerDown:Mo,onPointerMove:dn,onPointerUp:rr,onPointerCancel:Yc,onLostPointerCapture:Yc,onClickCapture:Z=>{if(E.current){E.current=!1,Z.preventDefault(),Z.stopPropagation();return}E.current=!1},onWheelCapture:Z=>{Z.stopPropagation(),Z.currentTarget.scrollLeft+=Z.deltaY,a(Z.currentTarget.scrollLeft)},children:Ut("div",{className:"gif-frame-gallery__spacer",style:{width:xe},children:or.map((Z,Te)=>{let Kt=st+Te;return Di("button",{type:"button",className:ub("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Kt===re}),style:{left:Kt*wc},onClick:()=>ce(Kt),title:`Frame ${Kt+1}`,children:[Ut("canvas",{width:Z.width,height:Z.height,ref:Hi=>{Hi?.getContext("2d")?.drawImage(Z,0,0)}}),Ut("span",{children:Kt+1})]},Kt)})})})]})})()]})};import Sk,{useMemo as TW}from"react";import Ck from"clsx";import{isDarwin as Pk,isFirefox as SW,isWindows as CW}from"@excalidraw/common";import{KEYS as vl}from"@excalidraw/common";import{SHAPES as PW}from"@excalidraw/element/shapes";import{isFirefox as EW,KEYS as gb}from"@excalidraw/common";import{SHAPES as bW}from"@excalidraw/element/shapes";import{Fragment as IW,jsx as Ve,jsxs as Ri}from"react/jsx-runtime";var xW=e=>Ri(IW,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),fb=e=>Ri("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*yW(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var wW=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),ft=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(vW,{children:wW(a)},a)));return Ri("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...yW(o,t?f("helpDialog.or"):null)]})]})},vW=e=>Ve("kbd",{className:"HelpDialog__key",...e});function Eb(){return Ri(xW,{title:f("helpDialog.shortcuts"),children:[Ri(fb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(ft,{label:f("toolBar.hand"),shortcuts:[gb.H]}),bW.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(ft,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(ft,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),B("Enter")],isOr:!0}),Ve(ft,{label:f("helpDialog.cropFinish"),shortcuts:[B("Enter"),B("Escape")],isOr:!0})]}),Ri(fb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(ft,{label:f("helpDialog.smartZoom"),shortcuts:[gb.F]}),Ve(ft,{label:f("labels.flipViewpointHorizontal"),shortcuts:[B("Shift+R")]}),Ve(ft,{label:f("labels.flipViewpointVertical"),shortcuts:[B("Alt+Shift+R")]}),Ve(ft,{label:f("helpDialog.dragToZoom"),shortcuts:[`${gb.Z}+${f("helpDialog.drag")}`]}),Ve(ft,{label:f("buttons.objectsSnapMode"),shortcuts:[B("Alt+S")]})]}),Ri(fb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(ft,{label:f("labels.pasteAsPlaintext"),shortcuts:[B("CtrlOrCmd+Shift+V")]}),Ve(ft,{label:f("labels.multiSelect"),shortcuts:[B(`Shift+${f("helpDialog.click")}`)]}),Ve(ft,{label:f("helpDialog.deepSelect"),shortcuts:[B(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(ft,{label:f("helpDialog.deepBoxSelect"),shortcuts:[B(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(xr||EW)&&Ve(ft,{label:f("labels.copyAsPng"),shortcuts:[B("Shift+Alt+C")]}),Ve(ft,{label:f("helpDialog.toggleElementLock"),shortcuts:[B("CtrlOrCmd+Shift+L")]}),Ve(ft,{label:f("labels.group"),shortcuts:[B("CtrlOrCmd+G")]}),Ve(ft,{label:f("labels.ungroup"),shortcuts:[B("CtrlOrCmd+Shift+G")]}),Ve(ft,{label:f("labels.flipHorizontal"),shortcuts:[B("Shift+H")]}),Ve(ft,{label:f("labels.flipVertical"),shortcuts:[B("Shift+V")]})]})]})}import{Fragment as Mk,jsx as j,jsxs as Ni}from"react/jsx-runtime";var kW=e=>Ni(Mk,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),bb=e=>Ni("div",{className:`HelpDialog__island ${e.className}`,children:[j("h4",{className:"HelpDialog__island-title",children:e.caption}),j("div",{className:"HelpDialog__island-content",children:e.children})]});function*MW(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var AW=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),ee=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(LW,{children:AW(a)},a)));return Ni("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...MW(o,t?f("helpDialog.or"):null)]})]})},LW=e=>j("kbd",{className:"HelpDialog__key",...e}),kk=({onClose:e})=>{let[n,t]=Sk.useState(!1),o=Sk.useCallback(()=>{e&&e()},[e]),r=TW(()=>n?j("button",{className:Ck("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:Ck("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(Mk,{children:j(kn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ni(kW,{title:f("helpDialog.shortcuts"),children:[Ni(bb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(ee,{label:f("toolBar.hand"),shortcuts:[vl.H]}),PW.map(({value:i,key:a})=>j(ee,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(ee,{label:f("toolBar.frame"),shortcuts:[vl.F]}),j(ee,{label:f("labels.eyeDropper"),shortcuts:[vl.I,"Shift+S","Shift+I"]}),j(ee,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[B("CtrlOrCmd+Enter")]}),j(ee,{label:f("helpDialog.editText"),shortcuts:[B("Enter")]}),j(ee,{label:f("helpDialog.textNewLine"),shortcuts:[B("Enter"),B("Shift+Enter")]}),j(ee,{label:f("helpDialog.textFinish"),shortcuts:[B("Esc"),B("CtrlOrCmd+Enter")]}),j(ee,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(ee,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(ee,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),B("Enter")],isOr:!0}),j(ee,{label:f("helpDialog.cropFinish"),shortcuts:[B("Enter"),B("Escape")],isOr:!0}),j(ee,{label:f("toolBar.lock"),shortcuts:[vl.Q]}),j(ee,{label:f("helpDialog.preventBinding"),shortcuts:[B("CtrlOrCmd")]}),j(ee,{label:f("toolBar.link"),shortcuts:[B("CtrlOrCmd+K")]}),j(ee,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ni(bb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(ee,{label:f("helpDialog.smartZoom"),shortcuts:[vl.F]}),j(ee,{label:f("helpDialog.dragToZoom"),shortcuts:[`${vl.Z}+${f("helpDialog.drag")}`]}),j(ee,{label:f("buttons.zoomIn"),shortcuts:[B("CtrlOrCmd++")]}),j(ee,{label:f("buttons.zoomOut"),shortcuts:[B("CtrlOrCmd+-")]}),j(ee,{label:f("buttons.resetZoom"),shortcuts:[B("CtrlOrCmd+0")]}),j(ee,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(ee,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(ee,{label:f("buttons.objectsSnapMode"),shortcuts:[B("Alt+S")]}),j(ee,{label:f("labels.toggleGrid"),shortcuts:[B("CtrlOrCmd+'")]}),j(ee,{label:f("labels.viewMode"),shortcuts:[B("Alt+R")]}),j(ee,{label:f("labels.flipViewpointHorizontal"),shortcuts:[B("Shift+R")]}),j(ee,{label:f("labels.flipViewpointVertical"),shortcuts:[B("Alt+Shift+R")]}),j(ee,{label:f("stats.fullTitle"),shortcuts:[B("Alt+/")]}),j(ee,{label:f("search.title"),shortcuts:[Qe("searchMenu")]})]}),Ni(bb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(ee,{label:f("labels.moveCanvas"),shortcuts:[B(`Space+${f("helpDialog.drag")}`),B(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(ee,{label:f("labels.delete"),shortcuts:[B("Delete")]}),j(ee,{label:f("labels.cut"),shortcuts:[B("CtrlOrCmd+X")]}),j(ee,{label:f("labels.copy"),shortcuts:[B("CtrlOrCmd+C")]}),j(ee,{label:f("labels.paste"),shortcuts:[B("CtrlOrCmd+V")]}),j(ee,{label:f("labels.pasteAsPlaintext"),shortcuts:[B("CtrlOrCmd+Shift+V")]}),j(ee,{label:f("labels.selectAll"),shortcuts:[B("CtrlOrCmd+A")]}),j(ee,{label:f("labels.multiSelect"),shortcuts:[B(`Shift+${f("helpDialog.click")}`)]}),j(ee,{label:f("helpDialog.deepSelect"),shortcuts:[B(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(ee,{label:f("helpDialog.deepBoxSelect"),shortcuts:[B(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(xr||SW)&&j(ee,{label:f("labels.copyAsPng"),shortcuts:[B("Shift+Alt+C")]}),j(ee,{label:f("labels.sendToBack"),shortcuts:[Pk?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")]}),j(ee,{label:f("labels.bringToFront"),shortcuts:[Pk?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")]}),j(ee,{label:f("labels.sendBackward"),shortcuts:[B("CtrlOrCmd+[")]}),j(ee,{label:f("labels.bringForward"),shortcuts:[B("CtrlOrCmd+]")]}),j(ee,{label:f("labels.alignTop"),shortcuts:[B("CtrlOrCmd+Shift+Up")]}),j(ee,{label:f("labels.alignBottom"),shortcuts:[B("CtrlOrCmd+Shift+Down")]}),j(ee,{label:f("labels.alignLeft"),shortcuts:[B("CtrlOrCmd+Shift+Left")]}),j(ee,{label:f("labels.alignRight"),shortcuts:[B("CtrlOrCmd+Shift+Right")]}),j(ee,{label:f("labels.arrangeElements"),shortcuts:[B("Shift+A")]}),j(ee,{label:f("labels.duplicateSelection"),shortcuts:[B("CtrlOrCmd+D"),B(`Alt+${f("helpDialog.drag")}`)]}),j(ee,{label:f("helpDialog.toggleElementLock"),shortcuts:[B("CtrlOrCmd+Shift+L")]}),j(ee,{label:f("buttons.undo"),shortcuts:[B("CtrlOrCmd+Z")]}),j(ee,{label:f("buttons.redo"),shortcuts:CW?[B("CtrlOrCmd+Y"),B("CtrlOrCmd+Shift+Z")]:[B("CtrlOrCmd+Shift+Z")]}),j(ee,{label:f("labels.group"),shortcuts:[B("CtrlOrCmd+G")]}),j(ee,{label:f("labels.ungroup"),shortcuts:[B("CtrlOrCmd+Shift+G")]}),j(ee,{label:f("labels.flipHorizontal"),shortcuts:[B("Shift+H")]}),j(ee,{label:f("labels.flipVertical"),shortcuts:[B("Shift+V")]}),j(ee,{label:f("labels.showStroke"),shortcuts:[B("S")]}),j(ee,{label:f("labels.showBackground"),shortcuts:[B("G")]}),j(ee,{label:f("labels.showFonts"),shortcuts:[B("Shift+F")]}),j(ee,{label:f("labels.decreaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+<")]}),j(ee,{label:f("labels.increaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+>")]})]})]}):j(Eb,{})})})};import{CANVAS_SEARCH_TAB as DW,DEFAULT_SIDEBAR as _W}from"@excalidraw/common";import{isArrowElement as RW,isFlowchartNodeElement as NW,isImageElement as Ak,isLinearElement as Lk,isLineElement as BW,isTextBindableContainer as FW,isTextElement as OW}from"@excalidraw/element";import{isNodeInFlowchart as zW}from"@excalidraw/element";import{jsx as xb}from"react/jsx-runtime";var Ie=e=>Array.isArray(e)?`<kbd>${e.map(B).join(" + ")}</kbd>`:`<kbd>${B(e)}</kbd>`,GW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===_W.name&&e.openSidebar.tab===DW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Ie("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(pn(e))return f("hints.eraserRevert",{shortcut:Ie("Alt")});let d=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&d[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Ie("Ctrl"),shortcut_2:Ie("Alt")});if(r.type==="arrow"||r.type==="line")return s?f("hints.linearElementMulti",{shortcut_1:Ie("Escape"),shortcut_2:Ie("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Ie("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&l==="mouse"&&d.length===1){let c=d[0];return Lk(c)&&c.points.length===2?f("hints.lockAngle",{shortcut:Ie("Shift")}):Ak(c)?f("hints.resizeImage",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):f("hints.resize",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")})}if(a&&l==="mouse")return f("hints.rotate",{shortcut:Ie("Shift")});if(d.length===1&&OW(d[0]))return f("hints.text_selected",{shortcut:Ie("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Ie("Escape"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Ie("Enter"),shortcut_2:Ie("Escape")});if(d.length===1&&Ak(d[0]))return f("hints.enterCropEditor",{shortcut_1:Ie("double click"),shortcut_2:Ie("Enter")});if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Ie("CtrlOrCmd")});if(Pr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Ie("CtrlOrCmd")});if(!d.length&&!n)return f("hints.canvasPanning",{shortcut_1:Ie(f("keys.mmb")),shortcut_2:Ie("Space")});if(d.length===1){if(Lk(d[0]))return RW(d[0])&&e.selectedLinearElement?.elementId===d[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===d[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Ie("Delete"),shortcut_2:Ie(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Ie("Shift"),shortcut_2:Ie("Alt")}):BW(d[0])?f("hints.lineEditor_line_info",{shortcut:Ie("Enter")}):f("hints.lineEditor_info",{shortcut_1:Ie("CtrlOrCmd"),shortcut_2:Ie(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&FW(d[0])){let c=f("hints.bindTextToElement",{shortcut:Ie("Enter")}),m=f("hints.createFlowchart",{shortcut:Ie(["CtrlOrCmd","\u2191\u2193"])});return NW(d[0])?zW(d[0],o.scene.getNonDeletedElementsMap())?[c,m]:[c,m]:c}}}return null},Il=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let i=Xi(Ma)?Fv:e.viewModeEnabled?null:GW({appState:e,isMobile:n,editorInterface:t,app:o});if(!i)return null;let l=(Array.isArray(i)?i.map(s=>s.replace(/\. ?$/,"")).join(", "):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,d)=>{if(d%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return xb("kbd",{children:c?c[1]:s},d)}return s});return xb("div",{className:"HintViewer",children:xb("span",{children:l})})};import{useEffect as _k,useRef as Rk,useState as Bi}from"react";import{DEFAULT_EXPORT_PADDING as YW,EXPORT_IMAGE_TYPES as yb,isFirefox as KW,EXPORT_SCALES as XW,cloneJSON as Nk}from"@excalidraw/common";import{useCallback as HW,useRef as UW,useState as WW}from"react";var VW=2e3,Dk=()=>{let[e,n]=WW(null),t=UW(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},VW)},r=HW(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ze,jsxs as Gr}from"react/jsx-runtime";var ZW=()=>Gr("div",{children:[Ze("h3",{children:f("canvasError.cannotShowPreview")}),Ze("p",{children:Ze("span",{children:f("canvasError.canvasTooBig")})}),Gr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),$W=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let l=Oe(n,e),[s,d]=Bi(i),[c,m]=Bi(l),[p,u]=Bi(e.exportBackground),[E,g]=Bi(e.exportEmbedScene),[b,w]=Bi(e.exportScale),y=Rk(null),x=Rk(0),[I,T]=Bi(null),{onCopy:P,copyStatus:C,resetCopyStatus:k}=Dk();_k(()=>{k()},[s,p,a,b,E,k]);let{exportedElements:M,exportingFrame:_}=di(n,e,c);return _k(()=>{let L=y.current;if(!L)return;let R=L.offsetWidth,z=L.offsetHeight;if(!R)return;let K=++x.current,U=()=>K!==x.current;return nu({elements:M,appState:{...e,name:s,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:YW,maxWidthOrHeight:Math.max(R,z),exportingFrame:_}).then(async D=>{if(!U()){try{await Hl(D)}catch(H){throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}U()||(T(null),L.replaceChildren(D))}}).catch(D=>{U()||(console.error(D),T(D))}),()=>{x.current+=1}},[e,t,M,_,s,p,a,b,E]),Gr("div",{className:"ImageExportModal",children:[Ze("h3",{children:f("imageExportDialog.header")}),Gr("div",{className:"ImageExportModal__preview",children:[Ze("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ze(ZW,{})}),Ze("div",{className:"ImageExportModal__preview__filename",children:!Vi&&Ze("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:L=>{d(L.target.value),o.executeAction(Pg,"ui",L.target.value)}})})]}),Gr("div",{className:"ImageExportModal__settings",children:[Ze("h3",{children:f("imageExportDialog.header")}),l&&Ze(vc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ze(gi,{name:"exportOnlySelected",checked:c,onChange:L=>{m(L)}})}),Ze(vc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ze(gi,{name:"exportBackgroundSwitch",checked:p,onChange:L=>{u(L),o.executeAction(kg,"ui",L)}})}),Ze(vc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ze(gi,{name:"exportDarkModeSwitch",checked:a,onChange:L=>{o.executeAction(rv,"ui",L)}})}),Ze(vc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ze(gi,{name:"exportEmbedSwitch",checked:E,onChange:L=>{g(L),o.executeAction(wm,"ui",L)}})}),Ze(vc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ze(Kp,{name:"exportScale",value:b,onChange:L=>{w(L),o.executeAction(nv,"ui",L)},choices:XW.map(L=>({value:L,label:`${L}\xD7`}))})}),Gr("div",{className:"ImageExportModal__settings__buttons",children:[Ze(Nr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(yb.png,M,{exportingFrame:_}),icon:wh,children:f("imageExportDialog.button.exportToPng")}),Ze(Nr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(yb.svg,M,{exportingFrame:_}),icon:wh,children:f("imageExportDialog.button.exportToSvg")}),(xr||KW)&&Ze(Nr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:C,onClick:async()=>{await r(yb.clipboard,M,{exportingFrame:_}),P()},icon:y0,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},vc=({label:e,children:n,tooltip:t,name:o})=>Gr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Gr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ze(bt,{label:t,long:!0,children:v0})]}),Ze("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),Bk=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Bi(()=>({appStateSnapshot:Nk(n),elementsSnapshot:Nk(e)}));return Ze(kn,{onCloseRequest:i,size:"wide",title:!1,children:Ze($W,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import FV from"clsx";import{CANVAS_SEARCH_TAB as tM,DEFAULT_SIDEBAR as OV}from"@excalidraw/common";import jW from"clsx";import qW from"lodash.debounce";import{Fragment as JW,memo as QW,useEffect as Ic,useMemo as Fk,useRef as wb,useState as Ok}from"react";import{CLASSES as eV,EVENT as tV,FONT_FAMILY as vb,FRAME_STYLE as Ib,getLineHeight as nV}from"@excalidraw/common";import{getCommonBounds as oV,isElementCompletelyInViewport as rV}from"@excalidraw/element";import{measureText as Tc}from"@excalidraw/element";import{KEYS as Tl,randomInteger as zk,addEventListener as iV,getFontString as mu}from"@excalidraw/common";import{newTextElement as aV}from"@excalidraw/element";import{isTextElement as Wk,isFrameLikeElement as pu}from"@excalidraw/element";import{getDefaultFrameName as Vk}from"@excalidraw/element/frame";import{Fragment as fV,jsx as It,jsxs as jn}from"react/jsx-runtime";var lV=et(""),Tb=et(null),sV=350,Yk=()=>{let e=ct(),n=ze(),t=wb(null),[o,r]=$e(lV),i=o.trim(),[a,l]=Ok(!1),[s,d]=Ok({nonce:null,items:[]}),c=wb(null),m=wb(void 0),[p,u]=$e(Tb),E=e.scene.getNonDeletedElementsMap();Ic(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==m.current)&&(c.current=null,Uk(i,e,(x,I)=>{d({nonce:zk(),items:x}),c.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{s.items.length>0&&u(x=>x===null?0:(x+1)%s.items.length)},b=()=>{s.items.length>0&&u(x=>x===null?0:x-1<0?s.items.length-1:x-1)};Ic(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,P)=>P===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),Ic(()=>{if(s.items.length>0&&p!==null){let x=s.items[p];if(x){let I=e.state.zoom.value,T=aV({text:x.searchQuery,x:x.element.x+(x.matchedLines[0]?.offsetX??0),y:x.element.y+(x.matchedLines[0]?.offsetY??0),width:x.matchedLines[0]?.width,height:x.matchedLines[0]?.height,fontSize:pu(x.element)?Ib.nameFontSize:x.element.fontSize,fontFamily:pu(x.element)?vb.Assistant:x.element.fontFamily}),P=14,C=T.fontSize,k=C*I<P;if(!rV([T],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||k){let M=k&&C<P?"contain":"scale-down";e.viewport.setViewport({target:oV([T]),fit:M,animation:{duration:300},offsets:{ui:!0}})}}}},[p,s,e]),Ic(()=>()=>{u(null),c.current=null,m.current=void 0,n({searchMatches:null}),l(!1)},[n,u]);let w=ra({goToNextItem:g,goToPreviousItem:b,searchMatches:s});Ic(()=>{let x=I=>{if(I.key===Tl.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[Tl.CTRL_OR_CMD]&&I.key===Tl.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(I.key===Tl.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===Tl.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===Tl.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return iV(window,tV.KEYDOWN,x,{capture:!0,passive:!1})},[n,w,e]);let y=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return jn("div",{className:"layer-ui__search",children:[jn("div",{className:"layer-ui__search-header",children:[It(cu,{className:eV.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:hn,onChange:x=>{r(x),l(!0);let I=x.trim();Uk(I,e,(T,P)=>{d({nonce:zk(),items:T}),u(P),c.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null}),l(!1)})},selectOnRender:!0}),It(Mn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:un})]}),jn("div",{className:"layer-ui__search-count",children:[s.items.length>0&&jn(fV,{children:[p!==null&&p>-1?jn("div",{children:[p+1," / ",y]}):It("div",{children:y}),jn("div",{className:"result-nav",children:[It(Mn,{onSelect:()=>{g()},className:"result-nav-btn",children:hd}),It(Mn,{onSelect:()=>{b()},className:"result-nav-btn",children:H0})]})]}),s.items.length===0&&i&&c.current&&It("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),It(mV,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},Gk=e=>{let n=[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 It("div",{tabIndex:-1,className:jW("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:It("div",{className:"preview-text",children:n.flatMap((t,o)=>It(JW,{children:o===2?It("b",{children:t}):t},o))})})},cV=e=>{let n=Fk(()=>e.matches.items.filter(o=>pu(o.element)),[e.matches]),t=Fk(()=>e.matches.items.filter(o=>Wk(o.element)),[e.matches]);return jn("div",{className:"layer-ui__search-results",children:[n.length>0&&jn("div",{className:"layer-ui__search-result-container",children:[jn("div",{className:"layer-ui__search-result-title",children:[It("div",{className:"title-icon",children:po}),It("div",{children:f("search.frames")})]}),n.map((o,r)=>It(Gk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&It("div",{className:"layer-ui__divider"})]}),t.length>0&&jn("div",{className:"layer-ui__search-result-container",children:[jn("div",{className:"layer-ui__search-result-title",children:[It("div",{className:"title-icon",children:Bn}),It("div",{children:f("search.texts")})]}),t.map((o,r)=>It(Gk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},dV=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,mV=QW(cV,dV),Hk=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;d=d.length>c?d.slice(-c):d;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+g,moreBefore:s>0,moreAfter:p.length>E}},pV=(e,n)=>{let t=e.split(`
|
|
19
19
|
`),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=n.indexOf(l,r);if(s>a.length+r){let d=s-(a.length+r);for(;d>0;)a+=" ",d--}}o.push(a),r=r+a.length}return o.join(`
|
|
20
|
-
`)},
|
|
21
|
-
`),i=[],a=0,l=0;for(let p of r){let m=a,u=m+p.length-1;i.push({line:p,startIndex:m,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,d=e.originalText.slice(t,t+n.length),c=[];for(let p of i){if(d==="")break;if(s>=p.startIndex&&s<=p.endIndex){let m=p.endIndex+1-s,u=p.line.slice(0,s-p.startIndex),E=d.slice(0,m);d=d.slice(m);let g=Ec(u,nu(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let I=Ec(p.line,nu(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=Ec(E,nu(e),e.lineHeight),y=g.width,x=p.lineNumber*g.height;c.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),s+=m}}return c},WW=(e,n,t,o)=>{let r=e.name??Ck(e),i=r.slice(t,t+n.length),a=r.slice(0,t),l=nu({fontSize:pb.nameFontSize,fontFamily:mb.Assistant}),s=LW(mb.Assistant),d=Ec(a,l,s);a===""&&(d.width=0);let c=Ec(i,l,s),p=d.width,m=-d.height-pb.strokeWidth,u=c.width;return[{offsetX:p,offsetY:m,width:u,height:c.height,showOnCanvas:p+u<=e.width*o}]},VW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Tk=CW((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(m=>Sk(m)),i=o.filter(m=>ou(m));r.sort((m,u)=>m.y-u.y),i.sort((m,u)=>m.y-u.y);let a=[],l=new RegExp(VW(e),"gi");for(let m of r){let u=null,E=m.originalText;for(;(u=l.exec(E))!==null;){let g=Ik(E,u.index,e),b=UW(m,e,u.index);b.length>0&&a.push({element:m,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let s=[];for(let m of i){let u=null,E=m.name??Ck(m);for(;(u=l.exec(E))!==null;){let g=Ik(E,u.index,e),b=WW(m,e,u.index,n.state.zoom.value);b.length>0&&s.push({element:m,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let d=new Set(n.visibleElements.map(m=>m.id)),c=[...s,...a],p=c.findIndex(m=>d.has(m.element.id))??null;t(c,p)},FW);import rV from"clsx";import{useEffect as _k,useLayoutEffect as Rk,useRef as vb,useState as iV,forwardRef as Nk,useImperativeHandle as aV,useCallback as Ak}from"react";import{CLASSES as lV,EVENT as Lk,isDevEnv as sV,KEYS as cV,updateObject as dV}from"@excalidraw/common";import XW from"clsx";import{useContext as ZW}from"react";import KW from"react";var ru=KW.createContext({});import{jsx as hb,jsxs as kk}from"react/jsx-runtime";var gb=({children:e,className:n})=>{let t=me(),o=ZW(ru),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return kk("div",{className:XW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,kk("div",{className:"sidebar__header__buttons",children:[r&&hb(bt,{label:f("labels.sidebarLock"),children:hb(Cn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:qx})}),hb(Cn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:mn})]})]})};gb.displayName="SidebarHeader";import{Tabs as $W}from"radix-ui";import{jsx as Mk}from"react/jsx-runtime";var fb=({children:e,tab:n,onSelect:t,...o})=>Mk($W.Trigger,{value:n,asChild:!0,onSelect:t,children:Mk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});fb.displayName="SidebarTabTrigger";import{Tabs as jW}from"radix-ui";import{jsx as qW}from"react/jsx-runtime";var Eb=({children:e,...n})=>qW(jW.List,{className:"sidebar-triggers",...n,children:e});Eb.displayName="SidebarTabTriggers";import JW from"clsx";import{jsx as bb,jsxs as QW}from"react/jsx-runtime";var xb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:l})=>{let s=ze(),c=ye().openSidebar?.name===e;return bb("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":c,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=!c;s({openSidebar:p?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(p)},children:QW("div",{className:JW("sidebar-trigger",a),style:l,children:[t&&bb("div",{children:t}),r&&bb("div",{className:"sidebar-trigger__label",children:r})]})})};xb.displayName="SidebarTrigger";import{Tabs as eV}from"radix-ui";import{jsx as tV}from"react/jsx-runtime";var yb=({children:e,...n})=>{let t=ye(),o=ze();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return tV(eV.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};yb.displayName="SidebarTabs";import{Tabs as nV}from"radix-ui";import{jsx as oV}from"react/jsx-runtime";var wb=({tab:e,children:n,...t})=>oV(nV.Content,{...t,value:e,"data-testid":e,children:n});wb.displayName="SidebarTab";import{jsx as Dk}from"react/jsx-runtime";import{createElement as mV}from"react";var Ib=et(!1),Bk=Nk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{sV()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=ze(),s=Yx(Ib);Rk(()=>(s(!!o),()=>{s(!1)}),[s,o]);let d=vb({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=dV(d.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let c=vb(null);aV(a,()=>c.current);let p=me(),m=Ak(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return qi(c,Ak(u=>{u.target.closest(".sidebar-trigger")||(!o||!p.canFitSidebar)&&m()},[m,o,p.canFitSidebar])),_k(()=>{let u=E=>{E.key===cV.ESCAPE&&(!o||!p.canFitSidebar)&&m()};return document.addEventListener(Lk.KEYDOWN,u),()=>{document.removeEventListener(Lk.KEYDOWN,u)}},[m,o,p.canFitSidebar]),Dk(Ke,{...i,className:rV(lV.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":p.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":p.formFactor!=="phone"?"sidebar":void 0,ref:c,children:Dk(ru.Provider,{value:d.current,children:n})})});Bk.displayName="SidebarInner";var Fr=Object.assign(Nk((e,n)=>{let t=ye(),{onStateChange:o}=e,r=vb(t.openSidebar);_k(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=iV(!1);return Rk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?mV(Bk,{...e,ref:n,key:e.name}):null}),{Header:gb,TabTriggers:Eb,TabTrigger:fb,Tabs:yb,Tab:wb,Trigger:xb});Fr.displayName="Sidebar";import{jsx as El,jsxs as hV}from"react/jsx-runtime";import{createElement as gV}from"react";var Ok=Ti("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=ut();return El(n.In,{children:El(Fr.Trigger,{...e,className:"default-sidebar-trigger",name:uV.name})})});Ok.displayName="DefaultSidebarTrigger";var zk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=ut();return El(n.In,{children:e})};zk.displayName="DefaultTabTriggers";var Tb=Object.assign(Ti("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=ze(),l=i.openSidebar?.tab===Fk,s=l?!1:t??i.defaultSidebarDockedPreference,d=!l&&t==null&&o!==!1;return gV(Fr,{...r,name:"default",key:"default",className:pV("default-sidebar",{"default-sidebar--search-only":l},n),docked:s,onDock:d?c=>{a({defaultSidebarDockedPreference:c}),o?.(c)}:void 0},hV(Fr.Tabs,{children:[!l&&El(Fr.Header,{}),El(Fr.Tab,{tab:Fk,children:El(Pk,{})}),!l&&e]}))}),{Trigger:Ok,TabTriggers:zk});import EV from"react";import{getFrame as bV}from"@excalidraw/common";import{jsx as fV}from"react/jsx-runtime";var Sb={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"}},Cb=({children:e,color:n})=>fV("div",{className:"Card",style:{"--card-color":Sb[n].base,"--card-color-darker":Sb[n].darker,"--card-color-darkest":Sb[n].darkest},children:e});import{Fragment as yV,jsx as Kn,jsxs as iu}from"react/jsx-runtime";var xV=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Kn("div",{className:"ExportDialog ExportDialog--json",children:iu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&iu(Cb,{color:"lime",children:[Kn("div",{className:"Card-icon",children:h1}),Kn("h2",{children:f("exportDialog.disk_title")}),iu("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Oi&&r.renderAction("changeProjectName")]}),Kn($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(bs,"ui")}})]}),s&&iu(Cb,{color:"pink",children:[Kn("div",{className:"Card-icon",children:zl}),Kn("h2",{children:f("exportDialog.link_title")}),Kn("div",{className:"Card-details",children:f("exportDialog.link_details")}),Kn($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ye("export","link",`ui (${bV()})`),await s(e,n,o),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Gk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let l=EV.useCallback(()=>{a({openDialog:null})},[a]);return Kn(yV,{children:n.openDialog?.name==="jsonExport"&&Kn(Sn,{onCloseRequest:l,title:f("buttons.export"),children:Kn(xV,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:l,exportOpts:r,canvas:i})})})};import wV from"clsx";import{jsx as vV}from"react/jsx-runtime";var Hk=e=>vV($,{className:wV("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:io,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Kk from"clsx";import{useState as SV}from"react";import{CANVAS_SEARCH_TAB as CV,DEFAULT_SIDEBAR as PV,KEYS as xl}from"@excalidraw/common";import IV from"clsx";import{jsx as TV}from"react/jsx-runtime";var au=e=>TV($,{className:IV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Jo:So,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as bl,jsx as ne,jsxs as Go}from"react/jsx-runtime";var kV=(e,n)=>e==="image"&&n.tools?.image===!1,Uk=({app:e,activeTool:n,type:t,shortcut:o})=>ne(pe.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Me[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Lo(t),disabled:ot(e,t),children:f(`toolBar.${t}`)}),Wk=({app:e})=>ne(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Jo:So,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:xl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),Vk=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Bt))return null;let t=Qe("objectsSnapMode");return ne(pe.Item,{onSelect:()=>e.executeAction(Bt,"ui"),icon:tr,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},Pb=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Bt))return null;let t=f("buttons.objectsSnapMode"),o=Qe("objectsSnapMode");return ne($,{type:"toggle",icon:tr,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Bt,"ui")})},Yk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Qe("searchMenu");return ne(pe.Item,{onSelect:()=>e.executeAction(Gs,"ui"),icon:ao,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===PV.name&&n.openSidebar.tab===CV,shortcut:o,children:t})},kb=({app:e})=>ne($,{type:"button",icon:jr,title:`${f("labels.eyeDropper")} - ${xl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":xl.I.toLocaleUpperCase(),keyBindingLabel:xl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),Mb=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i,overflowItems:a=[]})=>{let[l,s]=SV(!1),d=it()==="full",c=n.type==="frame",p=n.type==="autoshape",m=n.type==="laser",u=n.type==="bucketfill",E=d&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",g=n.type==="embeddable",b=r&&hr.includes(n.type),w=a.some(x=>x==="objectsSnapMode"?e.state.objectsSnapModeEnabled:x!=="strokeEyedropper"&&n.type===x),y=()=>a.map(x=>x==="objectsSnapMode"?ne(Vk,{actionManager:i,app:e},x):x==="strokeEyedropper"?ne(pe.Item,{onSelect:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1}),icon:jr,"data-testid":"toolbar-eyedropper",shortcut:xl.I.toLocaleUpperCase(),children:f("labels.eyeDropper")},x):ne(Uk,{app:e,activeTool:n,type:x},x));return Go(pe,{open:l,children:[ne(pe.Trigger,{className:Kk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":b||w||c||g||!r&&d&&p||E||u||m&&!e.props.isCollaborating}),onToggle:()=>{s(!l),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:b?Me[n.type].icon:c?ro:g?er:!r&&d&&p?qr:m&&!e.props.isCollaborating?io:E?Vi:u?oo:Rl}),ne(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Go(bl,{children:[y(),a.length>0&&ne("div",{className:"App-toolbar__dropdown-divider"}),d&&ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Vi,"data-testid":"toolbar-lasso",selected:E,disabled:ot(e,"lasso"),children:f("toolBar.lasso")}),hr.filter(x=>!kV(x,o)&&!a.includes(x)).map(x=>ne(Uk,{app:e,activeTool:n,type:x},x)),ne("div",{className:"App-toolbar__dropdown-divider"}),ne(Yk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ne(Wk,{app:e})]}):Go(bl,{children:[ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:ro,shortcut:xl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:ot(e,"frame"),children:f("toolBar.frame")}),ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:er,"data-testid":"toolbar-embeddable",selected:g,disabled:ot(e,"embeddable"),children:f("toolBar.embeddable")}),ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:qr,shortcut:Lo("autoshape"),"data-testid":"toolbar-autoshape",selected:p,disabled:ot(e,"autoshape"),children:f("toolBar.autoshape")}),ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:io,"data-testid":"toolbar-laser",selected:m,disabled:ot(e,"laser"),children:f("toolBar.laser")}),ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:oo,"data-testid":"toolbar-bucketfill",selected:u,disabled:ot(e,"bucketfill"),children:f("toolBar.bucketfill")}),d&&ne(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Vi,"data-testid":"toolbar-lasso",selected:E,disabled:ot(e,"lasso"),children:f("toolBar.lasso")}),ne("div",{className:"App-toolbar__dropdown-divider"}),y(),!a.includes("objectsSnapMode")&&ne(Vk,{actionManager:i,app:e}),ne(Yk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ne(Wk,{app:e})]})})]})},Xk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:l,showPenMode:s=!0})=>{let d=me(),c=it()==="compact",p=n.activeTool,m={app:e,activeTool:p},u=n.myocSimplifiedMode,E=c?ne(ri,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ne(ms,{...m}):ne(ds,{...m});return Go(Ke,{padding:1,className:Kk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),children:[ne(gl,{appState:n,isMobile:d.formFactor==="phone",editorInterface:d,app:e}),l,Go(an.Row,{gap:c?.5:1,children:[!c&&s&&ne(Ar,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!u&&Go(bl,{children:[ne(au,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ne("div",{className:"App-toolbar__divider"})]}),ne(Qd,{...m}),E,u?Go(bl,{children:[ne(as,{...m}),ne(ls,{...m}),ne(kb,{app:e}),o.tools?.image!==!1&&ne(ss,{...m}),ne(cs,{...m})]}):Go(bl,{children:[ne(mw,{...m}),ne(pw,{...m}),ne(uw,{...m}),ne(hw,{...m}),ne(gw,{...m}),c?ne(ma,{...m}):ne(as,{...m}),ne(ls,{...m}),o.tools?.image!==!1&&ne(ss,{...m}),ne(cs,{...m})]}),ne("div",{className:"App-toolbar__divider"}),ne(Mb,{app:e,activeTool:p,setAppState:t,UIOptions:o,isMyocSimplifiedMode:u,actionManager:r}),u&&Go(bl,{children:[ne("div",{className:"App-toolbar__divider"}),ne(Pb,{actionManager:r,app:e})]})]})]})};import{jsx as Zk}from"react/jsx-runtime";var $k=e=>Zk(bt,{label:`${f("helpDialog.title")} \u2014 ?`,children:Zk("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Zi})});import{Fragment as cu,jsx as q,jsxs as Xn}from"react/jsx-runtime";var bc={id:"desktopCanvasControls",className:"desktop-canvas-controls",padding:.75,gap:6},NV=({UIOptions:e})=>Xn(Gt,{__fallback:!0,children:[q(Gt.DefaultItems.LoadScene,{}),q(Gt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&q(Gt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&q(Gt.DefaultItems.SaveAsImage,{}),q(Gt.DefaultItems.SearchMenu,{}),q(Gt.DefaultItems.Help,{}),q(Gt.Separator,{}),q(Gt.Group,{title:"Excalidraw links",children:q(Gt.DefaultItems.Socials,{})}),q(Gt.Separator,{}),q(Gt.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),q(Gt.DefaultItems.ChangeCanvasBackground,{})]}),BV=()=>Xn(Up,{__fallback:!0,children:[q(Up.Actions.SaveToDisk,{}),q(Up.Actions.ExportToImage,{})]}),FV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:l,showExitZenModeBtn:s,renderTopLeftUI:d,renderTopRightUI:c,renderCustomStats:p,UIOptions:m,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C,uiLayout:P})=>{let M=me(),L=Dp(P,M),_=on(),D=it()==="compact",B=IS(),K=D?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1},z=B.tunnelsJotai.Provider,[U,W]=$e(Yt),G=()=>m.canvasActions.export?q(Gk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:m.canvasActions.export,canvas:i,setAppState:o}):null,oe=()=>!m.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:q(bk,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),le=(Fe=!0)=>Xn("div",{className:"excalidraw-ui-top-left",style:{position:"relative"},children:[q(B.MainMenuTunnel.Out,{}),Fe&&q(B.DefaultSidebarTriggerTunnel.Out,{}),E&&q(B.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>q(CE,{heading:"selectedShapeActions",className:lu("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:D?q(Ke,{className:lu("compact-shape-actions-island"),padding:0,style:{maxHeight:`${n.height-166}px`},children:q(US,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):q(Ke,{className:AV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},children:q(FS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),V=w&&RV(n,r),ce=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector",fe=()=>w&&V?q(an.Col,{gap:K.menuTopGap,children:q("div",{className:lu("selected-shape-actions-container",{"selected-shape-actions-container--compact":D}),children:F()})}):null,Be=(Fe=!0)=>!w||!n.viewModeEnabled&&n.openDialog?.name==="elementLinkSelector"?null:Xn(cu,{children:[w&&n.viewModeEnabled&&q("div",{className:"view-mode-hint",children:q(gl,{appState:n,isMobile:!1,editorInterface:M,app:b})}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&q(CE,{heading:"shapes",className:"shapes-section",children:st=>Xn("div",{style:{position:"relative"},children:[E&&q(B.WelcomeScreenToolbarHintTunnel.Out,{}),q(an.Col,{gap:K.toolbarColGap,align:"start",children:Xn(an.Row,{gap:K.toolbarRowGap,className:lu("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[q(Xk,{app:b,appState:n,setAppState:o,UIOptions:m,actionManager:e,onPenModeToggle:l,onLockToggle:a,heading:st,showPenMode:Fe}),I&&q(Ke,{style:{alignSelf:"center",height:"fit-content"},children:q(Hk,{title:f("toolBar.laser"),checked:n.activeTool.type===jk.laser,onChange:()=>b.setActiveTool({type:jk.laser}),isMobile:!0})})]})})]})})]}),Ee=()=>q("div",{className:"layer-ui__wrapper__top-right",children:w&&n.collaborators.size>0&&q(Bp,{collaborators:n.collaborators,userToFollow:_.userToFollow?.socketId||null,currentUserControls:C})}),He=()=>ce?q(uc,{app:b,onClose:()=>e.executeAction(yr),renderCustomStats:p}):null,se=()=>q(B.FooterCenterTunnel.Out,{}),Pe=()=>q("div",{className:"layer-ui__wrapper__footer-right",children:Xn("div",{style:{position:"relative"},children:[E&&q(B.WelcomeScreenHelpHintTunnel.Out,{}),w&&q($k,{onClick:()=>e.executeAction(si)})]})}),ke=()=>{let Fe=L?.items?.penMode!==void 0,st=L?.items?.sidebarTrigger!==void 0||L?.items?.mainMenu?.visible===!1,Vt=[{id:"hostTopLeftUI",defaultRegion:"topLeft",defaultOrder:-10,content:d?.(!1,n)},{id:"mainMenu",defaultRegion:"topLeft",content:le(!st)},{id:"sidebarTrigger",defaultRegion:"topLeft",defaultOrder:2,content:st?q("div",{className:"excalidraw-ui-top-left",style:{position:"relative"},children:q(B.DefaultSidebarTriggerTunnel.Out,{})}):null},{id:"stylesPanel",defaultRegion:"middleLeft",content:fe()},{id:"toolbar",defaultRegion:"topCenter",content:Be(!Fe)},{id:"hostTopRightUI",defaultRegion:"topRight",defaultOrder:-10,content:c?.(!1,n)},{id:"collaborators",defaultRegion:"topRight",content:Ee()},{id:"stats",defaultRegion:"topRight",content:He()},{id:"viewMode",defaultRegion:"bottomLeft",islandGroup:bc,content:w&&!n.viewModeOnly?q(bt,{label:n.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:q("div",{className:"view-mode-button",children:e.renderAction("viewMode")})}):null},{id:"smartZoom",defaultRegion:"bottomLeft",islandGroup:bc,content:w?q(bt,{label:f("buttons.smartZoom"),children:q("div",{className:"smart-zoom-button",children:e.renderAction("smartZoom")})}):null},{id:"zoom",defaultRegion:"bottomLeft",islandGroup:bc,content:y&&b.isNavigationEnabled()?q(VS,{renderAction:e.renderAction}):null},{id:"undo",defaultRegion:"bottomLeft",islandGroup:bc,content:w&&!n.viewModeEnabled?q("div",{className:"undo-button-container",children:e.renderAction("undo")}):null},{id:"redo",defaultRegion:"bottomLeft",islandGroup:bc,content:w&&!n.viewModeEnabled?q("div",{className:"redo-button-container",children:e.renderAction("redo")}):null},{id:"help",defaultRegion:"bottomRight",content:Pe()},{id:"penMode",defaultRegion:D?"topLeft":"topRight",content:w&&!n.viewModeEnabled&&(Fe||D&&V)?q(Ar,{checked:n.penMode,onChange:()=>l(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected}):null}];return q(Lp,{items:Vt,layout:L,app:b,appState:n,editorInterface:M,className:"ui-layout--desktop",legacyBottomCenter:se()})},xe=()=>q(Tb,{}),gt=!1,Qt=Xn(cu,{children:[g,w&&q(cu,{children:q(NV,{UIOptions:m})}),q(BV,{}),w&&n.isLoading&&q(Cp,{delay:250}),w&&n.errorMessage&&q(ek,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&U&&M.formFactor!=="phone"&&q(Q0,{colorPickerType:U.colorPickerType,onCancel:()=>{W(null)},onChange:(Fe,st,Vt,{altKey:Xo})=>{if(!(Fe!=="elementBackground"&&Fe!=="elementStroke"))if(Vt.length){for(let Zo of Vt)DV(Zo,LV(r),{[Xo&&U.swapPreviewOnAlt?Fe==="elementBackground"?"strokeColor":"backgroundColor":Fe==="elementBackground"?"backgroundColor":"strokeColor"]:st}),_V.delete(Zo);b.scene.triggerUpdate()}else o(Fe==="elementBackground"?{currentItemBackgroundColor:st}:{currentItemStrokeColor:st})},onSelect:(Fe,st)=>{W(Vt=>Vt?.keepOpenOnAlt&&st.altKey?Vt:null),U?.onSelect?.(Fe,st)}}),n.openDialog?.name==="help"&&q(dk,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&q(QP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),q(B.OverwriteConfirmDialogTunnel.Out,{}),oe(),G(),w&&n.openDialog?.name==="charts"&&q(DC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&q(ak,{app:b,files:t,setAppState:o}),M.formFactor==="phone"&&q(yC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:G,renderImageExportDialog:oe,setAppState:o,onPenModeToggle:l,renderTopLeftUI:d,renderTopRightUI:c,renderSidebars:xe,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x,uiLayout:P}),M.formFactor!=="phone"&&Xn(cu,{children:[_.viewportStatusFrame?.border&&q(Ip,{border:_.viewportStatusFrame.border,style:gt?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),Xn("div",{className:"layer-ui__wrapper",style:gt?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&q(B.WelcomeScreenCenterTunnel.Out,{}),ke(),w&&q(YS,{showExitZenModeBtn:s}),(n.toast||x&&n.scrolledOutside||_.viewportStatusFrame?.label)&&Xn("div",{className:"floating-status-stack",children:[n.toast&&q(om,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&q("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(Fe=>({...Bi(r,Fe)}))},children:f("buttons.scrollBackToContent")}),_.viewportStatusFrame?.label&&q(Tp,{label:_.viewportStatusFrame.label,border:_.viewportStatusFrame.border})]})]})]}),xe()]});return q(Dh.Provider,{value:n,children:q(z,{children:q(bE.Provider,{value:B,children:Qt})})})},qk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:l,suggestedBinding:s,frameToHighlight:d,elementsToHighlight:c,...p}=e;return p},OV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...l}=n;return su(qk(o),qk(a),{selectedElementIds:su,selectedGroupIds:su})&&su(r,l)},Jk=MV.memo(FV,OV);import{useEffect as zV,useRef as GV}from"react";import{jsx as Qk}from"react/jsx-runtime";var eM=({trails:e})=>{let n=GV(null);return zV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Qk("div",{className:"SVGLayer",children:Qk("svg",{ref:n})})};import HV,{useEffect as tM,useRef as nM}from"react";import{isShallowEqual as UV,sceneCoordsToViewportCoords as WV}from"@excalidraw/common";import{jsx as KV}from"react/jsx-runtime";var oM="animateInteractiveScene",VV=e=>{let n=nM(!1),t=nM(null);return tM(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&nE({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),tM(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((d,c)=>{if(d.selectedElementIds)for(let p of Object.keys(d.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(c);!d.pointer||d.pointer.renderCursor===!1||(d.username&&a.set(c,d.username),d.userState&&l.set(c,d.userState),r.set(c,WV({sceneX:d.pointer.x,sceneY:d.pointer.y},e.appState)),o.set(c,d.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:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},mt.running(oM)||mt.start(oM,({deltaTime:d,state:c})=>{let p=nE({...t.current,deltaTime:d,animationState:c}).animationState;if(p){for(let m in p)if(p[m]!==void 0)return p}})}),KV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.onDoubleClick,children:f("labels.drawingCanvas")})},rM=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),YV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:UV(rM(e.appState),rM(n.appState)),Ab=HV.memo(VV,YV);import lM,{useEffect as du,useRef as xc}from"react";import{isShallowEqual as iM}from"@excalidraw/common";import{hasActiveGifDecode as XV}from"@excalidraw/element";import{jsx as jV}from"react/jsx-runtime";var ZV=e=>{let n=xc(null),t=xc(!1),o=xc(e),r=xc(()=>{}),i=xc(null);o.current=e;let a=lM.useCallback(()=>{let l=o.current,s=n.current;if(!s)return;let d=getComputedStyle(s).getPropertyValue("--color-grid-bold").trim(),c=getComputedStyle(s).getPropertyValue("--color-grid-regular").trim();Dx({canvas:l.canvas,rc:l.rc,scale:l.scale,elementsMap:l.elementsMap,allElementsMap:l.allElementsMap,visibleElements:l.visibleElements,appState:l.appState,renderConfig:{...l.renderConfig,gridColorBold:d,gridColorRegular:c}},Fa());let p=l.renderConfig.imageTransitionDuration??0,m=p>0&&l.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=l.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<p}),u=XV(l.visibleElements,l.renderConfig.imageCache);(m||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,du(()=>{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]),du(()=>{let l=n.current;if(!l)return;let s=e.canvas;t.current||(t.current=!0,l.replaceChildren(s),s.classList.add("excalidraw__canvas","static")),a()}),du(()=>{let l=null,s=e.app.imagePlaceholderUpdateEmitter.on(()=>{l===null&&(l=requestAnimationFrame(()=>{l=null,a()}))});return()=>{s(),l!==null&&cancelAnimationFrame(l)}},[e.app,a]),du(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),jV("div",{className:"excalidraw__canvas-wrapper",ref:n})},aM=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,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}),$V=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:iM(aM(e.appState),aM(n.appState))&&iM(e.renderConfig,n.renderConfig),Lb=lM.memo(ZV,$V);import{useEffect as oY,useRef as rY}from"react";import{throttleRAF as qV}from"@excalidraw/common";import{getTargetFrame as JV,isInvisiblySmallElement as QV,renderElement as eY,shouldApplyFrameClip as tY}from"@excalidraw/element";var sM=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=Uc(e,i),c=Wc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(c.save(),Vc(c,a),t&&t.type!=="selection"){if(QV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=JV(t,o,a);u&&tY(t,u,a,o)&&Ax(u,c,l,a)}eY(t,o,r,n,c,l,a)}else c.clearRect(0,0,s,d);c.restore()}},nY=qV(e=>{sM(e)}),cM=(e,n)=>{if(n){nY(e);return}sM(e)};import{jsx as aY}from"react/jsx-runtime";var iY=e=>{let n=rY(null);return oY(()=>{n.current&&cM({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Fa())}),aY("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:n})},dM=iY;import lY from"clsx";import{useLayoutEffect as sY,useEffect as mM,useRef as cY,useState as dY}from"react";import{ARROW_TYPE as pM,EVENT as mu}from"@excalidraw/common";import{jsx as hY}from"react/jsx-runtime";var uM=700,mY=100,pY=16,uY=5*60*1e3,gM=et(null),hM=e=>e===pM.elbow?or:e===pM.round?rr:nr,pu=class{constructor(n){v(this,"app");v(this,"lastShownAt",0);v(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(gM,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<uY);v(this,"onArrowTypeCycled",n=>{this.show(hM(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Qo:hM(this.app.state.currentItemArrowType))});this.app=n}},fM=()=>{let[e,n]=$e(gM),t=ft(),{container:o}=Te(),r=cY(null),[i,a]=dY(!1),l=e?.nonce;return sY(()=>{if(l==null||!o)return;let s=(c,p)=>{let m=r.current;if(!m)return;let{left:u,top:E}=yd({cursor:{x:c,y:p},element:{width:m.offsetWidth,height:m.offsetHeight},container:o.getBoundingClientRect(),gap:pY});m.style.transform=`translate(${u}px, ${E}px)`};s(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let d=c=>{s(c.clientX,c.clientY)};return window.addEventListener(mu.POINTER_MOVE,d),()=>{window.removeEventListener(mu.POINTER_MOVE,d)}},[l,o,t]),mM(()=>()=>{n(null)},[n]),mM(()=>{if(l==null)return;a(!1);let s=window.setTimeout(()=>{a(!0)},uM),d=window.setTimeout(()=>{n(null)},uM+mY),c=()=>{n(null)};return window.addEventListener(mu.POINTER_DOWN,c,{capture:!0}),()=>{window.clearTimeout(s),window.clearTimeout(d),window.removeEventListener(mu.POINTER_DOWN,c,{capture:!0})}},[l,n]),e?hY("div",{ref:r,className:lY("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var uu=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}=this.normalize(n,t,o);return a?s&&(queueMicrotask(()=>{let d=this.getState();a(i(d),d)}),l)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:l}):s?Promise.resolve(i(this.getState())):new Promise(d=>{this.subscribe({predicate:r,getValue:i,callback:c=>d(c),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,l=o?.once??!1,s=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:d,callback:c,once:p}=n;r=d,i=m=>m,a=c?(m,u)=>c(u):void 0,l=p??!1,s=d(this.getState())}else if(typeof n=="function"){let d=n;r=(c,p)=>d(c)!==d(p),i=c=>d(c)}else if(Array.isArray(n)){let d=n;r=(c,p)=>d.some(m=>c[m]!==p[m]),i=c=>c}else{let d=n;r=(c,p)=>c[d]!==p[d],i=c=>c[d]}return{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as gY,getElementsInGroup as fY,isNonDeletedElement as EM,selectGroupsFromGivenElements as EY}from"@excalidraw/element";import{sceneCoordsToViewportCoords as bY}from"@excalidraw/common";import{flushSync as xY}from"react-dom";import{jsx as wY}from"react/jsx-runtime";var yY=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!EM(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&EM(t)?t:null,r=o?[o]:fY(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=gY(r),{x:l,y:s}=bY({sceneX:i,sceneY:a},e.state);return wY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-s+e.state.offsetTop}px`,left:`${l-e.state.offsetLeft}px`},onClick:()=>{xY(()=>{let d=EY(r,e.state);e.setState({selectedElementIds:r.reduce((c,p)=>({...c,[p.id]:!0}),{}),selectedGroupIds:d,activeLockedId:null})}),e.actionManager.executeAction(Ts)},title:f("labels.elementLock.unlock"),children:Jx})},bM=yY;import{Fragment as wX,jsx as Ce,jsxs as ex}from"react/jsx-runtime";var PA=Mn.createContext(null),kA=Mn.createContext(null),tx={formFactor:"desktop",desktopUIMode:"full",userAgent:SA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},ox=Mn.createContext(tx);ox.displayName="EditorInterfaceContext";var EX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},rx=Mn.createContext({container:null,id:null});rx.displayName="ExcalidrawContainerContext";var ix=Mn.createContext([]);ix.displayName="ExcalidrawElementsContext";var ax=Mn.createContext({...qo(),width:0,height:0,offsetLeft:0,offsetTop:0});ax.displayName="ExcalidrawAppStateContext";var lx=Mn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});lx.displayName="ExcalidrawSetAppStateContext";var sx=Mn.createContext(null);sx.displayName="ExcalidrawActionManagerContext";var Tl=Mn.createContext(null);Tl.displayName="ExcalidrawAPIContext";var Mu=Mn.createContext(null);Mu.displayName="ExcalidrawAPISetContext";var ft=()=>Ko(PA),on=()=>Ko(kA),me=()=>Ko(ox),it=()=>ku(me()),Te=()=>Ko(rx),Qi=()=>Ko(ix),nn=()=>Ko(ax),ze=()=>Ko(lx),nt=()=>Ko(sx),Wd=()=>Ko(Tl),Mc=!1,Ac=0,Lc=null,Vo=!1,Dc=!1,Yo=!1,Su=!1,_c={horizontal:null,vertical:null},Hr=0,Rc=!1,Qb=new Map,bX=4,xX=300,wA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,Cu=!1,Pu=0,vA=!1,Il=null,ue={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},nx=class e extends Mn.Component{constructor(t){super(t);v(this,"canvas");v(this,"interactiveCanvas",null);v(this,"sessionExportThemeOverride");v(this,"rc");v(this,"unmounted",!1);v(this,"actionManager");v(this,"editorInterface",tx);v(this,"stylesPanelMode",ku(tx));v(this,"excalidrawContainerRef",Mn.createRef());v(this,"scene");v(this,"fonts");v(this,"renderer");v(this,"visibleElements");v(this,"hasRenderableElements",!1);v(this,"resizeObserver");v(this,"id");v(this,"store");v(this,"history");v(this,"excalidrawContainerValue");v(this,"files",{});v(this,"imageCache",new Map);v(this,"imageLoadingProgress",new Map);v(this,"imageLoadingProgressEmitter",new bo);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new bo);v(this,"imagePlaceholderUpdateEmitter",new bo);v(this,"iFrameRefs",new Map);v(this,"embedsValidationStatus",new Map);v(this,"initializedEmbeds",new Set);v(this,"elementsPendingErasure",new Set);v(this,"_initialized",!1);v(this,"editorLifecycleEvents",new JY(EX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new uu(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new up(this));v(this,"flowchart",new bp(this));v(this,"cursor",new hp(this));v(this,"gifPlayback",new xp(this));v(this,"zDragZoom",null);v(this,"arrowText",new pp(this));v(this,"viewport",new wp(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>ue.pointers.size>=2||Yo}));v(this,"bindModeHandler",null);v(this,"textWysiwygSubmitHandler",null);v(this,"hitLinkElement");v(this,"lastPointerDownEvent",null);v(this,"lastPointerUpEvent",null);v(this,"lastPointerUpIsDoubleClick",!1);v(this,"lastPointerMoveEvent",null);v(this,"lastPointerMoveCoords",null);v(this,"lastCompletedCanvasClicks",[]);v(this,"lastKeyboardSmartZoomImageId",null);v(this,"smartZoomKeyDownAt",null);v(this,"smartZoomKeyHitElement",!1);v(this,"previousPointerMoveCoords",null);v(this,"drawShape",new Ep(this));v(this,"laserTrails",new Wm(this));v(this,"eraserTrail",new jm(this));v(this,"lassoTrail",new $m(this));v(this,"cursorHints",new pu(this));v(this,"onChangeEmitter",new bo);v(this,"onPointerDownEmitter",new bo);v(this,"onPointerUpEmitter",new bo);v(this,"onUserFollowEmitter",new bo);v(this,"onScrollChangeEmitter",new bo);v(this,"missingPointerEventCleanupEmitter",new bo);v(this,"onRemoveEventListenersEmitter",new bo);v(this,"api");v(this,"getCommandToolTypes",()=>this.state.myocSimplifiedMode?[...cw,...hr]:Object.keys(Me));v(this,"resolveCommandToolType",t=>{if(!Object.prototype.hasOwnProperty.call(Me,t))return null;let o=t;if(!this.getCommandToolTypes().includes(o))return null;let r=o==="selection"?this.state.preferredSelectionTool.type:o;return!this.isToolSupported(r)||this.props.activeTool!=null&&this.props.activeTool.type!==r?null:r});v(this,"getCommandActionEntry",(t,o)=>{if(!t.keyTest||!this.actionManager.isActionAvailableForUI(t))return null;let r=typeof t.label=="function"?t.label(o,this.state,this):t.label;if(!r.trim())return null;let i=typeof t.icon=="function"?t.icon(this.state,o):t.icon,a=wT(t.name);return{id:`action:${t.name}`,kind:"action",label:f(r,null,r),...i?{icon:i}:{},...t.keywords?{keywords:t.keywords}:{},...a?{shortcut:a}:{}}});v(this,"getCommandCatalog",()=>{let t=this.actionManager.getElementsIncludingDeleted(),o=Object.values(this.actionManager.actions).flatMap(i=>{let a=this.getCommandActionEntry(i,t);return a?[a]:[]}),r=this.getCommandToolTypes().flatMap(i=>{let a=this.resolveCommandToolType(i);if(!a)return[];let l=Lo(i);return[{id:`tool:${i}`,kind:"tool",label:jY(f(`toolBar.${a}`)),icon:Me[a].icon,...l?{shortcut:l}:{}}]});return[...o,...r]});v(this,"executeCommand",t=>{if(t.startsWith("action:")){let i=t.slice(7);if(!Object.prototype.hasOwnProperty.call(this.actionManager.actions,i))return!1;let a=this.actionManager.actions[i];return!a||`action:${a.name}`!==t||!this.getCommandActionEntry(a,this.actionManager.getElementsIncludingDeleted())?!1:(this.actionManager.executeAction(a,"ui"),!0)}if(!t.startsWith("tool:"))return!1;let o=t.slice(5),r=this.resolveCommandToolType(o);return r?(this.setActiveTool({type:r}),!0):!1});v(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});v(this,"updateEditorAtom",(t,...o)=>{let r=Tt.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>Ir(this)?this.state.gridSize:null);v(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});v(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&Pc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Le.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=MM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),_i.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Wo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Ub(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Gb(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});v(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);v(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.viewpointFlip!==this.state.viewpointFlip||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Se({clientX:i.x,clientY:i.y},this.state),l=Se({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,l.x),y:Math.min(a.y,l.y),width:Math.abs(l.x-a.x),height:Math.abs(l.y-a.y),zoom:this.state.zoom.value,viewpointFlip:this.state.viewpointFlip,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===vc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!XM(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:a,y:l}=Eu({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),s=6,d,c=BK(i);if(i.id===this.state.editingFrame){let p=c;d=Ce("input",{autoFocus:!0,value:p,onChange:m=>{this.scene.mutateElement(i,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:m=>{(m.key===Y.ESCAPE||m.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:qY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Ho.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?Ho.nameColorDarkTheme:Ho.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=c;return Ce("div",{id:this.getFrameNameDOMId(i),className:zb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Ho.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Ho.nameFontSize,color:t?Ho.nameColorDarkTheme:Ho.nameColorLightTheme,lineHeight:Ho.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:Le.MOVE,pointerEvents:this.state.viewModeEnabled?yl.disabled:yl.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Ye("export",t,"ui");let i=await ai(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(ZY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Kc(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Yt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(s=>this.state.selectedElementIds[s.id]?yo(s,{[a?"strokeColor":"backgroundColor"]:r}):s),captureUpdate:Jt.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Je(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||vc.LIGHT,l=t?.appState?.name??this.state.name,s=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let d=r.id,c=t.elements.find(p=>p.id===d);r=c&&Tu(c)&&qt(c)?c:null}this.setState(d=>{let c=t.appState||{};return{...d,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:l,errorMessage:s}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(Jt.NEVER));v(this,"onBlur",Je(()=>{Vo=!1,this.resetSmartZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[Y.CTRL_OR_CMD]&&t.preventDefault()});v(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});v(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==Y.PAGE_UP&&t.key!==Y.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===Y.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});v(this,"preventBrowserZoomKeyDown",t=>{t[Y.CTRL_OR_CMD]&&(t.code===Or.EQUAL||t.code===Or.MINUS||t.code===Or.ZERO||t.code===Or.NUM_ADD||t.code===Or.NUM_SUBTRACT||t.code===Or.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Vo=!1,Dc=!1,this.resetSmartZoomKey(),Yo=!1,Su=!1,Il=null,ue.pointers.clear(),ue.lastCenter=null,ue.initialDistance=null,ue.initialScale=null,clearTimeout(Ac),Ac=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(Pu),Pu=0,Cu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Tt.set(Yt,null),Tt.set(ho,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&kt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});v(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,l=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(l=!!this.props.viewModeEnabled):l=!0,l!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:l});let s=r&&!o.viewModeEnabled,d=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||s&&!d)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,Tm(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:sn(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});v(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));v(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});v(this,"resetHistory",()=>{this.history.clear()});v(this,"resetStore",()=>{this.store.clear()});v(this,"resetScene",Je(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...qo(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));v(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async s=>{if(!s.files.length)return;let d=s.files[0],c=await d.getFile();this.loadFileToCanvas(new File([c],c.name||"",{type:c.type}),d)}),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}catch(s){console.error(s),t={appState:{errorMessage:s.message||"Encountered an error during importing or restoring scene data"}}}let o=Yr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=zi(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,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,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};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},l=this.props.initialState?.viewport;if(l){let s=o.filter(p=>!p.isDeleted),d=Sc(s),c=this.viewport.resolveInitialViewport(l,d,a);c&&(r={...r,...c})}else t?.scrollToContent&&(r={...r,...Bi(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:Jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(s=>{this.fonts.onLoaded(s)}),oA(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});v(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??nK(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=aK(),a=SA(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:DY,s=Ob(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>l,isLandscape:o>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});v(this,"reconcileStylesPanelMode",t=>{let o=ku(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});v(this,"setDesktopUIMode",t=>{let o=lK(t);!o||o===this.editorInterface.desktopUIMode||(this.editorInterface=Ob(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface),this.forceUpdate())});v(this,"onResize",Je(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>_i.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));v(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(_c=t),this.scheduleImageRefresh()});v(this,"onScroll",DM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},_Y));v(this,"onCut",Je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ic(t.target)||(this.actionManager.executeAction(wm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ic(t.target)||(this.actionManager.executeAction(xa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(oK&&t.preventDefault(),!Mc){Mc=!0,t.touches.length===1&&(Lc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Ac),Ac=window.setTimeout(e.resetTapTwice,MM);return}if(Mc&&t.touches.length===1&&Lc){let o=t.touches[0];Eo(ie(o.clientX,o.clientY),ie(Lc.x,Lc.y))<=BM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Mc=!1,clearTimeout(Ac)}t.touches.length===2&&this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ne(this.state.previousSelectedElementIds,this.state)}):ue.pointers.clear())});v(this,"pasteFromClipboard",Je(async t=>{if(!this.isInteractionEnabled())return;let o=!!Cu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||Ic(r)))return;let l=await fr(t),s=l.getFiles(),d=await fs(l,o);if(!d.elements&&s.length>0&&!o)try{let p=(await sm())[Pn.excalidrawClipboard];typeof p=="string"&&(l=await fr(am({types:{[Pn.excalidrawClipboard]:p}})),s=l.getFiles(),d=await fs(l,o))}catch(c){console.warn(`Could not read editable image clipboard data: ${c.message}`)}if(this.state.viewModeEnabled){if(!this.containsImagePaste(d,s,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:s.map(c=>c.file),data:d,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(d,s,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Yr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=vl(o),s=wl(r,a)/2,d=wl(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:u}=Se({clientX:c,clientY:p},this.state),E=m-s,g=u-d,[b,w]=Dt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=WM({type:"everything",elements:o.map(M=>yo(M,{x:M.x+b-r,y:M.y+w-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...y];I=this.props.onDuplicate?.(I,x)||I,lA(I,Sc(y));let C=this.getTopLayerFrameAtSceneCoords({x:m,y:u});if(C){let M=FK(y,C);I=Xb(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if(qt(M)&&YM(M)){let L=qM(M,this.scene.getElementsMapIncludingDeleted());MK(M,L,this.scene)}}),iK&&To.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=QK(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Tt.get(Ib)?this.state.openSidebar:null,...sA(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:y,fit:t.fit,animation:!1,offsets:{ui:!0}})});v(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});v(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,l)=>r(t(a,l)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{Hr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=ue.pointers.size>=2;ue.pointers.delete(t.pointerId),o&&ue.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ye("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...sn(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});v(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});v(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});v(this,"revealIfHidden",t=>{!t.length||TK(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:vl(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});v(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Qn(t.zoom)},shouldCacheIgnoreZoom:!1})});v(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});v(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});v(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});v(this,"setToast",t=>{this.setState({toast:t})});v(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,SY,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Je(t=>{let o=new Map;for(let l of t){let s=l.id,d=this.imageCache.get(s);d&&!this.files[s]&&o.set(s,Promise.resolve(d.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Wb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:l=>this.handleImageCacheUpdate(l),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:l})=>{for(let[s,d]of o){let c=this.imageCache.get(s);!c||!l.has(s)||(this.imageCache.set(s,{...c,placeholderImage:await d,transitionStart:performance.now()}),this.clearImageLoadingProgress(s))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));v(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:l,customData:s})=>({file:await Kr(l),customData:s??{}}))),a=i.find(({file:l})=>!Gi(l));if(a)throw new Gu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:l})=>l),o,r,i.map(({customData:l})=>l))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Kr(o);if(!Gi(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((s,d)=>{i.onload=()=>s(i),i.onerror=()=>d(new Error(f("errors.imageInsertError")))}),l={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===Pn.gif?"pending":void 0};this.imageCache.set(t,l),l.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Xc(r);try{let s=await a;if(this.imageCache.get(t)!==l||this.files[t])return;this.imageCache.set(t,{...l,image:s}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(s){throw this.imageCache.get(t)===l&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),s}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=yc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});v(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});v(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,l=r===void 0?a:r??void 0,s=typeof o=="number";return{...i,uploadProgress:{...l,state:s?"uploading":o,...s?{progress:yc(o,0,1)}:{progress:void 0}}}})});v(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});v(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);v(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});v(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())Di(o)&&o.fileId===t&&_i.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Pn.svg))try{let s=Fx(jM(zx(l.dataURL)),Pn.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});v(this,"updateScene",Je(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=o||void 0,s=r?cK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));v(this,"applyDeltas",(t,o)=>{let r=hA.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return hA.applyTo(r,a,i,o)});v(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));v(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});v(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});v(this,"updateCurrentCursorPosition",Je(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"isPlainSmartZoomKey",t=>!t[Y.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey&&t.key.toLocaleLowerCase()===Y.F);v(this,"updateSmartZoomCursor",t=>{if(this.smartZoomKeyDownAt===null)return;let o=t?this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0}):null;this.cursor.set(o?Le.POINTER:"zoom-in")});v(this,"resetSmartZoomKey",()=>{let t=this.smartZoomKeyDownAt!==null;this.smartZoomKeyDownAt=null,this.smartZoomKeyHitElement=!1,t&&(this.cursor.reset(),this.updateEditorAtom(wa,!1))});v(this,"handleSmartZoomKeyDown",t=>this.isPlainSmartZoomKey(t)?(!t.repeat&&this.smartZoomKeyDownAt===null&&(this.smartZoomKeyDownAt=Date.now(),this.smartZoomKeyHitElement=!1,this.updateEditorAtom(wa,!0),this.updateSmartZoomCursor(this.lastPointerMoveCoords)),t.preventDefault(),t.stopPropagation(),!0):!1);v(this,"handleSmartZoomKeyUp",t=>{if(t.key.toLocaleLowerCase()!==Y.F||this.smartZoomKeyDownAt===null)return!1;let o=Date.now()-this.smartZoomKeyDownAt,r=!this.smartZoomKeyHitElement&&o<=xX;return this.resetSmartZoomKey(),t.stopPropagation(),r&&this.actionManager.executeAction(Bn,"keyboard",this.scene.getNonDeletedElements()),!0});v(this,"handleSmartZoomPointerDown",(t,o)=>{if(t.button!==kn.MAIN||this.smartZoomKeyDownAt===null)return!1;let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});return r?(this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Bn,"keyboard",[r]),!0):!1});v(this,"onKeyDown",Je(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(s,d){let c=s[d];return typeof c=="function"?c.bind(s):d==="key"?t.shiftKey?s.key.toUpperCase():s.key.toLowerCase():c}})),!_M(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let s=de(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&jn(s[0])&&t.key===Y.ENTER){this.startImageCropping(s[0]);return}if(s.length===0&&(t.key===Y.ARROW_LEFT||t.key===Y.ARROW_RIGHT)&&!t[Y.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey){let d=this.scene.getNonDeletedElementsMap(),c=yv(this.scene.getNonDeletedElements(),d,this.lastKeyboardSmartZoomImageId,t.key===Y.ARROW_RIGHT?"next":"previous");if(c){this.lastKeyboardSmartZoomImageId=c.id,this.actionManager.executeAction(Bn,"keyboard",[c]),t.preventDefault(),t.stopPropagation();return}}if(t.key===Y.ESCAPE)this.updateEditorAtom(ho,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(zb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let d=mp(s);Tt.get(ho)?.type==="panel"&&uE(this,{conversionType:d,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),d&&this.updateEditorAtom(ho,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(Cu=t.shiftKey,clearTimeout(Pu),Pu=window.setTimeout(()=>{Cu=!1},100)),t[Y.CTRL_OR_CMD]&&Ic(t.target)&&(t.code===Or.MINUS||t.code===Or.EQUAL)){t.preventDefault();return}if(Ic(t.target)&&t.key!==Y.ESCAPE||Rb(t.key)&&_M(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===Y.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Uo("COMPLEX_BINDINGS")?this.handleSkipBindMode():Iu({app:this,event:t});if(this.handleSmartZoomKeyDown(t)||this.actionManager.handleKeyDown(t))return;if(this.state.viewModeEnabled&&t.key.toLowerCase()===Y.Z&&!t[Y.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey){Dc=!0,this.cursor.set("zoom-in"),t.preventDefault();return}let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===Y.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let s=dw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!FM(s,["laser","hand"]))return;if(s){if(this.state.activeTool.type!==s&&Ye("toolbar",s,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),s==="arrow"&&this.state.activeTool.type==="arrow"){let d=this.state.currentItemArrowType===zr.sharp?zr.round:this.state.currentItemArrowType===zr.round?zr.elbow:zr.sharp;this.setState({currentItemArrowType:d}),this.cursorHints.onArrowTypeCycled(d)}else(s==="arrow"||s==="line")&&this.cursorHints.onToolShortcut(s,/^\d$/.test(t.key)?"digit":"letter");s==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():s==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:s},{toggle:!0}),t.stopPropagation();return}else if(t.key===Y.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[Y.CTRL_OR_CMD]&&!t.repeat&&(Uo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ut(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Iu({app:this,event:t})),Rb(t.key)){let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),d=new Set;s.filter(u=>wo(u)).filter(u=>{let E=u.startBinding&&!s.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!s.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>d.add(u.id)),s=s.filter(u=>!d.has(u.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?kM:this.getEffectiveGridSize())||(t.shiftKey?MY:kM),p=0,m=0;t.key===Y.ARROW_LEFT?p=-c:t.key===Y.ARROW_RIGHT?p=c:t.key===Y.ARROW_UP?m=-c:t.key===Y.ARROW_DOWN&&(m=c),p*=$n(this.state.viewpointFlip.horizontal),m*=$n(this.state.viewpointFlip.vertical),s.forEach(u=>{this.scene.mutateElement(u,{x:u.x+p,y:u.y+m},{informMutation:!1,isDragging:!1}),yu(u,this.scene,{simultaneouslyUpdated:s})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let s=this.scene.getSelectedElements(this.state);if(s.length===1){let d=s[0];if(t[Y.CTRL_OR_CMD]||jb(d))Wt(d)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==d.id)&&(this.store.scheduleCapture(),jt(d)||this.actionManager.executeAction(La));else if(qt(d)||JM(d)){let c;qt(d)||(c=d);let p=Yb(d,this.scene.getNonDeletedElementsMap()),m=p.x,u=p.y;this.startTextEditing({sceneX:m,sceneY:u,container:c}),t.preventDefault();return}else kt(d)&&this.setState({editingFrame:d.id})}}if(t.key===Y.SPACE&&ue.pointers.size===0&&(Vo=!0,this.cursor.set(Le.GRAB),t.preventDefault()),t.key.toLowerCase()===Y.Z&&!t[Y.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Dc=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;t.key===Y.G&&(jo(this.state.activeTool.type)||s.some(d=>jo(d.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.F){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;(this.state.activeTool.type==="text"||s.find(d=>qt(d)||Vb(d,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===Y.I&&!t.shiftKey&&!t[Y.CTRL_OR_CMD],a=r===Y.S&&t.shiftKey&&!t[Y.CTRL_OR_CMD]||i,l=r===Y.I&&t.shiftKey&&!t[Y.CTRL_OR_CMD];(a||l)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Je(t=>{if(this.isInteractionEnabled()&&!this.handleSmartZoomKeyUp(t)){if(t.key===Y.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Le.GRAB):bu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Vo=!1),t.key.toLowerCase()===Y.Z&&(Dc=!1,this.cursor.reset()),t.key===Y.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Iu({app:this,event:t})),(t.key===Y.ALT&&this.state.bindMode==="skip"||!t[Y.CTRL_OR_CMD]&&!xu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Uo("COMPLEX_BINDINGS"))){let o=Se({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Gr(ie(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());wo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[Y.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ut(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Iu({app:this,event:t})}if(Rb(t.key)){zM(this.scene.getSelectedElements(this.state).filter(Cc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(qb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...fA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...fA(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));v(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(xt);let i=da.includes(t.type),l=o.toggle===!0&&i&&this.state.activeTool.type===t.type?sn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?sn(this.state,{...t,lastActiveTool:this.state.activeTool}):sn(this.state,t);l.type==="hand"?this.cursor.set(Le.GRAB):Vo||this.cursor.applyForTool(l),YY(document.activeElement)&&this.focusContainer(),wK(l.type)||this.setState({suggestedBinding:null}),l.type==="image"&&this.onImageToolbarButtonClick(),this.setState(s=>{let d={snapLines:s.snapLines.length?[]:s.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:bu(l.type)?s.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return l.type==="freedraw"&&this.store.scheduleCapture(),l.type==="lasso"?{...s,...d,activeTool:l,...r?{}:{selectedElementIds:Ne({},s),selectedGroupIds:Ne({},s),editingGroupId:null,multiElement:null}}:l.type!=="selection"?{...s,...d,activeTool:l,selectedElementIds:Ne({},s),selectedGroupIds:Ne({},s),editingGroupId:null,multiElement:null}:{...s,...d,activeTool:l}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>ue.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${RM()}`);v(this,"onGestureStart",Je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null}),ue.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Je(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=ue.initialScale;o&&this.viewport.translate(r=>({...Io({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Qn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ne(this.state.previousSelectedElementIds,this.state)}),ue.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=yA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&mI(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=yA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(xf,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:l,arrowEndpoint:s})=>{let d=!1,c=s&&this.arrowText.getTextBinding(s,this.getCurrentItemStrokeWidth("text"));c&&(i=null,r=!1,t=c.anchor[0],o=c.anchor[1]);let p=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&p&&(Vb(i,this.scene.getNonDeletedElementsMap())||(d=!0));let m=c?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=m?.fontFamily||this.state.currentItemFontFamily,E=m?.lineHeight||LM(u),g=this.state.currentItemFontSize;if(!m&&d&&i&&!Cc(i)){let C=YK(Bb({fontSize:g,fontFamily:u}),E),P=KK(g,E),M=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:L}),t=i.x+L/2,o=i.y+M/2,p&&(p=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),w=c?{x:t,y:o}:p?{x:p.elementCenterX,y:p.elementCenterY}:m?{x:t,y:o}:{x:b?.x??t,y:b===null?o-iA(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!d||!i||i.frameId===y.id)?y.id:null,I=m||HM({x:w.x,y:w.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:c?.textAlign??(p?"center":this.state.currentItemTextAlign),verticalAlign:c?.verticalAlign??(p?BY.MIDDLE:CM),containerId:d?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?Cc(i)?0:i.angle:0,frameId:x});if(!m&&d&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!m)if(i&&d){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);s&&c&&this.arrowText.bindText(s,I,c.fixedPoint),a||m||i?this.handleTextWysiwyg(I,{isExistingElement:!!m,initialCaretSceneCoords:m?l:null}):this.setState({newElement:I,multiElement:null})});v(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});v(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});v(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return Eo(ie(o.x,o.y),ie(r.x,r.y))<=BM});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.state.viewModeEnabled&&!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement)return;if(this.state.viewModeEnabled){let{x:s,y:d}=Se(t,this.state),c=this.getElementAtPosition(s,d,{includeLockedElements:!0});c&&(this.cursor.reset(),this.actionManager.executeAction(Bn,"ui",[c]));return}if(this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Se(t,this.state);if(o.length===1&&Wt(o[0])){let s=o[0];if((t[Y.CTRL_OR_CMD]&&qb(s)||jb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(La);return}else if(this.state.selectedLinearElement&&jt(o[0])){let d=ge.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=d?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),ge.deleteFixedSegment(o[0],this.scene,c);let p=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=p?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,p,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:d,added:!1}},segmentMidPointHoveredCoords:p}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&jb(s))return}let a=this.getElementAtPosition(r,i,{includeLockedElements:!0});if(a&&jn(a)){this.actionManager.executeAction(Bn,"ui",[a]);return}if(this.cursor.reset(),qK(this.state).length>0){let s=this.getElementAtPosition(r,i),d=s&&jK(s,this.state.selectedGroupIds);if(d){this.store.scheduleCapture(),this.setState(c=>({...c,...qn({editingGroupId:d,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(Pc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){if(this.getElementAtPosition(r,i,{includeLockedElements:!0})?.locked)return;let c=!t[Y.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(c&&(this.state.activeTool.type==="autoshape"||VM(c)||!XY(c.backgroundColor)||kc({point:ie(r,i),element:c,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(c)}))){let p=Yb(c,this.scene.getNonDeletedElementsMap());r=p.x,i=p.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:c||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==kn.MAIN){this.lastCompletedCanvasClicks=[];return}if(this.smartZoomKeyHitElement){t.preventDefault(),t.stopPropagation();return}let o=Se(t,this.state);if(this.smartZoomKeyDownAt!==null&&!this.smartZoomKeyHitElement){let i=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(i){this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Bn,"keyboard",[i]);return}}let r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});v(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!jn(a)||!a.fileId)continue;let l=this.imageStatus.get(a.fileId),s=l?.uploadProgress?.onClick;if(s&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>s(a.fileId);let d=l?.downloadError?.onClick;if(d&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>d(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=js(o,r,this.state,i);return!!a&&Eo(ie(t.x,t.y),ie(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});v(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(o&&l.id===o.id&&(i=a),l.link&&a>=i&&Hc(l,this.scene.getNonDeletedElementsMap(),this.state,ie(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});v(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&Mx(a,i,this.state,ie(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=c=>c===kn.MAIN||c===kn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=Eo(ie(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ie(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>PM)return;let i=Se(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Hc(this.hitLinkElement,a,this.state,ie(i.x,i.y),this.editorInterface.formFactor==="phone"),s=Se(this.lastPointerUpEvent,this.state),d=Hc(this.hitLinkElement,a,this.state,ie(s.x,s.y),this.editorInterface.formFactor==="phone");l&&d&&(Tm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=fu(r);let i;if(this.props.onLinkOpen&&o&&(i=KY(ee.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=UY(r)?"_self":"_blank",l=window.open(void 0,a);l&&(l.opener=null,l.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Le.POINTER),Gv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(Tm(),!1));v(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});v(this,"handleInteractiveContentPointerMove",t=>{let o=Se(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});v(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Se(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(s=>!s.locked&&eA(t,s,r));if(!i.length)return null;let a=i.at(-1),l=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(s=>!o?.excludeElementIds?.[s.id]);if(l){if(kt(l)&&!l.locked)return a;let s=this.scene.getElementIndex(l.id),d=this.scene.getElementIndex(a.id);if(s!==-1&&d!==-1&&s<=d)return a;let c=o?.currentFrameId?i.find(p=>p.id===o.currentFrameId)??null:null;return c||(l.frameId?i.find(p=>p.id===l.frameId)??null:null)}return a});v(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});v(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&gX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});v(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?LK(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});v(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&kt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Qn(r*Math.max(.1,1+i/100));this.viewport.translate(l=>({...Io({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},l),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});v(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Yo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Se(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Vo||Yo||Su||kl(this.state))return;let l=Rf(_c,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(l?this.cursor.set(Le.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Le.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},l),!this.state.newElement&&lI(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=aI(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=Tc(w.snapLines,b),x=w.originSnapOffset?Tc(w.originSnapOffset,g):g;return w.snapLines===y&&w.originSnapOffset===x?null:{snapLines:y,originSnapOffset:x}})}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:ge.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Ut(()=>{this.setState({selectedLinearElement:g})})}if(yK(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&xu(this.state)){let b=ie(r,i),w=this.scene.getNonDeletedElementsMap(),y=Gr(b,this.scene.getNonDeletedElements(),w,xA(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Jb(b,y,w,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:w,y,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)Eo(ie(r-w,i-y),I)>=Nb?(this.store.scheduleCapture(),Ut(()=>{xo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,ie(r-w,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Le.POINTER);else if(x.length>2&&T&&Eo(ie(r-w,i-y),T)<Nb){this.cursor.set(Le.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{$M(x,this.state.zoom.value)&&this.cursor.set(Le.POINTER);let C=this.scene.getNonDeletedElementsMap();if(qb(g)){let M=Gr(ie(r,i),this.scene.getNonDeletedElements(),C);Uo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}xo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=ge.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=ie(r,i),b=Gr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),xA(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!bA(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:Jb(g,b,w,this.state.zoom)}})}let s=!!t.buttons,d=this.state.activeTool.type==="laser";if(s||!d&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),p=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(p,o)){this.cursor.set(Le.POINTER);return}if(p.length===1&&!l&&!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"&&!(p.length===1&&jt(p[0]))&&!(Wt(p[0])&&(this.editorInterface.userAgent.isMobileDevice||p[0].points.length===2))){let g=dA(c,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(wA(cA(g),this.state.viewpointFlip));return}}}else if(p.length>1&&!l&&this.state.openDialog?.name!=="elementLinkSelector"){let g=mA(vl(p),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(wA(cA({transformHandleType:g}),this.state.viewpointFlip));return}}if(dn(this.state))return;let m=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;m&&m.locked?u=null:u=m;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,m)),!this.applyElementLinkHoverAffordance()){if(d)return;u&&(u.link||Wo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Le.POINTER:qt(u)?Le.TEXT:Le.CROSSHAIR):!t[Y.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,p)?this.cursor.set(Le.MOVE):this.state.viewModeEnabled?this.cursor.set(Le.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Le.AUTO):l?this.cursor.set(Le.AUTO):!t[Y.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,p))&&!u?.locked&&(!u||!jt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||p.length>0)&&this.cursor.set(Le.MOVE):this.cursor.set(Le.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Tc(g.hoveredElementIds,qn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Tc(g.hoveredElementIds,{})})),this.updateSmartZoomCursor({x:r,y:i})});v(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});v(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(Rc=!0)});v(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Yo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Se(t,this.state),{x:i,y:a}=r;if(this.lastPointerMoveCoords={x:i,y:a},this.handleSmartZoomPointerDown(t,r))return;let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(ub,null)),Tt.get(ho)&&this.updateEditorAtom(ho,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Dc){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ne(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,w)=>(b[w]=this.state.selectedElementIds[w],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Jt.EVENTUALLY:Jt.NEVER});return}let s=document.getSelection();if(s?.anchorNode&&s.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=Ob(this.editorInterface,{isTouchScreen:!0})),Yo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===kn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Zn.eraser){this.setState({activeTool:sn(this.state,{type:Zn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),dn(this.state)&&this.setState({activeTool:sn(this.state,{...this.state.activeTool.lastActiveTool||{type:Zn.selection},lastActiveTool:null})})},b=we(window,ee.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==kn.MAIN&&t.button!==kn.TOUCH&&t.button!==kn.ERASER||ue.pointers.size>1)return;let d=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,d.origin)||this.handleDraggingScrollBar(t,d)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,d))||!(!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 g=d.hit.element&&this.isASelectedElement(d.hit.element);(t.altKey&&t[Y.CTRL_OR_CMD]&&!d.resize.handleType||!d.hit.hasHitCommonBoundingBoxOfSelectedElements&&!d.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(d.origin.x,d.origin.y,t.shiftKey),d.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&d.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[d.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=d.hit.element;if(kt(T))Kb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(M=>Ri(this.scene.getNonDeletedElements(),M)).filter(M=>kt(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(L=>Ri(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...qn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Wo(T)?"info":!1}}),d.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,d):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Zn.frame||this.state.activeTool.type===Zn.magicframe?this.createFrameElementOnPointerDown(d,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(d.lastCoords.x,d.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(d):this.state.activeTool.type===Zn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,d);this.props?.onPointerDown?.(this.state.activeTool,d),this.onPointerDownEmitter.trigger(this.state.activeTool,d,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(d.lastCoords.x,d.lastCoords.y);let p=this.onPointerMoveFromPointerDownHandler(d),m=this.onPointerUpFromPointerDownHandler(d),u=this.onKeyDownFromPointerDownHandler(d),E=this.onKeyUpFromPointerDownHandler(d);this.missingPointerEventCleanupEmitter.once(g=>m(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(ee.POINTER_MOVE,p),window.addEventListener(ee.POINTER_UP,m),window.addEventListener(ee.KEYDOWN,u),window.addEventListener(ee.KEYUP,E),d.eventListeners.onMove=p,d.eventListeners.onUp=m,d.eventListeners.onKeyUp=E,d.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Uo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Se({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});v(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Rc=!1,Hr?Rc=!0:Hr=window.setTimeout(()=>{Hr=0,Rc||this.handleCanvasContextMenu(t)},NY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Hr),Hr=0,Rc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{Il?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ue.pointers.size<=1&&((t.button===kn.WHEEL||t.button===kn.MAIN&&Vo||kl(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Yo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Le.GRABBING);let{clientX:i,clientY:a}=t,l=Hm(d=>{let c=i-d.clientX,p=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!o&&(Math.abs(c)>1||Math.abs(p)>1)){o=!0;let m=E=>{document.body.removeEventListener(ee.PASTE,m),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,m),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,m),window.addEventListener(ee.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-c*$n(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-p*$n(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),s=Je(Il=()=>{Il=null,Yo=!1,Vo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});v(this,"updateMultiTouchGesture",t=>{ue.pointers.has(t.pointerId)&&ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=ue.initialScale;if(ue.pointers.size===2&&ue.lastCenter&&o&&ue.initialDistance){let r=wf(ue.pointers),i=r.x-ue.lastCenter.x,a=r.y-ue.lastCenter.y;ue.lastCenter=r;let l=vf(Array.from(ue.pointers.values())),s=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:l/ue.initialDistance,d=s?Qn(o*s):this.state.zoom.value;this.setState(c=>{let p=Io({viewportX:r.x,viewportY:r.y,nextZoom:d},c),m=p.zoom.value;return this.viewport.translate({zoom:p.zoom,scrollX:p.scrollX+2*i*$n(c.viewpointFlip.horizontal)/m,scrollY:p.scrollY+2*a*$n(c.viewpointFlip.vertical)/m,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else ue.lastCenter=ue.initialDistance=ue.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{bu(this.state.activeTool.type)||this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(bu(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!jt(a[0])&&!(Wt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=dA(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),o.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),o.resize.handleType=l.transformHandleType))}else a.length>1&&(o.resize.handleType=mA(vl(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=Fb(eX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Wt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=tX(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let m=this.state.selectedLinearElement,u=ge.handlePointerDown(t,this,this.store,o.origin,m,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=ge.getElement(m.elementId,E);if(g&&wo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=pX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...m,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:w,initialState:{...m.initialState,arrowOtherEndpointInitialBinding:y}}}),!1}}let l=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),s=l.filter(m=>!m.locked),d=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.locked&&!s.some(m=>this.state.selectedElementIds[m.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=s;let c=o.hit.element,p=o.hit.allHitElements.some(m=>this.isASelectedElement(m));if((c===null||!p)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||c&&c?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState(m=>({selectedLinearElement:m.selectedLinearElement?{...m.selectedLinearElement,isEditing:!!c&&c.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:m.selectedLinearElement?Ne({[m.selectedLinearElement.elementId]:!0},this.state):Ne({},m)}));else if(c!=null){if(t[Y.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(o.hit.wasAddedToSelection=!0),this.setState(m=>({...$K(m,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!aA(c,this.state.editingGroupId)&&this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(m=>{let u={...m.selectedElementIds,[c.id]:!0},E=[];if(Object.keys(m.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),kt(c))Kb(E,c.id).forEach(g=>{delete u[g.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let g=c.groupIds,b=new Set(g.flatMap(w=>Ri(this.scene.getNonDeletedElements(),w)).filter(w=>kt(w)).map(w=>w.id));b.size>0&&E.forEach(w=>{w.frameId&&b.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(y=>Ri(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return m.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(g=>m.selectedGroupIds[g])||(u={[c.id]:!0})),{...qn({editingGroupId:m.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),m,this),showHyperlinkPopup:c.link||Wo(c)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let l=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(r,i);VM(l)&&(s=l,r=l.x+l.width/2,i=l.y+l.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Dt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=this.state.currentItemStrokeVariability,c=pK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,strokeOptions:{variability:d,streamline:t.pointerType!=="mouse"?PY:CY},locked:!1,frameId:l?l.id:null,points:[ie(0,0)],pressures:s?[]:[t.pressure]});this.insertNewElement(c),this.setState(p=>{let m={...p.selectedElementIds};return delete m[c.id],{selectedElementIds:Ne(m,p)}}),this.setState({newElement:c,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,l]=Dt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=hK({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(s),s});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Dt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=wu(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=GM({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.insertNewElement(s),s});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,l]=Dt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,d=100/this.state.zoom.value;return EK({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:s?s.id:null,customData:i,x:a-d/2,y:l-d/2,width:d,height:d})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ut(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(xo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&$M(i.points,this.state.zoom.value)){Ut(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(xt);return}if(jt(i)&&i.points.length>1){this.actionManager.executeAction(xt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:d}=a,c=Se(t,this.state),{start:p,end:m}=wo(i)&&xu(this.state)?fX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),c.x,c.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=p?.mode!=null&&m.mode!=null&&p.element.id===m.element.id&&!bA(m.focusPoint,m.element,u),g=m.mode==="orbit"&&i.startBinding?.elementId!==m.element?.id,b=d&&Eo(ie(r.origin.x-l,r.origin.y-s),d)<Nb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(xt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:Ne({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Le.POINTER)}else{let[i,a]=Dt(r.origin.x,r.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[c,p]=o==="arrow"?[s,d]:[null,null],m=o==="arrow"?gK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===zr.round?{type:hu.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===zr.elbow,fixedSegments:this.state.currentItemArrowType===zr.elbow?[]:null}):bK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:hu.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),u=ie(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=xu(this.state)?Gr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(m,{points:[ie(0,0),ie(0,0)]}),this.insertNewElement(m),wo(m)&&lX(m,new Map([[0,{point:ie(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:SM(t.nativeEvent)}),Ut(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(Wt(m)){w=new ge(m,this.scene.getNonDeletedElementsMap());let x=m.points.length-1;w={...w,selectedPointsIndices:[x],initialState:{...w.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ie(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:Ne({[m.id]:!0},b),{...b,bindMode:"orbit",newElement:m,suggestedBinding:g&&wo(m)?{element:g,midPoint:Jb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),wo(m)&&Uo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(m,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Dt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=GM({type:"embeddable",...l}):s=fK({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.insertNewElement(s),this.setState({multiElement:null,newElement:s}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Dt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Ho},l=o===Zn.magicframe?uK(a):mK(a);this.insertNewElement(l),this.setState({multiElement:null,newElement:l})});v(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});v(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(wo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);vu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);vu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else Hb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&vu(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&vu(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||YM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,yo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Gi(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===Pn.svg)try{o=Yu(jM(await o.text()),o.name)}catch(c){throw console.warn(c),new Error(f("errors.svgImageInsertError"))}else if(o.type!==Pn.gif){let{maxWidthOrHeight:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Gx)(o,{maxWidthOrHeight:c})}catch(p){console.error("Error trying to resize image file on insertion",p)}}let i=o.type,a=i===Pn.gif,l=await(this.props.generateIdForFile?.(o)||Bx(o));if(!l)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[l]?.dataURL){let{maxFileSizeBytes:c}=this.props.imageOptions;if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let d=this.files[l]?.dataURL||await Xc(o);return new Promise(async(c,p)=>{try{let m=this.getLatestInitializedImageElement(t,l);if(this.addMissingFiles([{mimeType:i,id:l,dataURL:d,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(m=this.gifPlayback.ensureElementPlaybackMetadata(m),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===m.id?m:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(l)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([m]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(l)?.image,E=u?SK(u):null;if(u&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,l);let g=this.getImageNaturalDimensions(m,u);Object.assign(m,g)}m=yo(m,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(m,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[l]:{...this.files[l],fileName:o.name,thumbHash:E??void 0}},r&&r!==l&&this.gifPlayback.removePlaceholderDecodeState(r),c(m)}catch(m){this.gifPlayback.removePlaceholderDecodeState(r),console.error(m),p(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return yo(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Se({clientX:t,clientY:o},this.state),a=await Px({description:"Image",extensions:Object.keys(AY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(xt)})}});v(this,"getImageNaturalDimensions",(t,o)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),l=a*(o.naturalWidth/o.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Di(o)&&o.fileId===t&&_i.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let l of t){let s=this.imageCache.get(l.fileId);s&&r.set(l.fileId,Promise.resolve(s.image))}let{updatedFiles:i,erroredFiles:a}=await Wb({imageCache:this.imageCache,fileIds:t.map(l=>l.fileId),files:o,onImageCacheUpdate:l=>this.handleImageCacheUpdate(l),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[l,s]of r){let d=this.imageCache.get(l);!d||!i.has(l)||this.imageCache.set(l,{...d,placeholderImage:await s,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(Jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(l=>{if(Di(l)){if(a.has(l.fileId))return yo(l,{status:"error"});if(i.has(l.fileId)&&l.status==="error")return yo(l,{status:"saved"})}return l}))),{updatedFiles:i,erroredFiles:a}});v(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});v(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==Pn.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Wb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});v(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));v(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});v(this,"addNewImagesToImageCache",async(t=kK(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&_i.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",vY(()=>{this.addNewImagesToImageCache()},LY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,l=gA(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(l);let s=await Promise.all(l.map(async(u,E)=>{try{return await this.initializeImage(u,await Kr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),yo(u,{isDeleted:!0})}})),d=Sc(s),c=gA(s.filter(u=>!u.isDeleted),o,r,a),p=Sc(c),m=this.scene.getElementsIncludingDeleted().map(u=>p.get(u.id)??d.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ne(Object.fromEntries(c.map(u=>[u.id,!0])),this.state)},elements:m,captureUpdate:Jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(xt)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Se(t,this.state),i=ug(t),a=await fr(t),l=a.getFiles(),s=l.map(c=>c.file).filter(c=>Gi(c));if(this.state.viewModeEnabled)return s.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:s,event:t})?void 0:this.insertImages(s,o,r,cm(a,s.length,i));if(l.length===1){let{file:c,fileHandle:p}=l[0];if(c&&(c.type===Pn.png||c.type===Pn.svg))try{let m=await Dl(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...m,appState:{...m.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Jt.IMMEDIATELY});return}catch(m){if(m.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(s.length>0&&this.isToolSupported("image"))return this.insertImages(s,o,r,cm(a,s.length,i));if(l.length>0){let{file:c,fileHandle:p}=l[0];c&&await this.loadFileToCanvas(c,p)}let d=a.findByType(Pn.text);if(d){let c=d.value;if(c&&Ub(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||wu(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:fu(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Kr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Dl(t,this.state,r,o)}catch(a){let l=a instanceof Cx;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;CA(r.concat(i.elements)),this.store.scheduleMicroAction({action:Jt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});v(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==kn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Se(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,l=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},l),d=s&&l.length===1&&l[0].link?l[0]:void 0,c=i??a??d,p=c||s?"element":"canvas",m=this.excalidrawContainerRef.current,{top:u,left:E}=m.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Ye("contextMenu","openContextMenu",p),this.setState({...c&&!this.state.selectedElementIds[c.id]?{...this.state,...qn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[c.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Wt(c)?new ge(c,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(p,c)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){pA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:wl(t.origin.x,a.x),height:wl(t.origin.y,a.y),shouldMaintainAspectRatio:wc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l||this.arrowText.maybeDragNewText(l,a))return;let[s,d]=Dt(a.x,a.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=Di(l)&&this.imageCache.get(l.fileId)?.image,p=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:m,snapLines:u}=iI(l,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=m.x,d+=m.y,this.setState({snapLines:u}),wo(l)||pA({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:wl(t.originInGrid.x,s),height:wl(t.originInGrid.y,d),shouldMaintainAspectRatio:jn(l)?!wc(o):wc(o),shouldResizeFromCenter:TM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Zn.frame||this.state.activeTool.type===Zn.magicframe)&&this.setState({elementsToHighlight:Zb(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});v(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=Dt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&jn(s)){let d=t.originalElements.get(s.id),c=Di(s)&&this.imageCache.get(s.fileId)?.image;if(d&&jn(d)&&c&&!(c instanceof Promise)){let[p,m]=Dt(i.x,i.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:E,snapLines:g}=Cf([s],[d],this,o,u,r);this.scene.mutateElement(s,HK(s,this.scene.getNonDeletedElementsMap(),r,c.naturalWidth,c.naturalHeight,a+E.x,l+E.y,o.shiftKey?d.width/d.height:void 0)),yu(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});v(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(kt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&jt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=Dt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(p=>{Kb(this.scene.getNonDeletedElements(),p.id).forEach(u=>{c.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,m]=Dt(l.x,l.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=Cf(r,de(E,this.state),this,o,u,a);s+=g.x,d+=g.y,this.setState({snapLines:b})}if(nX(t.originalElements,a,r,this.scene,SM(o),TM(o),r.some(p=>jn(p))?!wc(o):wc(o),s,d,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(m=>{Zb(this.scene.getNonDeletedElements(),m,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Tu(u)?p.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...p]}),!0}return!1});v(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>jn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&jn(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>jn(r))&&(!t||this.state.selectedElementIds[t.id])?[Tg,Sg]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=fu(t.link),r=oA(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await lo(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});v(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Bn,Ea,ba,We,ya,Na,yr]:[kg,We,Mh,Zv,We,ya,Bt,ys,ws,We,Ea,ba,We,Na,yr];if(this.state.viewModeEnabled)return[...a,a.length>0&&We,Bn,Ea,ba,We,xa,r.length>0&&We,...r];let l=this.editorInterface.formFactor==="desktop"?[We,Sh,Ch,Ph,kh]:[];return[We,Bn,Ea,ba,We,wm,xa,kg,r.length>0&&We,...r,i.length>0&&We,...i,We,O2,z2,G2,We,hf,We,wg,xf,Lg,Dg,Lv,vg,We,...l,We,Cg,Pg,We,La,We,Hg,a.length>0&&We,...a,We,Ah,Ts,We,Ul]});v(this,"handleWheel",Je(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(zb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Yo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=FY*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20);let c=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:OY;d=Math.max(d,c),this.viewport.translate(m=>({...Io({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Qn(d)},m),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:l})=>({scrollX:a-(r||o)*$n(l.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:l,viewpointFlip:s})=>({scrollX:a-o*$n(s.horizontal)/i.value,scrollY:l-r*$n(s.vertical)/i.value}))}));v(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Se({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:ue.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",DM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));v(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=o.getBoundingClientRect(),{width:s,height:d,offsetTop:c,offsetLeft:p}=this.state;if(r===s&&i===d&&a===p&&l===c){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=qo(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=o.theme,name:d=`${f("labels.untitled")}-${RM()}`,wheelZoomsOnDefault:c=!1}=t,p=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?p=sn(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:s,exportWithDarkMode:s===vc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:p??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:l,gridModeEnabled:a??o.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:c},this.refreshEditorInterface(),this.stylesPanelMode=ku(this.editorInterface),this.id=TY(),this.actionManager=new Fm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new uA,this.canvas=document.createElement("canvas"),this.rc=IY.canvas(this.canvas),this.renderer=new Ws(this.scene),this.visibleElements=[],this.store=new iX(this),this.history=new Hs(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new To(this.scene),this.history=new Hs(this.store),this.actionManager.registerAll(cd),this.actionManager.registerAction(V2(this.history)),this.actionManager.registerAction(Y2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},getCommandCatalog:this.getCommandCatalog,executeCommand:this.executeCommand,refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,setDesktopUIMode:this.setDesktopUIMode,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(gu).includes(i)&&Qb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){xo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Gr(ie(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=ge.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.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),Ut(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?ge.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):ge.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||jt(t))return;let r=()=>{if(this.bindModeHandler=null,xo(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 E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:p,y:m}=this.lastPointerMoveCoords,u=Gr(ie(p,m),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){xo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Ut(()=>{xo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xo(g,"Last event must exist");let b=p-this.state.selectedLinearElement.pointerOffset.x,w=m-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?ge.handlePointerMove(g,this,b,w,this.state.selectedLinearElement):ge.handlePointDragging(g,this,b,w,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),m=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=m?o:t.startBinding&&p.get(t.startBinding.elementId),g=u?o:t.endBinding&&p.get(t.endBinding.elementId),b=E&&EA(E,p),w=g&&EA(g,p);i=!!(b&&w&&E.id!==g.id&&sX(b,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,d=a?"endBinding":l?"startBinding":null,c=d&&t[d]?.mode==="inside"&&t[d]?.elementId===o?.id||s&&t[s]?.mode==="inside"&&o?.id===t[s]?.elementId;s&&d&&t[s]?.mode==="inside"&&o?.id!==t[s]?.elementId&&t[d]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Ut(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!c&&(this.bindModeHandler=setTimeout(r,tK)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==kn.MAIN||Vo||!FM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ie(Se({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ie(Se({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Eo(t,o)>PM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ue.pointers.size<2&&Pc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let l=i;if(this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:l,state:"active"},selectedElementIds:{[l.id]:!0},newElement:null,selectionElement:null})},100),Gb(l)))return!0;let s=this.getHTMLIFrameElement(l);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let d=Qb.get(l.id);switch(d||(Qb.set(l.id,gu.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:l.id}),"*")),d){case gu.PLAYING:case gu.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,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Wo(a)&&this.embedsValidationStatus.get(a.id)===!0||Gb(a));return Ce(wX,{children:i.map(a=>{let{x:l,y:s}=Eu({sceneX:a.x,sceneY:a.y},this.state),d=XM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(d&&!c&&this.initializedEmbeds.add(a.id),!(d||c))return null;let m=wu(WY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=m?.type==="video",b=yc(g?t:1,.75,bX);return Ce("div",{className:xM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t*$n(this.state.viewpointFlip.horizontal)}, ${t*$n(this.state.viewpointFlip.vertical)})`:"none",display:d?"block":"none",opacity:ZK(a,$b(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?HY:1),"--embeddable-radius":`${CK(Math.min(a.width,a.height),a)}px`},children:ex("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?yl.enabled:yl.disabled},children:[E&&Ce("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ce("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ce("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Wo(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ce("iframe",{ref:w=>this.cacheEmbeddableRef(a,w),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${m?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:l,canvasNonce:s,newElementCanvasElement:d}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=l,this.hasRenderableElements=a.size>0;let c=this.scene.getNonDeletedElementsMap(),p="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0],u=Tt.get(ho)?.type==="panel";return Ce("div",{translate:"no",className:xM("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":p?yl.disabled:yl.enabled,"--right-sidebar-width":`${fE}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Ce(Tl.Provider,{value:this.api,children:Ce(PA.Provider,{value:this,children:Ce(kA.Provider,{value:this.props,children:Ce(rx.Provider,{value:this.excalidrawContainerValue,children:Ce(ox.Provider,{value:this.editorInterface,children:Ce(lx.Provider,{value:this.setAppState,children:Ce(ax.Provider,{value:this.state,children:ex(ix.Provider,{value:this.scene.getNonDeletedElements(),children:[ex(sx.Provider,{value:this.actionManager,children:[Ce(Jk,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:to().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,uiLayout:this.props.uiLayout,children:this.props.children}),Ce("div",{className:"excalidraw-textEditorContainer"}),Ce("div",{className:"excalidraw-contextMenuContainer"}),Ce("div",{className:"excalidraw-eye-dropper-container"}),Ce(eM,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ce(fM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ce(Ov,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Ce(wS,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Ce(Lb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:c,visibleElements:l,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:Ir(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),d&&Ce(dM,{appState:this.state,newElement:d,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:c,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Ce(Ab,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:c,selectedElements:t,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Ce(Ip,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ce(bM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ce(ZT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Di(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),_i.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,IA()||TA()){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.excalidrawContainerRef.current&&this.focusContainer(),zY&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),rK()&&!WK()&&this.setState({errorMessage:Ce(hS,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),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("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new uA,this.fonts=new To(this.scene),this.renderer=new Ws(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),_i.destroy(),yn.destroy(),clearTimeout(Hr),Oe.clearCache(),qn.clearCache(),Hr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(window,ee.MESSAGE,this.onWindowMessage,!1),we(document,ee.POINTER_UP,this.removePointer,{passive:!1}),we(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),we(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,ee.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,ee.GESTURE_START,this.onGestureStart,!1),we(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),we(document,ee.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,ee.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),we(this.excalidrawContainerRef.current,ee.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,ee.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,ee.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,ee.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),we(document,ee.COPY,this.onCopy,{passive:!1}),we(document,ee.KEYUP,this.onKeyUp,{passive:!0}),we(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,ee.GESTURE_START,this.onGestureStart,!1),we(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),we(document,ee.GESTURE_END,this.onGestureEnd,!1),we(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),we(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),we(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(document,ee.CUT,this.onCut,{passive:!1}),we(window,ee.RESIZE,this.onResize,!1),we(window,ee.UNLOAD,this.onUnload,!1),we(window,ee.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(VY(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===vc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&dn(this.state)&&this.setState({activeTool:sn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),dn(o)&&!dn(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===vc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(xt)});let l=Object.keys(this.state.selectedElementIds);if(l.length){let d=l.filter(c=>{let p=this.scene.getElement(c);return!p||p.isDeleted});d.length&&this.setState(c=>{let p={...c.selectedElementIds};for(let m of d)delete p[m];return{selectedElementIds:Ne(p,c)}})}if(this.state.editingTextElement){let d=this.scene.getElement(this.state.editingTextElement.id);(!d||d.isDeleted)&&this.setState({editingTextElement:null})}let s=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==s&&this.setState({scrolledOutside:s}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Mc=!1,Lc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Se({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let c=op(t.text);if(c.ok){this.setState({openDialog:{name:"charts",data:c.data,rawText:t.text}});return}}if(t.elements){let c=t.programmaticAPI?cX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}let l=o.map(c=>c.file);if(l.length===0&&t.text&&!r){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(Yu(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(!t.text)return;let s=$Y(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),d=s.map(c=>PK(c)).filter(c=>Ub(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||wu(c)?.type==="video"));if(!r&&d.length>0&&d.length===s.length){let c=[];for(let p of d){let m=c[c.length-1],u=this.insertEmbeddableElement({sceneX:m?m.x+m.width+20:i,sceneY:a,link:fu(p)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Gi(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Ut(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await Hx(c)}}catch(p){let m=p.message;return p.cause==="FETCH_ERROR"?m=f("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(m=f("errors.unsupportedFileType")),{errorMessage:m}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,r,i);let d=l.find(c=>!!c.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
20
|
+
`)},uV=(e,n,t)=>{let r=pV(e.text,e.originalText).split(`
|
|
21
|
+
`),i=[],a=0,l=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,d=e.originalText.slice(t,t+n.length),c=[];for(let m of i){if(d==="")break;if(s>=m.startIndex&&s<=m.endIndex){let p=m.endIndex+1-s,u=m.line.slice(0,s-m.startIndex),E=d.slice(0,p);d=d.slice(p);let g=Tc(u,mu(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=Tc(m.line,mu(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=Tc(E,mu(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;c.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),s+=p}}return c},hV=(e,n,t,o)=>{let r=e.name??Vk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),l=mu({fontSize:Ib.nameFontSize,fontFamily:vb.Assistant}),s=nV(vb.Assistant),d=Tc(a,l,s);a===""&&(d.width=0);let c=Tc(i,l,s),m=d.width,p=-d.height-Ib.strokeWidth,u=c.width;return[{offsetX:m,offsetY:p,width:u,height:c.height,showOnCanvas:m+u<=e.width*o}]},gV=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Uk=qW((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>Wk(p)),i=o.filter(p=>pu(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(gV(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=l.exec(E))!==null;){let g=Hk(E,u.index,e),b=uV(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let s=[];for(let p of i){let u=null,E=p.name??Vk(p);for(;(u=l.exec(E))!==null;){let g=Hk(E,u.index,e),b=hV(p,e,u.index,n.state.zoom.value);b.length>0&&s.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let d=new Set(n.visibleElements.map(p=>p.id)),c=[...s,...a],m=c.findIndex(p=>d.has(p.element.id))??null;t(c,m)},sV);import MV from"clsx";import{useEffect as qk,useLayoutEffect as Jk,useRef as _b,useState as AV,forwardRef as Qk,useImperativeHandle as LV,useCallback as Zk}from"react";import{CLASSES as DV,EVENT as $k,isDevEnv as _V,KEYS as RV,updateObject as NV}from"@excalidraw/common";import bV from"clsx";import{useContext as xV}from"react";import EV from"react";var uu=EV.createContext({});import{jsx as Sb,jsxs as Kk}from"react/jsx-runtime";var Cb=({children:e,className:n})=>{let t=me(),o=xV(uu),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return Kk("div",{className:bV("sidebar__header",n),"data-testid":"sidebar-header",children:[e,Kk("div",{className:"sidebar__header__buttons",children:[r&&Sb(bt,{label:f("labels.sidebarLock"),children:Sb(Mn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:c1})}),Sb(Mn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:un})]})]})};Cb.displayName="SidebarHeader";import{Tabs as yV}from"radix-ui";import{jsx as Xk}from"react/jsx-runtime";var Pb=({children:e,tab:n,onSelect:t,...o})=>Xk(yV.Trigger,{value:n,asChild:!0,onSelect:t,children:Xk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});Pb.displayName="SidebarTabTrigger";import{Tabs as wV}from"radix-ui";import{jsx as vV}from"react/jsx-runtime";var kb=({children:e,...n})=>vV(wV.List,{className:"sidebar-triggers",...n,children:e});kb.displayName="SidebarTabTriggers";import IV from"clsx";import{jsx as Mb,jsxs as TV}from"react/jsx-runtime";var Ab=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:l})=>{let s=ze(),c=ye().openSidebar?.name===e;return Mb("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":c,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!c;s({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:TV("div",{className:IV("sidebar-trigger",a),style:l,children:[t&&Mb("div",{children:t}),r&&Mb("div",{className:"sidebar-trigger__label",children:r})]})})};Ab.displayName="SidebarTrigger";import{Tabs as SV}from"radix-ui";import{jsx as CV}from"react/jsx-runtime";var Lb=({children:e,...n})=>{let t=ye(),o=ze();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return CV(SV.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};Lb.displayName="SidebarTabs";import{Tabs as PV}from"radix-ui";import{jsx as kV}from"react/jsx-runtime";var Db=({tab:e,children:n,...t})=>kV(PV.Content,{...t,value:e,"data-testid":e,children:n});Db.displayName="SidebarTab";import{jsx as jk}from"react/jsx-runtime";import{createElement as BV}from"react";var Rb=et(!1),eM=Qk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{_V()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=ze(),s=n1(Rb);Jk(()=>(s(!!o),()=>{s(!1)}),[s,o]);let d=_b({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=NV(d.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let c=_b(null);LV(a,()=>c.current);let m=me(),p=Zk(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return oa(c,Zk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),qk(()=>{let u=E=>{E.key===RV.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener($k.KEYDOWN,u),()=>{document.removeEventListener($k.KEYDOWN,u)}},[p,o,m.canFitSidebar]),jk(Ke,{...i,className:MV(DV.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:c,children:jk(uu.Provider,{value:d.current,children:n})})});eM.displayName="SidebarInner";var Hr=Object.assign(Qk((e,n)=>{let t=ye(),{onStateChange:o}=e,r=_b(t.openSidebar);qk(()=>{(!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&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=AV(!1);return Jk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?BV(eM,{...e,ref:n,key:e.name}):null}),{Header:Cb,TabTriggers:kb,TabTrigger:Pb,Tabs:Lb,Tab:Db,Trigger:Ab});Hr.displayName="Sidebar";import{jsx as Sl,jsxs as zV}from"react/jsx-runtime";import{createElement as GV}from"react";var nM=Mi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=gt();return Sl(n.In,{children:Sl(Hr.Trigger,{...e,className:"default-sidebar-trigger",name:OV.name})})});nM.displayName="DefaultSidebarTrigger";var oM=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=gt();return Sl(n.In,{children:e})};oM.displayName="DefaultTabTriggers";var Nb=Object.assign(Mi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=ze(),l=i.openSidebar?.tab===tM,s=l?!1:t??i.defaultSidebarDockedPreference,d=!l&&t==null&&o!==!1;return GV(Hr,{...r,name:"default",key:"default",className:FV("default-sidebar",{"default-sidebar--search-only":l},n),docked:s,onDock:d?c=>{a({defaultSidebarDockedPreference:c}),o?.(c)}:void 0},zV(Hr.Tabs,{children:[!l&&Sl(Hr.Header,{}),Sl(Hr.Tab,{tab:tM,children:Sl(Yk,{})}),!l&&e]}))}),{Trigger:nM,TabTriggers:oM});import UV from"react";import{getFrame as WV}from"@excalidraw/common";import{jsx as HV}from"react/jsx-runtime";var Bb={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"}},Fb=({children:e,color:n})=>HV("div",{className:"Card",style:{"--card-color":Bb[n].base,"--card-color-darker":Bb[n].darker,"--card-color-darkest":Bb[n].darkest},children:e});import{Fragment as YV,jsx as qn,jsxs as hu}from"react/jsx-runtime";var VV=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return qn("div",{className:"ExportDialog ExportDialog--json",children:hu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&hu(Fb,{color:"lime",children:[qn("div",{className:"Card-icon",children:C1}),qn("h2",{children:f("exportDialog.disk_title")}),hu("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Vi&&r.renderAction("changeProjectName")]}),qn($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ss,"ui")}})]}),s&&hu(Fb,{color:"pink",children:[qn("div",{className:"Card-icon",children:Xl}),qn("h2",{children:f("exportDialog.link_title")}),qn("div",{className:"Card-details",children:f("exportDialog.link_details")}),qn($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ye("export","link",`ui (${WV()})`),await s(e,n,o),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},rM=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let l=UV.useCallback(()=>{a({openDialog:null})},[a]);return qn(YV,{children:n.openDialog?.name==="jsonExport"&&qn(kn,{onCloseRequest:l,title:f("buttons.export"),children:qn(VV,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:l,exportOpts:r,canvas:i})})})};import KV from"clsx";import{jsx as XV}from"react/jsx-runtime";var iM=e=>XV($,{className:KV("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:uo,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import dM from"clsx";import{useState as jV}from"react";import{CANVAS_SEARCH_TAB as qV,DEFAULT_SIDEBAR as JV,KEYS as Pl}from"@excalidraw/common";import ZV from"clsx";import{jsx as $V}from"react/jsx-runtime";var gu=e=>$V($,{className:ZV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?so:_o,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as Cl,jsx as oe,jsxs as $o}from"react/jsx-runtime";var QV=(e,n)=>e==="image"&&n.tools?.image===!1,aM=({app:e,activeTool:n,type:t,shortcut:o})=>oe(ue.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ae[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Go(t),disabled:ot(e,t),children:f(`toolBar.${t}`)}),lM=({app:e})=>oe(ue.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?so:_o,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Pl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),sM=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Ft))return null;let t=Qe("objectsSnapMode");return oe(ue.Item,{onSelect:()=>e.executeAction(Ft,"ui"),icon:cr,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},Ob=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Ft))return null;let t=f("buttons.objectsSnapMode"),o=Qe("objectsSnapMode");return oe($,{type:"toggle",icon:cr,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Ft,"ui")})},cM=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Qe("searchMenu");return oe(ue.Item,{onSelect:()=>e.executeAction(Xs,"ui"),icon:hn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===JV.name&&n.openSidebar.tab===qV,shortcut:o,children:t})},zb=({app:e})=>oe($,{type:"button",icon:ei,title:`${f("labels.eyeDropper")} - ${Pl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":Pl.I.toLocaleUpperCase(),keyBindingLabel:Pl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),Gb=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i,overflowItems:a=[]})=>{let[l,s]=jV(!1),d=it()==="full",c=n.type==="frame",m=n.type==="autoshape",p=n.type==="laser",u=n.type==="bucketfill",E=d&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",g=n.type==="embeddable",b=r&&br.includes(n.type),w=a.some(x=>x==="objectsSnapMode"?e.state.objectsSnapModeEnabled:x!=="strokeEyedropper"&&n.type===x),y=()=>a.map(x=>x==="objectsSnapMode"?oe(sM,{actionManager:i,app:e},x):x==="strokeEyedropper"?oe(ue.Item,{onSelect:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1}),icon:ei,"data-testid":"toolbar-eyedropper",shortcut:Pl.I.toLocaleUpperCase(),children:f("labels.eyeDropper")},x):oe(aM,{app:e,activeTool:n,type:x},x));return $o(ue,{open:l,children:[oe(ue.Trigger,{className:dM("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":b||w||c||g||!r&&d&&m||E||u||p&&!e.props.isCollaborating}),onToggle:()=>{s(!l),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:b?Ae[n.type].icon:c?po:g?sr:!r&&d&&m?ti:p&&!e.props.isCollaborating?uo:E?ji:u?mo:Ul}),oe(ue.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?$o(Cl,{children:[y(),a.length>0&&oe("div",{className:"App-toolbar__dropdown-divider"}),d&&oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ji,"data-testid":"toolbar-lasso",selected:E,disabled:ot(e,"lasso"),children:f("toolBar.lasso")}),br.filter(x=>!QV(x,o)&&!a.includes(x)).map(x=>oe(aM,{app:e,activeTool:n,type:x},x)),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(cM,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(lM,{app:e})]}):$o(Cl,{children:[oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:po,shortcut:Pl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:ot(e,"frame"),children:f("toolBar.frame")}),oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:sr,"data-testid":"toolbar-embeddable",selected:g,disabled:ot(e,"embeddable"),children:f("toolBar.embeddable")}),oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:ti,shortcut:Go("autoshape"),"data-testid":"toolbar-autoshape",selected:m,disabled:ot(e,"autoshape"),children:f("toolBar.autoshape")}),oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:uo,"data-testid":"toolbar-laser",selected:p,disabled:ot(e,"laser"),children:f("toolBar.laser")}),oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:mo,"data-testid":"toolbar-bucketfill",selected:u,disabled:ot(e,"bucketfill"),children:f("toolBar.bucketfill")}),d&&oe(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ji,"data-testid":"toolbar-lasso",selected:E,disabled:ot(e,"lasso"),children:f("toolBar.lasso")}),oe("div",{className:"App-toolbar__dropdown-divider"}),y(),!a.includes("objectsSnapMode")&&oe(sM,{actionManager:i,app:e}),oe(cM,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(lM,{app:e})]})})]})},mM=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:l,showPenMode:s=!0})=>{let d=me(),c=it()==="compact",m=n.activeTool,p={app:e,activeTool:m},u=n.myocSimplifiedMode,E=c?oe(ci,{...p,setAppState:t}):n.preferredSelectionTool.type==="lasso"?oe(bs,{...p}):oe(Es,{...p});return $o(Ke,{padding:1,className:dM("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),children:[oe(Il,{appState:n,isMobile:d.formFactor==="phone",editorInterface:d,app:e}),l,$o(an.Row,{gap:c?.5:1,children:[!c&&s&&oe(Rr,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!u&&$o(Cl,{children:[oe(gu,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),oe("div",{className:"App-toolbar__divider"})]}),oe(sm,{...p}),E,u?$o(Cl,{children:[oe(us,{...p}),oe(hs,{...p}),oe(zb,{app:e}),o.tools?.image!==!1&&oe(gs,{...p}),oe(fs,{...p})]}):$o(Cl,{children:[oe(Mw,{...p}),oe(Aw,{...p}),oe(Lw,{...p}),oe(Dw,{...p}),oe(_w,{...p}),c?oe(xa,{...p}):oe(us,{...p}),oe(hs,{...p}),o.tools?.image!==!1&&oe(gs,{...p}),oe(fs,{...p})]}),oe("div",{className:"App-toolbar__divider"}),oe(Gb,{app:e,activeTool:m,setAppState:t,UIOptions:o,isMyocSimplifiedMode:u,actionManager:r}),u&&$o(Cl,{children:[oe("div",{className:"App-toolbar__divider"}),oe(Ob,{actionManager:r,app:e})]})]})]})};import{jsx as pM}from"react/jsx-runtime";var uM=e=>pM(bt,{label:`${f("helpDialog.title")} \u2014 ?`,children:pM("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:ea})});import{Fragment as bu,jsx as q,jsxs as Jn}from"react/jsx-runtime";var Sc={id:"desktopCanvasControls",className:"desktop-canvas-controls",padding:.75,gap:6},aY=({UIOptions:e})=>Jn(Ht,{__fallback:!0,children:[q(Ht.DefaultItems.LoadScene,{}),q(Ht.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&q(Ht.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&q(Ht.DefaultItems.SaveAsImage,{}),q(Ht.DefaultItems.SearchMenu,{}),q(Ht.DefaultItems.Help,{}),q(Ht.Separator,{}),q(Ht.Group,{title:"Excalidraw links",children:q(Ht.DefaultItems.Socials,{})}),q(Ht.Separator,{}),q(Ht.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),q(Ht.DefaultItems.ChangeCanvasBackground,{})]}),lY=()=>Jn(qp,{__fallback:!0,children:[q(qp.Actions.SaveToDisk,{}),q(qp.Actions.ExportToImage,{})]}),sY=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:l,showExitZenModeBtn:s,renderTopLeftUI:d,renderTopRightUI:c,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:P,uiLayout:C})=>{let k=me(),M=Hp(C,k),_=St(),R=it()==="compact",z=HS(),K=R?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1},U=z.tunnelsJotai.Provider,[D,H]=$e(Xt),F=()=>p.canvasActions.export?q(rM,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,J=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:q(Bk,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),re=(Fe=!0)=>Jn("div",{className:"excalidraw-ui-top-left",style:{position:"relative"},children:[q(z.MainMenuTunnel.Out,{}),Fe&&q(z.DefaultSidebarTriggerTunnel.Out,{}),E&&q(z.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>q(FE,{heading:"selectedShapeActions",className:fu("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:R?q(Ke,{className:fu("compact-shape-actions-island"),padding:0,style:{maxHeight:`${n.height-166}px`},children:q(aC,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):q(Ke,{className:tY.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},children:q(tC,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),V=w&&iY(n,r),ce=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector",pe=()=>w&&V?q(an.Col,{gap:K.menuTopGap,children:q("div",{className:fu("selected-shape-actions-container",{"selected-shape-actions-container--compact":R}),children:O()})}):null,Be=(Fe=!0)=>!w||!n.viewModeEnabled&&n.openDialog?.name==="elementLinkSelector"?null:Jn(bu,{children:[w&&n.viewModeEnabled&&q("div",{className:"view-mode-hint",children:q(Il,{appState:n,isMobile:!1,editorInterface:k,app:b})}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&q(FE,{heading:"shapes",className:"shapes-section",children:st=>Jn("div",{style:{position:"relative"},children:[E&&q(z.WelcomeScreenToolbarHintTunnel.Out,{}),q(an.Col,{gap:K.toolbarColGap,align:"start",children:Jn(an.Row,{gap:K.toolbarRowGap,className:fu("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[q(mM,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:l,onLockToggle:a,heading:st,showPenMode:Fe}),I&&q(Ke,{style:{alignSelf:"center",height:"fit-content"},children:q(iM,{title:f("toolBar.laser"),checked:n.activeTool.type===hM.laser,onChange:()=>b.setActiveTool({type:hM.laser}),isMobile:!0})})]})})]})})]}),Ee=()=>q("div",{className:"layer-ui__wrapper__top-right",children:w&&n.collaborators.size>0&&q(Yp,{collaborators:n.collaborators,userToFollow:_.userToFollow?.socketId||null,currentUserControls:P})}),He=()=>ce?q(yc,{app:b,onClose:()=>e.executeAction(Tr),renderCustomStats:m}):null,se=()=>q(z.FooterCenterTunnel.Out,{}),ke=()=>q("div",{className:"layer-ui__wrapper__footer-right",children:Jn("div",{style:{position:"relative"},children:[E&&q(z.WelcomeScreenHelpHintTunnel.Out,{}),w&&q(uM,{onClick:()=>e.executeAction(ui)})]})}),Me=()=>{let Fe=M?.items?.penMode!==void 0,st=M?.items?.sidebarTrigger!==void 0||M?.items?.mainMenu?.visible===!1,Yt=[{id:"hostTopLeftUI",defaultRegion:"topLeft",defaultOrder:-10,content:d?.(!1,n)},{id:"mainMenu",defaultRegion:"topLeft",content:re(!st)},{id:"sidebarTrigger",defaultRegion:"topLeft",defaultOrder:2,content:st?q("div",{className:"excalidraw-ui-top-left",style:{position:"relative"},children:q(z.DefaultSidebarTriggerTunnel.Out,{})}):null},{id:"stylesPanel",defaultRegion:"middleLeft",content:pe()},{id:"toolbar",defaultRegion:"topCenter",content:Be(!Fe)},{id:"hostTopRightUI",defaultRegion:"topRight",defaultOrder:-10,content:c?.(!1,n)},{id:"collaborators",defaultRegion:"topRight",content:Ee()},{id:"stats",defaultRegion:"topRight",content:He()},{id:"viewMode",defaultRegion:"bottomLeft",islandGroup:Sc,content:w&&!n.viewModeOnly?q(bt,{label:n.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:q("div",{className:"view-mode-button",children:e.renderAction("viewMode")})}):null},{id:"smartZoom",defaultRegion:"bottomLeft",islandGroup:Sc,content:w?q(bt,{label:f("buttons.smartZoom"),children:q("div",{className:"smart-zoom-button",children:e.renderAction("smartZoom")})}):null},{id:"zoom",defaultRegion:"bottomLeft",islandGroup:Sc,content:y&&b.isNavigationEnabled()?q(sC,{renderAction:e.renderAction}):null},{id:"undo",defaultRegion:"bottomLeft",islandGroup:Sc,content:w&&!n.viewModeEnabled?q("div",{className:"undo-button-container",children:e.renderAction("undo")}):null},{id:"redo",defaultRegion:"bottomLeft",islandGroup:Sc,content:w&&!n.viewModeEnabled?q("div",{className:"redo-button-container",children:e.renderAction("redo")}):null},{id:"help",defaultRegion:"bottomRight",content:ke()},{id:"penMode",defaultRegion:R?"topLeft":"topRight",content:w&&!n.viewModeEnabled&&(Fe||R&&V)?q(Rr,{checked:n.penMode,onChange:()=>l(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected}):null}];return q(Gp,{items:Yt,layout:M,app:b,appState:n,editorInterface:k,className:"ui-layout--desktop",legacyBottomCenter:se()})},xe=()=>q(Nb,{}),Et=!1,en=Jn(bu,{children:[g,w&&q(bu,{children:q(aY,{UIOptions:p})}),q(lY,{}),w&&n.isLoading&&q(Np,{delay:250}),w&&n.errorMessage&&q(bk,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&D&&k.formFactor!=="phone"&&q(my,{colorPickerType:D.colorPickerType,onCancel:()=>{H(null)},onChange:(Fe,st,Yt,{altKey:nr})=>{if(!(Fe!=="elementBackground"&&Fe!=="elementStroke"))if(Yt.length){for(let or of Yt)oY(or,nY(r),{[nr&&D.swapPreviewOnAlt?Fe==="elementBackground"?"strokeColor":"backgroundColor":Fe==="elementBackground"?"backgroundColor":"strokeColor"]:st}),rY.delete(or);b.scene.triggerUpdate()}else o(Fe==="elementBackground"?{currentItemBackgroundColor:st}:{currentItemStrokeColor:st})},onSelect:(Fe,st)=>{H(Yt=>Yt?.keepOpenOnAlt&&st.altKey?Yt:null),D?.onSelect?.(Fe,st)}}),n.openDialog?.name==="help"&&q(kk,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&q(Ek,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),q(z.OverwriteConfirmDialogTunnel.Out,{}),J(),F(),w&&n.openDialog?.name==="charts"&&q(jC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&q(Tk,{app:b,files:t,setAppState:o}),k.formFactor==="phone"&&q(OC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:F,renderImageExportDialog:J,setAppState:o,onPenModeToggle:l,renderTopLeftUI:d,renderTopRightUI:c,renderSidebars:xe,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x,uiLayout:C}),k.formFactor!=="phone"&&Jn(bu,{children:[_.viewportStatusFrame?.border&&q(Dp,{border:_.viewportStatusFrame.border,style:Et?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),Jn("div",{className:"layer-ui__wrapper",style:Et?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&q(z.WelcomeScreenCenterTunnel.Out,{}),Me(),w&&q(cC,{showExitZenModeBtn:s}),(n.toast||x&&n.scrolledOutside||_.viewportStatusFrame?.label)&&Jn("div",{className:"floating-status-stack",children:[n.toast&&q(pm,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&q("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(Fe=>({...Ui(r,Fe)}))},children:f("buttons.scrollBackToContent")}),_.viewportStatusFrame?.label&&q(_p,{label:_.viewportStatusFrame.label,border:_.viewportStatusFrame.border})]})]})]}),xe()]});return q(Gh.Provider,{value:n,children:q(U,{children:q(ME.Provider,{value:z,children:en})})})},gM=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:l,suggestedBinding:s,frameToHighlight:d,elementsToHighlight:c,...m}=e;return m},cY=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...l}=n;return Eu(gM(o),gM(a),{selectedElementIds:Eu,selectedGroupIds:Eu})&&Eu(r,l)},fM=eY.memo(sY,cY);import{useEffect as dY,useRef as mY}from"react";import{jsx as EM}from"react/jsx-runtime";var bM=({trails:e})=>{let n=mY(null);return dY(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),EM("div",{className:"SVGLayer",children:EM("svg",{ref:n})})};import pY,{useEffect as xM,useRef as yM}from"react";import{isShallowEqual as uY,sceneCoordsToViewportCoords as hY}from"@excalidraw/common";import{jsx as EY}from"react/jsx-runtime";var wM="animateInteractiveScene",gY=e=>{let n=yM(!1),t=yM(null);return xM(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&uE({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),xM(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((d,c)=>{if(d.selectedElementIds)for(let m of Object.keys(d.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(c);!d.pointer||d.pointer.renderCursor===!1||(d.username&&a.set(c,d.username),d.userState&&l.set(c,d.userState),r.set(c,hY({sceneX:d.pointer.x,sceneY:d.pointer.y},e.appState)),o.set(c,d.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:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},pt.running(wM)||pt.start(wM,({deltaTime:d,state:c})=>{let m=uE({...t.current,deltaTime:d,animationState:c}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),EY("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.onDoubleClick,children:f("labels.drawingCanvas")})},vM=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),fY=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:uY(vM(e.appState),vM(n.appState)),Hb=pY.memo(gY,fY);import SM,{useEffect as xu,useRef as Cc}from"react";import{isShallowEqual as IM}from"@excalidraw/common";import{hasActiveGifDecode as bY}from"@excalidraw/element";import{jsx as wY}from"react/jsx-runtime";var xY=e=>{let n=Cc(null),t=Cc(!1),o=Cc(e),r=Cc(()=>{}),i=Cc(null);o.current=e;let a=SM.useCallback(()=>{let l=o.current,s=n.current;if(!s)return;let d=getComputedStyle(s).getPropertyValue("--color-grid-bold").trim(),c=getComputedStyle(s).getPropertyValue("--color-grid-regular").trim();Wx({canvas:l.canvas,rc:l.rc,scale:l.scale,elementsMap:l.elementsMap,allElementsMap:l.allElementsMap,visibleElements:l.visibleElements,appState:l.appState,renderConfig:{...l.renderConfig,gridColorBold:d,gridColorRegular:c}},Ya());let m=l.renderConfig.imageTransitionDuration??0,p=m>0&&l.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=l.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=bY(l.visibleElements,l.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,xu(()=>{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]),xu(()=>{let l=n.current;if(!l)return;let s=e.canvas;t.current||(t.current=!0,l.replaceChildren(s),s.classList.add("excalidraw__canvas","static")),a()}),xu(()=>{let l=null,s=e.app.imagePlaceholderUpdateEmitter.on(()=>{l===null&&(l=requestAnimationFrame(()=>{l=null,a()}))});return()=>{s(),l!==null&&cancelAnimationFrame(l)}},[e.app,a]),xu(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),wY("div",{className:"excalidraw__canvas-wrapper",ref:n})},TM=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,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}),yY=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:IM(TM(e.appState),TM(n.appState))&&IM(e.renderConfig,n.renderConfig),Ub=SM.memo(xY,yY);import{useEffect as kY,useRef as MY}from"react";import{throttleRAF as vY}from"@excalidraw/common";import{getTargetFrame as IY,isInvisiblySmallElement as TY,renderElement as SY,shouldApplyFrameClip as CY}from"@excalidraw/element";var CM=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=jc(e,i),c=qc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(c.save(),Jc(c,a),t&&t.type!=="selection"){if(TY(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=IY(t,o,a);u&&CY(t,u,a,o)&&Hx(u,c,l,a)}SY(t,o,r,n,c,l,a)}else c.clearRect(0,0,s,d);c.restore()}},PY=vY(e=>{CM(e)}),PM=(e,n)=>{if(n){PY(e);return}CM(e)};import{jsx as LY}from"react/jsx-runtime";var AY=e=>{let n=MY(null);return kY(()=>{n.current&&PM({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ya())}),LY("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:n})},kM=AY;import DY from"clsx";import{useLayoutEffect as _Y,useEffect as MM,useRef as RY,useState as NY}from"react";import{ARROW_TYPE as AM,EVENT as yu}from"@excalidraw/common";import{jsx as zY}from"react/jsx-runtime";var LM=700,BY=100,FY=16,OY=5*60*1e3,_M=et(null),DM=e=>e===AM.elbow?mr:e===AM.round?pr:dr,wu=class{constructor(n){v(this,"app");v(this,"lastShownAt",0);v(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(_M,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<OY);v(this,"onArrowTypeCycled",n=>{this.show(DM(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?lr:DM(this.app.state.currentItemArrowType))});this.app=n}},RM=()=>{let[e,n]=$e(_M),t=ct(),{container:o}=we(),r=RY(null),[i,a]=NY(!1),l=e?.nonce;return _Y(()=>{if(l==null||!o)return;let s=(c,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=kd({cursor:{x:c,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:FY});p.style.transform=`translate(${u}px, ${E}px)`};s(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let d=c=>{s(c.clientX,c.clientY)};return window.addEventListener(yu.POINTER_MOVE,d),()=>{window.removeEventListener(yu.POINTER_MOVE,d)}},[l,o,t]),MM(()=>()=>{n(null)},[n]),MM(()=>{if(l==null)return;a(!1);let s=window.setTimeout(()=>{a(!0)},LM),d=window.setTimeout(()=>{n(null)},LM+BY),c=()=>{n(null)};return window.addEventListener(yu.POINTER_DOWN,c,{capture:!0}),()=>{window.clearTimeout(s),window.clearTimeout(d),window.removeEventListener(yu.POINTER_DOWN,c,{capture:!0})}},[l,n]),e?zY("div",{ref:r,className:DY("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var vu=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}=this.normalize(n,t,o);return a?s&&(queueMicrotask(()=>{let d=this.getState();a(i(d),d)}),l)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:l}):s?Promise.resolve(i(this.getState())):new Promise(d=>{this.subscribe({predicate:r,getValue:i,callback:c=>d(c),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,l=o?.once??!1,s=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:d,callback:c,once:m}=n;r=d,i=p=>p,a=c?(p,u)=>c(u):void 0,l=m??!1,s=d(this.getState())}else if(typeof n=="function"){let d=n;r=(c,m)=>d(c)!==d(m),i=c=>d(c)}else if(Array.isArray(n)){let d=n;r=(c,m)=>d.some(p=>c[p]!==m[p]),i=c=>c}else{let d=n;r=(c,m)=>c[d]!==m[d],i=c=>c[d]}return{predicate:r,getValue:i,callback:a,once:l,matchesImmediately:s}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as GY,getElementsInGroup as HY,isNonDeletedElement as NM,selectGroupsFromGivenElements as UY}from"@excalidraw/element";import{sceneCoordsToViewportCoords as WY}from"@excalidraw/common";import{flushSync as VY}from"react-dom";import{jsx as KY}from"react/jsx-runtime";var YY=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!NM(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&NM(t)?t:null,r=o?[o]:HY(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=GY(r),{x:l,y:s}=WY({sceneX:i,sceneY:a},e.state);return KY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-s+e.state.offsetTop}px`,left:`${l-e.state.offsetLeft}px`},onClick:()=>{VY(()=>{let d=UY(r,e.state);e.setState({selectedElementIds:r.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:d,activeLockedId:null})}),e.actionManager.executeAction(Ls)},title:f("labels.elementLock.unlock"),children:d1})},BM=YY;import{Fragment as KX,jsx as Pe,jsxs as mx}from"react/jsx-runtime";var YA=Dn.createContext(null),KA=Dn.createContext(null),px={formFactor:"desktop",desktopUIMode:"full",userAgent:WA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},hx=Dn.createContext(px);hx.displayName="EditorInterfaceContext";var UX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},gx=Dn.createContext({container:null,id:null});gx.displayName="ExcalidrawContainerContext";var fx=Dn.createContext([]);fx.displayName="ExcalidrawElementsContext";var Ex=Dn.createContext({...ar(),width:0,height:0,offsetLeft:0,offsetTop:0});Ex.displayName="ExcalidrawAppStateContext";var bx=Dn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});bx.displayName="ExcalidrawSetAppStateContext";var xx=Dn.createContext(null);xx.displayName="ExcalidrawActionManagerContext";var Dl=Dn.createContext(null);Dl.displayName="ExcalidrawAPIContext";var Ou=Dn.createContext(null);Ou.displayName="ExcalidrawAPISetContext";var ct=()=>tr(YA),St=()=>tr(KA),me=()=>tr(hx),it=()=>Fu(me()),we=()=>tr(gx),ia=()=>tr(fx),on=()=>tr(Ex),ze=()=>tr(bx),nt=()=>tr(xx),Jd=()=>tr(Dl),Bc=!1,Fc=0,Oc=null,Qo=!1,zc=!1,er=!1,Ru=!1,Gc={horizontal:null,vertical:null},Yr=0,Hc=!1,dx=new Map,WX=4,VX=300,zA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,Nu=!1,Bu=0,GA=!1,Ll=null,he={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},ux=class e extends Dn.Component{constructor(t){super(t);v(this,"canvas");v(this,"interactiveCanvas",null);v(this,"sessionExportThemeOverride");v(this,"rc");v(this,"unmounted",!1);v(this,"actionManager");v(this,"editorInterface",px);v(this,"stylesPanelMode",Fu(px));v(this,"excalidrawContainerRef",Dn.createRef());v(this,"scene");v(this,"fonts");v(this,"renderer");v(this,"visibleElements");v(this,"hasRenderableElements",!1);v(this,"resizeObserver");v(this,"id");v(this,"store");v(this,"history");v(this,"excalidrawContainerValue");v(this,"files",{});v(this,"imageCache",new Map);v(this,"imageLoadingProgress",new Map);v(this,"imageLoadingProgressEmitter",new So);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new So);v(this,"imagePlaceholderUpdateEmitter",new So);v(this,"iFrameRefs",new Map);v(this,"embedsValidationStatus",new Map);v(this,"initializedEmbeds",new Set);v(this,"elementsPendingErasure",new Set);v(this,"_initialized",!1);v(this,"editorLifecycleEvents",new IK(UX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new vu(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new vp(this));v(this,"flowchart",new Pp(this));v(this,"cursor",new Ip(this));v(this,"gifPlayback",new kp(this));v(this,"zDragZoom",null);v(this,"arrowText",new wp(this));v(this,"viewport",new Ap(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>he.pointers.size>=2||er}));v(this,"bindModeHandler",null);v(this,"textWysiwygSubmitHandler",null);v(this,"hitLinkElement");v(this,"lastPointerDownEvent",null);v(this,"lastPointerUpEvent",null);v(this,"lastPointerUpIsDoubleClick",!1);v(this,"lastPointerMoveEvent",null);v(this,"lastPointerMoveCoords",null);v(this,"lastCompletedCanvasClicks",[]);v(this,"lastKeyboardSmartZoomImageId",null);v(this,"smartZoomKeyDownAt",null);v(this,"smartZoomKeyHitElement",!1);v(this,"previousPointerMoveCoords",null);v(this,"drawShape",new Cp(this));v(this,"laserTrails",new Jm(this));v(this,"eraserTrail",new ip(this));v(this,"lassoTrail",new rp(this));v(this,"cursorHints",new wu(this));v(this,"onChangeEmitter",new So);v(this,"onPointerDownEmitter",new So);v(this,"onPointerUpEmitter",new So);v(this,"onUserFollowEmitter",new So);v(this,"onScrollChangeEmitter",new So);v(this,"missingPointerEventCleanupEmitter",new So);v(this,"onRemoveEventListenersEmitter",new So);v(this,"api");v(this,"getCommandToolTypes",()=>this.state.myocSimplifiedMode?[...Pw,...br]:Object.keys(Ae));v(this,"resolveCommandToolType",t=>{if(!Object.prototype.hasOwnProperty.call(Ae,t))return null;let o=t;if(!this.getCommandToolTypes().includes(o))return null;let r=o==="selection"?this.state.preferredSelectionTool.type:o;return!this.isToolSupported(r)||this.props.activeTool!=null&&this.props.activeTool.type!==r?null:r});v(this,"getCommandActionEntry",(t,o)=>{if(!t.keyTest||!this.actionManager.isActionAvailableForUI(t))return null;let r=typeof t.label=="function"?t.label(o,this.state,this):t.label;if(!r.trim())return null;let i=typeof t.icon=="function"?t.icon(this.state,o):t.icon,a=zT(t.name);return{id:`action:${t.name}`,kind:"action",label:f(r,null,r),...i?{icon:i}:{},...t.keywords?{keywords:t.keywords}:{},...a?{shortcut:a}:{}}});v(this,"getCommandCatalog",()=>{let t=this.actionManager.getElementsIncludingDeleted(),o=Object.values(this.actionManager.actions).flatMap(i=>{let a=this.getCommandActionEntry(i,t);return a?[a]:[]}),r=this.getCommandToolTypes().flatMap(i=>{let a=this.resolveCommandToolType(i);if(!a)return[];let l=Go(i);return[{id:`tool:${i}`,kind:"tool",label:wK(f(`toolBar.${a}`)),icon:Ae[a].icon,...l?{shortcut:l}:{}}]});return[...o,...r]});v(this,"executeCommand",t=>{if(t.startsWith("action:")){let i=t.slice(7);if(!Object.prototype.hasOwnProperty.call(this.actionManager.actions,i))return!1;let a=this.actionManager.actions[i];return!a||`action:${a.name}`!==t||!this.getCommandActionEntry(a,this.actionManager.getElementsIncludingDeleted())?!1:(this.actionManager.executeAction(a,"ui"),!0)}if(!t.startsWith("tool:"))return!1;let o=t.slice(5),r=this.resolveCommandToolType(o);return r?(this.setActiveTool({type:r}),!0):!1});v(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});v(this,"updateEditorAtom",(t,...o)=>{let r=Tt.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>Pr(this)?this.state.gridSize:null);v(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});v(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&Rc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(De.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=XM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Oi.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Jo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Qb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else qb(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});v(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);v(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.viewpointFlip!==this.state.viewpointFlip||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Ce({clientX:i.x,clientY:i.y},this.state),l=Ce({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,l.x),y:Math.min(a.y,l.y),width:Math.abs(l.x-a.x),height:Math.abs(l.y-a.y),zoom:this.state.zoom.value,viewpointFlip:this.state.viewpointFlip,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Mc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&At(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!mA(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:a,y:l}=Cu({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),s=6,d,c=lX(i);if(i.id===this.state.editingFrame){let m=c;d=Pe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===Y.ESCAPE||p.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:vK(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${jo.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?jo.nameColorDarkTheme:jo.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=c;return Pe("div",{id:this.getFrameNameDOMId(i),className:jb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+jo.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:jo.nameFontSize,color:t?jo.nameColorDarkTheme:jo.nameColorLightTheme,lineHeight:jo.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:De.MOVE,pointerEvents:this.state.viewModeEnabled?kl.disabled:kl.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Ye("export",t,"ui");let i=await mi(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(xK).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&ed(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Xt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Qt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Qt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(s=>this.state.selectedElementIds[s.id]?Po(s,{[a?"strokeColor":"backgroundColor"]:r}):s),captureUpdate:Qt.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Je(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||Mc.LIGHT,l=t?.appState?.name??this.state.name,s=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let d=r.id,c=t.elements.find(m=>m.id===d);r=c&&_u(c)&&Jt(c)?c:null}this.setState(d=>{let c=t.appState||{};return{...d,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:l,errorMessage:s}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(Qt.NEVER));v(this,"onBlur",Je(()=>{Qo=!1,this.resetSmartZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[Y.CTRL_OR_CMD]&&t.preventDefault()});v(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});v(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==Y.PAGE_UP&&t.key!==Y.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===Y.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});v(this,"preventBrowserZoomKeyDown",t=>{t[Y.CTRL_OR_CMD]&&(t.code===Ur.EQUAL||t.code===Ur.MINUS||t.code===Ur.ZERO||t.code===Ur.NUM_ADD||t.code===Ur.NUM_SUBTRACT||t.code===Ur.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Qo=!1,zc=!1,this.resetSmartZoomKey(),er=!1,Ru=!1,Ll=null,he.pointers.clear(),he.lastCenter=null,he.initialDistance=null,he.initialScale=null,clearTimeout(Fc),Fc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(Bu),Bu=0,Nu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Tt.set(Xt,null),Tt.set(wo,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&At(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});v(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,l=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(l=!!this.props.viewModeEnabled):l=!0,l!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:l});let s=r&&!o.viewModeEnabled,d=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||s&&!d)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,_m(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:sn(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});v(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));v(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});v(this,"resetHistory",()=>{this.history.clear()});v(this,"resetStore",()=>{this.store.clear()});v(this,"resetScene",Je(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...ar(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));v(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async s=>{if(!s.files.length)return;let d=s.files[0],c=await d.getFile();this.loadFileToCanvas(new File([c],c.name||"",{type:c.type}),d)}),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}catch(s){console.error(s),t={appState:{errorMessage:s.message||"Encountered an error during importing or restoring scene data"}}}let o=$r(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Yi(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,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,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};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},l=this.props.initialState?.viewport;if(l){let s=o.filter(m=>!m.isDeleted),d=Dc(s),c=this.viewport.resolveInitialViewport(l,d,a);c&&(r={...r,...c})}else t?.scrollToContent&&(r={...r,...Ui(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:Qt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(s=>{this.fonts.onLoaded(s)}),wA(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});v(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??PK(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=LK(),a=WA(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:oK,s=$b(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>l,isLandscape:o>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});v(this,"reconcileStylesPanelMode",t=>{let o=Fu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});v(this,"setDesktopUIMode",t=>{let o=DK(t);!o||o===this.editorInterface.desktopUIMode||(this.editorInterface=$b(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface),this.forceUpdate())});v(this,"onResize",Je(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Oi.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));v(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(Gc=t),this.scheduleImageRefresh()});v(this,"onScroll",jM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},rK));v(this,"onCut",Je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ac(t.target)||(this.actionManager.executeAction(Am,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ac(t.target)||(this.actionManager.executeAction(Pa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(kK&&t.preventDefault(),!Bc){Bc=!0,t.touches.length===1&&(Oc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Fc),Fc=window.setTimeout(e.resetTapTwice,XM);return}if(Bc&&t.touches.length===1&&Oc){let o=t.touches[0];To(ae(o.clientX,o.clientY),ae(Oc.x,Oc.y))<=eA&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Bc=!1,clearTimeout(Fc)}t.touches.length===2&&this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ne(this.state.previousSelectedElementIds,this.state)}):he.pointers.clear())});v(this,"pasteFromClipboard",Je(async t=>{if(!this.isInteractionEnabled())return;let o=!!Nu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||Ac(r)))return;let l=await yr(t),s=l.getFiles(),d=await Is(l,o);if(!d.elements&&s.length>0&&!o)try{let m=(await Em())[An.excalidrawClipboard];typeof m=="string"&&(l=await yr(gm({types:{[An.excalidrawClipboard]:m}})),s=l.getFiles(),d=await Is(l,o))}catch(c){console.warn(`Could not read editable image clipboard data: ${c.message}`)}if(this.state.viewModeEnabled){if(!this.containsImagePaste(d,s,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:s.map(c=>c.file),data:d,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(d,s,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=$r(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=Al(o),s=Ml(r,a)/2,d=Ml(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ce({clientX:c,clientY:m},this.state),E=p-s,g=u-d,[b,w]=Nt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=lA({type:"everything",elements:o.map(k=>Po(k,{x:k.x+b-r,y:k.y+w-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...y];I=this.props.onDuplicate?.(I,x)||I,SA(I,Dc(y));let P=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(P){let k=sX(y,P);I=rx(I,k,P)}this.scene.replaceAllElements(I),y.forEach(k=>{if(Jt(k)&&cA(k)){let M=gA(k,this.scene.getElementsMapIncludingDeleted());eX(k,M,this.scene)}}),AK&&Do.loadElementsFonts(y).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let C=TX(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Tt.get(Rb)?this.state.openSidebar:null,...CA(C,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:y,fit:t.fit,animation:!1,offsets:{ui:!0}})});v(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});v(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,l)=>r(t(a,l)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{Yr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=he.pointers.size>=2;he.pointers.delete(t.pointerId),o&&he.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ye("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...sn(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});v(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});v(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});v(this,"revealIfHidden",t=>{!t.length||$K(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:Al(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});v(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:ro(t.zoom)},shouldCacheIgnoreZoom:!1})});v(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});v(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});v(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});v(this,"setToast",t=>{this.setState({toast:t})});v(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,jY,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Je(t=>{let o=new Map;for(let l of t){let s=l.id,d=this.imageCache.get(s);d&&!this.files[s]&&o.set(s,Promise.resolve(d.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());ex({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:l=>this.handleImageCacheUpdate(l),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:l})=>{for(let[s,d]of o){let c=this.imageCache.get(s);!c||!l.has(s)||(this.imageCache.set(s,{...c,placeholderImage:await d,transitionStart:performance.now()}),this.clearImageLoadingProgress(s))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));v(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:l,customData:s})=>({file:await jr(l),customData:s??{}}))),a=i.find(({file:l})=>!Ki(l));if(a)throw new Zu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:l})=>l),o,r,i.map(({customData:l})=>l))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await jr(o);if(!Ki(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((s,d)=>{i.onload=()=>s(i),i.onerror=()=>d(new Error(f("errors.imageInsertError")))}),l={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===An.gif?"pending":void 0};this.imageCache.set(t,l),l.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await td(r);try{let s=await a;if(this.imageCache.get(t)!==l||this.files[t])return;this.imageCache.set(t,{...l,image:s}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(s){throw this.imageCache.get(t)===l&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),s}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Pc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});v(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});v(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,l=r===void 0?a:r??void 0,s=typeof o=="number";return{...i,uploadProgress:{...l,state:s?"uploading":o,...s?{progress:Pc(o,0,1)}:{progress:void 0}}}})});v(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});v(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);v(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});v(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())Fi(o)&&o.fileId===t&&Oi.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===An.svg))try{let s=Zx(hA(jx(l.dataURL)),An.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});v(this,"updateScene",Je(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=o||void 0,s=r?RK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));v(this,"applyDeltas",(t,o)=>{let r=DA.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return DA.applyTo(r,a,i,o)});v(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));v(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});v(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});v(this,"updateCurrentCursorPosition",Je(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"isPlainSmartZoomKey",t=>!t[Y.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey&&t.key.toLocaleLowerCase()===Y.F);v(this,"updateSmartZoomCursor",t=>{if(this.smartZoomKeyDownAt===null)return;let o=t?this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0}):null;this.cursor.set(o?De.POINTER:"zoom-in")});v(this,"resetSmartZoomKey",()=>{let t=this.smartZoomKeyDownAt!==null;this.smartZoomKeyDownAt=null,this.smartZoomKeyHitElement=!1,t&&(this.cursor.reset(),this.updateEditorAtom(Ma,!1))});v(this,"handleSmartZoomKeyDown",t=>this.isPlainSmartZoomKey(t)?(!t.repeat&&this.smartZoomKeyDownAt===null&&(this.smartZoomKeyDownAt=Date.now(),this.smartZoomKeyHitElement=!1,this.updateEditorAtom(Ma,!0),this.updateSmartZoomCursor(this.lastPointerMoveCoords)),t.preventDefault(),t.stopPropagation(),!0):!1);v(this,"handleSmartZoomKeyUp",t=>{if(t.key.toLocaleLowerCase()!==Y.F||this.smartZoomKeyDownAt===null)return!1;let o=Date.now()-this.smartZoomKeyDownAt,r=!this.smartZoomKeyHitElement&&o<=VX;return this.resetSmartZoomKey(),t.stopPropagation(),r&&this.actionManager.executeAction(Hn,"keyboard",this.scene.getNonDeletedElements()),!0});v(this,"handleSmartZoomPointerDown",(t,o)=>{if(t.button!==Ln.MAIN||this.smartZoomKeyDownAt===null)return!1;let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});return r?(this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Hn,"keyboard",[r]),!0):!1});v(this,"onKeyDown",Je(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(s,d){let c=s[d];return typeof c=="function"?c.bind(s):d==="key"?t.shiftKey?s.key.toUpperCase():s.key.toLowerCase():c}})),!qM(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let s=de(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&to(s[0])&&t.key===Y.ENTER){this.startImageCropping(s[0]);return}if(s.length===0&&(t.key===Y.ARROW_LEFT||t.key===Y.ARROW_RIGHT)&&!t[Y.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey){let d=this.scene.getNonDeletedElementsMap(),c=Ov(this.scene.getNonDeletedElements(),d,this.lastKeyboardSmartZoomImageId,t.key===Y.ARROW_RIGHT?"next":"previous");if(c){this.lastKeyboardSmartZoomImageId=c.id,this.actionManager.executeAction(Hn,"keyboard",[c]),t.preventDefault(),t.stopPropagation();return}}if(t.key===Y.ESCAPE)this.updateEditorAtom(wo,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(jb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let d=yp(s);Tt.get(wo)?.type==="panel"&&TE(this,{conversionType:d,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),d&&this.updateEditorAtom(wo,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(Nu=t.shiftKey,clearTimeout(Bu),Bu=window.setTimeout(()=>{Nu=!1},100)),t[Y.CTRL_OR_CMD]&&Ac(t.target)&&(t.code===Ur.MINUS||t.code===Ur.EQUAL)){t.preventDefault();return}if(Ac(t.target)&&t.key!==Y.ESCAPE||Yb(t.key)&&qM(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===Y.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else qo("COMPLEX_BINDINGS")?this.handleSkipBindMode():Du({app:this,event:t});if(this.handleSmartZoomKeyDown(t)||this.actionManager.handleKeyDown(t))return;if(this.state.viewModeEnabled&&t.key.toLowerCase()===Y.Z&&!t[Y.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey){zc=!0,this.cursor.set("zoom-in"),t.preventDefault();return}let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===Y.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let s=kw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!tA(s,["laser","hand"]))return;if(s){if(this.state.activeTool.type!==s&&Ye("toolbar",s,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),s==="arrow"&&this.state.activeTool.type==="arrow"){let d=this.state.currentItemArrowType===Wr.sharp?Wr.round:this.state.currentItemArrowType===Wr.round?Wr.elbow:Wr.sharp;this.setState({currentItemArrowType:d}),this.cursorHints.onArrowTypeCycled(d)}else(s==="arrow"||s==="line")&&this.cursorHints.onToolShortcut(s,/^\d$/.test(t.key)?"digit":"letter");s==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():s==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:s},{toggle:!0}),t.stopPropagation();return}else if(t.key===Y.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[Y.CTRL_OR_CMD]&&!t.repeat&&(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Wt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Du({app:this,event:t})),Yb(t.key)){let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),d=new Set;s.filter(u=>ko(u)).filter(u=>{let E=u.startBinding&&!s.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!s.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>d.add(u.id)),s=s.filter(u=>!d.has(u.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?KM:this.getEffectiveGridSize())||(t.shiftKey?eK:KM),m=0,p=0;t.key===Y.ARROW_LEFT?m=-c:t.key===Y.ARROW_RIGHT?m=c:t.key===Y.ARROW_UP?p=-c:t.key===Y.ARROW_DOWN&&(p=c),m*=eo(this.state.viewpointFlip.horizontal),p*=eo(this.state.viewpointFlip.vertical),s.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),Mu(u,this.scene,{simultaneouslyUpdated:s})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let s=this.scene.getSelectedElements(this.state);if(s.length===1){let d=s[0];if(t[Y.CTRL_OR_CMD]||lx(d))Vt(d)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==d.id)&&(this.store.scheduleCapture(),qt(d)||this.actionManager.executeAction(za));else if(Jt(d)||fA(d)){let c;Jt(d)||(c=d);let m=nx(d,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:c}),t.preventDefault();return}else At(d)&&this.setState({editingFrame:d.id})}}if(t.key===Y.SPACE&&he.pointers.size===0&&(Qo=!0,this.cursor.set(De.GRAB),t.preventDefault()),t.key.toLowerCase()===Y.Z&&!t[Y.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(zc=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;t.key===Y.G&&(ir(this.state.activeTool.type)||s.some(d=>ir(d.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.F){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;(this.state.activeTool.type==="text"||s.find(d=>Jt(d)||tx(d,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===Y.I&&!t.shiftKey&&!t[Y.CTRL_OR_CMD],a=r===Y.S&&t.shiftKey&&!t[Y.CTRL_OR_CMD]||i,l=r===Y.I&&t.shiftKey&&!t[Y.CTRL_OR_CMD];(a||l)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Je(t=>{if(this.isInteractionEnabled()&&!this.handleSmartZoomKeyUp(t)){if(t.key===Y.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(De.GRAB):Pu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Qo=!1),t.key.toLowerCase()===Y.Z&&(zc=!1,this.cursor.reset()),t.key===Y.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Du({app:this,event:t})),(t.key===Y.ALT&&this.state.bindMode==="skip"||!t[Y.CTRL_OR_CMD]&&!ku(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&qo("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Vr(ae(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());ko(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[Y.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Wt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Du({app:this,event:t})}if(Yb(t.key)){oA(this.scene.getSelectedElements(this.state).filter(_c),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(sx).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...RA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...RA(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));v(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(xt);let i=ba.includes(t.type),l=o.toggle===!0&&i&&this.state.activeTool.type===t.type?sn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?sn(this.state,{...t,lastActiveTool:this.state.activeTool}):sn(this.state,t);l.type==="hand"?this.cursor.set(De.GRAB):Qo||this.cursor.applyForTool(l),fK(document.activeElement)&&this.focusContainer(),KK(l.type)||this.setState({suggestedBinding:null}),l.type==="image"&&this.onImageToolbarButtonClick(),this.setState(s=>{let d={snapLines:s.snapLines.length?[]:s.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:Pu(l.type)?s.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return l.type==="freedraw"&&this.store.scheduleCapture(),l.type==="lasso"?{...s,...d,activeTool:l,...r?{}:{selectedElementIds:Ne({},s),selectedGroupIds:Ne({},s),editingGroupId:null,multiElement:null}}:l.type!=="selection"?{...s,...d,activeTool:l,selectedElementIds:Ne({},s),selectedGroupIds:Ne({},s),editingGroupId:null,multiElement:null}:{...s,...d,activeTool:l}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>he.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${JM()}`);v(this,"onGestureStart",Je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null}),he.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Je(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=he.initialScale;o&&this.viewport.translate(r=>({...Ao({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:ro(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ne(this.state.previousSelectedElementIds,this.state)}),he.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=OA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&MI(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=OA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Af,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:l,arrowEndpoint:s})=>{let d=!1,c=s&&this.arrowText.getTextBinding(s,this.getCurrentItemStrokeWidth("text"));c&&(i=null,r=!1,t=c.anchor[0],o=c.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(tx(i,this.scene.getNonDeletedElementsMap())||(d=!0));let p=c?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||$M(u),g=this.state.currentItemFontSize;if(!p&&d&&i&&!_c(i)){let P=fX(Xb({fontSize:g,fontFamily:u}),E),C=EX(g,E),k=Math.max(i.height,C),M=Math.max(i.width,P);this.scene.mutateElement(i,{height:k,width:M}),t=i.x+M/2,o=i.y+k/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),w=c?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-IA(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!d||!i||i.frameId===y.id)?y.id:null,I=p||iA({x:w.x,y:w.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:c?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:c?.verticalAlign??(m?lK.MIDDLE:VM),containerId:d?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?_c(i)?0:i.angle:0,frameId:x});if(!p&&d&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&d){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);s&&c&&this.arrowText.bindText(s,I,c.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?l:null}):this.setState({newElement:I,multiElement:null})});v(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});v(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});v(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return To(ae(o.x,o.y),ae(r.x,r.y))<=eA});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.state.viewModeEnabled&&!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement)return;if(this.state.viewModeEnabled){let{x:s,y:d}=Ce(t,this.state),c=this.getElementAtPosition(s,d,{includeLockedElements:!0});c&&(this.cursor.reset(),this.actionManager.executeAction(Hn,"ui",[c]));return}if(this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Ce(t,this.state);if(o.length===1&&Vt(o[0])){let s=o[0];if((t[Y.CTRL_OR_CMD]&&sx(s)||lx(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(za);return}else if(this.state.selectedLinearElement&&qt(o[0])){let d=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=d?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,c);let m=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?fe.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:d,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&lx(s))return}let a=this.getElementAtPosition(r,i,{includeLockedElements:!0});if(a&&to(a)){this.actionManager.executeAction(Hn,"ui",[a]);return}if(this.cursor.reset(),vX(this.state).length>0){let s=this.getElementAtPosition(r,i),d=s&&wX(s,this.state.selectedGroupIds);if(d){this.store.scheduleCapture(),this.setState(c=>({...c,...no({editingGroupId:d,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(Rc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){if(this.getElementAtPosition(r,i,{includeLockedElements:!0})?.locked)return;let c=!t[Y.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(c&&(this.state.activeTool.type==="autoshape"||sA(c)||!bK(c.backgroundColor)||Nc({point:ae(r,i),element:c,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(c)}))){let m=nx(c,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:c||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Ln.MAIN){this.lastCompletedCanvasClicks=[];return}if(this.smartZoomKeyHitElement){t.preventDefault(),t.stopPropagation();return}let o=Ce(t,this.state);if(this.smartZoomKeyDownAt!==null&&!this.smartZoomKeyHitElement){let i=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(i){this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Hn,"keyboard",[i]);return}}let r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});v(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!to(a)||!a.fileId)continue;let l=this.imageStatus.get(a.fileId),s=l?.uploadProgress?.onClick;if(s&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>s(a.fileId);let d=l?.downloadError?.onClick;if(d&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>d(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=oc(o,r,this.state,i);return!!a&&To(ae(t.x,t.y),ae(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});v(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(o&&l.id===o.id&&(i=a),l.link&&a>=i&&$c(l,this.scene.getNonDeletedElementsMap(),this.state,ae(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});v(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&Gx(a,i,this.state,ae(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=c=>c===Ln.MAIN||c===Ln.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=To(ae(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ae(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>YM)return;let i=Ce(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=$c(this.hitLinkElement,a,this.state,ae(i.x,i.y),this.editorInterface.formFactor==="phone"),s=Ce(this.lastPointerUpEvent,this.state),d=$c(this.hitLinkElement,a,this.state,ae(s.x,s.y),this.editorInterface.formFactor==="phone");l&&d&&(_m(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Su(r);let i;if(this.props.onLinkOpen&&o&&(i=EK(ne.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=uK(r)?"_self":"_blank",l=window.open(void 0,a);l&&(l.opener=null,l.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(De.POINTER),r2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(_m(),!1));v(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});v(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});v(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});v(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(s=>!s.locked&&bA(t,s,r));if(!i.length)return null;let a=i.at(-1),l=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(s=>!o?.excludeElementIds?.[s.id]);if(l){if(At(l)&&!l.locked)return a;let s=this.scene.getElementIndex(l.id),d=this.scene.getElementIndex(a.id);if(s!==-1&&d!==-1&&s<=d)return a;let c=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return c||(l.frameId?i.find(m=>m.id===l.frameId)??null:null)}return a});v(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});v(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&GX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});v(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?nX(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});v(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&At(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=ro(r*Math.max(.1,1+i/100));this.viewport.translate(l=>({...Ao({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},l),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});v(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!er&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Qo||er||Ru||Bl(this.state))return;let l=Yf(Gc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(l?this.cursor.set(De.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(De.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},l),!this.state.newElement&&SI(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=TI(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=Lc(w.snapLines,b),x=w.originSnapOffset?Lc(w.originSnapOffset,g):g;return w.snapLines===y&&w.originSnapOffset===x?null:{snapLines:y,originSnapOffset:x}})}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:fe.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Wt(()=>{this.setState({selectedLinearElement:g})})}if(YK(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&ku(this.state)){let b=ae(r,i),w=this.scene.getNonDeletedElementsMap(),y=Vr(b,this.scene.getNonDeletedElements(),w,FA(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:cx(b,y,w,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:w,y,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)To(ae(r-w,i-y),I)>=Kb?(this.store.scheduleCapture(),Wt(()=>{Co(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,ae(r-w,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(De.POINTER);else if(x.length>2&&T&&To(ae(r-w,i-y),T)<Kb){this.cursor.set(De.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let P=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(C=>Math.min(C,P)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[P],initialState:{...b.initialState,lastClickedPoint:P}}})}else{uA(x,this.state.zoom.value)&&this.cursor.set(De.POINTER);let P=this.scene.getNonDeletedElementsMap();if(sx(g)){let k=Vr(ae(r,i),this.scene.getNonDeletedElements(),P);qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,k)}Co(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let C=fe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);C&&this.setState(C)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=ae(r,i),b=Vr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),FA(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!BA(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:cx(g,b,w,this.state.zoom)}})}let s=!!t.buttons,d=this.state.activeTool.type==="laser";if(s||!d&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(De.POINTER);return}if(m.length===1&&!l&&!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"&&!(m.length===1&&qt(m[0]))&&!(Vt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=kA(c,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(zA(PA(g),this.state.viewpointFlip));return}}}else if(m.length>1&&!l&&this.state.openDialog?.name!=="elementLinkSelector"){let g=MA(Al(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(zA(PA({transformHandleType:g}),this.state.viewpointFlip));return}}if(pn(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(d)return;u&&(u.link||Jo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?De.POINTER:Jt(u)?De.TEXT:De.CROSSHAIR):!t[Y.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(De.MOVE):this.state.viewModeEnabled?this.cursor.set(De.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(De.AUTO):l?this.cursor.set(De.AUTO):!t[Y.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!qt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(De.MOVE):this.cursor.set(De.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Lc(g.hoveredElementIds,no({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Lc(g.hoveredElementIds,{})})),this.updateSmartZoomCursor({x:r,y:i})});v(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});v(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(Hc=!0)});v(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),er||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;if(this.lastPointerMoveCoords={x:i,y:a},this.handleSmartZoomPointerDown(t,r))return;let l=t.target;if(l.setPointerCapture&&l.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(Tb,null)),Tt.get(wo)&&this.updateEditorAtom(wo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),zc){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Ne(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,w)=>(b[w]=this.state.selectedElementIds[w],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Qt.EVENTUALLY:Qt.NEVER});return}let s=document.getSelection();if(s?.anchorNode&&s.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=$b(this.editorInterface,{isTouchScreen:!0})),er||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Ln.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Qn.eraser){this.setState({activeTool:sn(this.state,{type:Qn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),pn(this.state)&&this.setState({activeTool:sn(this.state,{...this.state.activeTool.lastActiveTool||{type:Qn.selection},lastActiveTool:null})})},b=ve(window,ne.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Ln.MAIN&&t.button!==Ln.TOUCH&&t.button!==Ln.ERASER||he.pointers.size>1)return;let d=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,d.origin)||this.handleDraggingScrollBar(t,d)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,d))||!(!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 g=d.hit.element&&this.isASelectedElement(d.hit.element);(t.altKey&&t[Y.CTRL_OR_CMD]&&!d.resize.handleType||!d.hit.hasHitCommonBoundingBoxOfSelectedElements&&!d.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(d.origin.x,d.origin.y,t.shiftKey),d.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&d.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[d.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(P=>{let C=this.scene.getElement(P);C&&I.push(C)});let T=d.hit.element;if(At(T))ox(I,T.id).forEach(P=>{delete x[P.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let P=T.groupIds,C=new Set(P.flatMap(k=>zi(this.scene.getNonDeletedElements(),k)).filter(k=>At(k)).map(k=>k.id));C.size>0&&I.forEach(k=>{k.frameId&&C.has(k.frameId)&&(delete x[k.id],k.groupIds.flatMap(M=>zi(this.scene.getNonDeletedElements(),M)).forEach(M=>{delete x[M.id]}))})}return{...no({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Jo(T)?"info":!1}}),d.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,d):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Qn.frame||this.state.activeTool.type===Qn.magicframe?this.createFrameElementOnPointerDown(d,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(d.lastCoords.x,d.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(d):this.state.activeTool.type===Qn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,d);this.props?.onPointerDown?.(this.state.activeTool,d),this.onPointerDownEmitter.trigger(this.state.activeTool,d,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(d.lastCoords.x,d.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(d),p=this.onPointerUpFromPointerDownHandler(d),u=this.onKeyDownFromPointerDownHandler(d),E=this.onKeyUpFromPointerDownHandler(d);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(ne.POINTER_MOVE,m),window.addEventListener(ne.POINTER_UP,p),window.addEventListener(ne.KEYDOWN,u),window.addEventListener(ne.KEYUP,E),d.eventListeners.onMove=m,d.eventListeners.onUp=p,d.eventListeners.onKeyUp=E,d.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});v(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Hc=!1,Yr?Hc=!0:Yr=window.setTimeout(()=>{Yr=0,Hc||this.handleCanvasContextMenu(t)},aK))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Yr),Yr=0,Hc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{Ll?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(he.pointers.size<=1&&((t.button===Ln.WHEEL||t.button===Ln.MAIN&&Qo||Bl(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;er=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(De.GRABBING);let{clientX:i,clientY:a}=t,l=jm(d=>{let c=i-d.clientX,m=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!o&&(Math.abs(c)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(ne.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ne.PASTE,p),window.removeEventListener(ne.POINTER_UP,u)},100)};document.body.addEventListener(ne.PASTE,p),window.addEventListener(ne.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-c*eo(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-m*eo(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),s=Je(Ll=()=>{Ll=null,er=!1,Qo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ne.POINTER_MOVE,l),window.removeEventListener(ne.POINTER_UP,s),window.removeEventListener(ne.BLUR,s),l.flush()});return window.addEventListener(ne.BLUR,s),window.addEventListener(ne.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ne.POINTER_UP,s),!0});v(this,"updateMultiTouchGesture",t=>{he.pointers.has(t.pointerId)&&he.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=he.initialScale;if(he.pointers.size===2&&he.lastCenter&&o&&he.initialDistance){let r=Df(he.pointers),i=r.x-he.lastCenter.x,a=r.y-he.lastCenter.y;he.lastCenter=r;let l=_f(Array.from(he.pointers.values())),s=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:l/he.initialDistance,d=s?ro(o*s):this.state.zoom.value;this.setState(c=>{let m=Ao({viewportX:r.x,viewportY:r.y,nextZoom:d},c),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i*eo(c.viewpointFlip.horizontal)/p,scrollY:m.scrollY+2*a*eo(c.viewpointFlip.vertical)/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else he.lastCenter=he.initialDistance=he.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{Pu(this.state.activeTool.type)||this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(Pu(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!qt(a[0])&&!(Vt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=kA(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),o.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),o.resize.handleType=l.transformHandleType))}else a.length>1&&(o.resize.handleType=MA(Al(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=Zb(SX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Vt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=CX(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=fe.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=fe.getElement(p.elementId,E);if(g&&ko(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=FX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:w,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:y}}}),!1}}let l=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),d=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=s;let c=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||c&&c?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!c&&c.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Ne({[p.selectedLinearElement.elementId]:!0},this.state):Ne({},p)}));else if(c!=null){if(t[Y.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...yX(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!TA(c,this.state.editingGroupId)&&this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),At(c))ox(E,c.id).forEach(g=>{delete u[g.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let g=c.groupIds,b=new Set(g.flatMap(w=>zi(this.scene.getNonDeletedElements(),w)).filter(w=>At(w)).map(w=>w.id));b.size>0&&E.forEach(w=>{w.frameId&&b.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(y=>zi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(g=>p.selectedGroupIds[g])||(u={[c.id]:!0})),{...no({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||Jo(c)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let l=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(r,i);sA(l)&&(s=l,r=l.x+l.width/2,i=l.y+l.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Nt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=this.state.currentItemStrokeVariability,c=FK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,strokeOptions:{variability:d,streamline:t.pointerType!=="mouse"?JY:qY},locked:!1,frameId:l?l.id:null,points:[ae(0,0)],pressures:s?[]:[t.pressure]});this.insertNewElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:Ne(p,m)}}),this.setState({newElement:c,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,l]=Nt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=zK({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(s),s});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Nt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Au(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=rA({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.insertNewElement(s),s});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,l]=Nt(t,o,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,d=100/this.state.zoom.value;return UK({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:s?s.id:null,customData:i,x:a-d/2,y:l-d/2,width:d,height:d})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Wt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Co(a,"selectedLinearElement is expected to be set"),i.type==="line"&&uA(i.points,this.state.zoom.value)){Wt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(xt);return}if(qt(i)&&i.points.length>1){this.actionManager.executeAction(xt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:d}=a,c=Ce(t,this.state),{start:m,end:p}=ko(i)&&ku(this.state)?HX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),c.x,c.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!BA(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=d&&To(ae(r.origin.x-l,r.origin.y-s),d)<Kb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(xt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:Ne({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(De.POINTER)}else{let[i,a]=Nt(r.origin.x,r.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[c,m]=o==="arrow"?[s,d]:[null,null],p=o==="arrow"?GK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Wr.round?{type:Iu.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:m,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Wr.elbow,fixedSegments:this.state.currentItemArrowType===Wr.elbow?[]:null}):WK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Iu.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),u=ae(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=ku(this.state)?Vr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[ae(0,0),ae(0,0)]}),this.insertNewElement(p),ko(p)&&DX(p,new Map([[0,{point:ae(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:WM(t.nativeEvent)}),Wt(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(Vt(p)){w=new fe(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;w={...w,selectedPointsIndices:[x],initialState:{...w.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ae(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:Ne({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&ko(p)?{element:g,midPoint:cx(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),ko(p)&&qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Nt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=rA({type:"embeddable",...l}):s=HK({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.insertNewElement(s),this.setState({multiElement:null,newElement:s}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Nt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...jo},l=o===Qn.magicframe?OK(a):BK(a);this.insertNewElement(l),this.setState({multiElement:null,newElement:l})});v(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});v(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(ko(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Lu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Lu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else Jb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&Lu(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&Lu(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||cA(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Ki(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===An.svg)try{o=Qu(hA(await o.text()),o.name)}catch(c){throw console.warn(c),new Error(f("errors.svgImageInsertError"))}else if(o.type!==An.gif){let{maxWidthOrHeight:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??qx)(o,{maxWidthOrHeight:c})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===An.gif,l=await(this.props.generateIdForFile?.(o)||Xx(o));if(!l)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[l]?.dataURL){let{maxFileSizeBytes:c}=this.props.imageOptions;if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let d=this.files[l]?.dataURL||await td(o);return new Promise(async(c,m)=>{try{let p=this.getLatestInitializedImageElement(t,l);if(this.addMissingFiles([{mimeType:i,id:l,dataURL:d,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(l)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(l)?.image,E=u?jK(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,l);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=Po(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[l]:{...this.files[l],fileName:o.name,thumbHash:E??void 0}},r&&r!==l&&this.gifPlayback.removePlaceholderDecodeState(r),c(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return Po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await Ox({description:"Image",extensions:Object.keys(tK),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(xt)})}});v(this,"getImageNaturalDimensions",(t,o)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),l=a*(o.naturalWidth/o.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Fi(o)&&o.fileId===t&&Oi.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let l of t){let s=this.imageCache.get(l.fileId);s&&r.set(l.fileId,Promise.resolve(s.image))}let{updatedFiles:i,erroredFiles:a}=await ex({imageCache:this.imageCache,fileIds:t.map(l=>l.fileId),files:o,onImageCacheUpdate:l=>this.handleImageCacheUpdate(l),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[l,s]of r){let d=this.imageCache.get(l);!d||!i.has(l)||this.imageCache.set(l,{...d,placeholderImage:await s,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(Qt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(l=>{if(Fi(l)){if(a.has(l.fileId))return Po(l,{status:"error"});if(i.has(l.fileId)&&l.status==="error")return Po(l,{status:"saved"})}return l}))),{updatedFiles:i,erroredFiles:a}});v(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});v(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==An.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await ex({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});v(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));v(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});v(this,"addNewImagesToImageCache",async(t=QK(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&Oi.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",XY(()=>{this.addNewImagesToImageCache()},nK));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(ne.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ne.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ne.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ne.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,l=_A(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(l);let s=await Promise.all(l.map(async(u,E)=>{try{return await this.initializeImage(u,await jr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),Po(u,{isDeleted:!0})}})),d=Dc(s),c=_A(s.filter(u=>!u.isDeleted),o,r,a),m=Dc(c),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??d.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ne(Object.fromEntries(c.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:Qt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(xt)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=Tg(t),a=await yr(t),l=a.getFiles(),s=l.map(c=>c.file).filter(c=>Ki(c));if(this.state.viewModeEnabled)return s.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:s,event:t})?void 0:this.insertImages(s,o,r,bm(a,s.length,i));if(l.length===1){let{file:c,fileHandle:m}=l[0];if(c&&(c.type===An.png||c.type===An.svg))try{let p=await Gl(c,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Qt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(s.length>0&&this.isToolSupported("image"))return this.insertImages(s,o,r,bm(a,s.length,i));if(l.length>0){let{file:c,fileHandle:m}=l[0];c&&await this.loadFileToCanvas(c,m)}let d=a.findByType(An.text);if(d){let c=d.value;if(c&&Qb(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Au(c)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Su(c)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await jr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Gl(t,this.state,r,o)}catch(a){let l=a instanceof Fx;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;VA(r.concat(i.elements)),this.store.scheduleMicroAction({action:Qt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Qt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});v(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Ln.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,l=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},l),d=s&&l.length===1&&l[0].link?l[0]:void 0,c=i??a??d,m=c||s?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Ye("contextMenu","openContextMenu",m),this.setState({...c&&!this.state.selectedElementIds[c.id]?{...this.state,...no({editingGroupId:this.state.editingGroupId,selectedElementIds:{[c.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Vt(c)?new fe(c,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,c)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){AA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ml(t.origin.x,a.x),height:Ml(t.origin.y,a.y),shouldMaintainAspectRatio:kc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l||this.arrowText.maybeDragNewText(l,a))return;let[s,d]=Nt(a.x,a.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=Fi(l)&&this.imageCache.get(l.fileId)?.image,m=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:p,snapLines:u}=II(l,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),ko(l)||AA({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:Ml(t.originInGrid.x,s),height:Ml(t.originInGrid.y,d),shouldMaintainAspectRatio:to(l)?!kc(o):kc(o),shouldResizeFromCenter:UM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Qn.frame||this.state.activeTool.type===Qn.magicframe)&&this.setState({elementsToHighlight:ix(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});v(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=Nt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&to(s)){let d=t.originalElements.get(s.id),c=Fi(s)&&this.imageCache.get(s.fileId)?.image;if(d&&to(d)&&c&&!(c instanceof Promise)){let[m,p]=Nt(i.x,i.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:E,snapLines:g}=Ff([s],[d],this,o,u,r);this.scene.mutateElement(s,pX(s,this.scene.getNonDeletedElementsMap(),r,c.naturalWidth,c.naturalHeight,a+E.x,l+E.y,o.shiftKey?d.width/d.height:void 0)),Mu(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});v(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(At),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&qt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=Nt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(m=>{ox(this.scene.getNonDeletedElements(),m.id).forEach(u=>{c.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Nt(l.x,l.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=Ff(r,de(E,this.state),this,o,u,a);s+=g.x,d+=g.y,this.setState({snapLines:b})}if(PX(t.originalElements,a,r,this.scene,WM(o),UM(o),r.some(m=>to(m))?!kc(o):kc(o),s,d,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{ix(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{_u(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});v(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>to(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&to(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>to(r))&&(!t||this.state.selectedElementIds[t.id])?[Ng,Bg]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Su(t.link),r=wA(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await go(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});v(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Hn,Sa,Ca,We,ka,Wa,Tr]:[zg,We,Fh,p2,We,ka,Ft,Ps,ks,We,Sa,Ca,We,Wa,Tr];if(this.state.viewModeEnabled)return[...a,a.length>0&&We,Hn,Sa,Ca,We,Pa,r.length>0&&We,...r];let l=this.editorInterface.formFactor==="desktop"?[We,_h,Rh,Nh,Bh]:[];return[We,Hn,Sa,Ca,We,Am,Pa,zg,r.length>0&&We,...r,i.length>0&&We,...i,We,nI,oI,rI,We,Sf,We,Dg,Af,Ug,Wg,$v,_g,We,...l,We,Fg,Og,We,za,We,Jg,a.length>0&&We,...a,We,Oh,Ls,We,jl]});v(this,"handleWheel",Je(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(jb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),er)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=sK*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20);let c=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:cK;d=Math.max(d,c),this.viewport.translate(p=>({...Ao({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:ro(d)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:l})=>({scrollX:a-(r||o)*eo(l.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:l,viewpointFlip:s})=>({scrollX:a-o*eo(s.horizontal)/i.value,scrollY:l-r*eo(s.vertical)/i.value}))}));v(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:he.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",jM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));v(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=o.getBoundingClientRect(),{width:s,height:d,offsetTop:c,offsetLeft:m}=this.state;if(r===s&&i===d&&a===m&&l===c){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});Nl(t.googleFonts?.fontCssUrls);let o=ar(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:s=o.theme,name:d=`${f("labels.untitled")}-${JM()}`,wheelZoomsOnDefault:c=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=sn(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:s,exportWithDarkMode:s===Mc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:l,gridModeEnabled:a??o.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:c},this.refreshEditorInterface(),this.stylesPanelMode=Fu(this.editorInterface),this.id=$Y(),this.actionManager=new Km(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new LA,this.canvas=document.createElement("canvas"),this.rc=ZY.canvas(this.canvas),this.renderer=new js(this.scene),this.visibleElements=[],this.store=new AX(this),this.history=new Zs(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Do(this.scene),this.history=new Zs(this.store),this.actionManager.registerAll(Ed),this.actionManager.registerAction(sI(this.history)),this.actionManager.registerAction(cI(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},getCommandCatalog:this.getCommandCatalog,executeCommand:this.executeCommand,refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,setDesktopUIMode:this.setDesktopUIMode,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(Tu).includes(i)&&dx.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Co(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Vr(ae(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=fe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.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),Wt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Co(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?fe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):fe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||qt(t))return;let r=()=>{if(this.bindModeHandler=null,Co(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 E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Vr(ae(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Co(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Wt(()=>{Co(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Co(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,w=p-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?fe.handlePointerMove(g,this,b,w,this.state.selectedLinearElement):fe.handlePointDragging(g,this,b,w,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&NA(E,m),w=g&&NA(g,m);i=!!(b&&w&&E.id!==g.id&&_X(b,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,d=a?"endBinding":l?"startBinding":null,c=d&&t[d]?.mode==="inside"&&t[d]?.elementId===o?.id||s&&t[s]?.mode==="inside"&&o?.id===t[s]?.elementId;s&&d&&t[s]?.mode==="inside"&&o?.id!==t[s]?.elementId&&t[d]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Wt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!c&&(this.bindModeHandler=setTimeout(r,CK)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Ln.MAIN||Qo||!tA(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ae(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ae(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(To(t,o)>YM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&he.pointers.size<2&&Rc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let l=i;if(this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:l,state:"active"},selectedElementIds:{[l.id]:!0},newElement:null,selectionElement:null})},100),qb(l)))return!0;let s=this.getHTMLIFrameElement(l);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let d=dx.get(l.id);switch(d||(dx.set(l.id,Tu.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:l.id}),"*")),d){case Tu.PLAYING:case Tu.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,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.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,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Jo(a)&&this.embedsValidationStatus.get(a.id)===!0||qb(a));return Pe(KX,{children:i.map(a=>{let{x:l,y:s}=Cu({sceneX:a.x,sceneY:a.y},this.state),d=mA(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(d&&!c&&this.initializedEmbeds.add(a.id),!(d||c))return null;let p=Au(hK(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=Pc(g?t:1,.75,WX);return Pe("div",{className:FM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t*eo(this.state.viewpointFlip.horizontal)}, ${t*eo(this.state.viewpointFlip.vertical)})`:"none",display:d?"block":"none",opacity:xX(a,ax(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?pK:1),"--embeddable-radius":`${qK(Math.min(a.width,a.height),a)}px`},children:mx("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?kl.enabled:kl.disabled},children:[E&&Pe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Pe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Pe("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Jo(a)?this.props.renderEmbeddable?.(a,this.state):null)??Pe("iframe",{ref:w=>this.cacheEmbeddableRef(a,w),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:l,canvasNonce:s,newElementCanvasElement:d}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=l,this.hasRenderableElements=a.size>0;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],u=Tt.get(wo)?.type==="panel";return Pe("div",{translate:"no",className:FM("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?kl.disabled:kl.enabled,"--right-sidebar-width":`${PE}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Pe(Dl.Provider,{value:this.api,children:Pe(YA.Provider,{value:this,children:Pe(KA.Provider,{value:this.props,children:Pe(gx.Provider,{value:this.excalidrawContainerValue,children:Pe(hx.Provider,{value:this.editorInterface,children:Pe(bx.Provider,{value:this.setAppState,children:Pe(Ex.Provider,{value:this.state,children:mx(fx.Provider,{value:this.scene.getNonDeletedElements(),children:[mx(xx.Provider,{value:this.actionManager,children:[Pe(fM,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:lo().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,uiLayout:this.props.uiLayout,children:this.props.children}),Pe("div",{className:"excalidraw-textEditorContainer"}),Pe("div",{className:"excalidraw-contextMenuContainer"}),Pe("div",{className:"excalidraw-eye-dropper-container"}),Pe(bM,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(RM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(n2,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Pe(zS,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Pe(Ub,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:c,visibleElements:l,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:Pr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),d&&Pe(kM,{appState:this.state,newElement:d,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:c,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Pe(Hb,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:c,selectedElements:t,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Pe(Dp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(BM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(pS,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Fi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Oi.delete(r))})}async componentDidMount(){if(this.unmounted=!1,Nl(this.props.googleFonts?.fontCssUrls),this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,HA()||UA()){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.excalidrawContainerRef.current&&this.focusContainer(),dK&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),MK()&&!hX()&&this.setState({errorMessage:Pe(DS,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){Nl(void 0),this.gifPlayback.stop(),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("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new LA,this.fonts=new Do(this.scene),this.renderer=new js(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Oi.destroy(),In.destroy(),clearTimeout(Yr),Oe.clearCache(),no.clearCache(),Yr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ve(window,ne.MESSAGE,this.onWindowMessage,!1),ve(document,ne.POINTER_UP,this.removePointer,{passive:!1}),ve(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ve(window,ne.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,ne.WHEEL,this.handleWheel,{passive:!1}),ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,ne.KEYDOWN,this.handleNavigationModeKeyDown,!1),ve(document,ne.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,ne.GESTURE_START,this.onGestureStart,!1),ve(document,ne.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,ne.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,ne.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ve(this.excalidrawContainerRef.current,ne.GESTURE_START,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,ne.GESTURE_CHANGE,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,ne.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,ne.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ve(document,ne.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,ne.WHEEL,this.handleWheel,{passive:!1}),ve(document,ne.COPY,this.onCopy,{passive:!1}),ve(document,ne.KEYUP,this.onKeyUp,{passive:!0}),ve(document,ne.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,ne.GESTURE_START,this.onGestureStart,!1),ve(document,ne.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,ne.GESTURE_END,this.onGestureEnd,!1),ve(document,ne.PASTE,this.pasteFromClipboard,{passive:!1}),ve(this.excalidrawContainerRef.current,ne.DRAG_OVER,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,ne.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ve(document,ne.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ve(document,ne.CUT,this.onCut,{passive:!1}),ve(window,ne.RESIZE,this.onResize,!1),ve(window,ne.UNLOAD,this.onUnload,!1),ve(window,ne.BLUR,this.onBlur,!1),ve(this.excalidrawContainerRef.current,ne.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ve(gK(this.excalidrawContainerRef.current),ne.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){t.googleFonts?.fontCssUrls!==this.props.googleFonts?.fontCssUrls&&Nl(this.props.googleFonts?.fontCssUrls),!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===Mc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&pn(this.state)&&this.setState({activeTool:sn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),pn(o)&&!pn(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Mc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(xt)});let l=Object.keys(this.state.selectedElementIds);if(l.length){let d=l.filter(c=>{let m=this.scene.getElement(c);return!m||m.isDeleted});d.length&&this.setState(c=>{let m={...c.selectedElementIds};for(let p of d)delete m[p];return{selectedElementIds:Ne(m,c)}})}if(this.state.editingTextElement){let d=this.scene.getElement(this.state.editingTextElement.id);(!d||d.isDeleted)&&this.setState({editingTextElement:null})}let s=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==s&&this.setState({scrolledOutside:s}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Bc=!1,Oc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let c=pp(t.text);if(c.ok){this.setState({openDialog:{name:"charts",data:c.data,rawText:t.text}});return}}if(t.elements){let c=t.programmaticAPI?RX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}let l=o.map(c=>c.file);if(l.length===0&&t.text&&!r){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(Qu(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(!t.text)return;let s=yK(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),d=s.map(c=>JK(c)).filter(c=>Qb(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Au(c)?.type==="video"));if(!r&&d.length>0&&d.length===s.length){let c=[];for(let m of d){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Su(m)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Ki(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Wt(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await Jx(c)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,r,i);let d=l.find(c=>!!c.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
22
22
|
|
|
23
|
-
`),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=
|
|
24
|
-
`),g=E.reduce((b,w,y)=>{let x=VK(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=rA(x,l,s),C=T.width>p,P=C?UK(x,l,p):x;T=C?rA(P,l,s):T;let M=r-T.width/2,L=u-T.height/2,_=HM({...a,x:M,y:L,text:P,originalText:x,lineHeight:s,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+m}else E[y-1]?.trim()&&(u+=iA(a.fontSize,s)+m);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ne(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&vA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),vA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(l,s)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(d=>d.id===t.id&&qt(d)?yo(d,{originalText:l,isDeleted:s??d.isDeleted,...xK(d,qM(d,i),i,l)}):d)])};this.textWysiwygSubmitHandler=II({canvas:this.canvas,getViewportCoords:(l,s)=>{let{x:d,y:c}=Eu({sceneX:l,sceneY:s},this.state);return[d-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Je(l=>{a(l,!1),Tu(t)&&yu(t,this.scene)}),onSubmit:Je(({viaKeyboard:l,nextOriginalText:s})=>{this.textWysiwygSubmitHandler=null;let d=!s.trim();a(s,d);let c=l&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(d?null:t.id):null;c&&Ut(()=>{this.setState(p=>({selectedElementIds:Ne({...p.selectedElementIds,[c]:!0},p)}))}),d&&dK(this.scene.getNonDeletedElements(),[t]),(!d||o)&&this.store.scheduleCapture(),Ut(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return qt(r)?r:t?Vb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(qt(i))return null;if(!JM(i))return;let a=this.getSelectedTextElement(i),l=this.getTextElementAtPosition(o.x,o.y);if(!(!a||l?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&qt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return kc({point:ie(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(qt(s)&&s.containerId)))).filter(s=>this.hitElement(t,o,s)).filter(s=>{let d=$b(s,a);return d&&!Tu(d)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Pc(s)?eA({x:t,y:o},d,a):!0}).filter(s=>Pc(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(AM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&AK([r],this.state,this.editorInterface)&&aX(ie(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||OK(ie(t,o),r,this.scene.getNonDeletedElementsMap())?!0:kc({point:ie(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return KM(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,d,c,p]=OM(r[l],this.scene.getNonDeletedElementsMap());if(Cc(r[l])&&kc({point:ie(t,o),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<c&&d<o&&o<p){if(kt(r[l]))continue;a=r[l];break}}return KM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||qt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=ge.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;kc({point:ie(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=ge.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),s=ge.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(jt(a)?l===0||l===a.points.length-1:l>=0)||s?this.cursor.set(Le.POINTER):this.hitElement(o,r,a)&&(!jt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Le.MOVE)):this.hitElement(o,r,a)&&(!jt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Le.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),ge.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let d=null,c=a;(c.startBinding||c.endBinding)&&(d=mX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==d&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:d}}),d&&this.cursor.set(Le.POINTER)}else this.cursor.set(Le.AUTO)}updateGestureOnPointerDown(t){ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ue.pointers.size===2&&(ue.lastCenter=wf(ue.pointers),ue.initialScale=this.state.zoom.value,ue.initialDistance=vf(Array.from(ue.pointers.values())))}initialPointerDownState(t){let o=Se(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=vl(r),d=r.findIndex(jt)===0;return{origin:o,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:Fb(Dt(o.x,o.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:Rf(_c,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((c,p)=>(c.set(p.id,UM(p)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;Su=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=Hm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Je(()=>{Il=null,Su=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,r),window.removeEventListener(ee.POINTER_UP,i),r.flush()});return Il=i,window.addEventListener(ee.POINTER_MOVE,r),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(AM/this.state.zoom.value,1),i=kY*2/this.state.zoom.value,[a,l,s,d]=vl(o);return t.x>a-i-r&&t.x<s+i+r&&t.y>l-i-r&&t.y<d+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:vK(t)?hu.ADAPTIVE_RADIUS:hu.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return sK(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){No({event:t,app:this,selectedElements:o})&&(r||!yn.getReferenceSnapPoints())&&yn.setReferenceSnapPoints(oI(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){No({event:t,app:this,selectedElements:o})&&(r||!yn.getVisibleGaps())&&yn.setVisibleGaps(nI(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Je(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Je(o=>{o.key===Y.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return Hm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Se(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[m,u]=Dt(r.x,r.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=ge.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:m,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?ge.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=ge.moveFixedSegment(this.state.selectedLinearElement,E,m,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=Fb(rX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(dn(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[l,s]=Dt(r.x,r.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let m=this.state.selectedLinearElement;if(m.draggedFocusPointBinding){dX(m,d,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...m,isDragging:!1,selectedPointsIndices:[],initialState:{...m.initialState,lastClickedPoint:-1}}});return}if(ge.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let u=ge.addMidpoint(this.state.selectedLinearElement,r,this,!o[Y.CTRL_OR_CMD],this.scene);if(!u)return;Ut(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(m.initialState.segmentMidpoint.value!==null&&!m.initialState.segmentMidpoint.added)return;if(m.initialState.lastClickedPoint>-1){let u=ge.getElement(m.elementId,d);if(u?.isDeleted)return;if(wo(u)){let g=Gr(ie(r.x,r.y),this.scene.getNonDeletedElements(),d);Uo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Uo("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),m.initialState.lastClickedPoint===-1)return;let E=ge.handlePointDragging(o,this,r.x,r.y,m);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!NM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let c=t.hit.allHitElements.some(m=>this.isASelectedElement(m)),p=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let m=this.scene.getSelectedElements(this.state);if(m.length>0&&m.every(g=>g.locked))return;let E=m.some(g=>kt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:QM(m),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),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"&&m.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),m.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],w=o.shiftKey;if(w){let I=Math.abs(g.x),T=Math.abs(g.y),C=w&&I<T,P=w&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&jn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=Di(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=hX(I),M=yM(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[L,_,k,D,B,K]=OM(I,d),z=_b(Db(ie(L,_),ie(B,K),I.angle)),U=_b(Db(ie(k,_),ie(B,K),I.angle)),W=_b(Db(ie(L,D),ie(B,K),I.angle)),G=IM(wM(U,z)),oe=IM(wM(W,z)),le=yM(vM(M,G),vM(M,oe)),F={...T,x:yc(T.x-le[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:yc(T.y-le[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:F});return}}}this.maybeCacheVisibleGaps(o,m),this.maybeCacheReferenceSnapPoints(o,m);let{snapOffset:y,snapLines:x}=rI(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||oX(t,m,g,this.scene,y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:M,duplicateElementsMap:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=WM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:QY()})});M.forEach(z=>{t.originalElements.set(z.id,UM(z))});let D=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return yo(z,{x:U.x,y:U.y})}return z}),B=this.props.onDuplicate?.(D,I),K=lA(B||D,Sc(M));Ut(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&L.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let W=k.get(U.id),G=W&&L.get(W);return G&&z.push(G),z},[]),t.drag.origin=Se(o,this.state),this.setState(z=>({...sA(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(K),C.forEach(z=>{Hb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&yu(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.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,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let m=this.state.newElement;if(!m)return;if(m.type==="freedraw"){let u=m.points,E=r.x-m.x,g=r.y-m.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let y=m.simulatePressure?m.pressures:[...m.pressures,o.pressure];this.scene.mutateElement(m,{points:[...u,ie(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:m})}}else if(Wt(m)&&!m.isDeleted){t.drag.hasOccurred=!0;let u=m.points;xo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==m.id)&&(E=new ge(m,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:m,...ge.handlePointDragging(o,this,l,s,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let m=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)ge.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Oe(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>qn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?vx(m,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((w,y)=>(w[y.id]=!0,w),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...qn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Wt(E[0])?new ge(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Wo(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(_c.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(_c.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Je(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Zn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:l,multiElement:s,activeTool:d,isResizing:c,isRotating:p,isCropping:m}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Tc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,yn.setReferenceSnapPoints(null),yn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Se({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Uo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Hb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>jt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}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(xt);else{let x=ge.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(xt,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=ge.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(uX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding: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(xt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Wt(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(d,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Se(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,ie(T,C)],pressures:P}),this.actionManager.executeAction(xt);return}if(Wt(i)&&this.state.activeTool.type!=="autoshape"){let x=Se(o,this.state),I=Eo(ie(x.x,x.y),ie(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<eK)&&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:[ie(0,0),ie(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(xt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!s&&(this.store.scheduleCapture(),Wt(i)&&this.actionManager.executeAction(xt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ne({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new ge(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(qt(i)){let x=XK(Bb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(d.type!=="selection"&&i&&ZM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:Jt.NEVER});return}if(kt(i)){let x=RK(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Xb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,IK(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Se(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=$b(I,r);T&&I&&(NK(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),_K([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:QM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let L of M){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&Ri(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(L=>nA(L,C,this.state));this.state.editingGroupId&&P(M),C=Xb(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(L=>L.frameId&&!nA(L,C,this.state));P(M)}C=tA(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&ZM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:Jt.NEVER}),t.resize.isResizing){let x=tA(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(kt);for(let T of I)x=DK(x,Zb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Wt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new ge(g,this.scene.getNonDeletedElementsMap())}),(!l||l&&(!g&&!m||g&&g.id!==l))&&this.finishImageCropping();let b=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(dn(this.state)&&b&&w){if(this.eraserTrail.endPath(),Eo(ie(b.clientX,b.clientY),ie(w.clientX,w.clientY))===0){let I=Se({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.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"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?JK(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>Ri(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Ne(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=de(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...qn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Wt(T[0])?new ge(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>Ri(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...qn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Wo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ne({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...qn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Wt(g)&&x.selectedLinearElement?.elementId!==g.id?new ge(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&jt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&zK({point:ie(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:kt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(La):this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Le.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(d.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[Y.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(qt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&d.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ne({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Wo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(d.type!=="selection"||Oe(this.scene.getNonDeletedElements(),this.state)||!NM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||c||p||m){let x=this.scene.getSelectedElements(this.state).filter(Cc);zM(x,this.scene,this.state)}if(d.type==="laser"){this.laserTrails.endPath();return}if(d.type==="autoshape"){this.actionManager.executeAction(xt);return}!this.isToolLocked()&&d.type!=="freedraw"&&d.type!==Zn.bucketfill&&(d.type!=="lasso"||d.type==="lasso"&&d.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ne({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&aA(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Yb(i,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,o-l)<RY){let{x:p,y:m}=Eu({sceneX:a,sceneY:l},r);return{viewportX:p,viewportY:m,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Wi.find(o=>o.code===this.props.langCode)||eo;await jc(t),this.setAppState({})}},yX=()=>{(IA()||TA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(CA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};yX();var MA=nx;import{useEffect as vX,useState as IX}from"react";import{jsx as TX}from"react/jsx-runtime";var AA=e=>{let[n,t]=IX(!0);return vX(()=>{let o=async()=>{await jc(r),t(!1)},r=Wi.find(i=>i.code===e.langCode)||eo;o()},[e.langCode]),n?TX(Cp,{theme:e.theme}):e.children};import SX from"clsx";import{jsx as LA}from"react/jsx-runtime";var DA=({children:e})=>{let{FooterCenterTunnel:n}=ut(),t=ye();return LA(n.In,{children:LA("div",{className:SX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},CX=DA;DA.displayName="FooterCenter";import PX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as kX}from"@excalidraw/common";import{jsx as AX,jsxs as LX}from"react/jsx-runtime";var _A=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<kX;return LX(Cn,{...o,className:PX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?E1:f("labels.share"),r.collaborators.size>0&&AX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},MX=_A;_A.displayName="LiveCollaborationTrigger";import{jsx as Ur,jsxs as NA}from"react/jsx-runtime";var DX=()=>Ur("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ur("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"})}),_X=()=>NA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ur("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Ur("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Ur("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Ur("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),RA=({style:e,size:n="small",withText:t})=>NA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Ur(DX,{}),t&&Ur(_X,{})]});import{Fragment as OA,jsx as pt,jsxs as cx}from"react/jsx-runtime";var dx=({icon:e,shortcut:n,children:t})=>{let o=me();return cx(OA,{children:[pt("div",{className:"welcome-screen-menu-item__icon",children:e}),pt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&pt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};dx.displayName="WelcomeScreenMenuItemContent";var Nc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>pt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:pt(dx,{icon:t,shortcut:o,children:n})});Nc.displayName="WelcomeScreenMenuItem";var BA=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>pt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:pt(dx,{icon:t,shortcut:o,children:e})});BA.displayName="WelcomeScreenMenuItemLink";var An=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=ut();return pt(n.In,{children:pt("div",{className:"welcome-screen-center",children:e||cx(OA,{children:[pt(mx,{}),pt(px,{children:f("welcomeScreen.defaults.center_heading")}),cx(ux,{children:[pt(gx,{}),pt(hx,{})]})]})})})};An.displayName="Center";var mx=({children:e})=>pt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||pt(RA,{withText:!0})});mx.displayName="Logo";var px=({children:e})=>pt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});px.displayName="Heading";var ux=({children:e})=>pt("div",{className:"welcome-screen-menu",children:e});ux.displayName="Menu";var hx=()=>{let e=nt();return pt(Nc,{onSelect:()=>e.executeAction(si),shortcut:"?",icon:Zi,children:f("helpDialog.title")})};hx.displayName="MenuItemHelp";var gx=()=>{let e=ye(),n=nt();return e.viewModeEnabled?null:pt(Nc,{onSelect:()=>n.executeAction(ua),shortcut:Qe("loadScene"),icon:td,children:f("buttons.load")})};gx.displayName="MenuItemLoadScene";var FA=({onSelect:e})=>{let{t:n}=_e();return pt(Nc,{shortcut:null,onSelect:e,icon:nd,children:n("labels.liveCollaboration")})};FA.displayName="MenuItemLiveCollaborationTrigger";An.Logo=mx;An.Heading=px;An.Menu=ux;An.MenuItem=Nc;An.MenuItemLink=BA;An.MenuItemHelp=hx;An.MenuItemLoadScene=gx;An.MenuItemLiveCollaborationTrigger=FA;import{jsx as Sl,jsxs as fx}from"react/jsx-runtime";var Au=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=ut();return Sl(n.In,{children:fx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Qx,Sl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Au.displayName="MenuHint";var Lu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=ut();return Sl(n.In,{children:fx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Sl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),t1]})})};Lu.displayName="ToolbarHint";var Du=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=ut();return Sl(n.In,{children:fx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Sl("div",{children:e||f("welcomeScreen.defaults.helpHint")}),e1]})})};Du.displayName="HelpHint";import{Fragment as zA,jsx as Bc,jsxs as NX}from"react/jsx-runtime";var _u=e=>Bc(zA,{children:e.children||NX(zA,{children:[Bc(An,{}),Bc(Au,{}),Bc(Lu,{}),Bc(Du,{})]})});_u.displayName="WelcomeScreen";_u.Center=An;_u.Hints={MenuHint:Au,ToolbarHint:Lu,HelpHint:Du};var RX=_u;var BX=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},GA=BX;import{configureGifWorkerUrl as qYe,getSceneVersion as JYe,hashElementsVersion as QYe,hashString as eKe,getNonDeletedElements as tKe}from"@excalidraw/element";import{getTextFromElements as oKe}from"@excalidraw/element";import{isInvisiblySmallElement as iKe}from"@excalidraw/element";import FX from"lodash.throttle";import{arrayToMap as OX,isDevEnv as HA,isTestEnv as UA}from"@excalidraw/common";import{orderByFractionalIndex as zX,syncInvalidIndices as WA,validateFractionalIndices as GX}from"@excalidraw/element";var HX=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),UX=FX((e,n,t)=>{if(HA()||UA()||window?.DEBUG_FRACTIONAL_INDICES){let o=WA(e.map(r=>({...r})));GX(o,{shouldThrow:UA()||HA(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),WX=(e,n,t)=>{let o=OX(e),r=[],i=new Set;for(let l of n)if(!i.has(l.id)){let s=o.get(l.id),d=HX(t,s,l);s&&d?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=zX(r);return UX(a,e,n),WA(a),a};import{isLinearElement as gKe}from"@excalidraw/element";import{FONT_FAMILY as EKe,THEME as bKe,MIME_TYPES as xKe,ROUNDNESS as yKe,DEFAULT_LASER_COLOR as wKe,UserIdleState as vKe,normalizeLink as IKe,sceneCoordsToViewportCoords as TKe,viewportCoordsToSceneCoords as SKe,getFormFactor as CKe,throttleRAF as PKe}from"@excalidraw/common";import{mutateElement as MKe,newElementWith as AKe,bumpVersion as LKe}from"@excalidraw/element";import{CaptureUpdateAction as _Ke}from"@excalidraw/element";import{jsx as cn}from"react/jsx-runtime";var VX={...Object.fromEntries(Object.keys(Me).map(e=>[e,At(e)])),selection:ds,lasso:ms},YX=({item:e,hideShortcut:n,overflowItems:t})=>{let o=ft(),r=on(),i=nn(),a=ze(),l=nt(),s=me(),d=it();if(i.viewModeEnabled||i.openDialog?.name==="elementLinkSelector")return null;let c={app:o,activeTool:i.activeTool,hideShortcut:n??s.formFactor==="phone"};switch(e){case"undo":case"redo":return cn(bt,{label:f(`buttons.${e}`),children:l.renderAction(e)});case"selection":return d==="compact"?cn(ri,{...c,setAppState:a}):i.preferredSelectionTool.type==="lasso"?cn(ms,{...c}):cn(ds,{...c});case"selectionMenu":return cn(ri,{...c,setAppState:a});case"freedrawMenu":return cn(ma,{...c});case"moreTools":return cn(Mb,{app:o,activeTool:i.activeTool,setAppState:a,UIOptions:r.UIOptions,isMyocSimplifiedMode:i.myocSimplifiedMode,actionManager:l,overflowItems:t});case"objectsSnapMode":return cn(Pb,{app:o,actionManager:l});case"strokeEyedropper":return cn(kb,{app:o});case"penMode":return cn(Ar,{checked:i.penMode,onChange:()=>o.togglePenMode(null),title:f("toolBar.penMode"),penDetected:i.penDetected});case"lock":return cn(au,{checked:i.activeTool.locked,onChange:()=>o.toggleLock(),title:f("toolBar.lock"),disabled:r.activeTool!=null});case"image":if(r.UIOptions.tools?.image===!1)return null}let p=VX[e];return cn(p,{...c})},VA=()=>{let e=ft(),n=nn(),t=me();return cn(gl,{appState:n,isMobile:t.formFactor==="phone",editorInterface:t,app:e})};VA.displayName="ExcalidrawToolbarHint";import{getCommonBounds as VKe,getVisibleSceneBounds as YKe,convertToExcalidrawElements as KKe}from"@excalidraw/element";import{elementsOverlappingBBox as ZKe}from"@excalidraw/element";import{isElementLink as qKe}from"@excalidraw/element";import{setCustomTextMetricsProvider as eXe}from"@excalidraw/element";import{jsx as Fc}from"react/jsx-runtime";GA();var KYe=({children:e})=>{let[n,t]=qX(null);return Fc(Tl.Provider,{value:n,children:Fc(Mu.Provider,{value:t,children:e})})},QX=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:l,onExcalidrawAPI:s,onMount:d,onUnmount:c,onInitialize:p,isCollaborating:m=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=eo.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:B,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:W=!1,autoFocus:G=!1,compressImageFile:oe,generateIdForFile:le,onLinkOpen:F,generateLinkForSelection:V,onPointerDown:ce,onPointerUp:fe,onScrollChange:Be,onUserFollow:Ee,userToFollow:He,onDuplicate:se,imageContextMenuItems:Pe,children:ke,validateEmbeddable:xe,renderEmbeddable:gt,showDeprecatedFonts:Qt,wheelZoomsOnDefault:Fe,strokeColorTopPicks:st,backgroundColorTopPicks:Vt,renderScrollbars:Xo,viewportStatusFrame:Zo,currentUserControls:vo,imageOptions:_t,showDropEventDebugAlert:Cl,uiLayout:Oc}=e,$o=e.UIOptions?.canvasActions,Z={...e.UIOptions,canvasActions:{...YA.canvasActions,...$o},tools:{image:e.UIOptions?.tools?.image??!0}};$o?.export&&(Z.canvasActions.export.saveFileToDisk=$o.export?.saveFileToDisk??YA.canvasActions.export.saveFileToDisk),Z.canvasActions.toggleTheme===null&&(P==null||r)&&(Z.canvasActions.toggleTheme=!0);let De={maxFileSizeBytes:_t?.maxFileSizeBytes??Ln.maxFileSizeBytes,maxWidthOrHeight:_t?.maxWidthOrHeight??Ln.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:_t?.gifAutoDecodeMaxFileSizeBytes??Ln.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:_t?.placeholderTransitionDuration??Ln.placeholderTransitionDuration},Rt=ZX(Mu),Ni=jX(s);Ni.current=s;let Ru=XX(Nu=>{Rt?.(Nu),Ni.current?.(Nu)},[Rt]),Ex=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return $X(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Ex)return;let bx=Bu=>{typeof Bu.scale=="number"&&Bu.scale!==1&&Bu.preventDefault()};return document.addEventListener("touchmove",bx,{passive:!1}),()=>{document.removeEventListener("touchmove",bx)}},[Ex]),Fc(Kx,{store:Tt,children:Fc(AA,{langCode:b,theme:P,children:Fc(MA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:l,onExcalidrawAPI:Ru,onMount:d,onUnmount:c,onInitialize:p,isCollaborating:m,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:Z,onPaste:B,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:W,autoFocus:G,compressImageFile:oe,generateIdForFile:le,onLinkOpen:F,generateLinkForSelection:V,onPointerDown:ce,onPointerUp:fe,onScrollChange:Be,onUserFollow:Ee,userToFollow:He,onDuplicate:se,imageContextMenuItems:Pe,validateEmbeddable:xe,renderEmbeddable:gt,showDeprecatedFonts:Qt,wheelZoomsOnDefault:Fe,strokeColorTopPicks:st,backgroundColorTopPicks:Vt,renderScrollbars:Xo,viewportStatusFrame:Zo,currentUserControls:vo,imageOptions:De,showDropEventDebugAlert:Cl,uiLayout:Oc,children:ke})})})},eZ=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:l,...s}=e,{initialData:d,UIOptions:c={},imageOptions:p,interaction:m,ui:u,activeTool:E,...g}=n;if(!(l===E||l?.type===E?.type&&(l?.type==="custom"?l.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===m||typeof i=="object"&&i!==null&&typeof m=="object"&&m!==null&&!!i.enabled?.links==!!m.enabled?.links&&!!i.enabled?.embeds==!!m.enabled?.embeds&&!!i.enabled?.interactiveContent==!!m.enabled?.interactiveContent&&!!i.enabled?.navigation==!!m.enabled?.navigation&&!!i.enabled?.browserZoom==!!m.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!m.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!m.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(c);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&c?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===c.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===c?.canvasActions?.[L]):o[P]===c[P]),C=(r?.maxWidthOrHeight??Ln.maxWidthOrHeight)===(p?.maxWidthOrHeight??Ln.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Ln.maxFileSizeBytes)===(p?.maxFileSizeBytes??Ln.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Ln.gifAutoDecodeMaxFileSizeBytes)===(p?.gifAutoDecodeMaxFileSizeBytes??Ln.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Ln.placeholderTransitionDuration)===(p?.placeholderTransitionDuration??Ln.placeholderTransitionDuration);return T&&C&&JX(s,g)},tZ=KX.memo(QX,eZ);tZ.displayName="Excalidraw";function XYe(e){return ur(e,!1)}export{oh as AlignBottomIcon,rh as AlignLeftIcon,ih as AlignRightIcon,nh as AlignTopIcon,Jc as ArrowIcon,KZ as ArrowRightIcon,B1 as ArrowheadArrowIcon,W1 as ArrowheadBarIcon,X1 as ArrowheadCardinalityExactlyOneIcon,Y1 as ArrowheadCardinalityManyIcon,V1 as ArrowheadCardinalityOneIcon,K1 as ArrowheadCardinalityOneOrManyIcon,$1 as ArrowheadCardinalityZeroOrManyIcon,Z1 as ArrowheadCardinalityZeroOrOneIcon,z1 as ArrowheadCircleIcon,G1 as ArrowheadCircleOutlineIcon,H1 as ArrowheadDiamondIcon,U1 as ArrowheadDiamondOutlineIcon,N1 as ArrowheadNoneIcon,F1 as ArrowheadTriangleIcon,O1 as ArrowheadTriangleOutlineIcon,Ju as BringForwardIcon,eh as BringToFrontIcon,Cn as Button,_Ke as CaptureUpdateAction,lh as CenterHorizontallyIcon,ah as CenterVerticallyIcon,wZ as CirclePauseIcon,mn as CloseIcon,wKe as DEFAULT_LASER_COLOR,Ou as DEFAULT_OVERSCROLL,Tb as DefaultSidebar,S0 as DeviceDesktopIcon,Ki as DiamondIcon,s1 as DiscordIcon,y1 as DistributeHorizontallyIcon,w1 as DistributeVerticallyIcon,jx as DotsHorizontalIcon,Rl as DotsIcon,Nl as DuplicateIcon,R1 as EdgeRoundIcon,_1 as EdgeSharpIcon,Xi as EllipseIcon,ql as Ellipsify,er as EmbedIcon,Qc as EraserIcon,vZ as ExcalLogo,tZ as Excalidraw,Tl as ExcalidrawAPIContext,KYe as ExcalidrawAPIProvider,VA as ExcalidrawToolbarHint,YX as ExcalidrawToolbarItem,Ol as ExportIcon,u1 as ExportImageIcon,IZ as ExternalLinkIcon,EKe as FONT_FAMILY,T1 as FillCrossHatchIcon,I1 as FillHachureIcon,S1 as FillSolidIcon,v1 as FillZigZagIcon,od as FontFamilyCodeIcon,e0 as FontFamilyHeadingIcon,Gl as FontFamilyNormalIcon,Q1 as FontSizeExtraLargeIcon,J1 as FontSizeLargeIcon,q1 as FontSizeMediumIcon,j1 as FontSizeSmallIcon,To as Fonts,CX as Footer,no as FreedrawIcon,l1 as GithubIcon,sh as GroupIcon,i1 as HamburgerMenuIcon,Zi as HelpIcon,a1 as HelpIconThin,Xr as ImageIcon,Vi as LassoIcon,Qo as LineIcon,zl as LinkIcon,MX as LiveCollaborationTrigger,td as LoadIcon,Jo as LockedIcon,Jx as LockedIconFilled,xKe as MIME_TYPES,XZ as MagicIcon,ZZ as MagicIconThin,Gt as MainMenu,Bl as MoonIcon,bh as NormaliseSizeIcon,$Z as OpenAIIcon,n1 as PenModeIcon,qx as PinIcon,yZ as PlusIcon,xZ as PlusPromoIcon,yKe as ROUNDNESS,Yi as RectangleIcon,qu as RedoIcon,VZ as RetryIcon,qc as SelectionIcon,Qu as SendBackwardIcon,th as SendToBackIcon,Fr as Sidebar,A1 as SloppinessArchitectIcon,L1 as SloppinessArtistIcon,D1 as SloppinessCartoonistIcon,uc as Stats,k1 as StrokeStyleDashedIcon,M1 as StrokeStyleDottedIcon,zZ as StrokeStyleSolidIcon,dh as StrokeWidthBaseIcon,C1 as StrokeWidthBoldIcon,P1 as StrokeWidthExtraBoldIcon,Fl as SunIcon,bKe as THEME,Eh as TableCellsIcon,i0 as TextAlignBottomIcon,n0 as TextAlignCenterIcon,t0 as TextAlignLeftIcon,a0 as TextAlignMiddleIcon,o0 as TextAlignRightIcon,r0 as TextAlignTopIcon,_n as TextIcon,o1 as TextSizeIcon,Zr as TrashIcon,ju as UndoIcon,ch as UngroupIcon,So as UnlockedIcon,Gu as UnsupportedImageFileTypeError,vKe as UserIdleState,RX as WelcomeScreen,e1 as WelcomeScreenHelpArrow,Qx as WelcomeScreenMenuArrow,t1 as WelcomeScreenTopToolbarArrow,c1 as XBrandIcon,Xu as ZoomInIcon,Zu as ZoomOutIcon,r1 as ZoomResetIcon,y0 as abacusIcon,L0 as adjustmentsIcon,g0 as alertTriangleIcon,rd as angleIcon,LYe as applyDarkModeFilter,xh as arrowsToEyeIcon,t$ as boltIcon,qZ as brainIcon,JZ as brainIconThin,oo as bucketFillIcon,$u as bucketFillIconSvgPaths,LKe as bumpVersion,ug as captureDragEventData,ed as checkIcon,_0 as chevronDownIcon,a$ as chevronLeftIcon,R0 as chevronRight,TZ as clipboard,BZ as clone,t3 as codeIcon,n$ as coffeeIcon,ad as collapseDownIcon,k0 as collapseUpIcon,qYe as configureGifWorkerUrl,KKe as convertToExcalidrawElements,s0 as copyIcon,A as createIcon,fh as cropIcon,c0 as cutIcon,eo as defaultLang,g1 as done,uh as downloadIcon,qr as drawShapeToolIcon,or as elbowArrowIcon,A0 as elementLinkIcon,ZKe as elementsOverlappingBBox,ld as emptyIcon,HZ as eraser,NP as exportToBlob,Xp as exportToCanvas,AH as exportToClipboard,h1 as exportToFileIcon,LZ as exportToPlus,BP as exportToSvg,f0 as eyeClosedIcon,jr as eyeDropperIcon,hh as eyeDropperIconSvgPaths,Jr as eyeIcon,OZ as file,v0 as flipHorizontal,w0 as flipVertical,$r as fontSizeIcon,ro as frameToolIcon,u0 as frames,jZ as fullscreenIcon,VKe as getCommonBounds,Xc as getDataURL,CKe as getFormFactor,tKe as getNonDeletedElements,JYe as getSceneVersion,DYe as getStrokeWidthByKey,oKe as getTextFromElements,YKe as getVisibleSceneBounds,C0 as gridIcon,l0 as handIcon,QYe as hashElementsVersion,eKe as hashString,d0 as helpIcon,QZ as historyCommandIcon,e$ as historyIcon,Dn as iconFillColor,qKe as isElementLink,iKe as isInvisiblySmallElement,gKe as isLinearElement,Wa as isSpreadsheetValidForChartType,Wi as languages,io as laserPointerToolIcon,P0 as lineEditorIcon,Dl as loadFromBlob,o$ as loginIcon,tr as magnetIcon,kZ as menu,s$ as messageCircleIcon,E0 as microphoneIcon,b0 as microphoneMutedIcon,MKe as mutateElement,AKe as newElementWith,p0 as nextFrame,IKe as normalizeLink,gh as paintIcon,SZ as palette,fr as parseDataTransferEvent,cm as parseDragImageMetadata,yh as pencilIcon,UZ as playerPlayIcon,WZ as playerStopFilledIcon,T0 as pngIcon,Ku as polygonIcon,c$ as presentationIcon,m0 as prevFrame,GZ as publishIcon,f1 as questionCircle,WX as reconcileElements,Zf as renderSpreadsheet,_Z as resetZoom,i$ as resizeIcon,zi as restoreAppState,XA as restoreElement,Yr as restoreElements,rr as roundArrowIcon,d1 as save,m1 as saveAs,TKe as sceneCoordsToViewportCoords,ao as searchIcon,x0 as selectAllIcon,Ml as serializeAsJSON,eXe as setCustomTextMetricsProvider,N0 as settingsIcon,E1 as share,AZ as shareIOS,DZ as shareWindows,nr as sharpArrowIcon,FZ as shield,l$ as sidebarRightIcon,p1 as slashIcon,YZ as stackPushIcon,RZ as start,NZ as stop,D0 as strokeIcon,mh as strokeVariabilityConstantIcon,ph as strokeVariabilityVariableIcon,I0 as svgIcon,h0 as tablerCheckIcon,PKe as throttleRAF,op as tryParseSpreadsheet,M0 as upIcon,me as useEditorInterface,Wd as useExcalidrawAPI,XYe as useExcalidrawStateValue,_e as useI18n,o6 as useOnExcalidrawStateChange,it as useStylesPanelMode,nd as usersIcon,SKe as viewportCoordsToSceneCoords,MZ as warning,r$ as youtubeIcon,id as zoomAreaIcon,CZ as zoomIn,PZ as zoomOut,Wr as zoomToFitBounds};
|
|
23
|
+
`),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:mK,verticalAlign:VM,locked:!1},l=Xb({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=$M(a.fontFamily),[d,,c]=mX(this.state),m=Math.max(Math.min((c-d)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
|
|
24
|
+
`),g=E.reduce((b,w,y)=>{let x=gX(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=vA(x,l,s),P=T.width>m,C=P?uX(x,l,m):x;T=P?vA(C,l,s):T;let k=r-T.width/2,M=u-T.height/2,_=iA({...a,x:k,y:M,text:C,originalText:x,lineHeight:s,autoResize:!P,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[y-1]?.trim()&&(u+=IA(a.fontSize,s)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ne(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&GA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:B("CtrlOrCmd+Shift+V")}),duration:5e3}),GA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(l,s)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(d=>d.id===t.id&&Jt(d)?Po(d,{originalText:l,isDeleted:s??d.isDeleted,...VK(d,gA(d,i),i,l)}):d)])};this.textWysiwygSubmitHandler=HI({canvas:this.canvas,getViewportCoords:(l,s)=>{let{x:d,y:c}=Cu({sceneX:l,sceneY:s},this.state);return[d-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Je(l=>{a(l,!1),_u(t)&&Mu(t,this.scene)}),onSubmit:Je(({viaKeyboard:l,nextOriginalText:s})=>{this.textWysiwygSubmitHandler=null;let d=!s.trim();a(s,d);let c=l&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(d?null:t.id):null;c&&Wt(()=>{this.setState(m=>({selectedElementIds:Ne({...m.selectedElementIds,[c]:!0},m)}))}),d&&NK(this.scene.getNonDeletedElements(),[t]),(!d||o)&&this.store.scheduleCapture(),Wt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return Jt(r)?r:t?tx(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Jt(i))return null;if(!fA(i))return;let a=this.getSelectedTextElement(i),l=this.getTextElementAtPosition(o.x,o.y);if(!(!a||l?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Jt(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Nc({point:ae(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:At(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(Jt(s)&&s.containerId)))).filter(s=>this.hitElement(t,o,s)).filter(s=>{let d=ax(s,a);return d&&!_u(d)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Rc(s)?bA({x:t,y:o},d,a):!0}).filter(s=>Rc(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(ZM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&tX([r],this.state,this.editorInterface)&&LX(ae(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||cX(ae(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Nc({point:ae(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:At(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return dA(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,d,c,m]=nA(r[l],this.scene.getNonDeletedElementsMap());if(_c(r[l])&&Nc({point:ae(t,o),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<c&&d<o&&o<m){if(At(r[l]))continue;a=r[l];break}}return dA(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Jt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=fe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Nc({point:ae(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=fe.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),s=fe.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(qt(a)?l===0||l===a.points.length-1:l>=0)||s?this.cursor.set(De.POINTER):this.hitElement(o,r,a)&&(!qt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(De.MOVE)):this.hitElement(o,r,a)&&(!qt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(De.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),fe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let d=null,c=a;(c.startBinding||c.endBinding)&&(d=BX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==d&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:d}}),d&&this.cursor.set(De.POINTER)}else this.cursor.set(De.AUTO)}updateGestureOnPointerDown(t){he.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),he.pointers.size===2&&(he.lastCenter=Df(he.pointers),he.initialScale=this.state.zoom.value,he.initialDistance=_f(Array.from(he.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=Al(r),d=r.findIndex(qt)===0;return{origin:o,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:Zb(Nt(o.x,o.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:Yf(Gc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((c,m)=>(c.set(m.id,aA(m)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;Ru=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=jm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Je(()=>{Ll=null,Ru=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ne.POINTER_MOVE,r),window.removeEventListener(ne.POINTER_UP,i),r.flush()});return Ll=i,window.addEventListener(ne.POINTER_MOVE,r),window.addEventListener(ne.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(ZM/this.state.zoom.value,1),i=QY*2/this.state.zoom.value,[a,l,s,d]=Al(o);return t.x>a-i-r&&t.x<s+i+r&&t.y>l-i-r&&t.y<d+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:XK(t)?Iu.ADAPTIVE_RADIUS:Iu.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return _K(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Vo({event:t,app:this,selectedElements:o})&&(r||!In.getReferenceSnapPoints())&&In.setReferenceSnapPoints(wI(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Vo({event:t,app:this,selectedElements:o})&&(r||!In.getVisibleGaps())&&In.setVisibleGaps(yI(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Je(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Je(o=>{o.key===Y.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return jm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Nt(r.x,r.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=fe.moveFixedSegment(this.state.selectedLinearElement,E,p,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=Zb(MX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(pn(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[l,s]=Nt(r.x,r.y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){NX(p,d,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(fe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[Y.CTRL_OR_CMD],this.scene);if(!u)return;Wt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=fe.getElement(p.elementId,d);if(u?.isDeleted)return;if(ko(u)){let g=Vr(ae(r.x,r.y),this.scene.getNonDeletedElements(),d);qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&qo("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=fe.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!QM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>At(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:EA(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),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"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],w=o.shiftKey;if(w){let I=Math.abs(g.x),T=Math.abs(g.y),P=w&&I<T,C=w&&I>T;P&&(g.x=0),C&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&to(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,P=Fi(I)&&this.imageCache.get(I.fileId)?.image;if(P&&!(P instanceof Promise)){let C=zX(I),k=OM(r.x-i.x,r.y-i.y);k[0]*=P.naturalWidth/C.width,k[1]*=P.naturalHeight/C.height;let[M,_,L,R,z,K]=nA(I,d),U=Vb(Wb(ae(M,_),ae(z,K),I.angle)),D=Vb(Wb(ae(L,_),ae(z,K),I.angle)),H=Vb(Wb(ae(M,R),ae(z,K),I.angle)),F=HM(zM(D,U)),J=HM(zM(H,U)),re=OM(GM(k,F),GM(k,J)),O={...T,x:Pc(T.x-re[0]*Math.sign(I.scale[0]),0,P.naturalWidth-T.width),y:Pc(T.y-re[1]*Math.sign(I.scale[1]),0,P.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:O});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=vI(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||kX(t,p,g,this.scene,y,o[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!P.find(U=>U.id===T.id)&&P.push(T);let C=new Map(P.map(U=>[U.id,U])),{duplicatedElements:k,duplicateElementsMap:M,elementsWithDuplicates:_,origIdToDuplicateId:L}=lA({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:C,overrides:({duplicateElement:U,origElement:D})=>({frameId:U.frameId??D.frameId,seed:TK()})});k.forEach(U=>{t.originalElements.set(U.id,aA(U))});let R=_.map(U=>{if(C.has(U.id)){let D=t.originalElements.get(U.id);if(D)return Po(U,{x:D.x,y:D.y})}return U}),z=this.props.onDuplicate?.(R,I),K=SA(z||R,Dc(k));Wt(()=>{if(t.hit.element){let U=L.get(t.hit.element.id),D=U&&M.get(U);t.hit.element=D||null}t.hit.allHitElements=t.hit.allHitElements.reduce((U,D)=>{let H=L.get(D.id),F=H&&M.get(H);return F&&U.push(F),U},[]),t.drag.origin=Ce(o,this.state),this.setState(U=>({...CA(k,this.scene.getNonDeletedElements(),U)})),this.scene.replaceAllElements(K),P.forEach(U=>{Jb(U)&&U.boundElements?.some(D=>D.type==="arrow")&&Mu(U,this.scene)}),this.maybeCacheVisibleGaps(o,P,!0),this.maybeCacheReferenceSnapPoints(o,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.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,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let y=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,ae(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Vt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;Co(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new fe(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...fe.handlePointDragging(o,this,l,s,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)fe.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Oe(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>no({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?_x(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((w,y)=>(w[y.id]=!0,w),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...no({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Vt(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Jo(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(Gc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(Gc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Je(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Qn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:l,multiElement:s,activeTool:d,isResizing:c,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Lc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,In.setReferenceSnapPoints(null),In.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Jb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>qt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}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(xt);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(xt,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(OX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding: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(xt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Vt(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ne.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ne.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ne.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ne.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(d,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),I=i.points,T=x.x-i.x,P=x.y-i.y;T===I[0][0]&&P===I[0][1]&&(P+=1e-4,T+=1e-4);let C=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,ae(T,P)],pressures:C}),this.actionManager.executeAction(xt);return}if(Vt(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),I=To(ae(x.x,x.y),ae(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<SK)&&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:[ae(0,0),ae(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(xt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!s&&(this.store.scheduleCapture(),Vt(i)&&this.actionManager.executeAction(xt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ne({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Jt(i)){let x=bX(Xb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(d.type!=="selection"&&i&&pA(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:Qt.NEVER});return}if(At(i)){let x=iX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(rx(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,ZK(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=ax(I,r);T&&I&&(aX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),rX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:EA(I),excludeElementIds:this.state.selectedElementIds}),P=this.scene.getElementsMapIncludingDeleted(),C=k=>{if(k.length>0){for(let M of k){let _=M.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(M,{groupIds:M.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}P.forEach(M=>{M.groupIds.length&&zi(P,M.groupIds[M.groupIds.length-1]).length<2&&this.scene.mutateElement(M,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let k=I.filter(M=>yA(M,P,this.state));this.state.editingGroupId&&C(k),P=rx(P,k,T)}else if(!T&&this.state.editingGroupId){let k=I.filter(M=>M.frameId&&!yA(M,P,this.state));C(k)}P=xA(P,this.state,this),this.scene.replaceAllElements(P)}}if(a&&this.store.scheduleCapture(),a&&pA(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:Qt.NEVER}),t.resize.isResizing){let x=xA(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(At);for(let T of I)x=oX(x,ix(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Vt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new fe(g,this.scene.getNonDeletedElementsMap())}),(!l||l&&(!g&&!p||g&&g.id!==l))&&this.finishImageCropping();let b=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(pn(this.state)&&b&&w){if(this.eraserTrail.endPath(),To(ae(b.clientX,b.clientY),ae(w.clientX,w.clientY))===0){let I=Ce({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(P=>this.elementsPendingErasure.add(P.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"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?IX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(P=>zi(this.scene.getNonDeletedElements(),P)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,P)=>({...T,...P}),{})},selectedElementIds:Ne(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=de(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...no({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Vt(T[0])?new fe(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>zi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...no({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Jo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ne({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...no({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Vt(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&qt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&dX({point:ae(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:At(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(za):this.setState({selectedElementIds:Ne({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(De.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(d.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[Y.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Jt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&d.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ne({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Jo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(d.type!=="selection"||Oe(this.scene.getNonDeletedElements(),this.state)||!QM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||c||m||p){let x=this.scene.getSelectedElements(this.state).filter(_c);oA(x,this.scene,this.state)}if(d.type==="laser"){this.laserTrails.endPath();return}if(d.type==="autoshape"){this.actionManager.executeAction(xt);return}!this.isToolLocked()&&d.type!=="freedraw"&&d.type!==Qn.bucketfill&&(d.type!=="lasso"||d.type==="lasso"&&d.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:sn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ne({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&TA(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ne({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=nx(i,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,o-l)<iK){let{x:m,y:p}=Cu({sceneX:a,sceneY:l},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=$i.find(o=>o.code===this.props.langCode)||ao;await rd(t),this.setAppState({})}},YX=()=>{(HA()||UA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(VA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};YX();var XA=ux;import{useEffect as XX,useState as ZX}from"react";import{jsx as $X}from"react/jsx-runtime";var ZA=e=>{let[n,t]=ZX(!0);return XX(()=>{let o=async()=>{await rd(r),t(!1)},r=$i.find(i=>i.code===e.langCode)||ao;o()},[e.langCode]),n?$X(Np,{theme:e.theme}):e.children};import jX from"clsx";import{jsx as $A}from"react/jsx-runtime";var jA=({children:e})=>{let{FooterCenterTunnel:n}=gt(),t=ye();return $A(n.In,{children:$A("div",{className:jX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},qX=jA;jA.displayName="FooterCenter";import JX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as QX}from"@excalidraw/common";import{jsx as tZ,jsxs as nZ}from"react/jsx-runtime";var qA=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<QX;return nZ(Mn,{...o,className:JX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?M1:f("labels.share"),r.collaborators.size>0&&tZ("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},eZ=qA;qA.displayName="LiveCollaborationTrigger";import{jsx as Kr,jsxs as QA}from"react/jsx-runtime";var oZ=()=>Kr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Kr("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"})}),rZ=()=>QA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Kr("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Kr("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Kr("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Kr("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),JA=({style:e,size:n="small",withText:t})=>QA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Kr(oZ,{}),t&&Kr(rZ,{})]});import{Fragment as n3,jsx as ut,jsxs as yx}from"react/jsx-runtime";var wx=({icon:e,shortcut:n,children:t})=>{let o=me();return yx(n3,{children:[ut("div",{className:"welcome-screen-menu-item__icon",children:e}),ut("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&ut("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};wx.displayName="WelcomeScreenMenuItemContent";var Uc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>ut("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:ut(wx,{icon:t,shortcut:o,children:n})});Uc.displayName="WelcomeScreenMenuItem";var e3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>ut("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:ut(wx,{icon:t,shortcut:o,children:e})});e3.displayName="WelcomeScreenMenuItemLink";var _n=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=gt();return ut(n.In,{children:ut("div",{className:"welcome-screen-center",children:e||yx(n3,{children:[ut(vx,{}),ut(Ix,{children:f("welcomeScreen.defaults.center_heading")}),yx(Tx,{children:[ut(Cx,{}),ut(Sx,{})]})]})})})};_n.displayName="Center";var vx=({children:e})=>ut("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||ut(JA,{withText:!0})});vx.displayName="Logo";var Ix=({children:e})=>ut("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ix.displayName="Heading";var Tx=({children:e})=>ut("div",{className:"welcome-screen-menu",children:e});Tx.displayName="Menu";var Sx=()=>{let e=nt();return ut(Uc,{onSelect:()=>e.executeAction(ui),shortcut:"?",icon:ea,children:f("helpDialog.title")})};Sx.displayName="MenuItemHelp";var Cx=()=>{let e=ye(),n=nt();return e.viewModeEnabled?null:ut(Uc,{onSelect:()=>n.executeAction(wa),shortcut:Qe("loadScene"),icon:cd,children:f("buttons.load")})};Cx.displayName="MenuItemLoadScene";var t3=({onSelect:e})=>{let{t:n}=_e();return ut(Uc,{shortcut:null,onSelect:e,icon:dd,children:n("labels.liveCollaboration")})};t3.displayName="MenuItemLiveCollaborationTrigger";_n.Logo=vx;_n.Heading=Ix;_n.Menu=Tx;_n.MenuItem=Uc;_n.MenuItemLink=e3;_n.MenuItemHelp=Sx;_n.MenuItemLoadScene=Cx;_n.MenuItemLiveCollaborationTrigger=t3;import{jsx as _l,jsxs as Px}from"react/jsx-runtime";var zu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=gt();return _l(n.In,{children:Px("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[m1,_l("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};zu.displayName="MenuHint";var Gu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=gt();return _l(n.In,{children:Px("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[_l("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),u1]})})};Gu.displayName="ToolbarHint";var Hu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=gt();return _l(n.In,{children:Px("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[_l("div",{children:e||f("welcomeScreen.defaults.helpHint")}),p1]})})};Hu.displayName="HelpHint";import{Fragment as o3,jsx as Wc,jsxs as aZ}from"react/jsx-runtime";var Uu=e=>Wc(o3,{children:e.children||aZ(o3,{children:[Wc(_n,{}),Wc(zu,{}),Wc(Gu,{}),Wc(Hu,{})]})});Uu.displayName="WelcomeScreen";Uu.Center=_n;Uu.Hints={MenuHint:zu,ToolbarHint:Gu,HelpHint:Hu};var iZ=Uu;var lZ=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},r3=lZ;import{configureGifWorkerUrl as OKe,getSceneVersion as zKe,hashElementsVersion as GKe,hashString as HKe,getNonDeletedElements as UKe}from"@excalidraw/element";import{getTextFromElements as VKe}from"@excalidraw/element";import{isInvisiblySmallElement as KKe}from"@excalidraw/element";import sZ from"lodash.throttle";import{arrayToMap as cZ,isDevEnv as i3,isTestEnv as a3}from"@excalidraw/common";import{orderByFractionalIndex as dZ,syncInvalidIndices as l3,validateFractionalIndices as mZ}from"@excalidraw/element";var pZ=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),uZ=sZ((e,n,t)=>{if(i3()||a3()||window?.DEBUG_FRACTIONAL_INDICES){let o=l3(e.map(r=>({...r})));mZ(o,{shouldThrow:a3()||i3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),hZ=(e,n,t)=>{let o=cZ(e),r=[],i=new Set;for(let l of n)if(!i.has(l.id)){let s=o.get(l.id),d=pZ(t,s,l);s&&d?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=dZ(r);return uZ(a,e,n),l3(a),a};import{isLinearElement as nXe}from"@excalidraw/element";import{FONT_FAMILY as rXe,THEME as iXe,MIME_TYPES as aXe,ROUNDNESS as lXe,DEFAULT_LASER_COLOR as sXe,UserIdleState as cXe,normalizeLink as dXe,sceneCoordsToViewportCoords as mXe,viewportCoordsToSceneCoords as pXe,getFormFactor as uXe,throttleRAF as hXe}from"@excalidraw/common";import{mutateElement as fXe,newElementWith as EXe,bumpVersion as bXe}from"@excalidraw/element";import{CaptureUpdateAction as yXe}from"@excalidraw/element";import{jsx as cn}from"react/jsx-runtime";var gZ={...Object.fromEntries(Object.keys(Ae).map(e=>[e,_t(e)])),selection:Es,lasso:bs},fZ=({item:e,hideShortcut:n,overflowItems:t})=>{let o=ct(),r=St(),i=on(),a=ze(),l=nt(),s=me(),d=it();if(i.viewModeEnabled||i.openDialog?.name==="elementLinkSelector")return null;let c={app:o,activeTool:i.activeTool,hideShortcut:n??s.formFactor==="phone"};switch(e){case"undo":case"redo":return cn(bt,{label:f(`buttons.${e}`),children:l.renderAction(e)});case"selection":return d==="compact"?cn(ci,{...c,setAppState:a}):i.preferredSelectionTool.type==="lasso"?cn(bs,{...c}):cn(Es,{...c});case"selectionMenu":return cn(ci,{...c,setAppState:a});case"freedrawMenu":return cn(xa,{...c});case"moreTools":return cn(Gb,{app:o,activeTool:i.activeTool,setAppState:a,UIOptions:r.UIOptions,isMyocSimplifiedMode:i.myocSimplifiedMode,actionManager:l,overflowItems:t});case"objectsSnapMode":return cn(Ob,{app:o,actionManager:l});case"strokeEyedropper":return cn(zb,{app:o});case"penMode":return cn(Rr,{checked:i.penMode,onChange:()=>o.togglePenMode(null),title:f("toolBar.penMode"),penDetected:i.penDetected});case"lock":return cn(gu,{checked:i.activeTool.locked,onChange:()=>o.toggleLock(),title:f("toolBar.lock"),disabled:r.activeTool!=null});case"image":if(r.UIOptions.tools?.image===!1)return null}let m=gZ[e];return cn(m,{...c})},s3=()=>{let e=ct(),n=on(),t=me();return cn(Il,{appState:n,isMobile:t.formFactor==="phone",editorInterface:t,app:e})};s3.displayName="ExcalidrawToolbarHint";import{getCommonBounds as LXe,getVisibleSceneBounds as DXe,convertToExcalidrawElements as _Xe}from"@excalidraw/element";import{elementsOverlappingBBox as NXe}from"@excalidraw/element";import{isElementLink as OXe}from"@excalidraw/element";import{setCustomTextMetricsProvider as UXe}from"@excalidraw/element";import{jsx as Vc}from"react/jsx-runtime";r3();var _Ke=({children:e})=>{let[n,t]=vZ(null);return Vc(Dl.Provider,{value:n,children:Vc(Ou.Provider,{value:t,children:e})})},TZ=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:l,onExcalidrawAPI:s,onMount:d,onUnmount:c,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=ao.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:P,theme:C,renderCustomizations:k,name:M,renderCustomStats:_,editorPreferences:L,onEditorPreferencesChange:R,onPaste:z,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:U,detectScroll:D=!0,handleKeyboardGlobally:H=!1,autoFocus:F=!1,compressImageFile:J,generateIdForFile:re,onLinkOpen:O,generateLinkForSelection:V,onPointerDown:ce,onPointerUp:pe,onScrollChange:Be,onUserFollow:Ee,userToFollow:He,onDuplicate:se,imageContextMenuItems:ke,children:Me,validateEmbeddable:xe,renderEmbeddable:Et,googleFonts:en,showDeprecatedFonts:Fe,wheelZoomsOnDefault:st,strokeColorTopPicks:Yt,backgroundColorTopPicks:nr,renderScrollbars:or,viewportStatusFrame:Mo,currentUserControls:dn,imageOptions:rr,showDropEventDebugAlert:Yc,uiLayout:Gi}=e,Z=e.UIOptions?.canvasActions,Te={...e.UIOptions,canvasActions:{...c3.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};Z?.export&&(Te.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??c3.canvasActions.export.saveFileToDisk),Te.canvasActions.toggleTheme===null&&(C==null||r)&&(Te.canvasActions.toggleTheme=!0);let Kt={maxFileSizeBytes:rr?.maxFileSizeBytes??Rn.maxFileSizeBytes,maxWidthOrHeight:rr?.maxWidthOrHeight??Rn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:rr?.gifAutoDecodeMaxFileSizeBytes??Rn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:rr?.placeholderTransitionDuration??Rn.placeholderTransitionDuration},Hi=xZ(Ou),Kc=wZ(s);Kc.current=s;let d3=bZ(Wu=>{Hi?.(Wu),Kc.current?.(Wu)},[Hi]),kx=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return yZ(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),kx)return;let Mx=Vu=>{typeof Vu.scale=="number"&&Vu.scale!==1&&Vu.preventDefault()};return document.addEventListener("touchmove",Mx,{passive:!1}),()=>{document.removeEventListener("touchmove",Mx)}},[kx]),Vc(o1,{store:Tt,children:Vc(ZA,{langCode:b,theme:C,children:Vc(XA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:l,onExcalidrawAPI:d3,onMount:d,onUnmount:c,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:P,theme:C,renderCustomizations:k,name:M,renderCustomStats:_,editorPreferences:L,onEditorPreferencesChange:R,UIOptions:Te,onPaste:z,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:U,detectScroll:D,handleKeyboardGlobally:H,autoFocus:F,compressImageFile:J,generateIdForFile:re,onLinkOpen:O,generateLinkForSelection:V,onPointerDown:ce,onPointerUp:pe,onScrollChange:Be,onUserFollow:Ee,userToFollow:He,onDuplicate:se,imageContextMenuItems:ke,validateEmbeddable:xe,renderEmbeddable:Et,googleFonts:en,showDeprecatedFonts:Fe,wheelZoomsOnDefault:st,strokeColorTopPicks:Yt,backgroundColorTopPicks:nr,renderScrollbars:or,viewportStatusFrame:Mo,currentUserControls:dn,imageOptions:Kt,showDropEventDebugAlert:Yc,uiLayout:Gi,children:Me})})})},SZ=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:l,...s}=e,{initialData:d,UIOptions:c={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(l===E||l?.type===E?.type&&(l?.type==="custom"?l.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(c);if(x.length!==I.length)return!1;let T=x.every(C=>C==="getFormFactor"?!0:C==="canvasActions"?Object.keys(o.canvasActions).every(M=>M==="export"&&o?.canvasActions?.export&&c?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===c.canvasActions.export.saveFileToDisk:o?.canvasActions?.[M]===c?.canvasActions?.[M]):o[C]===c[C]),P=(r?.maxWidthOrHeight??Rn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Rn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Rn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Rn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Rn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Rn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Rn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Rn.placeholderTransitionDuration);return T&&P&&IZ(s,g)},CZ=EZ.memo(TZ,SZ);CZ.displayName="Excalidraw";function RKe(e){return Er(e,!1)}export{mh as AlignBottomIcon,ph as AlignLeftIcon,uh as AlignRightIcon,dh as AlignTopIcon,ad as ArrowIcon,f$ as ArrowRightIcon,Z1 as ArrowheadArrowIcon,t0 as ArrowheadBarIcon,i0 as ArrowheadCardinalityExactlyOneIcon,o0 as ArrowheadCardinalityManyIcon,n0 as ArrowheadCardinalityOneIcon,r0 as ArrowheadCardinalityOneOrManyIcon,l0 as ArrowheadCardinalityZeroOrManyIcon,a0 as ArrowheadCardinalityZeroOrOneIcon,q1 as ArrowheadCircleIcon,J1 as ArrowheadCircleOutlineIcon,Q1 as ArrowheadDiamondIcon,e0 as ArrowheadDiamondOutlineIcon,X1 as ArrowheadNoneIcon,$1 as ArrowheadTriangleIcon,j1 as ArrowheadTriangleOutlineIcon,ah as BringForwardIcon,sh as BringToFrontIcon,Mn as Button,yXe as CaptureUpdateAction,gh as CenterHorizontallyIcon,hh as CenterVerticallyIcon,YZ as CirclePauseIcon,un as CloseIcon,sXe as DEFAULT_LASER_COLOR,Ku as DEFAULT_OVERSCROLL,Nb as DefaultSidebar,F0 as DeviceDesktopIcon,Ji as DiamondIcon,y1 as DiscordIcon,D1 as DistributeHorizontallyIcon,_1 as DistributeVerticallyIcon,s1 as DotsHorizontalIcon,Ul as DotsIcon,Wl as DuplicateIcon,K1 as EdgeRoundIcon,Y1 as EdgeSharpIcon,Qi as EllipseIcon,os as Ellipsify,sr as EmbedIcon,ld as EraserIcon,KZ as ExcalLogo,CZ as Excalidraw,Dl as ExcalidrawAPIContext,_Ke as ExcalidrawAPIProvider,s3 as ExcalidrawToolbarHint,fZ as ExcalidrawToolbarItem,Kl as ExportIcon,S1 as ExportImageIcon,XZ as ExternalLinkIcon,rXe as FONT_FAMILY,B1 as FillCrossHatchIcon,N1 as FillHachureIcon,F1 as FillSolidIcon,R1 as FillZigZagIcon,md as FontFamilyCodeIcon,p0 as FontFamilyHeadingIcon,Zl as FontFamilyNormalIcon,m0 as FontSizeExtraLargeIcon,d0 as FontSizeLargeIcon,c0 as FontSizeMediumIcon,s0 as FontSizeSmallIcon,Do as Fonts,qX as Footer,co as FreedrawIcon,x1 as GithubIcon,fh as GroupIcon,E1 as HamburgerMenuIcon,ea as HelpIcon,b1 as HelpIconThin,qr as ImageIcon,ji as LassoIcon,lr as LineIcon,Xl as LinkIcon,eZ as LiveCollaborationTrigger,cd as LoadIcon,so as LockedIcon,d1 as LockedIconFilled,aXe as MIME_TYPES,E$ as MagicIcon,b$ as MagicIconThin,Ht as MainMenu,Vl as MoonIcon,Ch as NormaliseSizeIcon,x$ as OpenAIIcon,h1 as PenModeIcon,c1 as PinIcon,l1 as PlusIcon,VZ as PlusPromoIcon,lXe as ROUNDNESS,qi as RectangleIcon,ih as RedoIcon,h$ as RetryIcon,id as SelectionIcon,lh as SendBackwardIcon,ch as SendToBackIcon,Hr as Sidebar,U1 as SloppinessArchitectIcon,W1 as SloppinessArtistIcon,V1 as SloppinessCartoonistIcon,yc as Stats,G1 as StrokeStyleDashedIcon,H1 as StrokeStyleDottedIcon,c$ as StrokeStyleSolidIcon,bh as StrokeWidthBaseIcon,O1 as StrokeWidthBoldIcon,z1 as StrokeWidthExtraBoldIcon,Yl as SunIcon,iXe as THEME,Sh as TableCellsIcon,E0 as TextAlignBottomIcon,h0 as TextAlignCenterIcon,u0 as TextAlignLeftIcon,b0 as TextAlignMiddleIcon,g0 as TextAlignRightIcon,f0 as TextAlignTopIcon,Bn as TextIcon,g1 as TextSizeIcon,Jr as TrashIcon,rh as UndoIcon,Eh as UngroupIcon,_o as UnlockedIcon,Zu as UnsupportedImageFileTypeError,cXe as UserIdleState,iZ as WelcomeScreen,p1 as WelcomeScreenHelpArrow,m1 as WelcomeScreenMenuArrow,u1 as WelcomeScreenTopToolbarArrow,w1 as XBrandIcon,th as ZoomInIcon,nh as ZoomOutIcon,f1 as ZoomResetIcon,D0 as abacusIcon,W0 as adjustmentsIcon,P0 as alertTriangleIcon,pd as angleIcon,bKe as applyDarkModeFilter,Ph as arrowsToEyeIcon,S$ as boltIcon,w$ as brainIcon,v$ as brainIconThin,mo as bucketFillIcon,oh as bucketFillIconSvgPaths,bXe as bumpVersion,Tg as captureDragEventData,sd as checkIcon,Y0 as chevronDownIcon,A$ as chevronLeftIcon,K0 as chevronRight,ZZ as clipboard,a$ as clone,w3 as codeIcon,C$ as coffeeIcon,hd as collapseDownIcon,G0 as collapseUpIcon,OKe as configureGifWorkerUrl,_Xe as convertToExcalidrawElements,y0 as copyIcon,A as createIcon,Th as cropIcon,w0 as cutIcon,ao as defaultLang,P1 as done,wh as downloadIcon,ti as drawShapeToolIcon,mr as elbowArrowIcon,U0 as elementLinkIcon,NXe as elementsOverlappingBBox,gd as emptyIcon,m$ as eraser,QP as exportToBlob,nu as exportToCanvas,tU as exportToClipboard,C1 as exportToFileIcon,t$ as exportToPlus,ek as exportToSvg,k0 as eyeClosedIcon,ei as eyeDropperIcon,vh as eyeDropperIconSvgPaths,ni as eyeIcon,s$ as file,R0 as flipHorizontal,_0 as flipVertical,Qr as fontSizeIcon,Lo as formatGoogleFontId,po as frameToolIcon,S0 as frames,y$ as fullscreenIcon,LXe as getCommonBounds,td as getDataURL,uXe as getFormFactor,UKe as getNonDeletedElements,zKe as getSceneVersion,xKe as getStrokeWidthByKey,VKe as getTextFromElements,DXe as getVisibleSceneBounds,O0 as gridIcon,x0 as handIcon,GKe as hashElementsVersion,HKe as hashString,v0 as helpIcon,I$ as historyCommandIcon,T$ as historyIcon,Nn as iconFillColor,OXe as isElementLink,KKe as isInvisiblySmallElement,nXe as isLinearElement,qa as isSpreadsheetValidForChartType,$i as languages,uo as laserPointerToolIcon,z0 as lineEditorIcon,Gl as loadFromBlob,P$ as loginIcon,cr as magnetIcon,JZ as menu,D$ as messageCircleIcon,M0 as microphoneIcon,A0 as microphoneMutedIcon,fXe as mutateElement,EXe as newElementWith,T0 as nextFrame,dXe as normalizeLink,Ih as paintIcon,$Z as palette,yr as parseDataTransferEvent,bm as parseDragImageMetadata,p3 as parseGoogleFontFaceCss,mn as parseGoogleFontId,kh as pencilIcon,p$ as playerPlayIcon,u$ as playerStopFilledIcon,B0 as pngIcon,eh as polygonIcon,_$ as presentationIcon,I0 as prevFrame,d$ as publishIcon,k1 as questionCircle,hZ as reconcileElements,iE as renderSpreadsheet,o$ as resetZoom,M$ as resizeIcon,Yi as restoreAppState,u3 as restoreElement,$r as restoreElements,pr as roundArrowIcon,v1 as save,I1 as saveAs,mXe as sceneCoordsToViewportCoords,hn as searchIcon,L0 as selectAllIcon,Fl as serializeAsJSON,UXe as setCustomTextMetricsProvider,X0 as settingsIcon,M1 as share,e$ as shareIOS,n$ as shareWindows,dr as sharpArrowIcon,l$ as shield,L$ as sidebarRightIcon,T1 as slashIcon,g$ as stackPushIcon,r$ as start,i$ as stop,V0 as strokeIcon,xh as strokeVariabilityConstantIcon,yh as strokeVariabilityVariableIcon,N0 as svgIcon,C0 as tablerCheckIcon,hXe as throttleRAF,pp as tryParseSpreadsheet,H0 as upIcon,me as useEditorInterface,Jd as useExcalidrawAPI,RKe as useExcalidrawStateValue,_e as useI18n,k6 as useOnExcalidrawStateChange,it as useStylesPanelMode,dd as usersIcon,pXe as viewportCoordsToSceneCoords,QZ as warning,k$ as youtubeIcon,ud as zoomAreaIcon,jZ as zoomIn,qZ as zoomOut,Xr as zoomToFitBounds};
|