@myoc/excalidraw 0.19.540 → 0.19.542

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.
@@ -1,24 +1,24 @@
1
- import{$ as vx,A as ux,B as Mu,C as Ts,D as Lc,E as Au,F as hx,G as gx,H as _c,I as Ss,J as Rc,K as Nc,L as Cs,M as Bc,N as fx,O as Ex,P as bx,Q as Fc,R as Br,S as DA,T as Fr,U as _i,W as xx,Y as yx,Z as wx,_ as Oc,a as Su,aa as Ri,b as Kn,ba as Ps,c as yo,ca as ks,d as Nr,da as Ix,e as Ai,ea as zc,f as $n,fa as Tx,g as sx,ga as Sx,h as _e,ha as Cx,i as lx,ia as Du,j as de,ja as Px,k as Di,ka as kx,l as Xo,la as Mx,m as cx,ma as Or,n as Cu,o as dx,p as vs,q as mx,r as Dc,s as px,t as Pu,u as ku,v as wo,w as Ko,x as rn,y as Is,z as Li}from"./chunk-ACCWJMS6.js";import{a as S}from"./chunk-ZEI5AZ4Y.js";import{G as Tu}from"./chunk-KGIBYNMP.js";import{c as ax}from"./chunk-5XKZK2GL.js";import{b as ix,c as AA,d as v}from"./chunk-SRAX5OIU.js";import TK,{useCallback as SK,useContext as CK,useEffect as PK,useRef as kK,useState as MK}from"react";import{applyDarkModeFilter as eYe,DEFAULT_IMAGE_OPTIONS as Sn,DEFAULT_UI_OPTIONS as MA,getStrokeWidthByKey as tYe,isShallowEqual as AK}from"@excalidraw/common";import rM from"clsx";import rY from"lodash.throttle";import In,{useContext as Vo}from"react";import{flushSync as Gt}from"react-dom";import iY from"roughjs/bin/rough";import{nanoid as aY}from"nanoid";import{clamp as uc,pointFrom as oe,pointDistance as po,vector as iM,pointRotateRads as xb,vectorFromPoint as yb,vectorSubtract as aM,vectorDot as sM,vectorNormalize as lM}from"@excalidraw/math";import{CODES as Ar,shouldResizeFromCenter as cM,shouldMaintainAspectRatio as hc,shouldRotateWithDiscreteAngle as dM,isArrowKey as wb,KEYS as $,APP_NAME as sY,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as lY,DEFAULT_STROKE_STREAMLINE_PRECISE as cY,DEFAULT_TRANSFORM_HANDLE_SPACING as dY,DEFAULT_VERTICAL_ALIGN as mM,DRAGGING_THRESHOLD as pM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as mY,ELEMENT_TRANSLATE_AMOUNT as uM,EVENT as Q,FRAME_STYLE as zo,IMAGE_MIME_TYPES as pY,IMAGE_RENDER_TIMEOUT as uY,LINE_CONFIRM_THRESHOLD as vb,MIME_TYPES as uo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as hY,POINTER_BUTTON as Un,ROUNDNESS as tu,SCROLL_TIMEOUT as gY,TAP_TWICE_TIMEOUT as hM,TEXT_TO_CENTER_SNAP_THRESHOLD as fY,THEME as gc,TOUCH_CTX_MENU_TIMEOUT as EY,VERTICAL_ALIGN as bY,YOUTUBE_STATES as nu,ZOOM_STEP as xY,MIN_ZOOM as yY,POINTER_EVENTS as us,TOOL_TYPE as Wn,supportsResizeObserver as wY,DEFAULT_COLLISION_THRESHOLD as gM,DEFAULT_TEXT_ALIGN as vY,ARROW_TYPE as Dr,DEFAULT_REDUCED_GLOBAL_ALPHA as IY,isLocalLink as TY,normalizeLink as ou,toValidURL as SY,getGridPoint as Mt,getLineHeight as fM,debounce as EM,distance as hs,getFontString as Ib,getNearestScrollableContainer as CY,isInputLike as bM,isToolIcon as PY,isWritableElement as fc,sceneCoordsToViewportCoords as ru,tupleToCoors as Tb,viewportCoordsToSceneCoords as ke,wrapEvent as kY,updateObject as Sb,updateActiveTool as on,isTransparent as MY,muteFSAbortError as AY,isTestEnv as lA,isDevEnv as cA,updateStable as Ec,addEventListener as we,normalizeEOL as DY,getDateTime as xM,isShallowEqual as yM,arrayToMap as bc,applyDarkModeFilter as LY,AppEventBus as _Y,randomInteger as RY,CLASSES as Cb,Emitter as ho,MINIMUM_ARROW_SIZE as NY,DOUBLE_TAP_POSITION_THRESHOLD as wM,BIND_MODE_TIMEOUT as BY,invariant as go,getFeatureFlag as Go,createUserAgentDescriptor as dA,getFormFactor as FY,deriveStylesPanelMode as fu,isIOS as OY,isBrave as zY,isSafari as GY,loadDesktopUIModePreference as HY,setDesktopUIMode as UY,isSelectionLikeTool as iu,oneOf as vM,getStrokeWidthByKey as WY,getViewpointFlipSign as Vn}from"@excalidraw/common";import{getObservedAppState as VY,getCommonBounds as gs,getElementAbsoluteCoords as IM,bindOrUnbindBindingElements as TM,fixBindingsAfterDeletion as YY,getHoveredElementForBinding as Lr,isBindingEnabled as au,updateBoundElements as su,LinearElementEditor as fe,newElementWith as fo,newFrameElement as XY,newFreeDrawElement as KY,newEmbeddableElement as SM,newMagicFrameElement as $Y,newIframeElement as ZY,newArrowElement as jY,newElement as qY,newImageElement as JY,newLinearElement as QY,newTextElement as CM,refreshTextDimensions as eX,deepCopyElement as PM,duplicateElements as kM,hasBoundTextElement as MM,isArrowElement as xc,isBindingElement as Eo,isBindingElementType as tX,isBoundToContainer as AM,isFrameLikeElement as Tt,isImageElement as Yn,isEmbeddableElement as Ho,isInitializedImageElement as Ti,isLinearElement as Ht,isLinearElementType as nX,isUsingAdaptiveRadius as oX,isIframeElement as Pb,isIframeLikeElement as yc,isTextBindableContainer as DM,isElbowArrow as $t,isBindableElement as kb,isTextElement as Zt,getNormalizedDimensions as rX,isElementCompletelyInViewport as iX,isElementInViewport as LM,isInvisiblySmallElement as _M,generateThumbHash as aX,getCornerRadius as sX,isPathALoop as RM,embeddableURLValidator as Mb,maybeParseEmbedSrc as lX,getEmbedLink as lu,getInitializedImageElements as cX,normalizeSVG as NM,updateImageCache as Ab,getBoundTextElement as Db,getContainerCenter as Lb,getContainerElement as BM,isValidTextContainer as FM,redrawTextBoundingBox as dX,hasBoundingBox as mX,getCommonFrameId as OM,getFrameChildren as _b,getFrameChildrenInsertionIndex as pX,isCursorInFrame as zM,addElementsToFrame as Rb,replaceAllElementsInFrame as uX,removeElementsFromFrame as hX,getElementsInResizingFrame as Nb,getElementsInNewFrame as gX,getContainingFrame as Bb,elementOverlapsWithFrame as fX,updateFrameMembershipOfSelectedElements as GM,isElementInFrame as HM,getFrameLikeTitle as EX,filterElementsEligibleAsFrameChildren as bX,hitElementBoundText as xX,hitElementBoundingBoxOnly as yX,hitElementItself as wc,getVisibleSceneBounds as wX,cropElement as vX,wrapText as IX,isElementLink as UM,isMeasureTextSupported as TX,normalizeText as SX,measureText as WM,getLineHeightInPx as VM,getApproxMinLineWidth as CX,getApproxMinLineHeight as PX,getMinTextElementWidth as kX,ShapeCache as Si,getRenderOpacity as MX,editGroupForSelectedElement as AX,getElementsInGroup as Ci,getSelectedGroupIdForElement as DX,getSelectedGroupIds as LX,isElementInGroup as YM,isSelectedViaGroup as _X,selectGroupsForSelectedElements as Xn,syncInvalidIndices as mA,syncMovedIndices as XM,excludeElementsInFramesFromSelection as RX,getSelectionStateForElements as KM,makeNextSelectedElementIds as Ae,getResizeOffsetXY as NX,getResizeArrowDirection as BX,transformElements as FX,getCursorForResizingElement as $M,getElementWithTransformHandleType as ZM,getTransformHandleTypeFromCoords as jM,dragNewElement as qM,dragSelectedElements as OX,getDragOffsetXY as zX,Scene as JM,Store as GX,CaptureUpdateAction as jt,hitElementBoundingBox as HX,isLineElement as Fb,isSimpleArrow as Ob,StoreDelta as QM,positionElementsOnGrid as eA,calculateFixedPointForNonElbowArrowBinding as tA,bindOrUnbindBindingElement as UX,mutateElement as cu,getElementBounds as nA,doBoundsIntersect as WX,isPointInElement as oA,maxBindingDistance_simple as rA,convertToExcalidrawElements as VX,getSnapOutlineMidPoint as zb,handleFocusPointDrag as YX,handleFocusPointHover as XX,handleFocusPointPointerDown as KX,handleFocusPointPointerUp as $X,maybeHandleArrowPointlikeDrag as du,getUncroppedWidthAndHeight as ZX,getActiveTextElement as iA,isEligibleFrameChildType as jX,getBindingStrategyForDraggingBindingElementEndpoints as qX,isNonDeletedElement as mu}from"@excalidraw/element";import{KEYS as ch,MOBILE_ACTION_BUTTON_BG as YA,updateActiveTool as XA}from"@excalidraw/common";import{getNonDeletedElements as id}from"@excalidraw/element";import{fixBindingsAfterDeletion as KA}from"@excalidraw/element";import{LinearElementEditor as C0}from"@excalidraw/element/linearElementEditor";import{newElementWith as rd}from"@excalidraw/element";import{getContainerElement as P0}from"@excalidraw/element";import{isBoundToContainer as nd,isElbowArrow as $A,isFrameLikeElement as ZA}from"@excalidraw/element";import{getFrameChildren as jA}from"@excalidraw/element";import{getElementsInGroup as dh,selectGroupsForSelectedElements as qA}from"@excalidraw/element";import{CaptureUpdateAction as od}from"@excalidraw/element";import{isDevEnv as NA}from"@excalidraw/common";import{atom as et,createStore as LA}from"jotai";import{createIsolation as _A}from"jotai-scope";var Ax=_A();var{useAtom:Ye,useSetAtom:Dx,useAtomValue:Lx,useStore:BK}=Ax,_x=Ax.Provider,bt=LA();var RA=ix({"./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-2ZA2LKRK.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 BA=85,Zn={code:"en",label:"English"},Bi=[Zn,...[{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=>ax[e.code]>=BA).sort((e,n)=>e.label>n.label?1:-1)],Hc="__test__";NA()&&Bi.unshift({code:Hc,label:"test language"},{code:`${Hc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ni=Zn,Gc={},Uc=async e=>{if(Ni=e,document.documentElement.dir=Ni.rtl?"rtl":"ltr",document.documentElement.lang=Ni.code,e.code.startsWith(Hc))Gc={};else try{Gc=await RA(`./locales/${Ni.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Gc=Tu}bt.set(Nx,e.code)},jn=()=>Ni,Rx=(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(Ni.code.startsWith(Hc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Rx(Gc,o)||Rx(Tu,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},Nx=et(Zn.code),Re=()=>{let e=Lx(Nx);return{t:f,langCode:e}};import FA from"clsx";import tt from"react";import{THEME as OA}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var kn=e=>"var(--icon-fill-color)",Bx=e=>e===OA.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:FA({"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"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},_t={width:40,height:20},qK=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),JK=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),Fx=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),Ms=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),Ox=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),zx=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),Lu=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),vo=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"})})]}),le),$o=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"})]}),le),Gx=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}),Hx=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"}),Ux=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"}),Wx=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"}),QK=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"}),Wc=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}),Fi=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}),Oi=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),zi=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),Gi=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),Vc=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),Zo=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),Vx=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),qn=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"})]}),le),Mn=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),Yx=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),zr=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"})]}),le),Yc=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),_u=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Ru=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),Xx=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),Gr=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),jo=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"})]}),le),As=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"})]}),le),Ds=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),Ls=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}),Kx=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),_s=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),Hi=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),$x=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),e$=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),Zx=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),jx=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"})]}),le),qx=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),Xc=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Rs=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"})]}),le),Jx=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}),Qx=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}),Kc=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),t$=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}),n$=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"),Nu=["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"],Jn=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Nu.map(e=>h("path",{d:e},e))]}),H),e1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),t1=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),n1=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}),o$=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}),r$=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}),o1=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"),i$=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"),Bu=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),Fu=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),r1=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}),i1=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),a$=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"),s$=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}),l$=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),c$=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}),d$=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=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"})]}),s1=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"})]}),Ou=A(s1,H),zu=A(s1,{...H,style:{transform:"rotate(180deg)"}}),Gu=A(a1,H),Hu=A(a1,{...H,style:{transform:"rotate(180deg)"}}),Uu=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"})})})]}),le),Wu=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"})})})]}),le),Vu=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"})})})]}),le),Yu=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"})})})]}),le),l1=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"})})})]}),le),c1=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"})})})]}),le),Xu=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"})]}),le),Ku=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"})]}),le),$c=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),m$=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"),p$=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"),an=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"})})})]}),le),u$=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}),h$=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}),g$=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}),$u=tt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:kn(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:kn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:kn(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:kn(e),strokeWidth:"2"}),R("g",{fill:Bx(e),stroke:kn(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})),Zu=tt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:kn(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:kn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:kn(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:kn(e),strokeWidth:"2"}),R("g",{fill:Bx(e),stroke:kn(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})),d1=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),m1=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"})})]}),le),p1=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"})})})]}),le),u1=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"})})})]}),{...le,fill:"currentColor"}),ju=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),h1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),g1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),f$=tt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:kn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),f1=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),E1=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),b1=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),x1=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),y1=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),qu=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),Ju=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),w1=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"})]}),le),v1=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),I1=tt.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"})]}),_t)),T1=tt.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"})}),_t)),S1=tt.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"})]}),_t)),C1=tt.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"})]}),_t)),P1=tt.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"})]}),_t)),k1=tt.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"})]}),_t)),M1=tt.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"})]}),_t)),A1=tt.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"})]}),_t)),D1=tt.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"})}),_t)),L1=tt.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"})}),_t)),_1=tt.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"})}),_t)),R1=tt.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"})}),_t)),N1=tt.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"})}),_t)),B1=tt.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"})]}),_t)),F1=tt.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"})]}),_t)),O1=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"})})})]}),le),z1=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"})})})]}),le),G1=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"})})})]}),le),H1=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"})}),le),Hr=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),U1=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),Ns=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"})})}),le),zA=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),Zc=zA,W1=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),V1=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),Y1=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),X1=tt.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)),K1=tt.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)),$1=tt.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)),jc=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),E$=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}),b$=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"})),Z1=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),Qu=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),j1=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),q1=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),J1=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),x$=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),y$=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),Q1=A(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),e0=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),t0=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),n0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),o0=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),eh=["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"],Ui=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),eh.map(e=>h("path",{d:e},e))]}),H),Qn=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),w$=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),v$=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),I$=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"})]}),le),Ur=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),eo=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),T$=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),S$=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),C$=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),P$=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),Wr=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),r0=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),k$=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),M$=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),to=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),A$=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),D$=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),i0=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),a0=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),L$=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),s0=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),l0=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),c0=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),d0=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),th=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),qc=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),m0=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),p0=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),qo=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),_$=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),u0=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}),R$=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),N$=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),h0=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),g0=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),Jo=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),Qo=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),er=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Jc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),f0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),E0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),nh=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),b0=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),oh=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),rh=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),B$=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),ih=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"})})),x0=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),y0=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),ah=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),F$=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),O$=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),z$=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),G$=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),Qc=h("div",{style:{width:"1rem",height:"1rem"}}),w0=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),v0=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),I0=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 T0 from"clsx";import lh,{useEffect as UA,useRef as S0,useState as WA}from"react";import{isPromiseLike as VA}from"@excalidraw/common";import GA from"react";import{jsx as sh}from"react/jsx-runtime";var HA=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(GA.useRef(Date.now()).current%1600);return sh("div",{className:`Spinner ${o}`,children:sh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:sh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Io=HA;import{jsx as Bs,jsxs as ed}from"react/jsx-runtime";var Z=lh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=lh.useRef(null);lh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=WA(!1),c=S0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(VA(u))try{l(!0),await u}catch(E){if(E instanceof Dc)console.warn(E);else throw E}finally{c.current&&l(!1)}};UA(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=S0(null);return o.type==="button"||o.type==="icon"?ed("button",{className:T0("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:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&ed("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Bs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Bs(Io,{})]}),o.showAriaLabel&&ed("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Bs(Io,{})]}),o.children]}):Bs("button",{className:T0("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:ed("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Bs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});Z.displayName="IconButton";var td=[],O=e=>(td=td.concat(e),e);import{jsx as QA}from"react/jsx-runtime";var JA=(e,n,t)=>{let o=new Set(de(e.filter(d=>ZA(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=jA(e,d);for(let p of m)if(!a.has(p.id)){if(nd(p)){let u=P0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=nd(d)?P0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&$A(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),rd(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,nd(d)||(r[d.id]=!0),rd(d,{frameId:null})):nd(d)&&n.selectedElementIds[d.containerId]?rd(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=dh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=dh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...qA({selectedElementIds:r,editingGroupId:c},id(l),n,null)}}},k0=(e,n)=>{if(e.editingGroupId){let t=dh(id(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Fs=O({name:"deleteSelectedElements",label:"labels.delete",icon:Gr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=C0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?rd(p,{isDeleted:!0}):p),m=k0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:od.IMMEDIATELY}}return C0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:od.IMMEDIATELY}}let{elements:r,appState:i}=JA(e,n,o);return KA(r,r.filter(a=>a.isDeleted)),i=k0(i,r),{elements:r,appState:{...i,activeTool:XA(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:_e(id(e),n)?od.IMMEDIATELY:od.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===ch.BACKSPACE||e.key===ch.DELETE)&&!e[ch.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=dt()==="mobile";return QA(Z,{type:"button",icon:Gr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!_e(id(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?YA:{}}})}});import{KEYS as Wi,CODES as Vi,isDarwin as ad}from"@excalidraw/common";import{moveOneLeft as e3,moveOneRight as t3,moveAllLeft as n3,moveAllRight as o3}from"@excalidraw/element";import{CaptureUpdateAction as sd}from"@excalidraw/element";import{isDarwin as M0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,M0?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,M0?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 ld}from"react/jsx-runtime";var mh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:zu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:e3(e,n,o.scene),appState:n,captureUpdate:sd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Vi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:zu})}),ph=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Ou,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:t3(e,n,o.scene),appState:n,captureUpdate:sd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Wi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Vi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Ou})}),uh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Hu,trackEvent:{category:"element"},perform:(e,n)=>({elements:n3(e,n),appState:n,captureUpdate:sd.IMMEDIATELY}),keyTest:e=>ad?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Vi.BRACKET_LEFT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Vi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${ad?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Hu})}),hh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Gu,trackEvent:{category:"element"},perform:(e,n)=>({elements:o3(e,n),appState:n,captureUpdate:sd.IMMEDIATELY}),keyTest:e=>ad?e[Wi.CTRL_OR_CMD]&&e.altKey&&e.code===Vi.BRACKET_RIGHT:e[Wi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Vi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${ad?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Gu})});import{getNonDeletedElements as r3}from"@excalidraw/element";import{LinearElementEditor as i3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as a3,isTextElement as s3}from"@excalidraw/element";import{arrayToMap as l3,KEYS as A0}from"@excalidraw/common";import{selectGroupsForSelectedElements as c3}from"@excalidraw/element";import{CaptureUpdateAction as d3}from"@excalidraw/element";var gh=O({name:"selectAll",label:"labels.selectAll",icon:s0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(s3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...c3({editingGroupId:null,selectedElementIds:r},r3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&a3(e[0])?new i3(e[0],l3(e)):null},captureUpdate:d3.IMMEDIATELY}},keyTest:e=>e[A0.CTRL_OR_CMD]&&e.key===A0.A});import{DEFAULT_GRID_SIZE as D0,KEYS as L0,MOBILE_ACTION_BUTTON_BG as m3,arrayToMap as _0}from"@excalidraw/common";import{getNonDeletedElements as R0}from"@excalidraw/element";import{LinearElementEditor as p3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as u3,getSelectionStateForElements as h3}from"@excalidraw/element";import{syncMovedIndices as g3}from"@excalidraw/element";import{duplicateElements as f3}from"@excalidraw/element";import{CaptureUpdateAction as N0}from"@excalidraw/element";import{jsx as E3}from"react/jsx-runtime";var fh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:As,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=p3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:N0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=f3({type:"in-place",elements:e,idsOfElementsToDuplicate:_0(u3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+D0/2,y:a.y+D0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:g3(i,_0(r)),appState:{...n,...h3(r,R0(i),n)},captureUpdate:N0.IMMEDIATELY}},keyTest:e=>e[L0.CTRL_OR_CMD]&&e.key===L0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=dt()==="mobile";return E3(Z,{type:"button",icon:As,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!_e(R0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?m3:{}}})}});import{pointFrom as j4}from"@excalidraw/math";import{useEffect as Fh,useMemo as Gh,useRef as Oh,useState as q4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as J4,COLOR_PALETTE as Q4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Uy,DEFAULT_ELEMENT_BACKGROUND_PICKS as e6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as t6,DEFAULT_ELEMENT_STROKE_PICKS as n6,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as o6,DEFAULT_FONT_SIZE as r6,FONT_FAMILY as i6,ROUNDNESS as Md,STROKE_WIDTH_KEYS as a6,VERTICAL_ALIGN as Pd,KEYS as ea,randomInteger as s6,arrayToMap as Hh,getFontFamilyString as l6,getLineHeight as c6,isTransparent as d6,getStrokeWidthByKey as Wy,reduceToCommonValue as m6,invariant as Dd,FONT_SIZES as kd}from"@excalidraw/common";import{canBecomePolygon as p6,getNonDeletedElements as Vy,isNonDeletedElement as u6}from"@excalidraw/element";import{bindBindingElement as Fy,calculateFixedPointForElbowArrowBinding as Oy,updateBoundElements as h6}from"@excalidraw/element";import{LinearElementEditor as Yr}from"@excalidraw/element/linearElementEditor";import{newElementWith as at}from"@excalidraw/element";import{getArrowheadForPicker as zy}from"@excalidraw/element";import{getBoundTextElement as lr,redrawTextBoundingBox as js}from"@excalidraw/element";import{isArrowElement as Ad,isBoundToContainer as g6,isElbowArrow as Yy,isLinearElement as zh,isLineElement as Gy,isTextElement as Wt,isUsingAdaptiveRadius as f6}from"@excalidraw/element";import{hasStrokeColor as E6}from"@excalidraw/element";import{updateElbowArrowPoints as b6,CaptureUpdateAction as nt,toggleLinePolygonState as x6}from"@excalidraw/element";import{deriveStylesPanelMode as y6}from"@excalidraw/common";import{isDevEnv as b3}from"@excalidraw/common";var x3=new Set(["command_palette","export"]),He=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!x3.has(e)||b3())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 I3 from"clsx";import y3 from"clsx";import{forwardRef as w3}from"react";import{jsx as v3}from"react/jsx-runtime";var B0=w3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return v3("button",{type:"button",ref:n,title:t,"data-testid":r,className:y3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as S3,jsx as Eh,jsxs as T3}from"react/jsx-runtime";var qt=e=>Eh(S3,{children:e.options.map(n=>e.type==="button"?Eh(B0,{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):T3("label",{className:I3({active:e.value===n.value}),title:n.text,children:[Eh("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 gy}from"radix-ui";import fy from"clsx";import{memo as X5,useRef as Ey,useEffect as K5}from"react";import{applyDarkModeFilter as $5,COLOR_OUTLINE_CONTRAST_THRESHOLD as uy,COLOR_PALETTE as by,DEFAULT_ELEMENT_BACKGROUND_PICKS as Z5,DEFAULT_ELEMENT_STROKE_PICKS as j5,isColorDark as hy,isWritableElement as q5,THEME as J5}from"@excalidraw/common";import{jsx as C3}from"react/jsx-runtime";var cd=()=>C3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as L3,useLayoutEffect as _3,useRef as R3}from"react";import{createPortal as N3}from"react-dom";import{EVENT as tr,isColorDark as B3,KEYS as F3,MIME_TYPES as O3,THEME as z3,removeDarkModeFilter as G3,rgbToHex as H3}from"@excalidraw/common";import F0 from"react";var bh=F0.createContext(null),xe=()=>F0.useContext(bh);import{useState as P3,useLayoutEffect as O0}from"react";import{THEME as k3}from"@excalidraw/common";var dd=e=>{let[n,t]=P3(null),o=Ee(),{theme:r}=xe(),{container:i}=Fe();return O0(()=>{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===k3.DARK))},[n,r,o.formFactor,e?.className]),O0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as M3}from"react";import{EVENT as md}from"@excalidraw/common";function Yi(e,n,t){M3(()=>{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(md.POINTER_DOWN,o),document.addEventListener(md.TOUCH_START,o),()=>{document.removeEventListener(md.POINTER_DOWN,o),document.removeEventListener(md.TOUCH_START,o)}},[e,n,t])}import{useRef as A3}from"react";var Xi=e=>{let n=A3(e);return Object.assign(n.current,e),n.current};import{clamp as D3}from"@excalidraw/math";var z0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return D3(r,0,Math.max(0,t-n))},pd=({cursor:e,element:n,container:t,gap:o})=>({left:z0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:z0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as W3}from"react/jsx-runtime";var G0=eh.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),U3=`url(data:${O3.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">${G0}</g><g stroke="#1b1b1f" stroke-width="1.25">${G0}</g></svg>`)}) 2 21, auto`,Ut=et(null),H0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=dd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=Ki(),s=St(),l=de(a,i),c=Xi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Fe();_3(()=>{if(r)return r.style.cursor=U3,()=>{r.style.cursor=""}},[r]),L3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return H3(D[0],D[1],D[2])},b=P=>i.theme===z3.DARK?G3(P):P,w=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=pd({cursor:{x:P,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:M});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",B3(L)?"#fff":"#222")},y=()=>{c.onCancel()},x=(P,M)=>{c.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===F3.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(tr.KEYDOWN,C),r.addEventListener(tr.POINTER_DOWN,I),r.addEventListener(tr.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(tr.BLUR,y),()=>{u=!1,r.removeEventListener(tr.KEYDOWN,C),r.removeEventListener(tr.POINTER_DOWN,I),r.removeEventListener(tr.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(tr.BLUR,y)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=R3(null);return Yi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?N3(W3("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as xh}from"radix-ui";import K3 from"clsx";import $3 from"react";import{isInteractive as Z3}from"@excalidraw/common";import V3 from"react";import Y3 from"clsx";import{jsx as X3}from"react/jsx-runtime";var Xe=V3.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>X3("div",{className:Y3("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as yh,jsxs as j3}from"react/jsx-runtime";var To=$3.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=Ee(),p=m.formFactor==="phone"&&!m.isLandscape;return yh(xh.Portal,{container:n,children:j3(xh.Content,{ref:d,className:K3("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:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!Z3(document.activeElement)&&n.focus(),r()},children:[yh(Xe,{padding:3,style:o,children:t}),yh(xh.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 q3,useCallback as wh}from"react";var ud=()=>document.querySelector(".excalidraw-wysiwyg"),hd=()=>{let e=ud();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Os=e=>{setTimeout(()=>{let n=ud();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},zs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?hd():null;e(),n&&t&&Os(r)},U0=()=>{let[e,n]=q3(null),t=wh(()=>{let i=hd();n(i)},[]),o=wh(()=>{setTimeout(()=>{let i=ud();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}},W0=(e=100)=>{let n=ud();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import Y0 from"clsx";import{useCallback as e5,useEffect as Ih,useRef as X0,useState as K0}from"react";import{KEYS as Th,normalizeInputColor as t5}from"@excalidraw/common";import{isTransparent as J3,MAX_CUSTOM_COLORS_USED_IN_CANVAS as Q3}from"@excalidraw/common";var nr=({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},Gs=[["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),V0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!J3(s)&&vh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,Q3)},sn=et(null);import{Fragment as n5,jsx as Hs,jsxs as Sh}from"react/jsx-runtime";var $0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=Ee(),[a,s]=K0(e),[l,c]=K0(null),[d,m]=Ye(sn);Ih(()=>{s(e)},[e]);let p=e5(w=>{let y=w.toLowerCase().trim(),x=t5(y);x?(n(x),c(null)):y.length===0?c(null):/^#?[0-9a-f]+$/.test(y)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(y)},[n]),u=X0(null),E=X0(null);Ih(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Ye(Ut);return Ih(()=>()=>{b(null)},[b]),Sh("div",{className:"color-picker__input-label-container",children:[Sh("div",{className:Y0("color-picker__input-label",{"has-error":l}),children:[Hs("div",{className:"color-picker__input-hash",children:"#"}),Hs("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:w=>{p(w.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:w=>{w.key!==Th.TAB&&(w.key===Th.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Sh(n5,{children:[Hs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Hs("div",{ref:E,className:Y0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Th.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Ui})]})]}),l&&Hs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import kh,{useEffect as Mh,useImperativeHandle as R5,useState as N5}from"react";import{EVENT as ly}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as B5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as F5,KEYS as O5}from"@excalidraw/common";import m5 from"clsx";import{useEffect as p5,useRef as u5}from"react";import{applyDarkModeFilter as h5,THEME as g5}from"@excalidraw/common";import{isColorDark as o5}from"@excalidraw/common";import{jsxs as i5}from"react/jsx-runtime";var r5=({color:e,keyLabel:n,isShade:t=!1})=>i5("div",{className:"color-picker__button__hotkey-label",style:{color:o5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),$i=r5;import{createContext as a5,useContext as s5,useEffect as l5,useMemo as Z0,useRef as j0,useState as c5}from"react";import{colorToHex as q0,isTransparent as d5}from"@excalidraw/common";var Vr="excalidraw-color-dnd-ghost",J0="excalidraw-color-dnd-active",Q0=10,ey=100,ty=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=q0(e);return t!==null&&t===q0(n)},Ch=a5(null),ln=()=>s5(Ch),ny=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=c5(null),i=j0(null),a=j0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=Z0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((W,G)=>Number(W.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(W=>W.getBoundingClientRect());let[F,Y]=l.slotRects;l.slotSpan=Y?Y.left-F.left:F.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,F,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(F,Y))},u=(k,L)=>{if(!l)return;let{sourceRect:F,sourceEl:Y,color:z}=l,U=document.createElement("div");U.className=Vr;let W=document.createElement("div");if(W.className=`${Vr}__swatch`,d5(z))W.classList.add("is-transparent");else{let G=getComputedStyle(Y).backgroundColor;W.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(W),document.body.appendChild(U),l.ghost=U,l.ghostW=F.width,l.ghostH=F.height,U.style.width=`${F.width}px`,U.style.height=`${F.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Vr}--lifted`)}),document.body.classList.add(J0),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:Y}=l,z=null,U=null;if(k>=F.left&&k<=F.right&&L>=F.top&&L<=F.bottom){let W=0,G=1/0;if(Y.forEach((ie,me)=>{let B=Math.abs(k-(ie.left+ie.width/2));B<G&&(G=B,W=me)}),l.origin.kind==="swatch"){let ie=a.current.picks.findIndex(me=>ty(me,l.color));ie!==-1?U=ie:z=W}else z=W}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:W}=l;W&&(W.classList.toggle(`${Vr}--over`,z!==null),W.classList.toggle(`${Vr}--blocked`,U!==null)),c()}if(z!==null){let W=l.slotRects[z];p(W.width,W.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Vr}--dropping`);let F=k.rect;F&&(L.style.width=`${F.width}px`,L.style.height=`${F.height}px`,L.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{L.classList.add(`${Vr}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of L)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of L)F.style.transition=""},w=()=>{let k=L=>{L.preventDefault(),L.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",D,!0)},x=()=>{y(),document.body.classList.remove(J0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<Q0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<ey){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Q0&&T(l.lastX,l.lastY))},ey-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),w();let{overIndex:L,origin:F,color:Y,slotRects:z}=l,{picks:U,onPicksChange:W}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>ty(G,Y))){let G=[...U];G[L]=Y,W(G)}}else if(F.index!==L){let G=[...U],[ie]=G.splice(F.index,1);G.splice(L,0,ie),W(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},M=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,F)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:F,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",D,!0))},destroy:()=>I(!1)}},[]);return l5(()=>()=>s.destroy(),[s]),Z0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Ph,jsxs as f5}from"react/jsx-runtime";var oy=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Ye(sn),s=ln(),l=u5(null);return p5(()=>{l.current&&l.current.focus()},[t,i]),Ph("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=h5(c,e===g5.DARK);return f5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:m5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Ph("div",{className:"color-picker__button-outline"}),Ph($i,{color:m,keyLabel:d+1})]},d)})})};import E5 from"clsx";import{useEffect as b5,useRef as x5}from"react";import{applyDarkModeFilter as y5,isColorDark as w5,THEME as v5}from"@excalidraw/common";import{jsx as gd,jsxs as T5}from"react/jsx-runtime";var I5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=nr({color:t,palette:n}),[l,c]=Ye(sn),d=ln(),m=x5(null);return b5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),gd("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 gd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Gs[E],w=y5(g,e===v5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return T5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:E5("color-picker__button color-picker__button--large",{"has-outline":!w5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.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:[gd("div",{className:"color-picker__button-outline"}),i&&gd($i,{color:w,keyLabel:b})]},p)})})},ry=I5;import{jsx as C5}from"react/jsx-runtime";var S5=({children:e})=>C5("div",{className:"color-picker__heading",children:e}),Zi=S5;import P5 from"clsx";import{useEffect as k5,useRef as M5}from"react";import{applyDarkModeFilter as A5,THEME as D5}from"@excalidraw/common";import{jsx as Us,jsxs as iy}from"react/jsx-runtime";var ay=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=nr({color:n||"transparent",palette:o}),[a,s]=Ye(sn),l=ln(),c=M5(null);if(k5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Us("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=A5(u,e===D5.DARK);return iy("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:P5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Us("div",{className:"color-picker__button-outline"}),r&&Us($i,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return iy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Us("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Us("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 ji,COLOR_PALETTE as L5,KEYS as Ws}from"@excalidraw/common";var fd=(e,n,t)=>{let o=Math.ceil(t/ji);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+ji;return r>=t?n%ji:r}case"ArrowUp":{let r=n-ji,i=r<0?ji*o+r:r;return i>=t?void 0:i}}},_5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.colorName][l]),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(Gs.includes(e.key)){let l=Gs.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},sy=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ws.CTRL_OR_CMD])return!1;if(e.key===Ws.ESCAPE)return d(e),!0;if(e.key===Ws.ALT)return c(!0),!0;if(e.key===Ws.I)return c(),!0;let p=nr({color:o,palette:t});if(e.key===Ws.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(L5.black)),e.preventDefault(),e.stopPropagation(),!0}if(_5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=fd(e.key,u,ji);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=fd(e.key,g,E.length),w=0;for(;b!==void 0&&w++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[l]:y;if(!m?.includes(x))break;b=fd(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=fd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as So,jsxs as Ed}from"react/jsx-runtime";var cy=kh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=kh.useState(()=>o==="canvasBackground"?[]:V0(r,o,i)),[b,w]=Ye(sn),y=ln(),x=nr({color:n,palette:i});Mh(()=>{if(!b){let P=!!n&&vh({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]=N5(x?.shade??(o==="elementBackground"?B5:F5));Mh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===O5.ALT&&c(!1)};return document.addEventListener(ly.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ly.KEYUP,P,{capture:!0})}},[x,c]);let C=kh.useRef(null);return R5(u,()=>C.current),Mh(()=>{C?.current?.focus()},[]),So("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Ed("div",{ref:C,onKeyDown:P=>{sy({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&So("div",{className:"color-picker__title",children:E}),!!g.length&&Ed("div",{children:[So(Zi,{children:f("colorPicker.mostUsedCustomColors")}),So(oy,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),Ed("div",{children:[So(Zi,{children:f("colorPicker.colors")}),So(ry,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),Ed("div",{children:[So(Zi,{children:f("colorPicker.shades")}),So(ay,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&So("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import dy from"clsx";import{ContextMenu as Vs}from"radix-ui";import{applyDarkModeFilter as z5,COLOR_OUTLINE_CONTRAST_THRESHOLD as G5,DEFAULT_CANVAS_BACKGROUND_PICKS as H5,DEFAULT_ELEMENT_BACKGROUND_PICKS as U5,DEFAULT_ELEMENT_STROKE_PICKS as W5,isColorDark as V5,THEME as Y5}from"@excalidraw/common";import{jsx as or,jsxs as my}from"react/jsx-runtime";var py=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=Fe(),d;if(t==="elementStroke"&&(d=W5),t==="elementBackground"&&(d=U5),t==="canvasBackground"&&(d=H5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=my("div",{className:dy("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&or("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:or("rect",{})}),d.map((u,E)=>{let g=m(E),b=z5(u,e===Y5.DARK);return or("button",{className:dy("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!V5(u,G5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?w=>s.startPickDrag(w,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:or("div",{className:"color-picker__button-outline"})},u)})]});return i?my(Vs.Root,{children:[or(Vs.Trigger,{asChild:!0,children:p}),or(Vs.Portal,{container:c,children:or(Vs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:or(Vs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as bd}from"react/jsx-runtime";var Q5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=by,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Fe(),m=dt(),p=m!=="full",u=m==="mobile",[,E]=Ye(sn),[g,b]=Ye(Ut),w=bd("div",{children:[cn(Zi,{children:f("colorPicker.hexCode")}),cn($0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=Ey(null),x=()=>{y.current?.focus()};return cn(To,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}q5(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:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?cn(cy,{ref:y,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?hd():null;t(I),l.editingTextElement&&T&&Os(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})},e4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",t4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=dt(),l=s!=="full",c=s==="mobile",d=ln(),m=n?$5(n,o===J5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&W0(),i()};return bd(gy.Trigger,{type:"button",className:fy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!hy(n,uy),"compact-sizing":l,"mobile-border":c}),"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:d?u=>d.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&e1}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&hy(m,uy)?"#fff":"#111"},children:y0})})]})},n4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=by,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=Ey(l.openPopup);K5(()=>{m.current=l.openPopup},[l.openPopup]);let u=dt()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?j5:Z5),w=ny({enabled:E,picks:b,onPicksChange:y=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:y}})}});return cn(Ch.Provider,{value:E?w:null,children:bd("div",{role:"dialog","aria-modal":"true",className:fy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(py,{theme:l.theme,activeColor:n,onChange:y=>{t(y),e4(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&cn(cd,{}),bd(gy.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(t4,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&cn(Q5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},o4=(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,qi=X5(n4,o4);import{Popover as D4}from"radix-ui";import L4 from"clsx";import _4,{useCallback as R4,useMemo as N4}from"react";import{FONT_FAMILY as _h}from"@excalidraw/common";import w4,{useMemo as ar,useState as v4,useRef as vy,useEffect as Iy,useCallback as Ty}from"react";import{arrayToList as I4,debounce as T4,FONT_FAMILY as sr,getFontFamilyString as S4}from"@excalidraw/common";import r4 from"clsx";import i4 from"react";import{jsx as a4,jsxs as s4}from"react/jsx-runtime";var xd=i4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>s4("div",{className:r4("QuickSearch__wrapper",e),children:[to,a4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import l4 from"clsx";import{Children as c4}from"react";import{jsx as xy}from"react/jsx-runtime";var yd=({className:e,placeholder:n,children:t})=>{let o=!c4.count(t);return xy("div",{className:l4("ScrollableList__wrapper",e),role:"menu",children:o?xy("div",{className:"empty",children:n}):t})};import{jsx as d4,jsxs as m4}from"react/jsx-runtime";var yy=({children:e,className:n="",style:t,title:o})=>m4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&d4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Ys=yy;yy.displayName="DropdownMenuGroup";import{THEME as x4}from"@excalidraw/common";import{DropdownMenu as y4}from"radix-ui";import p4,{useContext as u4}from"react";import{composeEventHandlers as h4}from"@excalidraw/common";var Ah=p4.createContext({}),rr=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),wd=e=>{let n=u4(Ah);return h4(e,t=>{n.onSelect?.(t)})};import{jsx as g4}from"react/jsx-runtime";var Xs=({children:e,...n})=>g4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as E4,jsx as Ks,jsxs as b4}from"react/jsx-runtime";var f4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=Ee();return b4(E4,{children:[n&&Ks("div",{className:"dropdown-menu-item__icon",children:n}),Ks("div",{style:e,className:"dropdown-menu-item__text",children:Ks(Xs,{children:o})}),r&&Ks("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ks("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ir=f4;import{jsx as vd}from"react/jsx-runtime";var Dh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=wd(s);return vd(y4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:vd("button",{...l,value:t,className:rr(i,a),title:l.title??l["aria-label"],children:vd(ir,{icon:e,shortcut:r,badge:n,children:o})})})};Dh.displayName="DropdownMenuItem";var Ji={GREEN:"green",RED:"red",BLUE:"blue"},Id=({type:e=Ji.BLUE,children:n})=>{let{theme:t}=no(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===x4.LIGHT?"1.5px solid white":"none"};switch(e){case Ji.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ji.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ji.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return vd("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Id.displayName="DropdownMenuItemBadge";Dh.Badge=Id;var Jt=Dh;import{KEYS as Qi}from"@excalidraw/common";var wy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Qi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Qi.F)return n.current?.focus(),!0;if(e.key===Qi.ESCAPE)return r(),!0;if(e.key===Qi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Qi.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Qi.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as Co,jsxs as k4}from"react/jsx-runtime";var C4=e=>{switch(e){case sr.Excalifont:case sr.Virgil:return qn;case sr.Nunito:case sr.Helvetica:return Ns;case sr["Lilita One"]:return U1;case sr["Comic Shanns"]:case sr.Cascadia:return Zc;default:return Ns}},P4=(e,n)=>Object.entries(sr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Sy=w4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Fe(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=An(),m=dt(),[p,u]=v4(""),E=vy(null),g=ar(()=>Array.from(wo.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let Y={value:k,icon:C4(k),text:P4(k,F)};return L.deprecated&&Object.assign(Y,{deprecated:L.deprecated,badge:{type:Ji.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=ar(()=>new Set(c.getSceneFamilies()),[e]),w=ar(()=>g.filter(k=>b.has(k.value)),[g,b]),y=ar(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=ar(()=>I4([...w,...y].filter(k=>k.text?.toLowerCase().includes(p))),[w,y,p]),I=ar(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=Ty(k=>{let L=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(L={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&L&&(F.focus(),F.selectionStart=L.start,F.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=Ty(k=>{wy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);Iy(()=>(i(),()=>{a()}),[]);let P=ar(()=>x.filter(k=>b.has(k.value)),[x,b]),M=ar(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=vy(null),Y=k.value===I?.value,z=k.value===e;return Iy(()=>{Y&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,L]),Co("button",{ref:F,type:"button",value:k.value,className:rr("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:Co(ir,{icon:k.icon,badge:k.badge&&Co(Id,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:S4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(Co(Ys,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>Co(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(Co(Ys,{title:f("fontList.availableFonts"),children:M.map((k,L)=>Co(D,{font:k,order:L+P.length},k.value))},"group_2")),k4(To,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&Co(xd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:T4(u,20)}),Co(yd,{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 M4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as A4}from"@excalidraw/common";import{jsx as Lh}from"react/jsx-runtime";var Cy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ue(),r=t?{...A4,width:"2rem",height:"2rem"}:{};return Lh(M4.Trigger,{asChild:!0,children:Lh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Lh(Z,{type:"toggle",icon:Mn,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 $s,jsxs as Py}from"react/jsx-runtime";var ky=[{value:_h.Excalifont,icon:qn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:_h.Nunito,icon:Ns,text:f("labels.normal"),testId:"font-family-normal"},{value:_h["Comic Shanns"],icon:Zc,text:f("labels.code"),testId:"font-family-code"}],ute=new Set(ky.map(e=>e.value));var My=_4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=N4(()=>ky,[]),c=R4(d=>{d&&o(d)},[o]);return Py("div",{role:"dialog","aria-modal":"true",className:L4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&$s("div",{className:"buttonList",children:$s(qt,{type:"button",options:l,value:n,onClick:c})}),!s&&$s(cd,{}),Py(D4.Root,{open:e,onOpenChange:a,children:[$s(Cy,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&$s(Sy,{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 Rh}from"radix-ui";import z4 from"clsx";import _y,{useEffect as G4,useMemo as H4}from"react";import{isArrowKey as U4,KEYS as Po}from"@excalidraw/common";import{jsx as B4}from"react/jsx-runtime";var Td=({className:e,icon:n,size:t="1em"})=>B4("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 O4,jsx as Ay,jsxs as Dy}from"react/jsx-runtime";var F4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Dy(O4,{children:[Dy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Ay(Td,{icon:n?f0:Jc})]}),n&&Ay("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Zs=F4;import{jsx as oo,jsxs as Cd}from"react/jsx-runtime";var W4=et(!1),Sd=4,V4="default",Y4=e=>e.flatMap(n=>n.options),Ly=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},X4=(e,n)=>e.some(t=>t.options.some(n)),K4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/Sd)},(t,o)=>n.options.slice(o*Sd,o*Sd+Sd)));function $4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Fe(),[s,l]=Ye(W4),c=[...e,...n],d=Y4(c),m=K4([...e,...s?n:[]]),p=g=>{let b=d.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Po.TAB){let w=d.findIndex(x=>x.value===t),y=g.shiftKey?(d.length+w-1)%d.length:(w+1)%d.length;r(d[y].value)}else if(U4(g.key)){let w=jn().rtl,y=d.findIndex(x=>x.value===t);if(y!==-1){let x=d.length,I=y;switch(g.key){case(w?Po.ARROW_LEFT:Po.ARROW_RIGHT):I=(y+1)%x;break;case(w?Po.ARROW_RIGHT:Po.ARROW_LEFT):I=(x+y-1)%x;break;case Po.ARROW_DOWN:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(T+1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Po.ARROW_UP:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+T-1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===Po.ESCAPE||g.key===Po.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};G4(()=>{X4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>oo("div",{className:"picker-content",children:g.map(b=>Cd("button",{type:"button",className:z4("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&&oo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===V4?oo(_y.Fragment,{children:u(b.options)},`${b.name}-${w}`):Cd("div",{className:"picker-section",children:[oo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return oo(Rh.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:Cd("div",{className:"picker-sections",children:[E(e),n.length>0&&oo(Zs,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:oo("div",{className:"picker-sections",children:E(n)})})]})})}function Nh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=_y.useState(!1),s=H4(()=>Ly(t,l=>l.value===e)??Ly(o??[],l=>l.value===e),[t,o,e]);return oo("div",{children:Cd(Rh.Root,{open:i,onOpenChange:l=>a(l),children:[oo(Rh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&oo($4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Ry,{useEffect as Z4}from"react";import{jsx as Bh,jsxs as Ny}from"react/jsx-runtime";var By=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Ry.useRef(null),d=Ry.useRef(null);return Z4(()=>{if(c.current&&d.current){let m=c.current,p=d.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]),Ny("label",{className:"control-label",children:[e,Ny("div",{className:"range-wrapper",children:[Bh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Bh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Bh("div",{className:"zero-label",children:a})]})]})};import{Fragment as _d,jsx as ee,jsxs as xt}from"react/jsx-runtime";var Xy=.1,Xr=e=>{let n=y6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Hh(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(u6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},pt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Vy(e),s=null;if(i&&(s=t(i)),!s)if(_e(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=m6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},w6=(e,n,t)=>g6(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}),Uh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Wt(s)){let l=o(s);i.add(l);let c=at(s,{fontSize:l});return js(c,t.scene.getContainerElement(s),t.scene),c=w6(s,c,t.scene),c}return s},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(s=>{Wt(s)&&h6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:nt.IMMEDIATELY}},v6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>E6(o.type)?at(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?nt.IMMEDIATELY:nt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Xr(o);return xt(_d,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(qi,{topPicks:n6,palette:t6,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:pt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),I6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:nt.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!d6(t.currentItemBackgroundColor)&&i.every(s=>Gy(s)&&p6(s.points))){let s=Hh(i);r=e.map(l=>s.has(l.id)&&Gy(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,...x6(l,!0)}):l)}else r=Ct(e,n,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Xr(o);return xt(_d,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(qi,{topPicks:e6,palette:Uy,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:pt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Ld=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:nt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Xr(o);return xt(_d,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(qi,{topPicks:J4,palette:Uy,excludedColors:[Q4.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})]})}}),T6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(He("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>at(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:nt.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 xt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(qt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?d1:m1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:p1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:u1,testId:"fill-solid"}],value:pt(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),S6=e=>a6.find(n=>Wy(e.type,n)===e.strokeWidth)??null,C6=(e,n)=>Wy(e.type,n),P6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Dd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>at(o,{strokeWidth:C6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(qt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:ju,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:h1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:g1,testId:"strokeWidth-bold"}],value:pt(e,o,S6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),k6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{seed:s6(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(qt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:b1},{value:1,text:f("labels.artist"),icon:x1},{value:2,text:f("labels.cartoonist"),icon:y1}],value:pt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),M6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:at(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=pt(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 ee(Z,{type:"button",icon:a?Ju:qu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return xt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:qu},{value:"variable",text:f("labels.pressure_variable"),icon:Ju}],value:i,onChange:a=>t(a)})})]})}}),xne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:ju},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:f1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:E1}],value:pt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),A6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=pt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(By,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),D6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,()=>(Dd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Xr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(qt,{group:"font-size",options:[{value:kd.sm,text:f("labels.small"),icon:O1,testId:"fontSize-small"},{value:kd.md,text:f("labels.medium"),icon:z1,testId:"fontSize-medium"},{value:kd.lg,text:f("labels.large"),icon:G1,testId:"fontSize-large"},{value:kd.xl,text:f("labels.veryLarge"),icon:H1,testId:"fontSize-veryLarge"}],value:pt(e,o,a=>{if(Wt(a))return a.fontSize;let s=lr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Wt(a)||lr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||r6),onChange:a=>{zs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Wh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hr,trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,r=>Math.round(1/(1+Xy)*r.fontSize)),keyTest:e=>e[ea.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ea.CHEVRON_LEFT||e.key===ea.COMMA)}),Vh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hr,trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,r=>Math.round(r.fontSize*(1+Xy))),keyTest:e=>e[ea.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ea.CHEVRON_RIGHT||e.key===ea.PERIOD)}),L6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?at(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:nt.NEVER};Dd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=nt.EVENTUALLY,m,p=!1;if(l)m=l,d=nt.IMMEDIATELY;else if(c){m=c,d=nt.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Wt(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,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,w=Array.from(wo.loadedFontsCache.values()),y=Object.entries(i6).find(([T,C])=>C===m)?.[0];c&&y&&w.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Wt(T)&&(T.fontFamily!==m||l)){let C=at(T,{fontFamily:m,lineHeight:c6(m)}),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 ${l6({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)js(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),D=P?o.scene.getElement(P.id):null;M&&js(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Oh(new Map),i=Oh(null),[a,s]=q4({}),l=Oh(!0),{stylesPanelMode:c,isCompact:d}=Xr(t),m=Gh(()=>{let p=(u,E)=>pt(u,t,g=>{if(Wt(g))return g.fontFamily;let b=lr(g,E);return b?b.fontFamily:null},g=>Wt(g)||lr(g,E)!==null,g=>g?null:n.currentItemFontFamily||o6);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Fh(()=>{i.current=m},[m]),Fh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Fh(()=>(l.current=!1,()=>{l.current=!0}),[]),xt(_d,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(My,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{zs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,at(E||u,{},!0))}else{let E=de(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,at(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&Os(null)}}})]})}}),_6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=at(r,{textAlign:t});return js(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Xr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:W1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:V1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:Y1,testId:"align-right"}],value:pt(e,o,s=>{if(Wt(s))return s.textAlign;let l=lr(s,i);return l?l.textAlign:null},s=>Wt(s)||lr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{zs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),R6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=at(r,{verticalAlign:t});return js(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Xr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:Pd.TOP,text:f("labels.alignTop"),icon:ee(X1,{theme:n.theme}),testId:"align-top"},{value:Pd.MIDDLE,text:f("labels.centerVertically"),icon:ee($1,{theme:n.theme}),testId:"align-middle"},{value:Pd.BOTTOM,text:f("labels.alignBottom"),icon:ee(K1,{theme:n.theme}),testId:"align-bottom"}],value:pt(e,o,a=>{if(Wt(a)&&a.containerId)return a.verticalAlign;let s=lr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Wt(a)||lr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Pd.MIDDLE),onChange:a=>{zs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),yne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Yy(o)?o:at(o,{roundness:t==="round"?{type:f6(o.type)?Md.ADAPTIVE_RADIUS:Md.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Di(Vy(e),n).some(s=>s.roundness?.type===Md.LEGACY);return xt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),xt("div",{className:"buttonList",children:[ee(qt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:w1},{value:"round",text:f("labels.round"),icon:v1}],value:pt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!Ad(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Hy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(I1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(T1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(S1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(C1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(P1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(k1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(M1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(A1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(D1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(L1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(_1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(R1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(N1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(B1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(F1,{flip:e}),keyBinding:null}]}]}),wne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Dd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(zh(o)){let{position:r,type:i}=t;if(r==="start")return at(o,{startArrowhead:i});if(r==="end")return at(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=jn().rtl,i=Gh(()=>Hy(!r),[r]),a=Gh(()=>Hy(!!r),[r]);return xt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),xt("div",{className:"iconSelectList buttonList",children:[ee(Nh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:pt(e,o,s=>zh(s)&&vs(s.type)?zy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Nh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:pt(e,o,s=>zh(s)&&vs(s.type)?zy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),N6=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})=>xt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),vne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!Ad(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Yr.getPointAtIndexGlobalCoordinates(s,0,l),d=Yr.getPointAtIndexGlobalCoordinates(s,-1,l),m=at(s,{x:t===dn.elbow?c[0]:s.x,y:t===dn.elbow?c[1]:s.y,roundness:t===dn.round?{type:Md.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Yr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Yr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Yy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Yr.getPointAtIndexGlobalCoordinates(m,0,p),E=Yr.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,...Oy(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...Oy(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...b6(m,p,{points:[u,E].map(x=>j4(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&&Fy(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&Fy(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Yr(s,Hh(e)))}return{elements:r,appState:i,captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(qt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:Jo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:er,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:Qo,testId:"elbow-arrow"}],value:pt(e,o,r=>Ad(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>Ad(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as U6,MAX_ZOOM as W6,MIN_ZOOM as V6,THEME as qs,ZOOM_STEP as Zy,CODES as Kr,KEYS as Nd}from"@excalidraw/common";import{getNonDeletedElements as Js}from"@excalidraw/element";import{getCommonBounds as Qs}from"@excalidraw/element";import{CaptureUpdateAction as oa}from"@excalidraw/element";import{useEffect as B6}from"react";import{jsx as O6}from"react/jsx-runtime";var ta=()=>{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},Yh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},F6=(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();Yh(n,r)},ut=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(B6(()=>()=>ta().classList.remove("excalidraw-tooltip--visible"),[]),r?null:O6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>F6(i.currentTarget,ta(),n,t),onPointerLeave:()=>ta().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Ky,useRef as $y,useState as z6}from"react";var G6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Xh=(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},Ko())}return G6(o,n)};function na(e,n=!0){let t=Rd(),[,o]=z6(0),r=$y(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Xh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Xh(t,e,n)),Ky(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function H6(e,n){let t=Rd(),o=$y({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Ky(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Xh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Gd,jsxs as K6}from"react/jsx-runtime";var Y6=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?oa.IMMEDIATELY:oa.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Gd(qi,{palette:null,topPicks:U6,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})}),Bd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:_u,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:$n(n.zoom.value+Zy)},n)},captureUpdate:oa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=na(t=>t.zoom.value);return Gd(Z,{type:"button",className:"zoom-in-button zoom-button",icon:_u,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=W6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Kr.EQUAL||e.code===Kr.NUM_ADD)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Fd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Ru,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:$n(n.zoom.value-Zy)},n)},captureUpdate:oa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=na(t=>t.zoom.value);return Gd(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Ru,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=V6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Kr.MINUS||e.code===Kr.NUM_SUBTRACT)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Od=O({name:"resetZoom",label:"buttons.resetZoom",icon:Xx,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,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:$n(r)},n)},captureUpdate:oa.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=na(t=>t.zoom.value);return Gd(ut,{label:f("buttons.resetZoom"),style:{height:"100%"},children:K6(Z,{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===Kr.ZERO||e.code===Kr.NUM_ZERO)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Kh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Qne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:qc,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?Qs(Js(r)):n.scrollConstraints?Kh(n.scrollConstraints):Qs(Js(e)),a=Nr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Kn(a.appState)}}},keyTest:void 0}),eoe=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:qc,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?Qs(Js(r)):n.scrollConstraints?Kh(n.scrollConstraints):Qs(Js(e)),a=Nr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Kn(a.appState)}}},keyTest:void 0}),X6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:qc,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?Kh(n.scrollConstraints):Qs(Js(e)),i=Nr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Kn(i.appState)}}},keyTest:void 0}),zd=O({name:"toggleTheme",label:(e,n)=>n.theme===qs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===qs.LIGHT?Ds:Ls,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===qs.LIGHT?qs.DARK:qs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:oa.EVENTUALLY}},keyTest:e=>!e[Nd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Kr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as nD}from"@excalidraw/math";import{bindOrUnbindBindingElement as aw}from"@excalidraw/element/binding";import{isValidPolygon as sw,newElementWith as jh}from"@excalidraw/element";import{LinearElementEditor as rl}from"@excalidraw/element/linearElementEditor";import{isBindingElement as qh,isFreeDrawElement as lw,isLinearElement as cw,isLineElement as Kd}from"@excalidraw/element";import{KEYS as $d,arrayToMap as oD,invariant as dw,shouldRotateWithDiscreteAngle as rD,updateActiveTool as mw}from"@excalidraw/common";import{isPathALoop as iD}from"@excalidraw/element";import{isInvisiblySmallElement as Jh}from"@excalidraw/element";import{CaptureUpdateAction as Qh}from"@excalidraw/element";import q6 from"clsx";import{useEffect as J6,useState as Q6}from"react";import{KEYS as mn,capitalizeString as $r}from"@excalidraw/common";import{useEffect as $6,useState as Z6}from"react";import jy from"clsx";import{capitalizeString as Hd}from"@excalidraw/common";import{Popover as $h}from"radix-ui";import{jsx as Ud,jsxs as j6}from"react/jsx-runtime";var ra=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=Z6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Fe();return!n.some(u=>u.type===c)&&s&&l(!1),$6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),j6($h.Root,{open:s,children:[Ud($h.Trigger,{asChild:!0,children:Ud(Z,{className:jy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Qe(e,u.type)),title:Hd(a.title),"aria-label":Hd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Ud($h.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Ud(Z,{className:jy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Qe(e,u),title:Hd(u),"aria-label":Hd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(He("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Zh}from"react/jsx-runtime";var eD=e=>e,$e=eD({hand:{icon:Z1,letterKey:mn.H,toggle:!0},selection:{icon:Wc,letterKey:mn.V,fillable:!0},rectangle:{icon:Oi,letterKey:mn.R,fillable:!0},diamond:{icon:zi,letterKey:mn.D,fillable:!0},ellipse:{icon:Gi,letterKey:mn.O,fillable:!0},arrow:{icon:Vc,letterKey:mn.A,fillable:!0},line:{icon:Zo,letterKey:mn.L,fillable:!0},freedraw:{icon:qn,letterKey:mn.P},text:{icon:Mn,letterKey:mn.T},image:{icon:zr},eraser:{icon:Yc,letterKey:mn.E,toggle:!0},frame:{icon:Qn,letterKey:mn.F},autoshape:{icon:Ur,letterKey:mn.X,fillable:!1},embeddable:{icon:jo},laser:{icon:eo},bucketfill:{icon:Jn},lasso:{icon:Fi,fillable:!1}});var ia=["autoshape","rectangle","diamond","ellipse","arrow","line"],aa=Object.keys($e).filter(e=>$e[e].toggle),Wd=e=>{let{letterKey:n,shiftKey:t}=$e[e];if(!n)return n;let o=$r(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},sa=e=>Wd(e),tD=e=>{let n=Wd(e);return n?.length===1?n:void 0},qy=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys($e)){let{letterKey:i,shiftKey:a}=$e[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Qe=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Vt=(e,n)=>{let t=$e[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=$r(f(`toolBar.${e}`)),d=l?null:sa(o);return Zh(Z,{className:q6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Qe(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:tD(o),"aria-label":c,"aria-keyshortcuts":d??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&&(He("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${$r(e)}IconButton`,r},Vd=Vt("hand"),Jy=Vt("rectangle"),Qy=Vt("diamond"),ew=Vt("ellipse"),tw=Vt("arrow"),nw=Vt("line"),el=Vt("freedraw"),tl=Vt("text"),nl=Vt("image"),ol=Vt("eraser"),ow=Vt("frame"),koe=Vt("autoshape"),rw=Vt("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(He("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),iw=Vt("lasso",{shortcutType:"selection"}),Yd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:$e.selection.icon,fillable:$e.selection.fillable,title:$r(f("toolBar.selection"))},{type:"lasso",icon:$e.lasso.icon,fillable:$e.lasso.fillable,title:$r(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Zh(ra,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Xd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:$e.freedraw.icon,fillable:$e.freedraw.fillable,title:$r(f("toolBar.freedraw"))},{type:"autoshape",icon:$e.autoshape.icon,fillable:$e.autoshape.fillable,title:$r(f("toolBar.autoshape"))}],[o,r]=Q6(n.type==="autoshape"?"autoshape":"freedraw");J6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Zh(ra,{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 aD}from"react/jsx-runtime";var ht=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=rl.getElement(n.selectedLinearElement.elementId,l);dw(y,"Arrow element should exist if selectedLinearElement is set"),dw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=rl.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(qh(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=rD(b),P=b[$d.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:rl.createPointAt(y,l,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),D),new Map)??new Map;aw(y,M,w.x,w.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Kd(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!sw(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&Jh(y)&&(i=i.map(T=>T.id===y.id?jh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||Jh(y)?e.map(T=>T.id===y.id?jh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?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:Qh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||qh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.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,s.mutateElement(m,{points:m.points.slice(0,-1)}),qh(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=rl.getPointAtIndexGlobalCoordinates(m,-1,l);aw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&Jh(m)&&(i=i.map(b=>b.id===m?.id?jh(b,{isDeleted:!0}):b)),cw(m)||lw(m)){if(iD(m.points,n.zoom.value)&&(Kd(m)||lw(m))){let w=m.points,y=w[0],x=w.map((I,T)=>T===w.length-1?nD(y[0],y[1]):I);Kd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Kd(m)&&!sw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;aa.includes(n.activeTool.type)?p=mw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=mw(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&&cw(m)?new rl(m,oD(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:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Qh.IMMEDIATELY:Qh.NEVER}},keyTest:(e,n)=>e.key===$d.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===$d.ESCAPE||e.key===$d.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>aD(Z,{type:"button",icon:o1,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 hw,isSomeElementSelected as sD,makeNextSelectedElementIds as lD,selectGroupsForSelectedElements as cD}from"@excalidraw/element";import{CaptureUpdateAction as pw}from"@excalidraw/element";import{KEYS as dD,isWritableElement as mD,updateActiveTool as uw}from"@excalidraw/common";var pD=(e,n)=>aa.includes(e.activeTool.type)?uw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):uw(e,{type:n.state.preferredSelectionTool.type}),uD=(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:hw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},hD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=pD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:hw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...cD({editingGroupId:uD(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:pw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:lD({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:pw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==dD.ESCAPE||mD(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||sD(o.scene.getNonDeletedElements(),n))});import{KEYS as om,THEME as ll}from"@excalidraw/common";import{CaptureUpdateAction as Dn}from"@excalidraw/element";import gD from"clsx";import{jsx as gw,jsxs as fD}from"react/jsx-runtime";var eg=({children:e,checked:n,onChange:t,className:o})=>fD("div",{className:gD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[gw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Xc}),gw("div",{className:"Checkbox-label",children:e})]});import{THEME as il}from"@excalidraw/common";import{jsx as al}from"react/jsx-runtime";var Ew=e=>{let n=e.title||(e.value===il.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return al(Z,{type:"icon",icon:e.value===il.LIGHT?fw.MOON:fw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===il.DARK?il.LIGHT:il.DARK),"data-testid":"toggle-dark-mode"})},fw={SUN:al("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:al("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:al("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:al("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 ED}from"react";import{focusNearestParent as bD,KEYS as xD}from"@excalidraw/common";import{jsx as bw,jsxs as yD}from"react/jsx-runtime";var xw=e=>{let{id:n}=Fe(),[t,o]=ED(e.value),r=a=>{e.ignoreFocus||bD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===xD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return yD("div",{className:"ProjectName",children:[bw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),bw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as wD,useEffect as vD,useRef as ID}from"react";import{jsx as Zd,jsxs as PD}from"react/jsx-runtime";var TD=5e3,SD=({progress:e})=>Zd("div",{className:"Toast__progress-bar",children:Zd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),CD=({message:e,onClose:n,closable:t=!1,duration:o=TD,style:r})=>{let i=ID(0),a=o!==1/0,s=wD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return vD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),PD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Zd("div",{className:"Toast__message",children:e}),t&&Zd(Z,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},jd=Object.assign(CD,{ProgressBar:SD});import{DEFAULT_EXPORT_PADDING as YD,DEFAULT_FILENAME as XD,IMAGE_MIME_TYPES as Sw,isFirefox as KD,MIME_TYPES as $D,cloneJSON as ZD,SVG_DOCUMENT_PREAMBLE as jD,arrayToMap as qD}from"@excalidraw/common";import{getNonDeletedElements as JD}from"@excalidraw/element";import{isFrameLikeElement as QD}from"@excalidraw/element";import{getElementsOverlappingFrame as eL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as kD,EXPORT_DATA_TYPES as sl,MIME_TYPES as gt,arrayToMap as MD,isMemberOf as AD,isPromiseLike as DD,EVENT as qd}from"@excalidraw/common";import{mutateElement as LD}from"@excalidraw/element";import{deepCopyElement as _D}from"@excalidraw/element";import{isFrameLikeElement as RD,isInitializedImageElement as ND}from"@excalidraw/element";import{getContainingFrame as yw}from"@excalidraw/element";var Xre="clipboard"in navigator&&"readText"in navigator.clipboard,Jd="clipboard"in navigator&&"writeText"in navigator.clipboard,cr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,BD=e=>!!([sl.excalidraw,sl.excalidrawClipboard,sl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ww=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(qd.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},FD=({elements:e,files:n})=>{let t=MD(e),o=new Set(e.filter(s=>RD(s))),r=!1,i=e.reduce((s,l)=>(ND(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:sl.excalidrawClipboard,elements:e.map(s=>{if(yw(s,t)&&!o.has(yw(s,t))){let l=_D(s);return LD(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Qd=async(e,n,t)=>{let o=FD({elements:e,files:n});await ko({[gt.excalidrawClipboard]:o,[gt.text]:o},t)};function vw(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(vw(t));return n}var OD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,gt.html),o=vw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Iw=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{[gt.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(AD(kD,o))try{if(o===gt.text||o===gt.html)e[o]=await(await t.getType(o)).text();else if(vx(o)){let r=await t.getType(o),i=Mx(r,o,void 0);e[o]=i}else throw new ku(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof ku?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},zD=async(e,n=!1)=>{try{let t=e.findByType(gt.html),o=!n&&t&&OD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(gt.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(gt.text)||"").trim()}}catch{return{type:"text",value:""}}},GD=function(e){return this.find(n=>n.type===e)||null},HD=function(e){return this.find(t=>t.type===e)?.value??null},UD=function(){return this.filter(e=>e.kind==="file")},tg=e=>{let n=ng(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),gt.text,gt.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}},WD=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}}),em=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(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===gt.html)try{let E=new DOMParser().parseFromString(u.value,gt.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===gt.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:WD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},Tw=e=>{let n;ng(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},Zr=async e=>{let n;ng(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 kx(o);return r=await Or(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(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:GD,getData:HD,getFiles:UD})},tm=async(e,n=!1)=>{let t=await zD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===sl.excalidrawClipboardWithAPI;if(BD(o))return{elements:o.elements,files:o.files,text:n?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},nm=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[gt.png]:e})])}catch(n){if(DD(e))await navigator.clipboard.write([new ClipboardItem({[gt.png]:await e})]);else throw n}},ko=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[gt.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===gt.text);if(Jd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!VD(o[1]))throw new Error("Error copying to clipboard.")},VD=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},ng=e=>e.type===qd.PASTE||e.type===qd.COPY||e.type===qd.CUT;var jr=(e,{selectedElementIds:n},t)=>{let o=JD(e),r=qD(o),i=t&&_e(o,{selectedElementIds:n}),a=null,s=i?de(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&QD(l)?(a=l,s=eL(o,l,r)):s.length>1&&(s=de(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:ZD(s)}},qr=async(e,n,t,o,{exportBackground:r,exportPadding:i=YD,viewBackgroundColor:a,name:s=t.name||XD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Br(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return Mu(m.then(p=>new Blob([jD+p.outerHTML],{type:$D.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Sw.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await ko(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Fc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=ks(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-Q34WHCF3.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Ts(n,t,o,"local")})))),Mu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Sw.png],fileHandle:l})}else if(e==="clipboard")try{let m=ks(d);await nm(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):KD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as vx,A as ux,B as Mu,C as Ss,D as Lc,E as Au,F as hx,G as gx,H as _c,I as Cs,J as Rc,K as Nc,L as Ps,M as Bc,N as fx,O as Ex,P as bx,Q as Fc,R as Br,S as _A,T as Fr,U as Ri,W as xx,Y as yx,Z as wx,_ as Oc,a as Su,aa as Ni,b as Kn,ba as ks,c as yo,ca as Ms,d as Nr,da as Ix,e as Di,ea as zc,f as Zn,fa as Tx,g as sx,ga as Sx,h as _e,ha as Cx,i as lx,ia as Du,j as de,ja as Px,k as Li,ka as kx,l as Xo,la as Mx,m as cx,ma as Or,n as Cu,o as dx,p as Is,q as mx,r as Dc,s as px,t as Pu,u as ku,v as wo,w as Ko,x as rn,y as Ts,z as _i}from"./chunk-J5DZGRBF.js";import{a as S}from"./chunk-2YEDAYNK.js";import{G as Tu}from"./chunk-KGIBYNMP.js";import{c as ax}from"./chunk-5XKZK2GL.js";import{b as ix,c as LA,d as v}from"./chunk-SRAX5OIU.js";import PK,{useCallback as kK,useContext as MK,useEffect as AK,useRef as DK,useState as LK}from"react";import{applyDarkModeFilter as aYe,DEFAULT_IMAGE_OPTIONS as Sn,DEFAULT_UI_OPTIONS as DA,getStrokeWidthByKey as sYe,isShallowEqual as _K}from"@excalidraw/common";import aM from"clsx";import sY from"lodash.throttle";import In,{useContext as Vo}from"react";import{flushSync as Gt}from"react-dom";import lY from"roughjs/bin/rough";import{nanoid as cY}from"nanoid";import{clamp as uc,pointFrom as oe,pointDistance as po,vector as sM,pointRotateRads as xb,vectorFromPoint as yb,vectorSubtract as lM,vectorDot as cM,vectorNormalize as dM}from"@excalidraw/math";import{CODES as Ar,shouldResizeFromCenter as mM,shouldMaintainAspectRatio as hc,shouldRotateWithDiscreteAngle as pM,isArrowKey as wb,KEYS as X,APP_NAME as dY,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as mY,DEFAULT_STROKE_STREAMLINE_PRECISE as pY,DEFAULT_TRANSFORM_HANDLE_SPACING as uY,DEFAULT_VERTICAL_ALIGN as uM,DRAGGING_THRESHOLD as hM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as hY,ELEMENT_TRANSLATE_AMOUNT as gM,EVENT as Q,FRAME_STYLE as zo,IMAGE_MIME_TYPES as gY,IMAGE_RENDER_TIMEOUT as fY,LINE_CONFIRM_THRESHOLD as vb,MIME_TYPES as uo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as EY,POINTER_BUTTON as Un,ROUNDNESS as tu,SCROLL_TIMEOUT as bY,TAP_TWICE_TIMEOUT as fM,TEXT_TO_CENTER_SNAP_THRESHOLD as xY,THEME as gc,TOUCH_CTX_MENU_TIMEOUT as yY,VERTICAL_ALIGN as wY,YOUTUBE_STATES as nu,ZOOM_STEP as vY,MIN_ZOOM as IY,POINTER_EVENTS as hs,TOOL_TYPE as Wn,supportsResizeObserver as TY,DEFAULT_COLLISION_THRESHOLD as EM,DEFAULT_TEXT_ALIGN as SY,ARROW_TYPE as Dr,DEFAULT_REDUCED_GLOBAL_ALPHA as CY,isLocalLink as PY,normalizeLink as ou,toValidURL as kY,getGridPoint as Mt,getLineHeight as bM,debounce as xM,distance as gs,getFontString as Ib,getNearestScrollableContainer as MY,isInputLike as yM,isToolIcon as AY,isWritableElement as fc,sceneCoordsToViewportCoords as ru,tupleToCoors as Tb,viewportCoordsToSceneCoords as Pe,wrapEvent as DY,updateObject as Sb,updateActiveTool as on,isTransparent as LY,muteFSAbortError as _Y,isTestEnv as dA,isDevEnv as mA,updateStable as Ec,addEventListener as we,normalizeEOL as RY,getDateTime as wM,isShallowEqual as vM,arrayToMap as bc,applyDarkModeFilter as NY,AppEventBus as BY,randomInteger as FY,CLASSES as Cb,Emitter as ho,MINIMUM_ARROW_SIZE as OY,DOUBLE_TAP_POSITION_THRESHOLD as IM,BIND_MODE_TIMEOUT as zY,invariant as go,getFeatureFlag as Go,createUserAgentDescriptor as pA,getFormFactor as GY,deriveStylesPanelMode as fu,isIOS as HY,isBrave as UY,isSafari as WY,loadDesktopUIModePreference as VY,setDesktopUIMode as YY,isSelectionLikeTool as iu,oneOf as TM,getStrokeWidthByKey as XY,getViewpointFlipSign as Vn}from"@excalidraw/common";import{getObservedAppState as KY,getCommonBounds as fs,getElementAbsoluteCoords as SM,bindOrUnbindBindingElements as CM,fixBindingsAfterDeletion as ZY,getHoveredElementForBinding as Lr,isBindingEnabled as au,updateBoundElements as su,LinearElementEditor as fe,newElementWith as fo,newFrameElement as $Y,newFreeDrawElement as jY,newEmbeddableElement as PM,newMagicFrameElement as qY,newIframeElement as JY,newArrowElement as QY,newElement as eX,newImageElement as tX,newLinearElement as nX,newTextElement as kM,refreshTextDimensions as oX,deepCopyElement as MM,duplicateElements as AM,hasBoundTextElement as DM,isArrowElement as xc,isBindingElement as Eo,isBindingElementType as rX,isBoundToContainer as LM,isFrameLikeElement as Tt,isImageElement as Yn,isEmbeddableElement as Ho,isInitializedImageElement as Si,isLinearElement as Ht,isLinearElementType as iX,isUsingAdaptiveRadius as aX,isIframeElement as Pb,isIframeLikeElement as yc,isTextBindableContainer as _M,isElbowArrow as Zt,isBindableElement as kb,isTextElement as $t,getNormalizedDimensions as sX,isElementCompletelyInViewport as lX,isElementInViewport as RM,isInvisiblySmallElement as NM,generateThumbHash as cX,getCornerRadius as dX,isPathALoop as BM,embeddableURLValidator as Mb,maybeParseEmbedSrc as mX,getEmbedLink as lu,getInitializedImageElements as pX,normalizeSVG as FM,updateImageCache as Ab,getBoundTextElement as Db,getContainerCenter as Lb,getContainerElement as OM,isValidTextContainer as zM,redrawTextBoundingBox as uX,hasBoundingBox as hX,getCommonFrameId as GM,getFrameChildren as _b,getFrameChildrenInsertionIndex as gX,isCursorInFrame as HM,addElementsToFrame as Rb,replaceAllElementsInFrame as fX,removeElementsFromFrame as EX,getElementsInResizingFrame as Nb,getElementsInNewFrame as bX,getContainingFrame as Bb,elementOverlapsWithFrame as xX,updateFrameMembershipOfSelectedElements as UM,isElementInFrame as WM,getFrameLikeTitle as yX,filterElementsEligibleAsFrameChildren as wX,hitElementBoundText as vX,hitElementBoundingBoxOnly as IX,hitElementItself as wc,getVisibleSceneBounds as TX,cropElement as SX,wrapText as CX,isElementLink as VM,isMeasureTextSupported as PX,normalizeText as kX,measureText as YM,getLineHeightInPx as XM,getApproxMinLineWidth as MX,getApproxMinLineHeight as AX,getMinTextElementWidth as DX,ShapeCache as Ci,getRenderOpacity as LX,editGroupForSelectedElement as _X,getElementsInGroup as Pi,getSelectedGroupIdForElement as RX,getSelectedGroupIds as NX,isElementInGroup as KM,isSelectedViaGroup as BX,selectGroupsForSelectedElements as Xn,syncInvalidIndices as uA,syncMovedIndices as ZM,excludeElementsInFramesFromSelection as FX,getSelectionStateForElements as $M,makeNextSelectedElementIds as Ae,getResizeOffsetXY as OX,getResizeArrowDirection as zX,transformElements as GX,getCursorForResizingElement as jM,getElementWithTransformHandleType as qM,getTransformHandleTypeFromCoords as JM,dragNewElement as QM,dragSelectedElements as HX,getDragOffsetXY as UX,Scene as eA,Store as WX,CaptureUpdateAction as jt,hitElementBoundingBox as VX,isLineElement as Fb,isSimpleArrow as Ob,StoreDelta as tA,positionElementsOnGrid as nA,calculateFixedPointForNonElbowArrowBinding as oA,bindOrUnbindBindingElement as YX,mutateElement as cu,getElementBounds as rA,doBoundsIntersect as XX,isPointInElement as iA,maxBindingDistance_simple as aA,convertToExcalidrawElements as KX,getSnapOutlineMidPoint as zb,handleFocusPointDrag as ZX,handleFocusPointHover as $X,handleFocusPointPointerDown as jX,handleFocusPointPointerUp as qX,maybeHandleArrowPointlikeDrag as du,getUncroppedWidthAndHeight as JX,getActiveTextElement as sA,isEligibleFrameChildType as QX,getBindingStrategyForDraggingBindingElementEndpoints as eK,isNonDeletedElement as mu}from"@excalidraw/element";import{KEYS as ch,MOBILE_ACTION_BUTTON_BG as KA,updateActiveTool as ZA}from"@excalidraw/common";import{getNonDeletedElements as id}from"@excalidraw/element";import{fixBindingsAfterDeletion as $A}from"@excalidraw/element";import{LinearElementEditor as C0}from"@excalidraw/element/linearElementEditor";import{newElementWith as rd}from"@excalidraw/element";import{getContainerElement as P0}from"@excalidraw/element";import{isBoundToContainer as nd,isElbowArrow as jA,isFrameLikeElement as qA}from"@excalidraw/element";import{getFrameChildren as JA}from"@excalidraw/element";import{getElementsInGroup as dh,selectGroupsForSelectedElements as QA}from"@excalidraw/element";import{CaptureUpdateAction as od}from"@excalidraw/element";import{isDevEnv as FA}from"@excalidraw/common";import{atom as et,createStore as RA}from"jotai";import{createIsolation as NA}from"jotai-scope";var Ax=NA();var{useAtom:Ye,useSetAtom:Dx,useAtomValue:Lx,useStore:zK}=Ax,_x=Ax.Provider,bt=RA();var BA=ix({"./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-2ZA2LKRK.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 OA=85,$n={code:"en",label:"English"},Fi=[$n,...[{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=>ax[e.code]>=OA).sort((e,n)=>e.label>n.label?1:-1)],Hc="__test__";FA()&&Fi.unshift({code:Hc,label:"test language"},{code:`${Hc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Bi=$n,Gc={},Uc=async e=>{if(Bi=e,document.documentElement.dir=Bi.rtl?"rtl":"ltr",document.documentElement.lang=Bi.code,e.code.startsWith(Hc))Gc={};else try{Gc=await BA(`./locales/${Bi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Gc=Tu}bt.set(Nx,e.code)},jn=()=>Bi,Rx=(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(Bi.code.startsWith(Hc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Rx(Gc,o)||Rx(Tu,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},Nx=et($n.code),Re=()=>{let e=Lx(Nx);return{t:f,langCode:e}};import zA from"clsx";import tt from"react";import{THEME as GA}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var kn=e=>"var(--icon-fill-color)",Bx=e=>e===GA.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:zA({"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"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},_t={width:40,height:20},eZ=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),tZ=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),Fx=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),As=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),Ox=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),zx=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),Lu=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),vo=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"})})]}),le),Zo=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"})]}),le),Gx=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}),Hx=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"}),Ux=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"}),Wx=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"}),nZ=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"}),Wc=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}),Oi=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}),zi=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),Gi=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),Hi=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),Vc=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),$o=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),Vx=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),qn=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"})]}),le),Mn=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),Yx=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),zr=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"})]}),le),Yc=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),_u=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Ru=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),Xx=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),Gr=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),jo=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"})]}),le),Ds=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"})]}),le),Ls=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),_s=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}),Kx=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),Rs=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),Ui=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),Zx=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),oZ=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),$x=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),jx=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"})]}),le),qx=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),Xc=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ns=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"})]}),le),Jx=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}),Qx=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}),Kc=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),rZ=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}),iZ=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"),Nu=["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"],Jn=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Nu.map(e=>h("path",{d:e},e))]}),H),e1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),t1=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),n1=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}),aZ=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}),sZ=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}),o1=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"),lZ=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"),Bu=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),Fu=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),r1=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}),i1=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),cZ=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"),dZ=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}),mZ=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),pZ=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}),uZ=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=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"})]}),s1=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"})]}),Ou=A(s1,H),zu=A(s1,{...H,style:{transform:"rotate(180deg)"}}),Gu=A(a1,H),Hu=A(a1,{...H,style:{transform:"rotate(180deg)"}}),Uu=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"})})})]}),le),Wu=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"})})})]}),le),Vu=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"})})})]}),le),Yu=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"})})})]}),le),l1=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"})})})]}),le),c1=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"})})})]}),le),Xu=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"})]}),le),Ku=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"})]}),le),Zc=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),hZ=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"),gZ=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"),an=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"})})})]}),le),fZ=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}),EZ=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}),bZ=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}),Zu=tt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:kn(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:kn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:kn(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:kn(e),strokeWidth:"2"}),R("g",{fill:Bx(e),stroke:kn(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})),$u=tt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:kn(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:kn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:kn(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:kn(e),strokeWidth:"2"}),R("g",{fill:Bx(e),stroke:kn(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})),d1=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),m1=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"})})]}),le),p1=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"})})})]}),le),u1=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"})})})]}),{...le,fill:"currentColor"}),ju=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),h1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),g1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),xZ=tt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:kn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),f1=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),E1=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),b1=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),x1=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),y1=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),qu=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),Ju=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),w1=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"})]}),le),v1=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),I1=tt.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"})]}),_t)),T1=tt.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"})}),_t)),S1=tt.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"})]}),_t)),C1=tt.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"})]}),_t)),P1=tt.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"})]}),_t)),k1=tt.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"})]}),_t)),M1=tt.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"})]}),_t)),A1=tt.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"})]}),_t)),D1=tt.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"})}),_t)),L1=tt.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"})}),_t)),_1=tt.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"})}),_t)),R1=tt.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"})}),_t)),N1=tt.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"})}),_t)),B1=tt.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"})]}),_t)),F1=tt.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"})]}),_t)),O1=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"})})})]}),le),z1=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"})})})]}),le),G1=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"})})})]}),le),H1=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"})}),le),Hr=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),U1=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),Bs=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"})})}),le),HA=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),$c=HA,W1=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),V1=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),Y1=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),X1=tt.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)),K1=tt.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)),Z1=tt.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)),jc=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),yZ=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}),wZ=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"})),$1=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),Qu=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),j1=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),q1=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),J1=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),vZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),IZ=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),Q1=A(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),e0=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),t0=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),n0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),o0=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),eh=["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"],Wi=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),eh.map(e=>h("path",{d:e},e))]}),H),Qn=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),TZ=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),SZ=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),CZ=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"})]}),le),Ur=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),eo=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),PZ=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),kZ=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),MZ=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),AZ=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),Wr=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),r0=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),DZ=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),LZ=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),to=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),_Z=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),RZ=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),i0=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),a0=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),NZ=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),s0=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),l0=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),c0=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),d0=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),th=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),qc=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),m0=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),p0=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),qo=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),BZ=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),u0=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}),FZ=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),OZ=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),h0=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),g0=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),Jo=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),Qo=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),er=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Jc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),f0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),E0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),nh=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),b0=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),oh=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),rh=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),zZ=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),ih=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"})})),x0=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),y0=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),ah=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),GZ=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),HZ=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),UZ=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),WZ=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),Qc=h("div",{style:{width:"1rem",height:"1rem"}}),w0=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),v0=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),I0=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 T0 from"clsx";import lh,{useEffect as VA,useRef as S0,useState as YA}from"react";import{isPromiseLike as XA}from"@excalidraw/common";import UA from"react";import{jsx as sh}from"react/jsx-runtime";var WA=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(UA.useRef(Date.now()).current%1600);return sh("div",{className:`Spinner ${o}`,children:sh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:sh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},Io=WA;import{jsx as Fs,jsxs as ed}from"react/jsx-runtime";var $=lh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=lh.useRef(null);lh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=YA(!1),c=S0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(XA(u))try{l(!0),await u}catch(E){if(E instanceof Dc)console.warn(E);else throw E}finally{c.current&&l(!1)}};VA(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=S0(null);return o.type==="button"||o.type==="icon"?ed("button",{className:T0("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:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&ed("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Fs(Io,{})]}),o.showAriaLabel&&ed("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Fs(Io,{})]}),o.children]}):Fs("button",{className:T0("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:ed("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var td=[],O=e=>(td=td.concat(e),e);import{jsx as t3}from"react/jsx-runtime";var e3=(e,n,t)=>{let o=new Set(de(e.filter(d=>qA(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=JA(e,d);for(let p of m)if(!a.has(p.id)){if(nd(p)){let u=P0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=nd(d)?P0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&jA(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),rd(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,nd(d)||(r[d.id]=!0),rd(d,{frameId:null})):nd(d)&&n.selectedElementIds[d.containerId]?rd(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=dh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=dh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...QA({selectedElementIds:r,editingGroupId:c},id(l),n,null)}}},k0=(e,n)=>{if(e.editingGroupId){let t=dh(id(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Os=O({name:"deleteSelectedElements",label:"labels.delete",icon:Gr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=C0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?rd(p,{isDeleted:!0}):p),m=k0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:od.IMMEDIATELY}}return C0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:od.IMMEDIATELY}}let{elements:r,appState:i}=e3(e,n,o);return $A(r,r.filter(a=>a.isDeleted)),i=k0(i,r),{elements:r,appState:{...i,activeTool:ZA(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:_e(id(e),n)?od.IMMEDIATELY:od.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===ch.BACKSPACE||e.key===ch.DELETE)&&!e[ch.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=dt()==="mobile";return t3($,{type:"button",icon:Gr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!_e(id(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?KA:{}}})}});import{KEYS as Vi,CODES as Yi,isDarwin as ad}from"@excalidraw/common";import{moveOneLeft as n3,moveOneRight as o3,moveAllLeft as r3,moveAllRight as i3}from"@excalidraw/element";import{CaptureUpdateAction as sd}from"@excalidraw/element";import{isDarwin as M0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,M0?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,M0?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 ld}from"react/jsx-runtime";var mh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:zu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:n3(e,n,o.scene),appState:n,captureUpdate:sd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:zu})}),ph=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Ou,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:o3(e,n,o.scene),appState:n,captureUpdate:sd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Ou})}),uh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Hu,trackEvent:{category:"element"},perform:(e,n)=>({elements:r3(e,n),appState:n,captureUpdate:sd.IMMEDIATELY}),keyTest:e=>ad?e[Vi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_LEFT:e[Vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${ad?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Hu})}),hh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Gu,trackEvent:{category:"element"},perform:(e,n)=>({elements:i3(e,n),appState:n,captureUpdate:sd.IMMEDIATELY}),keyTest:e=>ad?e[Vi.CTRL_OR_CMD]&&e.altKey&&e.code===Yi.BRACKET_RIGHT:e[Vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Yi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>ld("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${ad?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Gu})});import{getNonDeletedElements as a3}from"@excalidraw/element";import{LinearElementEditor as s3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as l3,isTextElement as c3}from"@excalidraw/element";import{arrayToMap as d3,KEYS as A0}from"@excalidraw/common";import{selectGroupsForSelectedElements as m3}from"@excalidraw/element";import{CaptureUpdateAction as p3}from"@excalidraw/element";var gh=O({name:"selectAll",label:"labels.selectAll",icon:s0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(c3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...m3({editingGroupId:null,selectedElementIds:r},a3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&l3(e[0])?new s3(e[0],d3(e)):null},captureUpdate:p3.IMMEDIATELY}},keyTest:e=>e[A0.CTRL_OR_CMD]&&e.key===A0.A});import{DEFAULT_GRID_SIZE as D0,KEYS as L0,MOBILE_ACTION_BUTTON_BG as u3,arrayToMap as _0}from"@excalidraw/common";import{getNonDeletedElements as R0}from"@excalidraw/element";import{LinearElementEditor as h3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as g3,getSelectionStateForElements as f3}from"@excalidraw/element";import{syncMovedIndices as E3}from"@excalidraw/element";import{duplicateElements as b3}from"@excalidraw/element";import{CaptureUpdateAction as N0}from"@excalidraw/element";import{jsx as x3}from"react/jsx-runtime";var fh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ds,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=h3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:N0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=b3({type:"in-place",elements:e,idsOfElementsToDuplicate:_0(g3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+D0/2,y:a.y+D0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:E3(i,_0(r)),appState:{...n,...f3(r,R0(i),n)},captureUpdate:N0.IMMEDIATELY}},keyTest:e=>e[L0.CTRL_OR_CMD]&&e.key===L0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=dt()==="mobile";return x3($,{type:"button",icon:Ds,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!_e(R0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?u3:{}}})}});import{pointFrom as J4}from"@excalidraw/math";import{useEffect as Fh,useMemo as Gh,useRef as Oh,useState as Q4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as e6,COLOR_PALETTE as t6,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Uy,DEFAULT_ELEMENT_BACKGROUND_PICKS as n6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as o6,DEFAULT_ELEMENT_STROKE_PICKS as r6,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as i6,DEFAULT_FONT_SIZE as a6,FONT_FAMILY as s6,ROUNDNESS as Md,STROKE_WIDTH_KEYS as l6,VERTICAL_ALIGN as Pd,KEYS as ta,randomInteger as c6,arrayToMap as Hh,getFontFamilyString as d6,getLineHeight as m6,isTransparent as p6,getStrokeWidthByKey as Wy,reduceToCommonValue as u6,invariant as Dd,FONT_SIZES as kd}from"@excalidraw/common";import{canBecomePolygon as h6,getNonDeletedElements as Vy,isNonDeletedElement as g6}from"@excalidraw/element";import{bindBindingElement as Fy,calculateFixedPointForElbowArrowBinding as Oy,updateBoundElements as f6}from"@excalidraw/element";import{LinearElementEditor as Yr}from"@excalidraw/element/linearElementEditor";import{newElementWith as at}from"@excalidraw/element";import{getArrowheadForPicker as zy}from"@excalidraw/element";import{getBoundTextElement as lr,redrawTextBoundingBox as qs}from"@excalidraw/element";import{isArrowElement as Ad,isBoundToContainer as E6,isElbowArrow as Yy,isLinearElement as zh,isLineElement as Gy,isTextElement as Wt,isUsingAdaptiveRadius as b6}from"@excalidraw/element";import{hasStrokeColor as x6}from"@excalidraw/element";import{updateElbowArrowPoints as y6,CaptureUpdateAction as nt,toggleLinePolygonState as w6}from"@excalidraw/element";import{deriveStylesPanelMode as v6}from"@excalidraw/common";import{isDevEnv as y3}from"@excalidraw/common";var w3=new Set(["command_palette","export"]),He=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!w3.has(e)||y3())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 S3 from"clsx";import v3 from"clsx";import{forwardRef as I3}from"react";import{jsx as T3}from"react/jsx-runtime";var B0=I3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return T3("button",{type:"button",ref:n,title:t,"data-testid":r,className:v3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as P3,jsx as Eh,jsxs as C3}from"react/jsx-runtime";var qt=e=>Eh(P3,{children:e.options.map(n=>e.type==="button"?Eh(B0,{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):C3("label",{className:S3({active:e.value===n.value}),title:n.text,children:[Eh("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 gy}from"radix-ui";import fy from"clsx";import{memo as Z5,useRef as Ey,useEffect as $5}from"react";import{applyDarkModeFilter as j5,COLOR_OUTLINE_CONTRAST_THRESHOLD as uy,COLOR_PALETTE as by,DEFAULT_ELEMENT_BACKGROUND_PICKS as q5,DEFAULT_ELEMENT_STROKE_PICKS as J5,isColorDark as hy,isWritableElement as Q5,THEME as e4}from"@excalidraw/common";import{jsx as k3}from"react/jsx-runtime";var cd=()=>k3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as R3,useLayoutEffect as N3,useRef as B3}from"react";import{createPortal as F3}from"react-dom";import{EVENT as tr,isColorDark as O3,KEYS as z3,MIME_TYPES as G3,THEME as H3,removeDarkModeFilter as U3,rgbToHex as W3}from"@excalidraw/common";import F0 from"react";var bh=F0.createContext(null),xe=()=>F0.useContext(bh);import{useState as M3,useLayoutEffect as O0}from"react";import{THEME as A3}from"@excalidraw/common";var dd=e=>{let[n,t]=M3(null),o=Ee(),{theme:r}=xe(),{container:i}=Fe();return O0(()=>{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===A3.DARK))},[n,r,o.formFactor,e?.className]),O0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as D3}from"react";import{EVENT as md}from"@excalidraw/common";function Xi(e,n,t){D3(()=>{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(md.POINTER_DOWN,o),document.addEventListener(md.TOUCH_START,o),()=>{document.removeEventListener(md.POINTER_DOWN,o),document.removeEventListener(md.TOUCH_START,o)}},[e,n,t])}import{useRef as L3}from"react";var Ki=e=>{let n=L3(e);return Object.assign(n.current,e),n.current};import{clamp as _3}from"@excalidraw/math";var z0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return _3(r,0,Math.max(0,t-n))},pd=({cursor:e,element:n,container:t,gap:o})=>({left:z0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:z0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as Y3}from"react/jsx-runtime";var G0=eh.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),V3=`url(data:${G3.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">${G0}</g><g stroke="#1b1b1f" stroke-width="1.25">${G0}</g></svg>`)}) 2 21, auto`,Ut=et(null),H0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=dd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=Zi(),s=St(),l=de(a,i),c=Ki({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Fe();N3(()=>{if(r)return r.style.cursor=V3,()=>{r.style.cursor=""}},[r]),R3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return W3(D[0],D[1],D[2])},b=P=>i.theme===H3.DARK?U3(P):P,w=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=pd({cursor:{x:P,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:M});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",O3(L)?"#fff":"#222")},y=()=>{c.onCancel()},x=(P,M)=>{c.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===z3.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(tr.KEYDOWN,C),r.addEventListener(tr.POINTER_DOWN,I),r.addEventListener(tr.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(tr.BLUR,y),()=>{u=!1,r.removeEventListener(tr.KEYDOWN,C),r.removeEventListener(tr.POINTER_DOWN,I),r.removeEventListener(tr.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(tr.BLUR,y)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=B3(null);return Xi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?F3(Y3("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as xh}from"radix-ui";import $3 from"clsx";import j3 from"react";import{isInteractive as q3}from"@excalidraw/common";import X3 from"react";import K3 from"clsx";import{jsx as Z3}from"react/jsx-runtime";var Xe=X3.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>Z3("div",{className:K3("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as yh,jsxs as J3}from"react/jsx-runtime";var To=j3.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=Ee(),p=m.formFactor==="phone"&&!m.isLandscape;return yh(xh.Portal,{container:n,children:J3(xh.Content,{ref:d,className:$3("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:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!q3(document.activeElement)&&n.focus(),r()},children:[yh(Xe,{padding:3,style:o,children:t}),yh(xh.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 Q3,useCallback as wh}from"react";var ud=()=>document.querySelector(".excalidraw-wysiwyg"),hd=()=>{let e=ud();return e?{start:e.selectionStart,end:e.selectionEnd}:null},zs=e=>{setTimeout(()=>{let n=ud();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Gs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?hd():null;e(),n&&t&&zs(r)},U0=()=>{let[e,n]=Q3(null),t=wh(()=>{let i=hd();n(i)},[]),o=wh(()=>{setTimeout(()=>{let i=ud();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}},W0=(e=100)=>{let n=ud();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import Y0 from"clsx";import{useCallback as n5,useEffect as Ih,useRef as X0,useState as K0}from"react";import{KEYS as Th,normalizeInputColor as o5}from"@excalidraw/common";import{isTransparent as e5,MAX_CUSTOM_COLORS_USED_IN_CANVAS as t5}from"@excalidraw/common";var nr=({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},Hs=[["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),V0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!e5(s)&&vh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,t5)},sn=et(null);import{Fragment as r5,jsx as Us,jsxs as Sh}from"react/jsx-runtime";var Z0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=Ee(),[a,s]=K0(e),[l,c]=K0(null),[d,m]=Ye(sn);Ih(()=>{s(e)},[e]);let p=n5(w=>{let y=w.toLowerCase().trim(),x=o5(y);x?(n(x),c(null)):y.length===0?c(null):/^#?[0-9a-f]+$/.test(y)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(y)},[n]),u=X0(null),E=X0(null);Ih(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Ye(Ut);return Ih(()=>()=>{b(null)},[b]),Sh("div",{className:"color-picker__input-label-container",children:[Sh("div",{className:Y0("color-picker__input-label",{"has-error":l}),children:[Us("div",{className:"color-picker__input-hash",children:"#"}),Us("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:w=>{p(w.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:w=>{w.key!==Th.TAB&&(w.key===Th.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Sh(r5,{children:[Us("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Us("div",{ref:E,className:Y0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Th.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Wi})]})]}),l&&Us("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import kh,{useEffect as Mh,useImperativeHandle as B5,useState as F5}from"react";import{EVENT as ly}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as O5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as z5,KEYS as G5}from"@excalidraw/common";import u5 from"clsx";import{useEffect as h5,useRef as g5}from"react";import{applyDarkModeFilter as f5,THEME as E5}from"@excalidraw/common";import{isColorDark as i5}from"@excalidraw/common";import{jsxs as s5}from"react/jsx-runtime";var a5=({color:e,keyLabel:n,isShade:t=!1})=>s5("div",{className:"color-picker__button__hotkey-label",style:{color:i5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),$i=a5;import{createContext as l5,useContext as c5,useEffect as d5,useMemo as $0,useRef as j0,useState as m5}from"react";import{colorToHex as q0,isTransparent as p5}from"@excalidraw/common";var Vr="excalidraw-color-dnd-ghost",J0="excalidraw-color-dnd-active",Q0=10,ey=100,ty=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=q0(e);return t!==null&&t===q0(n)},Ch=l5(null),ln=()=>c5(Ch),ny=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=m5(null),i=j0(null),a=j0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=$0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((W,G)=>Number(W.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(W=>W.getBoundingClientRect());let[F,Y]=l.slotRects;l.slotSpan=Y?Y.left-F.left:F.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,F,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(F,Y))},u=(k,L)=>{if(!l)return;let{sourceRect:F,sourceEl:Y,color:z}=l,U=document.createElement("div");U.className=Vr;let W=document.createElement("div");if(W.className=`${Vr}__swatch`,p5(z))W.classList.add("is-transparent");else{let G=getComputedStyle(Y).backgroundColor;W.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(W),document.body.appendChild(U),l.ghost=U,l.ghostW=F.width,l.ghostH=F.height,U.style.width=`${F.width}px`,U.style.height=`${F.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Vr}--lifted`)}),document.body.classList.add(J0),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:Y}=l,z=null,U=null;if(k>=F.left&&k<=F.right&&L>=F.top&&L<=F.bottom){let W=0,G=1/0;if(Y.forEach((ie,me)=>{let B=Math.abs(k-(ie.left+ie.width/2));B<G&&(G=B,W=me)}),l.origin.kind==="swatch"){let ie=a.current.picks.findIndex(me=>ty(me,l.color));ie!==-1?U=ie:z=W}else z=W}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:W}=l;W&&(W.classList.toggle(`${Vr}--over`,z!==null),W.classList.toggle(`${Vr}--blocked`,U!==null)),c()}if(z!==null){let W=l.slotRects[z];p(W.width,W.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Vr}--dropping`);let F=k.rect;F&&(L.style.width=`${F.width}px`,L.style.height=`${F.height}px`,L.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{L.classList.add(`${Vr}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of L)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of L)F.style.transition=""},w=()=>{let k=L=>{L.preventDefault(),L.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",D,!0)},x=()=>{y(),document.body.classList.remove(J0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<Q0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<ey){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Q0&&T(l.lastX,l.lastY))},ey-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),w();let{overIndex:L,origin:F,color:Y,slotRects:z}=l,{picks:U,onPicksChange:W}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>ty(G,Y))){let G=[...U];G[L]=Y,W(G)}}else if(F.index!==L){let G=[...U],[ie]=G.splice(F.index,1);G.splice(L,0,ie),W(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},M=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,F)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:F,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",D,!0))},destroy:()=>I(!1)}},[]);return d5(()=>()=>s.destroy(),[s]),$0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Ph,jsxs as b5}from"react/jsx-runtime";var oy=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Ye(sn),s=ln(),l=g5(null);return h5(()=>{l.current&&l.current.focus()},[t,i]),Ph("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=f5(c,e===E5.DARK);return b5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:u5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Ph("div",{className:"color-picker__button-outline"}),Ph($i,{color:m,keyLabel:d+1})]},d)})})};import x5 from"clsx";import{useEffect as y5,useRef as w5}from"react";import{applyDarkModeFilter as v5,isColorDark as I5,THEME as T5}from"@excalidraw/common";import{jsx as gd,jsxs as C5}from"react/jsx-runtime";var S5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=nr({color:t,palette:n}),[l,c]=Ye(sn),d=ln(),m=w5(null);return y5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),gd("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 gd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Hs[E],w=v5(g,e===T5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return C5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:x5("color-picker__button color-picker__button--large",{"has-outline":!I5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.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:[gd("div",{className:"color-picker__button-outline"}),i&&gd($i,{color:w,keyLabel:b})]},p)})})},ry=S5;import{jsx as k5}from"react/jsx-runtime";var P5=({children:e})=>k5("div",{className:"color-picker__heading",children:e}),ji=P5;import M5 from"clsx";import{useEffect as A5,useRef as D5}from"react";import{applyDarkModeFilter as L5,THEME as _5}from"@excalidraw/common";import{jsx as Ws,jsxs as iy}from"react/jsx-runtime";var ay=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=nr({color:n||"transparent",palette:o}),[a,s]=Ye(sn),l=ln(),c=D5(null);if(A5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Ws("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=L5(u,e===_5.DARK);return iy("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:M5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Ws("div",{className:"color-picker__button-outline"}),r&&Ws($i,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return iy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ws("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ws("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 qi,COLOR_PALETTE as R5,KEYS as Vs}from"@excalidraw/common";var fd=(e,n,t)=>{let o=Math.ceil(t/qi);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+qi;return r>=t?n%qi:r}case"ArrowUp":{let r=n-qi,i=r<0?qi*o+r:r;return i>=t?void 0:i}}},N5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.colorName][l]),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(Hs.includes(e.key)){let l=Hs.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},sy=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Vs.CTRL_OR_CMD])return!1;if(e.key===Vs.ESCAPE)return d(e),!0;if(e.key===Vs.ALT)return c(!0),!0;if(e.key===Vs.I)return c(),!0;let p=nr({color:o,palette:t});if(e.key===Vs.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(R5.black)),e.preventDefault(),e.stopPropagation(),!0}if(N5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=fd(e.key,u,qi);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=fd(e.key,g,E.length),w=0;for(;b!==void 0&&w++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[l]:y;if(!m?.includes(x))break;b=fd(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=fd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as So,jsxs as Ed}from"react/jsx-runtime";var cy=kh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=kh.useState(()=>o==="canvasBackground"?[]:V0(r,o,i)),[b,w]=Ye(sn),y=ln(),x=nr({color:n,palette:i});Mh(()=>{if(!b){let P=!!n&&vh({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]=F5(x?.shade??(o==="elementBackground"?O5:z5));Mh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===G5.ALT&&c(!1)};return document.addEventListener(ly.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ly.KEYUP,P,{capture:!0})}},[x,c]);let C=kh.useRef(null);return B5(u,()=>C.current),Mh(()=>{C?.current?.focus()},[]),So("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Ed("div",{ref:C,onKeyDown:P=>{sy({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&So("div",{className:"color-picker__title",children:E}),!!g.length&&Ed("div",{children:[So(ji,{children:f("colorPicker.mostUsedCustomColors")}),So(oy,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),Ed("div",{children:[So(ji,{children:f("colorPicker.colors")}),So(ry,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),Ed("div",{children:[So(ji,{children:f("colorPicker.shades")}),So(ay,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&So("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import dy from"clsx";import{ContextMenu as Ys}from"radix-ui";import{applyDarkModeFilter as H5,COLOR_OUTLINE_CONTRAST_THRESHOLD as U5,DEFAULT_CANVAS_BACKGROUND_PICKS as W5,DEFAULT_ELEMENT_BACKGROUND_PICKS as V5,DEFAULT_ELEMENT_STROKE_PICKS as Y5,isColorDark as X5,THEME as K5}from"@excalidraw/common";import{jsx as or,jsxs as my}from"react/jsx-runtime";var py=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=Fe(),d;if(t==="elementStroke"&&(d=Y5),t==="elementBackground"&&(d=V5),t==="canvasBackground"&&(d=W5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=my("div",{className:dy("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&or("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:or("rect",{})}),d.map((u,E)=>{let g=m(E),b=H5(u,e===K5.DARK);return or("button",{className:dy("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!X5(u,U5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?w=>s.startPickDrag(w,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:or("div",{className:"color-picker__button-outline"})},u)})]});return i?my(Ys.Root,{children:[or(Ys.Trigger,{asChild:!0,children:p}),or(Ys.Portal,{container:c,children:or(Ys.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:or(Ys.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as bd}from"react/jsx-runtime";var t4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=by,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Fe(),m=dt(),p=m!=="full",u=m==="mobile",[,E]=Ye(sn),[g,b]=Ye(Ut),w=bd("div",{children:[cn(ji,{children:f("colorPicker.hexCode")}),cn(Z0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=Ey(null),x=()=>{y.current?.focus()};return cn(To,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}Q5(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:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?cn(cy,{ref:y,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?hd():null;t(I),l.editingTextElement&&T&&zs(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})},n4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",o4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=dt(),l=s!=="full",c=s==="mobile",d=ln(),m=n?j5(n,o===e4.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&W0(),i()};return bd(gy.Trigger,{type:"button",className:fy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!hy(n,uy),"compact-sizing":l,"mobile-border":c}),"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:d?u=>d.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&e1}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&hy(m,uy)?"#fff":"#111"},children:y0})})]})},r4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=by,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=Ey(l.openPopup);$5(()=>{m.current=l.openPopup},[l.openPopup]);let u=dt()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?J5:q5),w=ny({enabled:E,picks:b,onPicksChange:y=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:y}})}});return cn(Ch.Provider,{value:E?w:null,children:bd("div",{role:"dialog","aria-modal":"true",className:fy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(py,{theme:l.theme,activeColor:n,onChange:y=>{t(y),n4(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&cn(cd,{}),bd(gy.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(o4,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&cn(t4,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},i4=(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,Ji=Z5(r4,i4);import{Popover as _4}from"radix-ui";import R4 from"clsx";import N4,{useCallback as B4,useMemo as F4}from"react";import{FONT_FAMILY as _h}from"@excalidraw/common";import I4,{useMemo as ar,useState as T4,useRef as vy,useEffect as Iy,useCallback as Ty}from"react";import{arrayToList as S4,debounce as C4,FONT_FAMILY as sr,getFontFamilyString as P4}from"@excalidraw/common";import a4 from"clsx";import s4 from"react";import{jsx as l4,jsxs as c4}from"react/jsx-runtime";var xd=s4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>c4("div",{className:a4("QuickSearch__wrapper",e),children:[to,l4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import d4 from"clsx";import{Children as m4}from"react";import{jsx as xy}from"react/jsx-runtime";var yd=({className:e,placeholder:n,children:t})=>{let o=!m4.count(t);return xy("div",{className:d4("ScrollableList__wrapper",e),role:"menu",children:o?xy("div",{className:"empty",children:n}):t})};import{jsx as p4,jsxs as u4}from"react/jsx-runtime";var yy=({children:e,className:n="",style:t,title:o})=>u4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&p4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Xs=yy;yy.displayName="DropdownMenuGroup";import{THEME as w4}from"@excalidraw/common";import{DropdownMenu as v4}from"radix-ui";import h4,{useContext as g4}from"react";import{composeEventHandlers as f4}from"@excalidraw/common";var Ah=h4.createContext({}),rr=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),wd=e=>{let n=g4(Ah);return f4(e,t=>{n.onSelect?.(t)})};import{jsx as E4}from"react/jsx-runtime";var Ks=({children:e,...n})=>E4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as x4,jsx as Zs,jsxs as y4}from"react/jsx-runtime";var b4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=Ee();return y4(x4,{children:[n&&Zs("div",{className:"dropdown-menu-item__icon",children:n}),Zs("div",{style:e,className:"dropdown-menu-item__text",children:Zs(Ks,{children:o})}),r&&Zs("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Zs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ir=b4;import{jsx as vd}from"react/jsx-runtime";var Dh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=wd(s);return vd(v4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:vd("button",{...l,value:t,className:rr(i,a),title:l.title??l["aria-label"],children:vd(ir,{icon:e,shortcut:r,badge:n,children:o})})})};Dh.displayName="DropdownMenuItem";var Qi={GREEN:"green",RED:"red",BLUE:"blue"},Id=({type:e=Qi.BLUE,children:n})=>{let{theme:t}=no(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===w4.LIGHT?"1.5px solid white":"none"};switch(e){case Qi.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Qi.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Qi.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return vd("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Id.displayName="DropdownMenuItemBadge";Dh.Badge=Id;var Jt=Dh;import{KEYS as ea}from"@excalidraw/common";var wy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[ea.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ea.F)return n.current?.focus(),!0;if(e.key===ea.ESCAPE)return r(),!0;if(e.key===ea.ENTER)return t?.value&&i(t.value),!0;if(e.key===ea.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===ea.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as Co,jsxs as A4}from"react/jsx-runtime";var k4=e=>{switch(e){case sr.Excalifont:case sr.Virgil:return qn;case sr.Nunito:case sr.Helvetica:return Bs;case sr["Lilita One"]:return U1;case sr["Comic Shanns"]:case sr.Cascadia:return $c;default:return Bs}},M4=(e,n)=>Object.entries(sr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Sy=I4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Fe(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=An(),m=dt(),[p,u]=T4(""),E=vy(null),g=ar(()=>Array.from(wo.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let Y={value:k,icon:k4(k),text:M4(k,F)};return L.deprecated&&Object.assign(Y,{deprecated:L.deprecated,badge:{type:Qi.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=ar(()=>new Set(c.getSceneFamilies()),[e]),w=ar(()=>g.filter(k=>b.has(k.value)),[g,b]),y=ar(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=ar(()=>S4([...w,...y].filter(k=>k.text?.toLowerCase().includes(p))),[w,y,p]),I=ar(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=Ty(k=>{let L=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(L={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&L&&(F.focus(),F.selectionStart=L.start,F.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=Ty(k=>{wy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);Iy(()=>(i(),()=>{a()}),[]);let P=ar(()=>x.filter(k=>b.has(k.value)),[x,b]),M=ar(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=vy(null),Y=k.value===I?.value,z=k.value===e;return Iy(()=>{Y&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,L]),Co("button",{ref:F,type:"button",value:k.value,className:rr("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:Co(ir,{icon:k.icon,badge:k.badge&&Co(Id,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:P4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(Co(Xs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>Co(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(Co(Xs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>Co(D,{font:k,order:L+P.length},k.value))},"group_2")),A4(To,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&Co(xd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:C4(u,20)}),Co(yd,{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 D4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as L4}from"@excalidraw/common";import{jsx as Lh}from"react/jsx-runtime";var Cy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ue(),r=t?{...L4,width:"2rem",height:"2rem"}:{};return Lh(D4.Trigger,{asChild:!0,children:Lh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Lh($,{type:"toggle",icon:Mn,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 $s,jsxs as Py}from"react/jsx-runtime";var ky=[{value:_h.Excalifont,icon:qn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:_h.Nunito,icon:Bs,text:f("labels.normal"),testId:"font-family-normal"},{value:_h["Comic Shanns"],icon:$c,text:f("labels.code"),testId:"font-family-code"}],fte=new Set(ky.map(e=>e.value));var My=N4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=F4(()=>ky,[]),c=B4(d=>{d&&o(d)},[o]);return Py("div",{role:"dialog","aria-modal":"true",className:R4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&$s("div",{className:"buttonList",children:$s(qt,{type:"button",options:l,value:n,onClick:c})}),!s&&$s(cd,{}),Py(_4.Root,{open:e,onOpenChange:a,children:[$s(Cy,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&$s(Sy,{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 Rh}from"radix-ui";import H4 from"clsx";import _y,{useEffect as U4,useMemo as W4}from"react";import{isArrowKey as V4,KEYS as Po}from"@excalidraw/common";import{jsx as O4}from"react/jsx-runtime";var Td=({className:e,icon:n,size:t="1em"})=>O4("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 G4,jsx as Ay,jsxs as Dy}from"react/jsx-runtime";var z4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Dy(G4,{children:[Dy("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Ay(Td,{icon:n?f0:Jc})]}),n&&Ay("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),js=z4;import{jsx as oo,jsxs as Cd}from"react/jsx-runtime";var Y4=et(!1),Sd=4,X4="default",K4=e=>e.flatMap(n=>n.options),Ly=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},Z4=(e,n)=>e.some(t=>t.options.some(n)),$4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/Sd)},(t,o)=>n.options.slice(o*Sd,o*Sd+Sd)));function j4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Fe(),[s,l]=Ye(Y4),c=[...e,...n],d=K4(c),m=$4([...e,...s?n:[]]),p=g=>{let b=d.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Po.TAB){let w=d.findIndex(x=>x.value===t),y=g.shiftKey?(d.length+w-1)%d.length:(w+1)%d.length;r(d[y].value)}else if(V4(g.key)){let w=jn().rtl,y=d.findIndex(x=>x.value===t);if(y!==-1){let x=d.length,I=y;switch(g.key){case(w?Po.ARROW_LEFT:Po.ARROW_RIGHT):I=(y+1)%x;break;case(w?Po.ARROW_RIGHT:Po.ARROW_LEFT):I=(x+y-1)%x;break;case Po.ARROW_DOWN:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(T+1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Po.ARROW_UP:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+T-1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===Po.ESCAPE||g.key===Po.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};U4(()=>{Z4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>oo("div",{className:"picker-content",children:g.map(b=>Cd("button",{type:"button",className:H4("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&&oo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===X4?oo(_y.Fragment,{children:u(b.options)},`${b.name}-${w}`):Cd("div",{className:"picker-section",children:[oo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return oo(Rh.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:Cd("div",{className:"picker-sections",children:[E(e),n.length>0&&oo(js,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:oo("div",{className:"picker-sections",children:E(n)})})]})})}function Nh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=_y.useState(!1),s=W4(()=>Ly(t,l=>l.value===e)??Ly(o??[],l=>l.value===e),[t,o,e]);return oo("div",{children:Cd(Rh.Root,{open:i,onOpenChange:l=>a(l),children:[oo(Rh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&oo(j4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Ry,{useEffect as q4}from"react";import{jsx as Bh,jsxs as Ny}from"react/jsx-runtime";var By=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Ry.useRef(null),d=Ry.useRef(null);return q4(()=>{if(c.current&&d.current){let m=c.current,p=d.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]),Ny("label",{className:"control-label",children:[e,Ny("div",{className:"range-wrapper",children:[Bh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Bh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Bh("div",{className:"zero-label",children:a})]})]})};import{Fragment as _d,jsx as ee,jsxs as xt}from"react/jsx-runtime";var Xy=.1,Xr=e=>{let n=v6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Hh(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(g6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},pt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Vy(e),s=null;if(i&&(s=t(i)),!s)if(_e(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=u6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},I6=(e,n,t)=>E6(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}),Uh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Wt(s)){let l=o(s);i.add(l);let c=at(s,{fontSize:l});return qs(c,t.scene.getContainerElement(s),t.scene),c=I6(s,c,t.scene),c}return s},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(s=>{Wt(s)&&f6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:nt.IMMEDIATELY}},T6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>x6(o.type)?at(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?nt.IMMEDIATELY:nt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Xr(o);return xt(_d,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(Ji,{topPicks:r6,palette:o6,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:pt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),S6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:nt.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!p6(t.currentItemBackgroundColor)&&i.every(s=>Gy(s)&&h6(s.points))){let s=Hh(i);r=e.map(l=>s.has(l.id)&&Gy(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,...w6(l,!0)}):l)}else r=Ct(e,n,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Xr(o);return xt(_d,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Ji,{topPicks:n6,palette:Uy,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:pt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Ld=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:nt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Xr(o);return xt(_d,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Ji,{topPicks:e6,palette:Uy,excludedColors:[t6.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})]})}}),C6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(He("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>at(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:nt.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 xt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(qt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?d1:m1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:p1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:u1,testId:"fill-solid"}],value:pt(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),P6=e=>l6.find(n=>Wy(e.type,n)===e.strokeWidth)??null,k6=(e,n)=>Wy(e.type,n),M6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Dd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>at(o,{strokeWidth:k6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(qt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:ju,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:h1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:g1,testId:"strokeWidth-bold"}],value:pt(e,o,P6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),A6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{seed:c6(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(qt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:b1},{value:1,text:f("labels.artist"),icon:x1},{value:2,text:f("labels.cartoonist"),icon:y1}],value:pt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),D6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:at(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=pt(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 ee($,{type:"button",icon:a?Ju:qu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return xt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:qu},{value:"variable",text:f("labels.pressure_variable"),icon:Ju}],value:i,onChange:a=>t(a)})})]})}}),vne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:ju},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:f1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:E1}],value:pt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),L6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=pt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(By,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),_6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,()=>(Dd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Xr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(qt,{group:"font-size",options:[{value:kd.sm,text:f("labels.small"),icon:O1,testId:"fontSize-small"},{value:kd.md,text:f("labels.medium"),icon:z1,testId:"fontSize-medium"},{value:kd.lg,text:f("labels.large"),icon:G1,testId:"fontSize-large"},{value:kd.xl,text:f("labels.veryLarge"),icon:H1,testId:"fontSize-veryLarge"}],value:pt(e,o,a=>{if(Wt(a))return a.fontSize;let s=lr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Wt(a)||lr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||a6),onChange:a=>{Gs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Wh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hr,trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,r=>Math.round(1/(1+Xy)*r.fontSize)),keyTest:e=>e[ta.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ta.CHEVRON_LEFT||e.key===ta.COMMA)}),Vh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hr,trackEvent:!1,perform:(e,n,t,o)=>Uh(e,n,o,r=>Math.round(r.fontSize*(1+Xy))),keyTest:e=>e[ta.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ta.CHEVRON_RIGHT||e.key===ta.PERIOD)}),R6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?at(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:nt.NEVER};Dd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=nt.EVENTUALLY,m,p=!1;if(l)m=l,d=nt.IMMEDIATELY;else if(c){m=c,d=nt.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Wt(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,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,w=Array.from(wo.loadedFontsCache.values()),y=Object.entries(s6).find(([T,C])=>C===m)?.[0];c&&y&&w.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Wt(T)&&(T.fontFamily!==m||l)){let C=at(T,{fontFamily:m,lineHeight:m6(m)}),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 ${d6({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)qs(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),D=P?o.scene.getElement(P.id):null;M&&qs(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Oh(new Map),i=Oh(null),[a,s]=Q4({}),l=Oh(!0),{stylesPanelMode:c,isCompact:d}=Xr(t),m=Gh(()=>{let p=(u,E)=>pt(u,t,g=>{if(Wt(g))return g.fontFamily;let b=lr(g,E);return b?b.fontFamily:null},g=>Wt(g)||lr(g,E)!==null,g=>g?null:n.currentItemFontFamily||i6);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Fh(()=>{i.current=m},[m]),Fh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Fh(()=>(l.current=!1,()=>{l.current=!0}),[]),xt(_d,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(My,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{Gs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,at(E||u,{},!0))}else{let E=de(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,at(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&zs(null)}}})]})}}),N6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=at(r,{textAlign:t});return qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Xr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:W1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:V1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:Y1,testId:"align-right"}],value:pt(e,o,s=>{if(Wt(s))return s.textAlign;let l=lr(s,i);return l?l.textAlign:null},s=>Wt(s)||lr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Gs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),B6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=at(r,{verticalAlign:t});return qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Xr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:Pd.TOP,text:f("labels.alignTop"),icon:ee(X1,{theme:n.theme}),testId:"align-top"},{value:Pd.MIDDLE,text:f("labels.centerVertically"),icon:ee(Z1,{theme:n.theme}),testId:"align-middle"},{value:Pd.BOTTOM,text:f("labels.alignBottom"),icon:ee(K1,{theme:n.theme}),testId:"align-bottom"}],value:pt(e,o,a=>{if(Wt(a)&&a.containerId)return a.verticalAlign;let s=lr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Wt(a)||lr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Pd.MIDDLE),onChange:a=>{Gs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Ine=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Yy(o)?o:at(o,{roundness:t==="round"?{type:b6(o.type)?Md.ADAPTIVE_RADIUS:Md.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Li(Vy(e),n).some(s=>s.roundness?.type===Md.LEGACY);return xt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),xt("div",{className:"buttonList",children:[ee(qt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:w1},{value:"round",text:f("labels.round"),icon:v1}],value:pt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!Ad(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Hy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(I1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(T1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(S1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(C1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(P1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(k1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(M1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(A1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(D1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(L1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(_1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(R1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(N1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(B1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(F1,{flip:e}),keyBinding:null}]}]}),Tne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Dd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(zh(o)){let{position:r,type:i}=t;if(r==="start")return at(o,{startArrowhead:i});if(r==="end")return at(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:nt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=jn().rtl,i=Gh(()=>Hy(!r),[r]),a=Gh(()=>Hy(!!r),[r]);return xt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),xt("div",{className:"iconSelectList buttonList",children:[ee(Nh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:pt(e,o,s=>zh(s)&&Is(s.type)?zy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Nh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:pt(e,o,s=>zh(s)&&Is(s.type)?zy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),F6=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})=>xt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Sne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!Ad(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Yr.getPointAtIndexGlobalCoordinates(s,0,l),d=Yr.getPointAtIndexGlobalCoordinates(s,-1,l),m=at(s,{x:t===dn.elbow?c[0]:s.x,y:t===dn.elbow?c[1]:s.y,roundness:t===dn.round?{type:Md.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Yr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Yr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Yy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Yr.getPointAtIndexGlobalCoordinates(m,0,p),E=Yr.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,...Oy(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...Oy(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...y6(m,p,{points:[u,E].map(x=>J4(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&&Fy(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&Fy(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Yr(s,Hh(e)))}return{elements:r,appState:i,captureUpdate:nt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(qt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:Jo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:er,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:Qo,testId:"elbow-arrow"}],value:pt(e,o,r=>Ad(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>Ad(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as V6,MAX_ZOOM as Y6,MIN_ZOOM as X6,THEME as Js,ZOOM_STEP as $y,CODES as Kr,KEYS as Nd}from"@excalidraw/common";import{getNonDeletedElements as Qs}from"@excalidraw/element";import{getCommonBounds as el}from"@excalidraw/element";import{CaptureUpdateAction as ra}from"@excalidraw/element";import{useEffect as O6}from"react";import{jsx as G6}from"react/jsx-runtime";var na=()=>{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},Yh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},z6=(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();Yh(n,r)},ut=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(O6(()=>()=>na().classList.remove("excalidraw-tooltip--visible"),[]),r?null:G6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>z6(i.currentTarget,na(),n,t),onPointerLeave:()=>na().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Ky,useRef as Zy,useState as H6}from"react";var U6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Xh=(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},Ko())}return U6(o,n)};function oa(e,n=!0){let t=Rd(),[,o]=H6(0),r=Zy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Xh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Xh(t,e,n)),Ky(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function W6(e,n){let t=Rd(),o=Zy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Ky(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Xh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Gd,jsxs as $6}from"react/jsx-runtime";var K6=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?ra.IMMEDIATELY:ra.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Gd(Ji,{palette:null,topPicks:V6,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})}),Bd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:_u,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Zn(n.zoom.value+$y)},n)},captureUpdate:ra.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=oa(t=>t.zoom.value);return Gd($,{type:"button",className:"zoom-in-button zoom-button",icon:_u,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=Y6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Kr.EQUAL||e.code===Kr.NUM_ADD)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Fd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Ru,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Zn(n.zoom.value-$y)},n)},captureUpdate:ra.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=oa(t=>t.zoom.value);return Gd($,{type:"button",className:"zoom-out-button zoom-button",icon:Ru,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=X6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Kr.MINUS||e.code===Kr.NUM_SUBTRACT)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Od=O({name:"resetZoom",label:"buttons.resetZoom",icon:Xx,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,...yo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Zn(r)},n)},captureUpdate:ra.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=oa(t=>t.zoom.value);return Gd(ut,{label:f("buttons.resetZoom"),style:{height:"100%"},children:$6($,{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===Kr.ZERO||e.code===Kr.NUM_ZERO)&&(e[Nd.CTRL_OR_CMD]||e.shiftKey)}),Kh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],noe=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:qc,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?el(Qs(r)):n.scrollConstraints?Kh(n.scrollConstraints):el(Qs(e)),a=Nr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Kn(a.appState)}}},keyTest:void 0}),ooe=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:qc,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?el(Qs(r)):n.scrollConstraints?Kh(n.scrollConstraints):el(Qs(e)),a=Nr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Kn(a.appState)}}},keyTest:void 0}),Z6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:qc,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?Kh(n.scrollConstraints):el(Qs(e)),i=Nr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Kn(i.appState)}}},keyTest:void 0}),zd=O({name:"toggleTheme",label:(e,n)=>n.theme===Js.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Js.LIGHT?Ls:_s,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Js.LIGHT?Js.DARK:Js.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:ra.EVENTUALLY}},keyTest:e=>!e[Nd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Kr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as rD}from"@excalidraw/math";import{bindOrUnbindBindingElement as aw}from"@excalidraw/element/binding";import{isValidPolygon as sw,newElementWith as jh}from"@excalidraw/element";import{LinearElementEditor as il}from"@excalidraw/element/linearElementEditor";import{isBindingElement as qh,isFreeDrawElement as lw,isLinearElement as cw,isLineElement as Kd}from"@excalidraw/element";import{KEYS as Zd,arrayToMap as iD,invariant as dw,shouldRotateWithDiscreteAngle as aD,updateActiveTool as mw}from"@excalidraw/common";import{isPathALoop as sD}from"@excalidraw/element";import{isInvisiblySmallElement as Jh}from"@excalidraw/element";import{CaptureUpdateAction as Qh}from"@excalidraw/element";import Q6 from"clsx";import{useEffect as eD,useState as tD}from"react";import{KEYS as mn,capitalizeString as Zr}from"@excalidraw/common";import{useEffect as j6,useState as q6}from"react";import jy from"clsx";import{capitalizeString as Hd}from"@excalidraw/common";import{Popover as Zh}from"radix-ui";import{jsx as Ud,jsxs as J6}from"react/jsx-runtime";var ia=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=q6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Fe();return!n.some(u=>u.type===c)&&s&&l(!1),j6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),J6(Zh.Root,{open:s,children:[Ud(Zh.Trigger,{asChild:!0,children:Ud($,{className:jy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Qe(e,u.type)),title:Hd(a.title),"aria-label":Hd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Ud(Zh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Ud($,{className:jy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Qe(e,u),title:Hd(u),"aria-label":Hd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(He("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as $h}from"react/jsx-runtime";var nD=e=>e,Ze=nD({hand:{icon:$1,letterKey:mn.H,toggle:!0},selection:{icon:Wc,letterKey:mn.V,fillable:!0},rectangle:{icon:zi,letterKey:mn.R,fillable:!0},diamond:{icon:Gi,letterKey:mn.D,fillable:!0},ellipse:{icon:Hi,letterKey:mn.O,fillable:!0},arrow:{icon:Vc,letterKey:mn.A,fillable:!0},line:{icon:$o,letterKey:mn.L,fillable:!0},freedraw:{icon:qn,letterKey:mn.P},text:{icon:Mn,letterKey:mn.T},image:{icon:zr},eraser:{icon:Yc,letterKey:mn.E,toggle:!0},frame:{icon:Qn,letterKey:mn.F},autoshape:{icon:Ur,letterKey:mn.X,fillable:!1},embeddable:{icon:jo},laser:{icon:eo},bucketfill:{icon:Jn},lasso:{icon:Oi,fillable:!1}});var aa=["autoshape","rectangle","diamond","ellipse","arrow","line"],sa=Object.keys(Ze).filter(e=>Ze[e].toggle),Wd=e=>{let{letterKey:n,shiftKey:t}=Ze[e];if(!n)return n;let o=Zr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},la=e=>Wd(e),oD=e=>{let n=Wd(e);return n?.length===1?n:void 0},qy=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ze)){let{letterKey:i,shiftKey:a}=Ze[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Qe=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Vt=(e,n)=>{let t=Ze[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Zr(f(`toolBar.${e}`)),d=l?null:la(o);return $h($,{className:Q6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Qe(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:oD(o),"aria-label":c,"aria-keyshortcuts":d??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&&(He("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Zr(e)}IconButton`,r},Vd=Vt("hand"),Jy=Vt("rectangle"),Qy=Vt("diamond"),ew=Vt("ellipse"),tw=Vt("arrow"),nw=Vt("line"),tl=Vt("freedraw"),nl=Vt("text"),ol=Vt("image"),rl=Vt("eraser"),ow=Vt("frame"),Doe=Vt("autoshape"),rw=Vt("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(He("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),iw=Vt("lasso",{shortcutType:"selection"}),Yd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Ze.selection.icon,fillable:Ze.selection.fillable,title:Zr(f("toolBar.selection"))},{type:"lasso",icon:Ze.lasso.icon,fillable:Ze.lasso.fillable,title:Zr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return $h(ia,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},Xd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ze.freedraw.icon,fillable:Ze.freedraw.fillable,title:Zr(f("toolBar.freedraw"))},{type:"autoshape",icon:Ze.autoshape.icon,fillable:Ze.autoshape.fillable,title:Zr(f("toolBar.autoshape"))}],[o,r]=tD(n.type==="autoshape"?"autoshape":"freedraw");eD(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return $h(ia,{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 lD}from"react/jsx-runtime";var ht=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=il.getElement(n.selectedLinearElement.elementId,l);dw(y,"Arrow element should exist if selectedLinearElement is set"),dw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=il.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(qh(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=aD(b),P=b[Zd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:il.createPointAt(y,l,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),D),new Map)??new Map;aw(y,M,w.x,w.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Kd(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!sw(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&Jh(y)&&(i=i.map(T=>T.id===y.id?jh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||Jh(y)?e.map(T=>T.id===y.id?jh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?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:Qh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||qh(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.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,s.mutateElement(m,{points:m.points.slice(0,-1)}),qh(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=il.getPointAtIndexGlobalCoordinates(m,-1,l);aw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&Jh(m)&&(i=i.map(b=>b.id===m?.id?jh(b,{isDeleted:!0}):b)),cw(m)||lw(m)){if(sD(m.points,n.zoom.value)&&(Kd(m)||lw(m))){let w=m.points,y=w[0],x=w.map((I,T)=>T===w.length-1?rD(y[0],y[1]):I);Kd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Kd(m)&&!sw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;sa.includes(n.activeTool.type)?p=mw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=mw(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&&cw(m)?new il(m,iD(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:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Qh.IMMEDIATELY:Qh.NEVER}},keyTest:(e,n)=>e.key===Zd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Zd.ESCAPE||e.key===Zd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>lD($,{type:"button",icon:o1,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 hw,isSomeElementSelected as cD,makeNextSelectedElementIds as dD,selectGroupsForSelectedElements as mD}from"@excalidraw/element";import{CaptureUpdateAction as pw}from"@excalidraw/element";import{KEYS as pD,isWritableElement as uD,updateActiveTool as uw}from"@excalidraw/common";var hD=(e,n)=>sa.includes(e.activeTool.type)?uw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):uw(e,{type:n.state.preferredSelectionTool.type}),gD=(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:hw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},fD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=hD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:hw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...mD({editingGroupId:gD(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:pw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:dD({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:pw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==pD.ESCAPE||uD(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||cD(o.scene.getNonDeletedElements(),n))});import{KEYS as om,THEME as cl}from"@excalidraw/common";import{CaptureUpdateAction as Dn}from"@excalidraw/element";import ED from"clsx";import{jsx as gw,jsxs as bD}from"react/jsx-runtime";var eg=({children:e,checked:n,onChange:t,className:o})=>bD("div",{className:ED("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[gw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Xc}),gw("div",{className:"Checkbox-label",children:e})]});import{THEME as al}from"@excalidraw/common";import{jsx as sl}from"react/jsx-runtime";var Ew=e=>{let n=e.title||(e.value===al.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return sl($,{type:"icon",icon:e.value===al.LIGHT?fw.MOON:fw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===al.DARK?al.LIGHT:al.DARK),"data-testid":"toggle-dark-mode"})},fw={SUN:sl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:sl("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:sl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:sl("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 xD}from"react";import{focusNearestParent as yD,KEYS as wD}from"@excalidraw/common";import{jsx as bw,jsxs as vD}from"react/jsx-runtime";var xw=e=>{let{id:n}=Fe(),[t,o]=xD(e.value),r=a=>{e.ignoreFocus||yD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===wD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return vD("div",{className:"ProjectName",children:[bw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),bw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as ID,useEffect as TD,useRef as SD}from"react";import{jsx as $d,jsxs as MD}from"react/jsx-runtime";var CD=5e3,PD=({progress:e})=>$d("div",{className:"Toast__progress-bar",children:$d("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),kD=({message:e,onClose:n,closable:t=!1,duration:o=CD,style:r})=>{let i=SD(0),a=o!==1/0,s=ID(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return TD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),MD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[$d("div",{className:"Toast__message",children:e}),t&&$d($,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},jd=Object.assign(kD,{ProgressBar:PD});import{DEFAULT_EXPORT_PADDING as KD,DEFAULT_FILENAME as ZD,IMAGE_MIME_TYPES as Sw,isFirefox as $D,MIME_TYPES as jD,cloneJSON as qD,SVG_DOCUMENT_PREAMBLE as JD,arrayToMap as QD}from"@excalidraw/common";import{getNonDeletedElements as eL}from"@excalidraw/element";import{isFrameLikeElement as tL}from"@excalidraw/element";import{getElementsOverlappingFrame as nL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as AD,EXPORT_DATA_TYPES as ll,MIME_TYPES as gt,arrayToMap as DD,isMemberOf as LD,isPromiseLike as _D,EVENT as qd}from"@excalidraw/common";import{mutateElement as RD}from"@excalidraw/element";import{deepCopyElement as ND}from"@excalidraw/element";import{isFrameLikeElement as BD,isInitializedImageElement as FD}from"@excalidraw/element";import{getContainingFrame as yw}from"@excalidraw/element";var $re="clipboard"in navigator&&"readText"in navigator.clipboard,Jd="clipboard"in navigator&&"writeText"in navigator.clipboard,cr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,OD=e=>!!([ll.excalidraw,ll.excalidrawClipboard,ll.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ww=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(qd.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},zD=({elements:e,files:n})=>{let t=DD(e),o=new Set(e.filter(s=>BD(s))),r=!1,i=e.reduce((s,l)=>(FD(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:ll.excalidrawClipboard,elements:e.map(s=>{if(yw(s,t)&&!o.has(yw(s,t))){let l=ND(s);return RD(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Qd=async(e,n,t)=>{let o=zD({elements:e,files:n});await ko({[gt.excalidrawClipboard]:o,[gt.text]:o},t)};function vw(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(vw(t));return n}var GD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,gt.html),o=vw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Iw=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{[gt.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(LD(AD,o))try{if(o===gt.text||o===gt.html)e[o]=await(await t.getType(o)).text();else if(vx(o)){let r=await t.getType(o),i=Mx(r,o,void 0);e[o]=i}else throw new ku(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof ku?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},HD=async(e,n=!1)=>{try{let t=e.findByType(gt.html),o=!n&&t&&GD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(gt.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(gt.text)||"").trim()}}catch{return{type:"text",value:""}}},UD=function(e){return this.find(n=>n.type===e)||null},WD=function(e){return this.find(t=>t.type===e)?.value??null},VD=function(){return this.filter(e=>e.kind==="file")},tg=e=>{let n=ng(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),gt.text,gt.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}},YD=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}}),em=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(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===gt.html)try{let E=new DOMParser().parseFromString(u.value,gt.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===gt.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:YD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},Tw=e=>{let n;ng(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},$r=async e=>{let n;ng(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 kx(o);return r=await Or(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(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:UD,getData:WD,getFiles:VD})},tm=async(e,n=!1)=>{let t=await HD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===ll.excalidrawClipboardWithAPI;if(OD(o))return{elements:o.elements,files:o.files,text:n?JSON.stringify(o.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},nm=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[gt.png]:e})])}catch(n){if(_D(e))await navigator.clipboard.write([new ClipboardItem({[gt.png]:await e})]);else throw n}},ko=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[gt.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===gt.text);if(Jd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!XD(o[1]))throw new Error("Error copying to clipboard.")},XD=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},ng=e=>e.type===qd.PASTE||e.type===qd.COPY||e.type===qd.CUT;var jr=(e,{selectedElementIds:n},t)=>{let o=eL(e),r=QD(o),i=t&&_e(o,{selectedElementIds:n}),a=null,s=i?de(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&tL(l)?(a=l,s=nL(o,l,r)):s.length>1&&(s=de(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:qD(s)}},qr=async(e,n,t,o,{exportBackground:r,exportPadding:i=KD,viewBackgroundColor:a,name:s=t.name||ZD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Br(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return Mu(m.then(p=>new Blob([JD+p.outerHTML],{type:jD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Sw.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await ko(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Fc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Ms(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-I7AV73WO.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Ss(n,t,o,"local")})))),Mu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Sw.png],fileHandle:l})}else if(e==="clipboard")try{let m=Ms(d);await nm(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):$D&&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 Cw=async(e,n,t)=>{let o=yx(n);if(!wx(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:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=jr(r,i,!1);return await qr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as nL,jsx as dr,jsxs as Aw}from"react/jsx-runtime";var rg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>dr(xw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Pw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Dn.EVENTUALLY})}),ig=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>dr(eg,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),rm=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Aw(eg,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),dr(ut,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:dr("div",{className:"excalidraw-tooltip-icon",children:r1})})]})}),la=!1,og=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Aw(nL,{children:[t,dr(jd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function tL(e,n){if(n.app.state.isLoading&&(og(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")og(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(og(n.app,{progress:null}),await e)}function kw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await tL(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var Jr=O({name:"saveToActiveFile",label:"buttons.save",icon:_s,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(la)return!1;la=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=kw(e,n,o.files,o);try{let{fileHandle:l}=Oc(r)?await Cw(s,r,i):await Lc({data:s,filename:i,fileHandle:r});return{captureUpdate:Dn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Dn.NEVER,appState:{toast:null}}}finally{la=!1}},keyTest:e=>!1}),cl=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:_s,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(la)return!1;la=!0;let{abortController:r,data:i}=kw(e,n,o.files,o);try{let{fileHandle:a}=await Lc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Dn.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:Dn.NEVER,appState:{toast:null}}}finally{la=!1}},keyTest:e=>e.key.toLowerCase()===om.S&&e.shiftKey&&e[om.CTRL_OR_CMD],PanelComponent:({updateData:e})=>dr(Z,{type:"button",icon:Qx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ee().formFactor==="phone",hidden:!Li,onClick:()=>e(null),"data-testid":"save-as-button"})}),ca=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 Au(n,e);return{elements:r,appState:i,files:a,captureUpdate:Dn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Dn.EVENTUALLY}}},keyTest:e=>e[om.CTRL_OR_CMD]&&e.key===om.O}),Mw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?ll.DARK:ll.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>dr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:dr(Ew,{value:e.exportWithDarkMode?ll.DARK:ll.LIGHT,onChange:t=>{n(t===ll.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as oL,DEFAULT_FONT_FAMILY as rL,DEFAULT_TEXT_ALIGN as iL,getLineHeight as aL}from"@excalidraw/common";import{newElementWith as im}from"@excalidraw/element";import{hasBoundTextElement as sL,canApplyRoundnessTypeToElement as lL,getDefaultRoundnessTypeForElement as cL,isFrameLikeElement as dL,isArrowElement as mL,isExcalidrawElement as pL,isTextElement as Dw}from"@excalidraw/element";import{getBoundTextElement as uL,redrawTextBoundingBox as hL}from"@excalidraw/element";import{CaptureUpdateAction as ag}from"@excalidraw/element";var Lw="{}",gL=O({name:"copyStyles",label:"labels.copyStyles",icon:th,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&sL(i)){let a=uL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Lw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:ag.EVENTUALLY}}}),fL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:th,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Lw),i=r[0],a=r[1];if(!pL(i))return{elements:e,captureUpdate:ag.EVENTUALLY};let s=de(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Dw(c)&&c.containerId&&(d=a),!d)return c;let m=im(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?lL(d.roundness.type,c)?d.roundness:cL(c):null});if(Dw(m)){let p=d.fontSize||oL,u=d.fontFamily||rL,E=im(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||iL,lineHeight:d.lineHeight||aL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),hL(E,g,o.scene)}return m.type==="arrow"&&mL(d)&&(m=im(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),dL(c)&&(m=im(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:ag.IMMEDIATELY}}});import{KEYS as EL}from"@excalidraw/common";import{CaptureUpdateAction as bL}from"@excalidraw/element";var Qr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:$x,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:bL.EVENTUALLY}),keyTest:e=>e.key===EL.QUESTION_MARK});import{getNonDeletedElements as sm}from"@excalidraw/element";import{newElementWith as Rw}from"@excalidraw/element";import{isBoundToContainer as xL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as yL,getElementsInResizingFrame as wL,getFrameLikeElements as vL,getRootElements as IL,groupByFrameLikes as TL,removeElementsFromFrame as SL,replaceAllElementsInFrame as CL}from"@excalidraw/element";import{KEYS as lm,randomId as PL,arrayToMap as lg}from"@excalidraw/common";import{getSelectedGroupIds as am,selectGroup as kL,selectGroupsForSelectedElements as ML,getElementsInGroup as _w,addToGroup as AL,removeFromSelectedGroups as DL,isElementInGroup as Nw}from"@excalidraw/element";import{syncMovedIndices as LL}from"@excalidraw/element";import{CaptureUpdateAction as dl}from"@excalidraw/element";import{jsx as da}from"react/jsx-runtime";var _L=(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=>Nw(i,r)))return!0}return!1},sg=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!_L(t,e.editingGroupId)&&!yL(t)},cg=O({name:"group",label:"labels.group",icon:e=>da($u,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!sg(n,o))return!1;let r=IL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:dl.EVENTUALLY};let i=am(n);if(i.length===1){let b=i[0],w=new Set(_w(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:dl.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&TL(r).forEach((w,y)=>{SL(w,o.scene.getNonDeletedElementsMap())});let l=PL(),c=lg(r);a=a.map(b=>c.get(b.id)?Rw(b,{groupIds:AL(b.groupIds,l,n.editingGroupId)}):b);let d=_w(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Nw(b,l)),g=LL([...E,...d,...u],lg(d));return{appState:{...n,...kL(l,{...n,selectedGroupIds:{}},sm(a))},elements:g,captureUpdate:dl.IMMEDIATELY}},predicate:(e,n,t,o)=>sg(n,o),keyTest:e=>!e.shiftKey&&e[lm.CTRL_OR_CMD]&&e.key===lm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!sg(n,o),type:"button",icon:da($u,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:_e(sm(e),n)})}),dg=O({name:"ungroup",label:"labels.ungroup",icon:e=>da(Zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=am(n),i=lg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:dl.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{xL(p)&&s.push(p.id);let u=DL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Rw(p,{groupIds:u})});let l=ML(n,sm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return vL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=CL(a,wL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:dl.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[lm.CTRL_OR_CMD]&&e.key===lm.G.toUpperCase(),predicate:(e,n)=>am(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>da(Z,{type:"button",hidden:am(n).length===0,icon:da(Zu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:_e(sm(e),n)})});import GL from"clsx";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{invariant as HL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as RL,COLOR_VOICE_CALL as NL,COLOR_WHITE as dm,THEME as BL,UserIdleState as Bw}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 FL(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 ei=(e,n)=>`hsl(${Math.abs(FL(n?.id||e))%37*10}, 100%, 83%)`,Fw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Ow=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=ei(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Bw.IDLE||E===Bw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===BL.DARK?"#2f6330":NL,w=c?.isSpeaking;w&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=dm,e.strokeStyle=dm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let x=(w?s+0:s)+d/2,I=(w?l+0:l)+m+2,T=5,C=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(M,12),_=x-1,k=I-1,L=P.width+2+T*2+2,F=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=dm,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):cm(e,_,k,L,F,8,dm),e.fillStyle=RL,e.fillText(y,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-M)/2)+2),w){e.fillStyle=b;let Y=8,z=8,U=5;e.fillRect(_+L+z,k+(F/2-Y/2),2,Y),e.fillRect(_+L+z+U,k+(F/2-Y*2/2),2,Y*2),e.fillRect(_+L+z+U*2,k+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import OL from"clsx";import{useState as zL}from"react";import{jsx as zw}from"react/jsx-runtime";var mg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Fw(t),[a,s]=zL(!1),l=!a&&o,c=l?void 0:{background:e};return zw("div",{className:OL("Avatar",r),style:c,onClick:n,children:l?zw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as ro,jsxs as mm}from"react/jsx-runtime";var UL=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(HL(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:Gw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Gw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=ei(o,r),l=GL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?mm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[ro("div",{}),ro("div",{}),ro("div",{})]}):r.isMuted?ro("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:a0}):ro("div",{title:f("userList.hint.inCall"),children:i0}):null;return i?mm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[ro(mg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),ro("div",{className:"UserList__collaborator-name",children:r.username}),mm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&ro("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Wr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):mm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[ro(mg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&ro("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as ma}from"@excalidraw/element";import{isFrameLikeElement as XL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as KL}from"@excalidraw/element";import{KEYS as mr,arrayToMap as $L}from"@excalidraw/common";import{alignElements as ZL}from"@excalidraw/element";import{CaptureUpdateAction as ni}from"@excalidraw/element";import{getSelectedElementsByGroup as jL}from"@excalidraw/element";import WL from"clsx";import{jsx as Hw}from"react/jsx-runtime";var ti=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>Hw("div",{className:WL("Switch",{toggled:t,disabled:r}),children:Hw("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var VL={stacking:!1},YL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},io=(e,n)=>({smartZoom:{...YL,...n?.smartZoom},align:{...VL,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as pr,jsxs as r_}from"react/jsx-runtime";var st=(e,n)=>{let t=n.scene.getSelectedElements(e);return jL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>XL(o))},pa=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=io(n,t.props.editorPreferences),s=ZL(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),l=$L(s);return KL(e.map(c=>l.get(c.id)||c),n,t)},qL=O({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>{let r=io(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:ni.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=io(e,t.editorPreferences).align.stacking;return r_("div",{className:"align-stacking-toggle",children:[pr("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),pr(ti,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),JL=O({name:"alignTop",label:"labels.alignTop",icon:Uu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"start",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Uu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:_e(ma(e),n)})}),QL=O({name:"alignBottom",label:"labels.alignBottom",icon:Wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"end",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Wu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:_e(ma(e),n)})}),e_=O({name:"alignLeft",label:"labels.alignLeft",icon:Vu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"start",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Vu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:_e(ma(e),n)})}),t_=O({name:"alignRight",label:"labels.alignRight",icon:Yu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"end",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Yu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:_e(ma(e),n)})}),n_=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Xu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"center",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Xu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:_e(ma(e),n)})}),o_=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ku,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:pa(e,n,o,{position:"center",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr(Z,{hidden:!st(n,o),type:"button",icon:Ku,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:_e(ma(e),n)})});import{getNonDeletedElements as Uw}from"@excalidraw/element";import{isFrameLikeElement as i_}from"@excalidraw/element";import{CODES as Ww,KEYS as Vw,arrayToMap as a_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as s_}from"@excalidraw/element";import{distributeElements as l_}from"@excalidraw/element";import{CaptureUpdateAction as Yw}from"@excalidraw/element";import{getSelectedElementsByGroup as c_}from"@excalidraw/element";import{jsx as $w}from"react/jsx-runtime";var Xw=(e,n)=>{let t=n.scene.getSelectedElements(e);return c_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>i_(o))},Kw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=l_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=a_(i);return s_(e.map(s=>a.get(s.id)||s),n,t)},d_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Kw(e,n,o,{space:"between",axis:"x"}),captureUpdate:Yw.IMMEDIATELY}),keyTest:e=>!e[Vw.CTRL_OR_CMD]&&e.altKey&&e.code===Ww.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>$w(Z,{hidden:!Xw(n,o),type:"button",icon:l1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:_e(Uw(e),n)})}),m_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Kw(e,n,o,{space:"between",axis:"y"}),captureUpdate:Yw.IMMEDIATELY}),keyTest:e=>!e[Vw.CTRL_OR_CMD]&&e.altKey&&e.code===Ww.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>$w(Z,{hidden:!Xw(n,o),type:"button",icon:c1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:_e(Uw(e),n)})});import{arrayToMap as Zw,KEYS as p_,matchKey as u_}from"@excalidraw/common";import{CaptureUpdateAction as h_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as g_}from"@excalidraw/element/frame";import{arrangeElements as f_}from"@excalidraw/element/arrange";import{jsx as x_}from"react/jsx-runtime";var E_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Zw(e),{arrange:i}=io(n,t.props.editorPreferences),a=f_(t.scene,o,r,i.algorithm,i.gap),s=Zw(a);return g_(e.map(l=>s.get(l.id)||l),n,t)},b_=st,pg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:oh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>b_(n,o),perform:(e,n,t,o)=>({appState:n,elements:E_(e,n,o),captureUpdate:h_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&u_(e,p_.A),PanelComponent:({updateData:e})=>x_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+A")}`,children:oh})});import{arrayToMap as jw}from"@excalidraw/common";import{CaptureUpdateAction as y_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as w_}from"@excalidraw/element/frame";import{normaliseElements as v_}from"@excalidraw/element/normalise";import{jsx as S_}from"react/jsx-runtime";var I_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=jw(e),{normalise:i}=io(n,t.props.editorPreferences),a=v_(t.scene,o,r,i.mode,i.metric),s=jw(a);return w_(e.map(l=>s.get(l.id)||l),n,t)},T_=st,ug=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:rh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>T_(n,o),perform:(e,n,t,o)=>({appState:n,elements:I_(e,n,o),captureUpdate:y_.IMMEDIATELY}),PanelComponent:({updateData:e})=>S_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:rh})});import{getNonDeletedElements as C_}from"@excalidraw/element";import{bindOrUnbindBindingElements as P_}from"@excalidraw/element";import{getCommonBoundingBox as qw}from"@excalidraw/element";import{newElementWith as k_}from"@excalidraw/element";import{deepCopyElement as M_}from"@excalidraw/element";import{resizeMultipleElements as A_}from"@excalidraw/element";import{isArrowElement as Jw,isElbowArrow as D_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Qw}from"@excalidraw/element";import{CODES as ev,KEYS as L_,arrayToMap as __}from"@excalidraw/common";import{CaptureUpdateAction as tv}from"@excalidraw/element";var hg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:d0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Qw(nv(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:tv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ev.H}),gg=O({name:"flipVertical",label:"labels.flipVertical",icon:c0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Qw(nv(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:tv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ev.V&&!e[L_.CTRL_OR_CMD]}),nv=(e,n,t,o,r)=>{let i=de(C_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=R_(i,n,o,r),s=__(a);return e.map(l=>s.get(l.id)||l)},R_=(e,n,t,o)=>{if(e.every(p=>Jw(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return k_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=qw(e);A_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,M_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),P_(e.filter(Jw),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>D_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=qw(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{CODES as ov,KEYS as rv}from"@excalidraw/common";import{CaptureUpdateAction as N_}from"@excalidraw/element";var iv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:N_.NEVER}),ua=O({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>iv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[rv.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===ov.R}),ha=O({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>iv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[rv.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===ov.R});import{isTextElement as B_}from"@excalidraw/element";import{getTextFromElements as F_}from"@excalidraw/element";import{CODES as O_,KEYS as av,isFirefox as z_}from"@excalidraw/common";import{CaptureUpdateAction as Qt}from"@excalidraw/element";var ga=O({name:"copy",label:"labels.copy",icon:As,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Qd(r,o.files,t)}catch(i){return{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),fg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Iw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),z_?{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(ww({types:r}))}catch(i){return console.error(i),{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),pm=O({name:"cut",label:"labels.cut",icon:q1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(ga.perform(e,n,t,o),Fs.perform(e,n,null,o)),keyTest:e=>e[av.CTRL_OR_CMD]&&e.key===av.X}),G_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:m0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=jr(e,n,!0);try{await qr("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:Qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>Jd&&e.length>0,keywords:["svg","clipboard","copy"]}),H_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:p0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=jr(e,n,!0);try{return await qr("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:Qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>cr&&e.length>0,keyTest:e=>e.code===O_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),U_=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{ko(F_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Qt.EVENTUALLY}},predicate:(e,n,t,o)=>Jd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(B_),keywords:["text","clipboard","copy"]});import{CODES as W_,KEYS as V_}from"@excalidraw/common";import{CaptureUpdateAction as Y_}from"@excalidraw/element";var fa=O({name:"gridMode",icon:h0,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:Y_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[V_.CTRL_OR_CMD]&&e.code===W_.QUOTE});import{KEYS as um}from"@excalidraw/common";import{CaptureUpdateAction as X_}from"@excalidraw/element/store";import{jsx as K_}from"react/jsx-runtime";var ml=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:ih,viewMode:!0,perform:(e,n,t,o)=>{let r=io(n,o.props.editorPreferences).smartZoom,i=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:X_.NEVER}},keyTest:e=>!e[um.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===um.F,PanelComponent:({data:e,updateData:n})=>K_(Z,{type:"button",icon:ih,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${um.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:um.F.toLocaleUpperCase()})});import{CODES as $_,KEYS as Z_}from"@excalidraw/common";import{CaptureUpdateAction as j_}from"@excalidraw/element";var Rt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:qo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:j_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[Z_.CTRL_OR_CMD]&&e.altKey&&e.code===$_.S});import{CaptureUpdateAction as q_}from"@excalidraw/element";var pl=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:q_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as J_}from"@excalidraw/element";var ul=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:J_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as Q_,KEYS as eR}from"@excalidraw/common";import{CaptureUpdateAction as tR}from"@excalidraw/element";var ur=O({name:"stats",label:"stats.fullTitle",icon:l0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:tR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[eR.CTRL_OR_CMD]&&e.altKey&&e.code===Q_.SLASH});import{BOUND_TEXT_PADDING as sv,ROUNDNESS as lv,TEXT_ALIGN as mv,VERTICAL_ALIGN as pv,arrayToMap as uv,getFontString as nR,getStrokeWidthByKey as oR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as rR,isBoundToContainer as cv,resetOriginalContainerCache as iR,updateOriginalContainerCache as aR}from"@excalidraw/element";import{computeBoundTextPosition as sR,computeContainerDimensionForBoundText as dv,getBoundTextElement as hv,redrawTextBoundingBox as gv}from"@excalidraw/element";import{hasBoundTextElement as lR,isArrowElement as cR,isTextBindableContainer as Eg,isTextElement as hl,isUsingAdaptiveRadius as dR}from"@excalidraw/element";import{measureText as mR}from"@excalidraw/element";import{syncMovedIndices as fv}from"@excalidraw/element";import{newElement as pR}from"@excalidraw/element";import{CaptureUpdateAction as bg}from"@excalidraw/element";var xg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>lR(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=hv(a,i);if(s){let{width:l,height:c}=mR(s.originalText,nR(s),s.lineHeight),d=rR(a.id);iR(a.id);let{x:m,y:p}=sR(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:bg.IMMEDIATELY}}}),yg=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=hl(r[0])||hl(r[1]),a;if(Eg(r[0])?a=r[0]:Eg(r[1])&&(a=r[1]),i&&a&&hv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;hl(r[0])&&Eg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:pv.MIDDLE,textAlign:mv.CENTER,autoResize:!0,angle:cR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return gv(i,a,o.scene),aR(a.id,s),{elements:uR(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:bg.IMMEDIATELY}}}),uR=(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),fv(o,uv([n,t])),o},hR=(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),fv(o,uv([n,t])),o},Ev=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>hl(a)&&!cv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(hl(s)&&!cv(s)){let l=pR({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:oR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:dR("rectangle")?lv.ADAPTIVE_RADIUS:lv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-sv,y:s.y-sv,width:dv(s.width,"rectangle"),height:dv(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:pv.MIDDLE,boundElements:null,textAlign:mv.CENTER,autoResize:!0}),gv(s,l,o.scene),i=hR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:bg.IMMEDIATELY}}});import{getNonDeletedElements as Pv,isEmbeddableElement as DR}from"@excalidraw/element";import{KEYS as kv}from"@excalidraw/common";import{CaptureUpdateAction as LR}from"@excalidraw/element";import{pointFrom as wv}from"@excalidraw/math";import gR from"clsx";import{useCallback as bv,useEffect as xv,useLayoutEffect as fR,useRef as ER,useState as bR}from"react";import{EVENT as wg,HYPERLINK_TOOLTIP_DELAY as xR,KEYS as hm}from"@excalidraw/common";import{getElementAbsoluteCoords as Cg}from"@excalidraw/element";import{hitElementBoundingBox as yR}from"@excalidraw/element";import{isElementLink as wR}from"@excalidraw/element";import{getEmbedLink as vR,embeddableURLValidator as IR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as vv,viewportCoordsToSceneCoords as TR,wrapEvent as SR,isLocalLink as CR,normalizeLink as vg}from"@excalidraw/common";import{isEmbeddableElement as Ig}from"@excalidraw/element";import{jsx as Ea,jsxs as yv}from"react/jsx-runtime";var Pg=380,PR=42,Tg=5,Iv=85,kR=500,Sg=!1,gm=new Map,Tv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=no(),l=An(),c=Ee(),d=e.link||"",[m,p]=bR(d),u=ER(null),E=s.showHyperlinkPopup==="editor",g=bv(()=>{if(!u.current)return;let I=vg(u.current.value)||null;if(!e.link&&I&&He("hyperlink","create"),Ig(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!IR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&gm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=vR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=gm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),gm.has(e.id)&&gm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);fR(()=>()=>{g()},[g]),xv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),xv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),AR(e,a,s,wv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},kR))};return window.addEventListener(wg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(wg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=bv(()=>{He("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{He("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Sv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:yv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Pg,padding:Tg},children:[E?Ea("input",{className:gR("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[hm.CTRL_OR_CMD]&&I.key===hm.K&&I.preventDefault(),(I.key===hm.ENTER||I.key===hm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Ea("a",{href:vg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:CR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=SR(wg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:vg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ea("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),yv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&Ea(Z,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:qn}),Ea(Z,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:b0}),d&&!Ig(e)&&Ea(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Gr})]})]})},Sv=(e,n,t)=>{let[o,r]=Cg(e,t),{x:i,y:a}=vv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Pg/2,l=a-n.offsetTop-Iv;return{x:s,y:l}},kg=(e,n)=>{let t=de(e,n);return Ig(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},gl=null,Cv=(e,n,t)=>{gl&&clearTimeout(gl),gl=window.setTimeout(()=>MR(e,n,t),xR)},MR=(e,n,t)=>{if(!e.link)return;let o=ta();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=wR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=Cg(e,t),[l,c,d,m]=hx([r,i,a,s],e.angle,n),p=vv({sceneX:l,sceneY:c},n);Yh(o,{left:p.x,top:p.y,width:d,height:m},"top"),He("hyperlink","tooltip","link-icon"),Sg=!0},fm=()=>{gl&&clearTimeout(gl),Sg&&(Sg=!1,ta().classList.remove("excalidraw-tooltip--visible"))},AR=(e,n,t,[o,r])=>{let{x:i,y:a}=TR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(yR(wv(i,a),e,n))return!1;let[l,c,d]=Cg(e,n);if(i>=l&&i<=d&&a>=c-Iv&&a<=c)return!1;let{x:m,y:p}=Sv(e,t,n);return!(o>=m-s&&o<=m+Pg+Tg*2+s&&r>=p-s&&r<=p+s+Tg*2+PR)};import{jsx as _R}from"react/jsx-runtime";var Mg=O({name:"hyperlink",label:(e,n)=>kg(Pv(e),n),icon:Rs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:LR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[kv.CTRL_OR_CMD]&&e.key===kv.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return _R(Z,{type:"toggle",icon:Rs,"aria-label":f(kg(Pv(e),n)),title:`${DR(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 Mv,arrayToMap as Dg,randomId as RR}from"@excalidraw/common";import{elementsAreInSameGroup as NR,getNonDeletedElements as Av,newElementWith as Dv,selectGroupsFromGivenElements as Lv}from"@excalidraw/element";import{CaptureUpdateAction as _v}from"@excalidraw/element";var Ag=e=>e.every(n=>!n.locked),fl=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Ag(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Ag(t)?$o:vo},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=Ag(r),a=Dg(r),s=r.length>1&&NR(r),c=r.length===1||s?null:RR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let w=r[0].groupIds.at(-1);delete d[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!n.lockedMultiSelections[x]),Dv(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=Dg(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:Lv(Av(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:_v.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Mv.L&&e[Mv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Rv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:vo,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return Dv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Dg(o),i=t.map(s=>r.get(s.id)||s),a=Av(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Lv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:_v.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as K8,isLinearElement as $8,isLineElement as Sa}from"@excalidraw/element";import{arrayToMap as Z8,invariant as E2}from"@excalidraw/common";import{toggleLinePolygonState as j8,CaptureUpdateAction as b2}from"@excalidraw/element";import{getSizeFromPoints as QTe,randomInteger as Y8,getUpdatedTimestamp as X8}from"@excalidraw/common";import{simplify as S8}from"points-on-curve";import{getStroke as C8,getStrokePoints as RTe}from"perfect-freehand";function qe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function ba([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function ot([e,n,t],o){return[e*o,n*o,t*o]}function ri([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function yt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Nv(e,n,t){return qe(e,ot(ba(n,e),t))}function Lg(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 _g(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Rg([e,n]){return Math.sqrt(e**2+n**2)}function oi([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Bv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=oi(e[t-1],e[t]);return n+=oi(e[e.length-2],e[e.length-1]),n}var BR=(e,n,t)=>Math.max(n,Math.min(t,e));function Fv(e,n,t){let o=oi(n,t);if(o===0)return oi(e,n);let r=BR(((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 oi(i,e)}function El(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Fv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...El([t,...e.slice(1,i),a],n).slice(0,-1),a,...El([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var hr=class hr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},hr.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=Nv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Bv(this.tailPoints)>hr.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=El(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 D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push(qe(P,ot(yt([1,0,0],_),M)));return D.push(qe(P,ot([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],M=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=Lg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(qe(P,ot(yt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(qe(M,ot(yt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=oi(M,D);c+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let Y=ri(ba(M,D)),z=ri(ba(_,D)),U=yt(Y,Math.PI/2),W=yt(Y,-Math.PI/2),G=yt(z,Math.PI/2),ie=yt(z,-Math.PI/2),me=qe(D,ot(U,F)),B=qe(D,ot(W,F)),V=qe(D,ot(G,F)),pe=qe(D,ot(ie,F)),ae=qe(U,ie),be=qe(W,G),ce=qe(D,ot(Rg(ae)===0?Y:ri(ae),F)),Be=qe(D,ot(Rg(be)===0?z:ri(be),F)),se=_g(Lg(D,M,_)),De=hr.constants.cornerDetectionMaxAngle/180*Math.PI*hr.constants.cornerDetectionVariance(a);if(Math.abs(se)<De){let Le=Math.abs(_g(Math.PI-se));if(Le===0)continue;if(se<0){i.push(B,Be);for(let Ce=0;Ce<=Le;Ce+=Le/4)r.push(qe(D,yt(ot(U,F),Ce)));for(let Ce=Le;Ce>=0;Ce-=Le/4)i.push(qe(D,yt(ot(U,F),Ce)));i.push(Be,V)}else{r.push(me,ce);for(let Ce=0;Ce<=Le;Ce+=Le/4)i.push(qe(D,yt(ot(U,-F),-Ce)));for(let Ce=Le;Ce>=0;Ce-=Le/4)r.push(qe(D,yt(ot(U,-F),-Ce)));r.push(ce,pe)}}else r.push(ce),i.push(Be);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)M.push(qe(P,ot(yt([1,0,0],D),this.options.size)));return M.push(qe(P,ot([1,0,0],this.options.size))),M}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=ri(ba(m,d)),g=ri(ba(p,u)),b=yt(E,-Math.PI/2),w=yt(g,Math.PI/2),y=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(qe(d,yt(ot(b,y),-P)));x.unshift(qe(d,ot(b,-y)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(qe(u,yt(ot(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"?El(C,this.options.simplify):C}};v(hr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(hr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var xa=hr;import{pointsOnBezierCurves as Ade}from"points-on-curve";import{invariant as Lde}from"@excalidraw/common";import{curve as Rde,lineSegment as Nde,pointFrom as Bde,pointDistance as Fde,pointFromArray as Ode,pointFromVector as zde,pointRotateRads as Gde,polygon as Hde,polygonFromPoints as Ude,PRECISION as Wde,segmentsIntersectAt as Vde,vector as Yde,vectorAdd as Xde,vectorFromPoint as Kde,vectorScale as $de}from"@excalidraw/math";import{getElementAbsoluteCoords as jde}from"@excalidraw/element";var Ng=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 P8,pointDistance as m2,pointRotateRads as OTe}from"@excalidraw/math";import{ROUGHNESS as k8,THEME as ef,isTransparent as Al,assertNever as M8,COLOR_PALETTE as A8,LINE_POLYGON_POINT_MERGE_DISTANCE as GTe,applyDarkModeFilter as Dl,DEFAULT_STROKE_STREAMLINE as D8}from"@excalidraw/common";import{RoughGenerator as L8}from"roughjs/bin/generator";import YIe from"roughjs/bin/rough";import{isRightAngleRads as KIe,lineSegment as $Ie,pointFrom as ZIe,pointRotateRads as jIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as JIe,DEFAULT_REDUCED_GLOBAL_ALPHA as QIe,ELEMENT_READY_TO_ERASE_OPACITY as eTe,FRAME_STYLE as tTe,DARK_THEME_FILTER as nTe,MIME_TYPES as d2,THEME as oTe,distance as rTe,getFontString as iTe,isRTL as aTe,getVerticalOffset as sTe,invariant as lTe,applyDarkModeFilter as cTe,isSafari as dTe}from"@excalidraw/common";import hIe from"roughjs/bin/rough";import{arrayToMap as fIe,invariant as c2,rescalePoints as EIe,sizeOf as bIe}from"@excalidraw/common";import{degreesToRadians as jg,lineSegment as yIe,pointFrom as wt,pointFromArray as b8,pointRotateRads as Ta}from"@excalidraw/math";import{pointsOnBezierCurves as IIe}from"points-on-curve";import{pointCenter as L2e,pointFrom as _2e,pointRotateRads as R2e,pointsEqual as N2e,pointDistance as B2e,vectorFromPoint as F2e,curveLength as O2e,curvePointAtLength as z2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as U2e,KEYS as W2e,shouldRotateWithDiscreteAngle as V2e,getGridPoint as Y2e,invariant as X2e,isShallowEqual as K2e,getFeatureFlag as $2e}from"@excalidraw/common";import{arrayToMap as Kve,getFeatureFlag as $ve,getGridPoint as Zve,invariant as jve,isTransparent as qve}from"@excalidraw/common";import{PRECISION as Qve,clamp as e2e,lineSegment as t2e,pointDistance as n2e,pointDistanceSq as o2e,pointFrom as r2e,pointFromArray as i2e,pointFromVector as a2e,pointRotateRads as s2e,pointsEqual as l2e,vectorFromPoint as c2e,vectorNormalize as d2e,vectorScale as m2e}from"@excalidraw/math";import{invariant as hve,isTransparent as gve}from"@excalidraw/common";import{curveIntersectLineSegment as Eve,isPointWithinBounds as bve,lineSegment as xve,lineSegmentIntersectionPoints as yve,pointFrom as wve,pointFromVector as vve,pointRotateRads as Ive,pointsEqual as Tve,vectorFromPoint as Sve,vectorNormalize as Cve,vectorScale as Pve}from"@excalidraw/math";import{ellipse as Mve,ellipseSegmentInterceptPoints as Ave}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as GR,DEFAULT_PROPORTIONAL_RADIUS as Og,invariant as sme,LINE_CONFIRM_THRESHOLD as HR,ROUNDNESS as zg}from"@excalidraw/common";import{bezierEquation as cme,curve as dme,curveCatmullRomCubicApproxPoints as mme,curveOffsetPoints as pme,lineSegment as ume,lineSegmentIntersectionPoints as hme,pointDistance as UR,pointFrom as gme,pointFromArray as fme,pointFromVector as Eme,pointRotateRads as bme,pointTranslate as xme,rectangle as yme,vectorFromPoint as wme,vectorNormalize as vme,vectorScale as Ime}from"@excalidraw/math";import{ROUNDNESS as eme,assertNever as tme}from"@excalidraw/common";import{pointsEqual as ome}from"@excalidraw/math";var Ov=e=>!!e&&e.type==="embeddable",Bg=e=>!!e&&e.type==="iframe",Fg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var ao=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&OR(e.type);var Ln=e=>e!=null&&e.type==="arrow",_n=e=>Ln(e)&&e.elbowed;var OR=e=>e==="arrow"||e==="line";var Mo=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var ya=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return UR(t,o)<=HR/n}return!1},bl=(e,n)=>{if(n.roundness?.type===zg.PROPORTIONAL_RADIUS||n.roundness?.type===zg.LEGACY)return e*Og;if(n.roundness?.type===zg.ADAPTIVE_RADIUS){let t=n.roundness?.value??GR,o=t/Og;return e<=o?e*Og:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Kwe,ARROW_LABEL_WIDTH_FRACTION as $we,BOUND_TEXT_PADDING as Zwe,DEFAULT_FONT_SIZE as jwe,TEXT_ALIGN as qwe,VERTICAL_ALIGN as Jwe,getFontString as Qwe,isProdEnv as eve,invariant as tve}from"@excalidraw/common";import{pointFrom as ove,pointRotateRads as rve}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Fme,DEFAULT_FONT_SIZE as Ome,DEFAULT_FONT_FAMILY as zme,getFontString as Gme,isTestEnv as Hme,normalizeEOL as Ume}from"@excalidraw/common";var Wme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as jme,isTestEnv as qme}from"@excalidraw/common";import{toIterable as Gye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as npe,viewportCoordsToSceneCoords as ope}from"@excalidraw/common";import{normalizeRadians as ipe,radiansBetweenAngles as ape,radiansDifference as spe}from"@excalidraw/math";import{pointsEqual as cpe}from"@excalidraw/math";import{arrayToMap as Kpe,isShallowEqual as XR}from"@excalidraw/common";import{arrayToMap as Ppe}from"@excalidraw/common";import{isPointWithinBounds as Mpe,pointFrom as Ape,segmentsIntersectAt as Dpe}from"@excalidraw/math";import{arrayToMap as gpe}from"@excalidraw/common";import{validateOrderKey as Epe,generateNKeysBetween as bpe}from"@excalidraw/fractional-indexing";var Gg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var tue=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}(),Il=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ii(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&&Mo(i)&&ii(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{ao(a)&&Gg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Ug=(e,n)=>XR(n.selectedElementIds,e)?n.selectedElementIds:e;var KR=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Ug({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Il(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ug(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var xue=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as ghe,VERTICAL_ALIGN as fhe}from"@excalidraw/common";import{pointDistance as bhe,pointFromVector as xhe,pointsEqual as yhe,vector as whe,vectorDot as vhe,vectorFromPoint as Ihe,vectorNormalize as The,vectorScale as She}from"@excalidraw/math";import{invariant as Due,isDevEnv as Lue,isTestEnv as _ue}from"@excalidraw/common";import{pointFrom as Nue,pointFromVector as Bue,pointRotateRads as Fue,pointScaleFromOrigin as Oue,pointsEqual as zue,triangleIncludesPoint as Gue,vectorCross as Hue,vectorFromPoint as jR,vectorScale as Uue}from"@excalidraw/math";var Cl=[1,0],wm=[0,1],Pl=[-1,0],vm=[0,-1],Im=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Cl:n<=-r?Pl:t>o?wm:vm},Kv=(e,n)=>Im(jR(e,n)),Tm=(e,n)=>Sm(Kv(e,n)),Sl=(e,n)=>e[0]===n[0]&&e[1]===n[1],Sm=e=>Sl(e,Cl)||Sl(e,Pl);import{DEFAULT_ELEMENT_PROPS as Kue,DEFAULT_FONT_FAMILY as $ue,DEFAULT_FONT_SIZE as Zue,DEFAULT_TEXT_ALIGN as jue,DEFAULT_VERTICAL_ALIGN as que,DEFAULT_STROKE_STREAMLINE as Jue,VERTICAL_ALIGN as Que,randomInteger as ehe,randomId as the,getFontString as nhe,getUpdatedTimestamp as ohe,getLineHeight as rhe}from"@excalidraw/common";import{pointsOnBezierCurves as $he,simplify as Zhe}from"points-on-curve";import{curveToBezier as qhe}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Qhe,lineSegment as ege,lineSegmentIntersectionPoints as tge,pointDistance as nge,pointFrom as oge,pointRotateRads as rge,polygonArea as ige,polygonIncludesPoint as age,polygonIncludesPointNonZero as sge,polygonSignedArea as lge}from"@excalidraw/math";import{isOpaqueColor as dge,isTransparent as mge}from"@excalidraw/common";var qv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as Bhe,distanceToLineSegment as Fhe,pointRotateRads as Ohe}from"@excalidraw/math";import{ellipse as Ghe,ellipseDistanceFromPoint as Hhe}from"@excalidraw/math/ellipse";import{pointFrom as Sge,pointCenter as Cge,pointRotateRads as Pge,vectorFromPoint as kge,vectorNormalize as Mge,vectorSubtract as Age,vectorAdd as Dge,vectorScale as Lge,pointFromVector as _ge,clamp as Rge,isCloseTo as Nge}from"@excalidraw/math";import{arrayToMap as dEe,arrayToObject as mEe,assertNever as pEe,isDevEnv as uEe,isShallowEqual as hEe,isTestEnv as gEe,randomInteger as fEe}from"@excalidraw/common";import{assertNever as Efe,COLOR_PALETTE as bfe,isDevEnv as xfe,isTestEnv as yfe,randomId as wfe,Emitter as vfe,toIterable as Ife}from"@excalidraw/common";import{ORIG_ID as $ge,randomId as Zge,randomInteger as jge,arrayToMap as qge,castArray as Jge,findLastIndex as Qge,getUpdatedTimestamp as efe,isTestEnv as tfe}from"@excalidraw/common";import{arrayToMap as Gge}from"@excalidraw/common";import QR from"lodash.throttle";import{randomInteger as Ofe,arrayToMap as zfe,toBrandedType as Gfe,isDevEnv as e2,isTestEnv as t2,toArray as Hfe}from"@excalidraw/common";import{isNonDeletedElement as Wfe}from"@excalidraw/element";import{isFrameLikeElement as Yfe}from"@excalidraw/element";import{getElementsInGroup as Kfe}from"@excalidraw/element";import{syncInvalidIndices as Zfe,syncMovedIndices as jfe,validateFractionalIndices as e8}from"@excalidraw/element";import{getSelectedElements as Jfe}from"@excalidraw/element";import{mutateElement as eEe}from"@excalidraw/element";var tEe=QR(e=>{(e2()||t2()||window?.DEBUG_FRACTIONAL_INDICES)&&e8(e,{shouldThrow:e2()||t2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as HEe,getGridPoint as UEe,getFontString as WEe,DRAGGING_THRESHOLD as VEe}from"@excalidraw/common";import{clamp as tbe,pointDistance as nbe,pointFrom as obe,pointScaleFromOrigin as rbe,pointsEqual as ibe,pointTranslate as abe,vector as sbe,vectorCross as lbe,vectorFromPoint as cbe,vectorScale as dbe}from"@excalidraw/math";import{BinaryHeap as pbe,invariant as ube,isAnyTrue as hbe,getSizeFromPoints as gbe,isDevEnv as fbe,arrayToMap as Ebe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as Dbe,normalizeLink as Lbe}from"@excalidraw/common";import{FONT_FAMILY as Fbe,VERTICAL_ALIGN as Obe,escapeDoubleQuotes as zbe,getFontString as Gbe}from"@excalidraw/common";import{invariant as Zbe,toBrandedType as jbe}from"@excalidraw/common";import{clamp as Jbe,pointFrom as Qbe}from"@excalidraw/math";import{pointDistance as kxe,pointFrom as Mxe}from"@excalidraw/math";import{invariant as Dxe}from"@excalidraw/common";import{arrayToMap as uxe,findIndex as hxe,findLastIndex as gxe}from"@excalidraw/common";import{isFiniteNumber as Exe}from"@excalidraw/math";import{decode as Hxe,decodeFrames as Uxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as Zxe,MIME_TYPES as jxe,SVG_NS as qxe}from"@excalidraw/common";import{rgbaToThumbHash as Qxe,thumbHashToRGBA as e1e}from"thumbhash";import{pointCenter as x1e,normalizeRadians as y1e,pointFrom as w1e,pointRotateRads as v1e}from"@excalidraw/math";import{MIN_FONT_SIZE as T1e,SHIFT_LOCKING_ANGLE as S1e,rescalePoints as C1e,getFontString as P1e}from"@excalidraw/common";import{pointFrom as e0e,pointOnLineSegment as t0e,pointRotateRads as n0e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as r0e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as H1e}from"@excalidraw/common";import{pointFrom as W1e,pointRotateRads as V1e}from"@excalidraw/math";import{KEYS as Nn}from"@excalidraw/common";var g0e=[{icon:Wc,value:"selection",key:Nn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Oi,value:"rectangle",key:Nn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zi,value:"diamond",key:Nn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Gi,value:"ellipse",key:Nn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Vc,value:"arrow",key:Nn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Zo,value:"line",key:Nn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:qn,value:"freedraw",key:[Nn.P,Nn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Mn,value:"text",key:Nn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:zr,value:"image",key:[Nn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Yc,value:"eraser",key:Nn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as P0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as M0e,DEFAULT_FONT_SIZE as A0e,TEXT_ALIGN as D0e,VERTICAL_ALIGN as L0e,getSizeFromPoints as _0e,randomId as R0e,arrayToMap as N0e,assertNever as B0e,cloneJSON as F0e,getFontString as O0e,isDevEnv as z0e,toBrandedType as G0e,getLineHeight as H0e}from"@excalidraw/common";import{getBoundsFromPoints as dye,getElementAbsoluteCoords as mye}from"@excalidraw/element/bounds";import{newArrowElement as uye,newElement as hye,newLinearElement as gye}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Eye,getStrokeWidthByKey as bye,ROUNDNESS as xye}from"@excalidraw/common";import{convexHull as wye,distanceToLineSegment as vye,elongation as Iye,kurtosis as Tye,lineSegment as Sye,orientPrincipalAxes as Cye,pointFrom as Pye,polygonArea as kye,principalAxes as Mye,principalCoords as Aye,skewness as Dye}from"@excalidraw/math";var Nye=[{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 ii=e=>!e.isDeleted;var m8=10/1.5;var Em=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 x8=20,y8=15,w8=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 y8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return x8;default:return 15}},v8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Bt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Ng(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;c2(s.length===6,"Op data length is not 6");let l=wt(s[4],s[5]),c=wt(s[2],s[3]),d=wt(s[0],s[1]),m=i[a-1],p=wt(0,0);if(m.op==="move"){let G=b8(m.data);c2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=wt(m.data[4],m.data[5]));let u=(G,ie)=>Math.pow(1-G,3)*l[ie]+3*G*Math.pow(1-G,2)*c[ie]+3*Math.pow(G,2)*(1-G)*d[ie]+p[ie]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,w]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-w),x=(E-b)/y,I=(g-w)/y,T=w8(o),C=0;{let[G,ie]=t==="end"?e.points[e.points.length-1]:e.points[0],[me,B]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-me,ie-B)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*M*r,_=g-I*M*r,k=D-x*M,L=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let F=v8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,ie]=Ta(wt(D,_),wt(k,L),jg(-F)),[me,B]=Ta(wt(D,_),wt(k,L),jg(F));return[k,L,G,ie,me,B]}let[Y,z]=Ta(wt(k,L),wt(D,_),-F*Math.PI/180),[U,W]=Ta(wt(k,L),wt(D,_),jg(F));if(o==="diamond"||o==="diamond_outline"){let G,ie;if(t==="start"){let[me,B]=e.points.length>1?e.points[1]:[0,0];[G,ie]=Ta(wt(D+M*2,_),wt(D,_),Math.atan2(B-_,me-D))}else{let[me,B]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,ie]=Ta(wt(D-M*2,_),wt(D,_),Math.atan2(_-B,D-me))}return[D,_,Y,z,G,ie,U,W]}return[D,_,Y,z,U,W]};var I8=typeof document<"u"?document.createElement("img"):{src:""};I8.src=`data:${d2.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 T8=typeof document<"u"?document.createElement("img"):{src:""};T8.src=`data:${d2.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 qg=new WeakMap;var Yt=class Yt{};v(Yt,"rg",new L8),v(Yt,"cache",new WeakMap),v(Yt,"get",(n,t)=>{let o=Yt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Yt,"delete",n=>{Yt.cache.delete(n),qg.delete(n)}),v(Yt,"destroy",()=>{Yt.cache=new WeakMap}),v(Yt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Yt.get(n,t?t.theme:null);if(o!==void 0)return o;qg.delete(n);let r=N8(n,Yt.rg,t||{isExporting:!1,canvasBackgroundColor:A8.white,embedsValidationStatus:null,theme:ef.LIGHT});return t?.isExporting||Yt.cache.set(n,{shape:r,theme:t?.theme||ef.LIGHT}),r});var Ia=Yt,_8=e=>[8,8+e],g2=e=>[1.5,6+e];function R8(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&&qv(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Do=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?_8(e.strokeWidth):e.strokeStyle==="dotted"?g2(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:R8(e),stroke:Dl(e.strokeColor,t),preserveVertices:n||e.roughness<k8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Al(e.backgroundColor)?void 0:Dl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return ya(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Dl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},p2=(e,n,t)=>Fg(e)&&(n||Ov(e)&&t?.get(e.id)!==!0)&&Al(e.backgroundColor)&&Al(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Bg(e)?{...e,strokeColor:Al(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Al(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ml=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Pm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},si=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=g2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Jg=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},u2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Dl(e.strokeColor,s),c=Dl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Jg(r,i,l,Bt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Bt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y]=p,x={...i,fill:o==="triangle_outline"?c:l,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=Bt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,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 Ml(r,Bt(e,n,t,o),si(e,i));case"cardinality_many":return Pm(r,Bt(e,n,t,o),si(e,i));case"cardinality_one_or_many":{let p=si(e,i);return[...Pm(r,Bt(e,n,t,"cardinality_many"),p),...Ml(r,Bt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=si(e,i);return[...Ml(r,Bt(e,n,t,"cardinality_one",-.5),p),...Ml(r,Bt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=si(e,i);return[...Jg(r,i,l,Bt(e,n,t,"circle_outline",1.5),c,m),...Ml(r,Bt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=si(e,i);return[...Pm(r,Bt(e,n,t,"cardinality_many"),p),...Jg(r,i,l,Bt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return Pm(r,Bt(e,n,t,o),si(e,i))}};var N8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===ef.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=bl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,Do(p2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Do(p2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=Em(e);if(e.roundness){let b=bl(Math.abs(l-E),e),w=bl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+w} L ${d-b} ${m-w}
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Cw=async(e,n,t)=>{let o=yx(n);if(!wx(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:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=jr(r,i,!1);return await qr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as rL,jsx as dr,jsxs as Aw}from"react/jsx-runtime";var rg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>dr(xw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Pw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Dn.EVENTUALLY})}),ig=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>dr(eg,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),rm=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Aw(eg,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),dr(ut,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:dr("div",{className:"excalidraw-tooltip-icon",children:r1})})]})}),ca=!1,og=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Aw(rL,{children:[t,dr(jd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function oL(e,n){if(n.app.state.isLoading&&(og(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")og(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(og(n.app,{progress:null}),await e)}function kw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await oL(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var Jr=O({name:"saveToActiveFile",label:"buttons.save",icon:Rs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(ca)return!1;ca=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=kw(e,n,o.files,o);try{let{fileHandle:l}=Oc(r)?await Cw(s,r,i):await Lc({data:s,filename:i,fileHandle:r});return{captureUpdate:Dn.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Dn.NEVER,appState:{toast:null}}}finally{ca=!1}},keyTest:e=>!1}),dl=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Rs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(ca)return!1;ca=!0;let{abortController:r,data:i}=kw(e,n,o.files,o);try{let{fileHandle:a}=await Lc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Dn.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:Dn.NEVER,appState:{toast:null}}}finally{ca=!1}},keyTest:e=>e.key.toLowerCase()===om.S&&e.shiftKey&&e[om.CTRL_OR_CMD],PanelComponent:({updateData:e})=>dr($,{type:"button",icon:Qx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ee().formFactor==="phone",hidden:!_i,onClick:()=>e(null),"data-testid":"save-as-button"})}),da=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 Au(n,e);return{elements:r,appState:i,files:a,captureUpdate:Dn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Dn.EVENTUALLY}}},keyTest:e=>e[om.CTRL_OR_CMD]&&e.key===om.O}),Mw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?cl.DARK:cl.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Dn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>dr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:dr(Ew,{value:e.exportWithDarkMode?cl.DARK:cl.LIGHT,onChange:t=>{n(t===cl.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as iL,DEFAULT_FONT_FAMILY as aL,DEFAULT_TEXT_ALIGN as sL,getLineHeight as lL}from"@excalidraw/common";import{newElementWith as im}from"@excalidraw/element";import{hasBoundTextElement as cL,canApplyRoundnessTypeToElement as dL,getDefaultRoundnessTypeForElement as mL,isFrameLikeElement as pL,isArrowElement as uL,isExcalidrawElement as hL,isTextElement as Dw}from"@excalidraw/element";import{getBoundTextElement as gL,redrawTextBoundingBox as fL}from"@excalidraw/element";import{CaptureUpdateAction as ag}from"@excalidraw/element";var Lw="{}",EL=O({name:"copyStyles",label:"labels.copyStyles",icon:th,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&cL(i)){let a=gL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Lw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:ag.EVENTUALLY}}}),bL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:th,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Lw),i=r[0],a=r[1];if(!hL(i))return{elements:e,captureUpdate:ag.EVENTUALLY};let s=de(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Dw(c)&&c.containerId&&(d=a),!d)return c;let m=im(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?dL(d.roundness.type,c)?d.roundness:mL(c):null});if(Dw(m)){let p=d.fontSize||iL,u=d.fontFamily||aL,E=im(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||sL,lineHeight:d.lineHeight||lL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),fL(E,g,o.scene)}return m.type==="arrow"&&uL(d)&&(m=im(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),pL(c)&&(m=im(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:ag.IMMEDIATELY}}});import{KEYS as xL}from"@excalidraw/common";import{CaptureUpdateAction as yL}from"@excalidraw/element";var Qr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Zx,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:yL.EVENTUALLY}),keyTest:e=>e.key===xL.QUESTION_MARK});import{getNonDeletedElements as sm}from"@excalidraw/element";import{newElementWith as Rw}from"@excalidraw/element";import{isBoundToContainer as wL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as vL,getElementsInResizingFrame as IL,getFrameLikeElements as TL,getRootElements as SL,groupByFrameLikes as CL,removeElementsFromFrame as PL,replaceAllElementsInFrame as kL}from"@excalidraw/element";import{KEYS as lm,randomId as ML,arrayToMap as lg}from"@excalidraw/common";import{getSelectedGroupIds as am,selectGroup as AL,selectGroupsForSelectedElements as DL,getElementsInGroup as _w,addToGroup as LL,removeFromSelectedGroups as _L,isElementInGroup as Nw}from"@excalidraw/element";import{syncMovedIndices as RL}from"@excalidraw/element";import{CaptureUpdateAction as ml}from"@excalidraw/element";import{jsx as ma}from"react/jsx-runtime";var NL=(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=>Nw(i,r)))return!0}return!1},sg=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!NL(t,e.editingGroupId)&&!vL(t)},cg=O({name:"group",label:"labels.group",icon:e=>ma(Zu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!sg(n,o))return!1;let r=SL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:ml.EVENTUALLY};let i=am(n);if(i.length===1){let b=i[0],w=new Set(_w(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:ml.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&CL(r).forEach((w,y)=>{PL(w,o.scene.getNonDeletedElementsMap())});let l=ML(),c=lg(r);a=a.map(b=>c.get(b.id)?Rw(b,{groupIds:LL(b.groupIds,l,n.editingGroupId)}):b);let d=_w(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Nw(b,l)),g=RL([...E,...d,...u],lg(d));return{appState:{...n,...AL(l,{...n,selectedGroupIds:{}},sm(a))},elements:g,captureUpdate:ml.IMMEDIATELY}},predicate:(e,n,t,o)=>sg(n,o),keyTest:e=>!e.shiftKey&&e[lm.CTRL_OR_CMD]&&e.key===lm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ma($,{hidden:!sg(n,o),type:"button",icon:ma(Zu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:_e(sm(e),n)})}),dg=O({name:"ungroup",label:"labels.ungroup",icon:e=>ma($u,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=am(n),i=lg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:ml.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{wL(p)&&s.push(p.id);let u=_L(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Rw(p,{groupIds:u})});let l=DL(n,sm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return TL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=kL(a,IL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:ml.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[lm.CTRL_OR_CMD]&&e.key===lm.G.toUpperCase(),predicate:(e,n)=>am(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ma($,{type:"button",hidden:am(n).length===0,icon:ma($u,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:_e(sm(e),n)})});import UL from"clsx";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{invariant as WL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as BL,COLOR_VOICE_CALL as FL,COLOR_WHITE as dm,THEME as OL,UserIdleState as Bw}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 zL(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 ei=(e,n)=>`hsl(${Math.abs(zL(n?.id||e))%37*10}, 100%, 83%)`,Fw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Ow=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=ei(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Bw.IDLE||E===Bw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===OL.DARK?"#2f6330":FL,w=c?.isSpeaking;w&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=dm,e.strokeStyle=dm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let x=(w?s+0:s)+d/2,I=(w?l+0:l)+m+2,T=5,C=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(M,12),_=x-1,k=I-1,L=P.width+2+T*2+2,F=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=dm,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):cm(e,_,k,L,F,8,dm),e.fillStyle=BL,e.fillText(y,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-M)/2)+2),w){e.fillStyle=b;let Y=8,z=8,U=5;e.fillRect(_+L+z,k+(F/2-Y/2),2,Y),e.fillRect(_+L+z+U,k+(F/2-Y*2/2),2,Y*2),e.fillRect(_+L+z+U*2,k+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import GL from"clsx";import{useState as HL}from"react";import{jsx as zw}from"react/jsx-runtime";var mg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Fw(t),[a,s]=HL(!1),l=!a&&o,c=l?void 0:{background:e};return zw("div",{className:GL("Avatar",r),style:c,onClick:n,children:l?zw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as ro,jsxs as mm}from"react/jsx-runtime";var VL=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(WL(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:Gw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Gw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=ei(o,r),l=UL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?mm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[ro("div",{}),ro("div",{}),ro("div",{})]}):r.isMuted?ro("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:a0}):ro("div",{title:f("userList.hint.inCall"),children:i0}):null;return i?mm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[ro(mg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),ro("div",{className:"UserList__collaborator-name",children:r.username}),mm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&ro("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Wr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):mm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[ro(mg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&ro("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as pa}from"@excalidraw/element";import{isFrameLikeElement as ZL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as $L}from"@excalidraw/element";import{KEYS as mr,arrayToMap as jL}from"@excalidraw/common";import{alignElements as qL}from"@excalidraw/element";import{CaptureUpdateAction as ni}from"@excalidraw/element";import{getSelectedElementsByGroup as JL}from"@excalidraw/element";import YL from"clsx";import{jsx as Hw}from"react/jsx-runtime";var ti=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>Hw("div",{className:YL("Switch",{toggled:t,disabled:r}),children:Hw("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var XL={stacking:!1},KL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},io=(e,n)=>({smartZoom:{...KL,...n?.smartZoom},align:{...XL,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as pr,jsxs as a_}from"react/jsx-runtime";var st=(e,n)=>{let t=n.scene.getSelectedElements(e);return JL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>ZL(o))},ua=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=io(n,t.props.editorPreferences),s=qL(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),l=jL(s);return $L(e.map(c=>l.get(c.id)||c),n,t)},QL=O({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>{let r=io(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:ni.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=io(e,t.editorPreferences).align.stacking;return a_("div",{className:"align-stacking-toggle",children:[pr("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),pr(ti,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),e_=O({name:"alignTop",label:"labels.alignTop",icon:Uu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"start",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Uu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:_e(pa(e),n)})}),t_=O({name:"alignBottom",label:"labels.alignBottom",icon:Wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"end",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Wu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:_e(pa(e),n)})}),n_=O({name:"alignLeft",label:"labels.alignLeft",icon:Vu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"start",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Vu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:_e(pa(e),n)})}),o_=O({name:"alignRight",label:"labels.alignRight",icon:Yu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"end",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),keyTest:e=>e[mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===mr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Yu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:_e(pa(e),n)})}),r_=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Xu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"center",axis:"y"}),captureUpdate:ni.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Xu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:_e(pa(e),n)})}),i_=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ku,trackEvent:{category:"element"},predicate:(e,n,t,o)=>st(n,o),perform:(e,n,t,o)=>({appState:n,elements:ua(e,n,o,{position:"center",axis:"x"}),captureUpdate:ni.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pr($,{hidden:!st(n,o),type:"button",icon:Ku,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:_e(pa(e),n)})});import{getNonDeletedElements as Uw}from"@excalidraw/element";import{isFrameLikeElement as s_}from"@excalidraw/element";import{CODES as Ww,KEYS as Vw,arrayToMap as l_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as c_}from"@excalidraw/element";import{distributeElements as d_}from"@excalidraw/element";import{CaptureUpdateAction as Yw}from"@excalidraw/element";import{getSelectedElementsByGroup as m_}from"@excalidraw/element";import{jsx as Zw}from"react/jsx-runtime";var Xw=(e,n)=>{let t=n.scene.getSelectedElements(e);return m_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>s_(o))},Kw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=d_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=l_(i);return c_(e.map(s=>a.get(s.id)||s),n,t)},p_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Kw(e,n,o,{space:"between",axis:"x"}),captureUpdate:Yw.IMMEDIATELY}),keyTest:e=>!e[Vw.CTRL_OR_CMD]&&e.altKey&&e.code===Ww.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Zw($,{hidden:!Xw(n,o),type:"button",icon:l1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:_e(Uw(e),n)})}),u_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Kw(e,n,o,{space:"between",axis:"y"}),captureUpdate:Yw.IMMEDIATELY}),keyTest:e=>!e[Vw.CTRL_OR_CMD]&&e.altKey&&e.code===Ww.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Zw($,{hidden:!Xw(n,o),type:"button",icon:c1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:_e(Uw(e),n)})});import{arrayToMap as $w,KEYS as h_,matchKey as g_}from"@excalidraw/common";import{CaptureUpdateAction as f_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as E_}from"@excalidraw/element/frame";import{arrangeElements as b_}from"@excalidraw/element/arrange";import{jsx as w_}from"react/jsx-runtime";var x_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=$w(e),{arrange:i}=io(n,t.props.editorPreferences),a=b_(t.scene,o,r,i.algorithm,i.gap),s=$w(a);return E_(e.map(l=>s.get(l.id)||l),n,t)},y_=st,pg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:oh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>y_(n,o),perform:(e,n,t,o)=>({appState:n,elements:x_(e,n,o),captureUpdate:f_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&g_(e,h_.A),PanelComponent:({updateData:e})=>w_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+A")}`,children:oh})});import{arrayToMap as jw}from"@excalidraw/common";import{CaptureUpdateAction as v_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as I_}from"@excalidraw/element/frame";import{normaliseElements as T_}from"@excalidraw/element/normalise";import{jsx as P_}from"react/jsx-runtime";var S_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=jw(e),{normalise:i}=io(n,t.props.editorPreferences),a=T_(t.scene,o,r,i.mode,i.metric),s=jw(a);return I_(e.map(l=>s.get(l.id)||l),n,t)},C_=st,ug=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:rh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>C_(n,o),perform:(e,n,t,o)=>({appState:n,elements:S_(e,n,o),captureUpdate:v_.IMMEDIATELY}),PanelComponent:({updateData:e})=>P_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:rh})});import{getNonDeletedElements as k_}from"@excalidraw/element";import{bindOrUnbindBindingElements as M_}from"@excalidraw/element";import{getCommonBoundingBox as qw}from"@excalidraw/element";import{newElementWith as A_}from"@excalidraw/element";import{deepCopyElement as D_}from"@excalidraw/element";import{resizeMultipleElements as L_}from"@excalidraw/element";import{isArrowElement as Jw,isElbowArrow as __}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Qw}from"@excalidraw/element";import{CODES as ev,KEYS as R_,arrayToMap as N_}from"@excalidraw/common";import{CaptureUpdateAction as tv}from"@excalidraw/element";var hg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:d0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Qw(nv(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:tv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ev.H}),gg=O({name:"flipVertical",label:"labels.flipVertical",icon:c0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Qw(nv(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:tv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ev.V&&!e[R_.CTRL_OR_CMD]}),nv=(e,n,t,o,r)=>{let i=de(k_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=B_(i,n,o,r),s=N_(a);return e.map(l=>s.get(l.id)||l)},B_=(e,n,t,o)=>{if(e.every(p=>Jw(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return A_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=qw(e);L_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,D_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),M_(e.filter(Jw),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>__(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=qw(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{CODES as ov,KEYS as rv}from"@excalidraw/common";import{CaptureUpdateAction as F_}from"@excalidraw/element";var iv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:F_.NEVER}),ha=O({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>iv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[rv.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===ov.R}),ga=O({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>iv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[rv.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===ov.R});import{isTextElement as O_}from"@excalidraw/element";import{getTextFromElements as z_}from"@excalidraw/element";import{CODES as G_,KEYS as av,isFirefox as H_}from"@excalidraw/common";import{CaptureUpdateAction as Qt}from"@excalidraw/element";var fa=O({name:"copy",label:"labels.copy",icon:Ds,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Qd(r,o.files,t)}catch(i){return{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),fg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Iw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),H_?{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(ww({types:r}))}catch(i){return console.error(i),{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),pm=O({name:"cut",label:"labels.cut",icon:q1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(fa.perform(e,n,t,o),Os.perform(e,n,null,o)),keyTest:e=>e[av.CTRL_OR_CMD]&&e.key===av.X}),U_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:m0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=jr(e,n,!0);try{await qr("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:Qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>Jd&&e.length>0,keywords:["svg","clipboard","copy"]}),W_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:p0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=jr(e,n,!0);try{return await qr("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:Qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>cr&&e.length>0,keyTest:e=>e.code===G_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),V_=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{ko(z_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Qt.EVENTUALLY}},predicate:(e,n,t,o)=>Jd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(O_),keywords:["text","clipboard","copy"]});import{CODES as Y_,KEYS as X_}from"@excalidraw/common";import{CaptureUpdateAction as K_}from"@excalidraw/element";var Ea=O({name:"gridMode",icon:h0,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:K_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[X_.CTRL_OR_CMD]&&e.code===Y_.QUOTE});import{KEYS as um}from"@excalidraw/common";import{CaptureUpdateAction as Z_}from"@excalidraw/element/store";import{getElementBounds as sv}from"@excalidraw/element";import{isImageElement as $_}from"@excalidraw/element/typeChecks";import{jsx as j_}from"react/jsx-runtime";var lv=(e,n,t,o)=>{let r=e.filter($_).sort((s,l)=>{let[c,d]=sv(s,n),[m,p]=sv(l,n);return d-p||c-m});if(r.length===0)return null;let i=r.findIndex(s=>s.id===t),a=o==="next"?(i+1)%r.length:(i<0?r.length-1:i-1+r.length)%r.length;return r[a]},oi=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:ih,viewMode:!0,perform:(e,n,t,o)=>{let r=io(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:Z_.NEVER}},keyTest:e=>!e[um.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===um.F,PanelComponent:({data:e,updateData:n})=>j_($,{type:"button",icon:ih,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${um.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:um.F.toLocaleUpperCase()})});import{CODES as q_,KEYS as J_}from"@excalidraw/common";import{CaptureUpdateAction as Q_}from"@excalidraw/element";var Rt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:qo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:Q_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[J_.CTRL_OR_CMD]&&e.altKey&&e.code===q_.S});import{CaptureUpdateAction as eR}from"@excalidraw/element";var pl=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 tR}from"@excalidraw/element";var ul=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:tR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as nR,KEYS as oR}from"@excalidraw/common";import{CaptureUpdateAction as rR}from"@excalidraw/element";var ur=O({name:"stats",label:"stats.fullTitle",icon:l0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:rR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[oR.CTRL_OR_CMD]&&e.altKey&&e.code===nR.SLASH});import{BOUND_TEXT_PADDING as cv,ROUNDNESS as dv,TEXT_ALIGN as uv,VERTICAL_ALIGN as hv,arrayToMap as gv,getFontString as iR,getStrokeWidthByKey as aR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as sR,isBoundToContainer as mv,resetOriginalContainerCache as lR,updateOriginalContainerCache as cR}from"@excalidraw/element";import{computeBoundTextPosition as dR,computeContainerDimensionForBoundText as pv,getBoundTextElement as fv,redrawTextBoundingBox as Ev}from"@excalidraw/element";import{hasBoundTextElement as mR,isArrowElement as pR,isTextBindableContainer as Eg,isTextElement as hl,isUsingAdaptiveRadius as uR}from"@excalidraw/element";import{measureText as hR}from"@excalidraw/element";import{syncMovedIndices as bv}from"@excalidraw/element";import{newElement as gR}from"@excalidraw/element";import{CaptureUpdateAction as bg}from"@excalidraw/element";var xg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>mR(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=fv(a,i);if(s){let{width:l,height:c}=hR(s.originalText,iR(s),s.lineHeight),d=sR(a.id);lR(a.id);let{x:m,y:p}=dR(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:bg.IMMEDIATELY}}}),yg=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=hl(r[0])||hl(r[1]),a;if(Eg(r[0])?a=r[0]:Eg(r[1])&&(a=r[1]),i&&a&&fv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;hl(r[0])&&Eg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:hv.MIDDLE,textAlign:uv.CENTER,autoResize:!0,angle:pR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Ev(i,a,o.scene),cR(a.id,s),{elements:fR(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:bg.IMMEDIATELY}}}),fR=(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),bv(o,gv([n,t])),o},ER=(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),bv(o,gv([n,t])),o},xv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>hl(a)&&!mv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(hl(s)&&!mv(s)){let l=gR({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:aR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:uR("rectangle")?dv.ADAPTIVE_RADIUS:dv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-cv,y:s.y-cv,width:pv(s.width,"rectangle"),height:pv(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:hv.MIDDLE,boundElements:null,textAlign:uv.CENTER,autoResize:!0}),Ev(s,l,o.scene),i=ER([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:bg.IMMEDIATELY}}});import{getNonDeletedElements as Mv,isEmbeddableElement as RR}from"@excalidraw/element";import{KEYS as Av}from"@excalidraw/common";import{CaptureUpdateAction as NR}from"@excalidraw/element";import{pointFrom as Iv}from"@excalidraw/math";import bR from"clsx";import{useCallback as yv,useEffect as wv,useLayoutEffect as xR,useRef as yR,useState as wR}from"react";import{EVENT as wg,HYPERLINK_TOOLTIP_DELAY as vR,KEYS as hm}from"@excalidraw/common";import{getElementAbsoluteCoords as Cg}from"@excalidraw/element";import{hitElementBoundingBox as IR}from"@excalidraw/element";import{isElementLink as TR}from"@excalidraw/element";import{getEmbedLink as SR,embeddableURLValidator as CR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Tv,viewportCoordsToSceneCoords as PR,wrapEvent as kR,isLocalLink as MR,normalizeLink as vg}from"@excalidraw/common";import{isEmbeddableElement as Ig}from"@excalidraw/element";import{jsx as ba,jsxs as vv}from"react/jsx-runtime";var Pg=380,AR=42,Tg=5,Sv=85,DR=500,Sg=!1,gm=new Map,Cv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=no(),l=An(),c=Ee(),d=e.link||"",[m,p]=wR(d),u=yR(null),E=s.showHyperlinkPopup==="editor",g=yv(()=>{if(!u.current)return;let I=vg(u.current.value)||null;if(!e.link&&I&&He("hyperlink","create"),Ig(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!CR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&gm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=SR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=gm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),gm.has(e.id)&&gm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);xR(()=>()=>{g()},[g]),wv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),wv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),_R(e,a,s,Iv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},DR))};return window.addEventListener(wg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(wg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=yv(()=>{He("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{He("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Pv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:vv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Pg,padding:Tg},children:[E?ba("input",{className:bR("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[hm.CTRL_OR_CMD]&&I.key===hm.K&&I.preventDefault(),(I.key===hm.ENTER||I.key===hm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ba("a",{href:vg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:MR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=kR(wg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:vg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ba("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),vv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ba($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:qn}),ba($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:b0}),d&&!Ig(e)&&ba($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Gr})]})]})},Pv=(e,n,t)=>{let[o,r]=Cg(e,t),{x:i,y:a}=Tv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Pg/2,l=a-n.offsetTop-Sv;return{x:s,y:l}},kg=(e,n)=>{let t=de(e,n);return Ig(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},gl=null,kv=(e,n,t)=>{gl&&clearTimeout(gl),gl=window.setTimeout(()=>LR(e,n,t),vR)},LR=(e,n,t)=>{if(!e.link)return;let o=na();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=TR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=Cg(e,t),[l,c,d,m]=hx([r,i,a,s],e.angle,n),p=Tv({sceneX:l,sceneY:c},n);Yh(o,{left:p.x,top:p.y,width:d,height:m},"top"),He("hyperlink","tooltip","link-icon"),Sg=!0},fm=()=>{gl&&clearTimeout(gl),Sg&&(Sg=!1,na().classList.remove("excalidraw-tooltip--visible"))},_R=(e,n,t,[o,r])=>{let{x:i,y:a}=PR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(IR(Iv(i,a),e,n))return!1;let[l,c,d]=Cg(e,n);if(i>=l&&i<=d&&a>=c-Sv&&a<=c)return!1;let{x:m,y:p}=Pv(e,t,n);return!(o>=m-s&&o<=m+Pg+Tg*2+s&&r>=p-s&&r<=p+s+Tg*2+AR)};import{jsx as BR}from"react/jsx-runtime";var Mg=O({name:"hyperlink",label:(e,n)=>kg(Mv(e),n),icon:Ns,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:NR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Av.CTRL_OR_CMD]&&e.key===Av.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return BR($,{type:"toggle",icon:Ns,"aria-label":f(kg(Mv(e),n)),title:`${RR(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 Dv,arrayToMap as Dg,randomId as FR}from"@excalidraw/common";import{elementsAreInSameGroup as OR,getNonDeletedElements as Lv,newElementWith as _v,selectGroupsFromGivenElements as Rv}from"@excalidraw/element";import{CaptureUpdateAction as Nv}from"@excalidraw/element";var Ag=e=>e.every(n=>!n.locked),fl=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Ag(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Ag(t)?Zo:vo},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=Ag(r),a=Dg(r),s=r.length>1&&OR(r),c=r.length===1||s?null:FR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let w=r[0].groupIds.at(-1);delete d[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!n.lockedMultiSelections[x]),_v(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=Dg(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:Rv(Lv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:Nv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Dv.L&&e[Dv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Bv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:vo,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return _v(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Dg(o),i=t.map(s=>r.get(s.id)||s),a=Lv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Rv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Nv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as jN,isLinearElement as qN,isLineElement as Ca}from"@excalidraw/element";import{arrayToMap as JN,invariant as x2}from"@excalidraw/common";import{toggleLinePolygonState as QN,CaptureUpdateAction as y2}from"@excalidraw/element";import{getSizeFromPoints as rSe,randomInteger as ZN,getUpdatedTimestamp as $N}from"@excalidraw/common";import{simplify as kN}from"points-on-curve";import{getStroke as MN,getStrokePoints as zTe}from"perfect-freehand";function qe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function xa([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function ot([e,n,t],o){return[e*o,n*o,t*o]}function ii([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function yt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Fv(e,n,t){return qe(e,ot(xa(n,e),t))}function Lg(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 _g(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Rg([e,n]){return Math.sqrt(e**2+n**2)}function ri([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Ov(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=ri(e[t-1],e[t]);return n+=ri(e[e.length-2],e[e.length-1]),n}var zR=(e,n,t)=>Math.max(n,Math.min(t,e));function zv(e,n,t){let o=ri(n,t);if(o===0)return ri(e,n);let r=zR(((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 ri(i,e)}function El(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=zv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...El([t,...e.slice(1,i),a],n).slice(0,-1),a,...El([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var hr=class hr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},hr.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=Fv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Ov(this.tailPoints)>hr.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=El(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 D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push(qe(P,ot(yt([1,0,0],_),M)));return D.push(qe(P,ot([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],M=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=Lg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(qe(P,ot(yt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(qe(M,ot(yt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=ri(M,D);c+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let Y=ii(xa(M,D)),z=ii(xa(_,D)),U=yt(Y,Math.PI/2),W=yt(Y,-Math.PI/2),G=yt(z,Math.PI/2),ie=yt(z,-Math.PI/2),me=qe(D,ot(U,F)),B=qe(D,ot(W,F)),V=qe(D,ot(G,F)),pe=qe(D,ot(ie,F)),ae=qe(U,ie),be=qe(W,G),ce=qe(D,ot(Rg(ae)===0?Y:ii(ae),F)),Be=qe(D,ot(Rg(be)===0?z:ii(be),F)),se=_g(Lg(D,M,_)),De=hr.constants.cornerDetectionMaxAngle/180*Math.PI*hr.constants.cornerDetectionVariance(a);if(Math.abs(se)<De){let Le=Math.abs(_g(Math.PI-se));if(Le===0)continue;if(se<0){i.push(B,Be);for(let Ce=0;Ce<=Le;Ce+=Le/4)r.push(qe(D,yt(ot(U,F),Ce)));for(let Ce=Le;Ce>=0;Ce-=Le/4)i.push(qe(D,yt(ot(U,F),Ce)));i.push(Be,V)}else{r.push(me,ce);for(let Ce=0;Ce<=Le;Ce+=Le/4)i.push(qe(D,yt(ot(U,-F),-Ce)));for(let Ce=Le;Ce>=0;Ce-=Le/4)r.push(qe(D,yt(ot(U,-F),-Ce)));r.push(ce,pe)}}else r.push(ce),i.push(Be);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)M.push(qe(P,ot(yt([1,0,0],D),this.options.size)));return M.push(qe(P,ot([1,0,0],this.options.size))),M}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=ii(xa(m,d)),g=ii(xa(p,u)),b=yt(E,-Math.PI/2),w=yt(g,Math.PI/2),y=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(qe(d,yt(ot(b,y),-P)));x.unshift(qe(d,ot(b,-y)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(qe(u,yt(ot(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"?El(C,this.options.simplify):C}};v(hr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(hr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var ya=hr;import{pointsOnBezierCurves as Nde}from"points-on-curve";import{invariant as Fde}from"@excalidraw/common";import{curve as zde,lineSegment as Gde,pointFrom as Hde,pointDistance as Ude,pointFromArray as Wde,pointFromVector as Vde,pointRotateRads as Yde,polygon as Xde,polygonFromPoints as Kde,PRECISION as Zde,segmentsIntersectAt as $de,vector as jde,vectorAdd as qde,vectorFromPoint as Jde,vectorScale as Qde}from"@excalidraw/math";import{getElementAbsoluteCoords as tme}from"@excalidraw/element";var Ng=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 AN,pointDistance as u2,pointRotateRads as WTe}from"@excalidraw/math";import{ROUGHNESS as DN,THEME as ef,isTransparent as Al,assertNever as LN,COLOR_PALETTE as _N,LINE_POLYGON_POINT_MERGE_DISTANCE as YTe,applyDarkModeFilter as Dl,DEFAULT_STROKE_STREAMLINE as RN}from"@excalidraw/common";import{RoughGenerator as NN}from"roughjs/bin/generator";import jIe from"roughjs/bin/rough";import{isRightAngleRads as JIe,lineSegment as QIe,pointFrom as eTe,pointRotateRads as tTe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as oTe,DEFAULT_REDUCED_GLOBAL_ALPHA as rTe,ELEMENT_READY_TO_ERASE_OPACITY as iTe,FRAME_STYLE as aTe,DARK_THEME_FILTER as sTe,MIME_TYPES as p2,THEME as lTe,distance as cTe,getFontString as dTe,isRTL as mTe,getVerticalOffset as pTe,invariant as uTe,applyDarkModeFilter as hTe,isSafari as gTe}from"@excalidraw/common";import xIe from"roughjs/bin/rough";import{arrayToMap as wIe,invariant as m2,rescalePoints as vIe,sizeOf as IIe}from"@excalidraw/common";import{degreesToRadians as jg,lineSegment as SIe,pointFrom as wt,pointFromArray as wN,pointRotateRads as Sa}from"@excalidraw/math";import{pointsOnBezierCurves as kIe}from"points-on-curve";import{pointCenter as F2e,pointFrom as O2e,pointRotateRads as z2e,pointsEqual as G2e,pointDistance as H2e,vectorFromPoint as U2e,curveLength as W2e,curvePointAtLength as V2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as K2e,KEYS as Z2e,shouldRotateWithDiscreteAngle as $2e,getGridPoint as j2e,invariant as q2e,isShallowEqual as J2e,getFeatureFlag as Q2e}from"@excalidraw/common";import{arrayToMap as Jve,getFeatureFlag as Qve,getGridPoint as e2e,invariant as t2e,isTransparent as n2e}from"@excalidraw/common";import{PRECISION as r2e,clamp as i2e,lineSegment as a2e,pointDistance as s2e,pointDistanceSq as l2e,pointFrom as c2e,pointFromArray as d2e,pointFromVector as m2e,pointRotateRads as p2e,pointsEqual as u2e,vectorFromPoint as h2e,vectorNormalize as g2e,vectorScale as f2e}from"@excalidraw/math";import{invariant as xve,isTransparent as yve}from"@excalidraw/common";import{curveIntersectLineSegment as vve,isPointWithinBounds as Ive,lineSegment as Tve,lineSegmentIntersectionPoints as Sve,pointFrom as Cve,pointFromVector as Pve,pointRotateRads as kve,pointsEqual as Mve,vectorFromPoint as Ave,vectorNormalize as Dve,vectorScale as Lve}from"@excalidraw/math";import{ellipse as Rve,ellipseSegmentInterceptPoints as Nve}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as WR,DEFAULT_PROPORTIONAL_RADIUS as Og,invariant as pme,LINE_CONFIRM_THRESHOLD as VR,ROUNDNESS as zg}from"@excalidraw/common";import{bezierEquation as hme,curve as gme,curveCatmullRomCubicApproxPoints as fme,curveOffsetPoints as Eme,lineSegment as bme,lineSegmentIntersectionPoints as xme,pointDistance as YR,pointFrom as yme,pointFromArray as wme,pointFromVector as vme,pointRotateRads as Ime,pointTranslate as Tme,rectangle as Sme,vectorFromPoint as Cme,vectorNormalize as Pme,vectorScale as kme}from"@excalidraw/math";import{ROUNDNESS as ime,assertNever as ame}from"@excalidraw/common";import{pointsEqual as lme}from"@excalidraw/math";var Gv=e=>!!e&&e.type==="embeddable",Bg=e=>!!e&&e.type==="iframe",Fg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var ao=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&HR(e.type);var Ln=e=>e!=null&&e.type==="arrow",_n=e=>Ln(e)&&e.elbowed;var HR=e=>e==="arrow"||e==="line";var Mo=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var wa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return YR(t,o)<=VR/n}return!1},bl=(e,n)=>{if(n.roundness?.type===zg.PROPORTIONAL_RADIUS||n.roundness?.type===zg.LEGACY)return e*Og;if(n.roundness?.type===zg.ADAPTIVE_RADIUS){let t=n.roundness?.value??WR,o=t/Og;return e<=o?e*Og:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Jwe,ARROW_LABEL_WIDTH_FRACTION as Qwe,BOUND_TEXT_PADDING as eve,DEFAULT_FONT_SIZE as tve,TEXT_ALIGN as nve,VERTICAL_ALIGN as ove,getFontString as rve,isProdEnv as ive,invariant as ave}from"@excalidraw/common";import{pointFrom as lve,pointRotateRads as cve}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Ume,DEFAULT_FONT_SIZE as Wme,DEFAULT_FONT_FAMILY as Vme,getFontString as Yme,isTestEnv as Xme,normalizeEOL as Kme}from"@excalidraw/common";var Zme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as tpe,isTestEnv as npe}from"@excalidraw/common";import{toIterable as Yye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as spe,viewportCoordsToSceneCoords as lpe}from"@excalidraw/common";import{normalizeRadians as dpe,radiansBetweenAngles as mpe,radiansDifference as ppe}from"@excalidraw/math";import{pointsEqual as hpe}from"@excalidraw/math";import{arrayToMap as Jpe,isShallowEqual as $R}from"@excalidraw/common";import{arrayToMap as Lpe}from"@excalidraw/common";import{isPointWithinBounds as Rpe,pointFrom as Npe,segmentsIntersectAt as Bpe}from"@excalidraw/math";import{arrayToMap as ype}from"@excalidraw/common";import{validateOrderKey as vpe,generateNKeysBetween as Ipe}from"@excalidraw/fractional-indexing";var Gg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var aue=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}(),Il=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ai(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&&Mo(i)&&ai(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{ao(a)&&Gg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Ug=(e,n)=>$R(n.selectedElementIds,e)?n.selectedElementIds:e;var jR=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Ug({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Il(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ug(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Tue=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as yhe,VERTICAL_ALIGN as whe}from"@excalidraw/common";import{pointDistance as Ihe,pointFromVector as The,pointsEqual as She,vector as Che,vectorDot as Phe,vectorFromPoint as khe,vectorNormalize as Mhe,vectorScale as Ahe}from"@excalidraw/math";import{invariant as Bue,isDevEnv as Fue,isTestEnv as Oue}from"@excalidraw/common";import{pointFrom as Gue,pointFromVector as Hue,pointRotateRads as Uue,pointScaleFromOrigin as Wue,pointsEqual as Vue,triangleIncludesPoint as Yue,vectorCross as Xue,vectorFromPoint as QR,vectorScale as Kue}from"@excalidraw/math";var Cl=[1,0],wm=[0,1],Pl=[-1,0],vm=[0,-1],Im=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Cl:n<=-r?Pl:t>o?wm:vm},$v=(e,n)=>Im(QR(e,n)),Tm=(e,n)=>Sm($v(e,n)),Sl=(e,n)=>e[0]===n[0]&&e[1]===n[1],Sm=e=>Sl(e,Cl)||Sl(e,Pl);import{DEFAULT_ELEMENT_PROPS as Jue,DEFAULT_FONT_FAMILY as Que,DEFAULT_FONT_SIZE as ehe,DEFAULT_TEXT_ALIGN as the,DEFAULT_VERTICAL_ALIGN as nhe,DEFAULT_STROKE_STREAMLINE as ohe,VERTICAL_ALIGN as rhe,randomInteger as ihe,randomId as ahe,getFontString as she,getUpdatedTimestamp as lhe,getLineHeight as che}from"@excalidraw/common";import{pointsOnBezierCurves as Qhe,simplify as ege}from"points-on-curve";import{curveToBezier as nge}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as rge,lineSegment as ige,lineSegmentIntersectionPoints as age,pointDistance as sge,pointFrom as lge,pointRotateRads as cge,polygonArea as dge,polygonIncludesPoint as mge,polygonIncludesPointNonZero as pge,polygonSignedArea as uge}from"@excalidraw/math";import{isOpaqueColor as gge,isTransparent as fge}from"@excalidraw/common";var Qv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as Hhe,distanceToLineSegment as Uhe,pointRotateRads as Whe}from"@excalidraw/math";import{ellipse as Yhe,ellipseDistanceFromPoint as Xhe}from"@excalidraw/math/ellipse";import{pointFrom as Age,pointCenter as Dge,pointRotateRads as Lge,vectorFromPoint as _ge,vectorNormalize as Rge,vectorSubtract as Nge,vectorAdd as Bge,vectorScale as Fge,pointFromVector as Oge,clamp as zge,isCloseTo as Gge}from"@excalidraw/math";import{arrayToMap as gEe,arrayToObject as fEe,assertNever as EEe,isDevEnv as bEe,isShallowEqual as xEe,isTestEnv as yEe,randomInteger as wEe}from"@excalidraw/common";import{assertNever as vfe,COLOR_PALETTE as Ife,isDevEnv as Tfe,isTestEnv as Sfe,randomId as Cfe,Emitter as Pfe,toIterable as kfe}from"@excalidraw/common";import{ORIG_ID as Qge,randomId as efe,randomInteger as tfe,arrayToMap as nfe,castArray as ofe,findLastIndex as rfe,getUpdatedTimestamp as ife,isTestEnv as afe}from"@excalidraw/common";import{arrayToMap as Yge}from"@excalidraw/common";import nN from"lodash.throttle";import{randomInteger as Wfe,arrayToMap as Vfe,toBrandedType as Yfe,isDevEnv as n2,isTestEnv as o2,toArray as Xfe}from"@excalidraw/common";import{isNonDeletedElement as Zfe}from"@excalidraw/element";import{isFrameLikeElement as jfe}from"@excalidraw/element";import{getElementsInGroup as Jfe}from"@excalidraw/element";import{syncInvalidIndices as eEe,syncMovedIndices as tEe,validateFractionalIndices as oN}from"@excalidraw/element";import{getSelectedElements as oEe}from"@excalidraw/element";import{mutateElement as iEe}from"@excalidraw/element";var aEe=nN(e=>{(n2()||o2()||window?.DEBUG_FRACTIONAL_INDICES)&&oN(e,{shouldThrow:n2()||o2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as XEe,getGridPoint as KEe,getFontString as ZEe,DRAGGING_THRESHOLD as $Ee}from"@excalidraw/common";import{clamp as abe,pointDistance as sbe,pointFrom as lbe,pointScaleFromOrigin as cbe,pointsEqual as dbe,pointTranslate as mbe,vector as pbe,vectorCross as ube,vectorFromPoint as hbe,vectorScale as gbe}from"@excalidraw/math";import{BinaryHeap as Ebe,invariant as bbe,isAnyTrue as xbe,getSizeFromPoints as ybe,isDevEnv as wbe,arrayToMap as vbe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as Bbe,normalizeLink as Fbe}from"@excalidraw/common";import{FONT_FAMILY as Ube,VERTICAL_ALIGN as Wbe,escapeDoubleQuotes as Vbe,getFontString as Ybe}from"@excalidraw/common";import{invariant as exe,toBrandedType as txe}from"@excalidraw/common";import{clamp as oxe,pointFrom as rxe}from"@excalidraw/math";import{pointDistance as _xe,pointFrom as Rxe}from"@excalidraw/math";import{invariant as Bxe}from"@excalidraw/common";import{arrayToMap as bxe,findIndex as xxe,findLastIndex as yxe}from"@excalidraw/common";import{isFiniteNumber as vxe}from"@excalidraw/math";import{decode as Xxe,decodeFrames as Kxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as e1e,MIME_TYPES as t1e,SVG_NS as n1e}from"@excalidraw/common";import{rgbaToThumbHash as r1e,thumbHashToRGBA as i1e}from"thumbhash";import{pointCenter as T1e,normalizeRadians as S1e,pointFrom as C1e,pointRotateRads as P1e}from"@excalidraw/math";import{MIN_FONT_SIZE as M1e,SHIFT_LOCKING_ANGLE as A1e,rescalePoints as D1e,getFontString as L1e}from"@excalidraw/common";import{pointFrom as i0e,pointOnLineSegment as a0e,pointRotateRads as s0e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as c0e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as X1e}from"@excalidraw/common";import{pointFrom as Z1e,pointRotateRads as $1e}from"@excalidraw/math";import{KEYS as Nn}from"@excalidraw/common";var y0e=[{icon:Wc,value:"selection",key:Nn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:zi,value:"rectangle",key:Nn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Gi,value:"diamond",key:Nn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Hi,value:"ellipse",key:Nn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Vc,value:"arrow",key:Nn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$o,value:"line",key:Nn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:qn,value:"freedraw",key:[Nn.P,Nn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Mn,value:"text",key:Nn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:zr,value:"image",key:[Nn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Yc,value:"eraser",key:Nn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as L0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as R0e,DEFAULT_FONT_SIZE as N0e,TEXT_ALIGN as B0e,VERTICAL_ALIGN as F0e,getSizeFromPoints as O0e,randomId as z0e,arrayToMap as G0e,assertNever as H0e,cloneJSON as U0e,getFontString as W0e,isDevEnv as V0e,toBrandedType as Y0e,getLineHeight as X0e}from"@excalidraw/common";import{getBoundsFromPoints as gye,getElementAbsoluteCoords as fye}from"@excalidraw/element/bounds";import{newArrowElement as bye,newElement as xye,newLinearElement as yye}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as vye,getStrokeWidthByKey as Iye,ROUNDNESS as Tye}from"@excalidraw/common";import{convexHull as Cye,distanceToLineSegment as Pye,elongation as kye,kurtosis as Mye,lineSegment as Aye,orientPrincipalAxes as Dye,pointFrom as Lye,polygonArea as _ye,principalAxes as Rye,principalCoords as Nye,skewness as Bye}from"@excalidraw/math";var Gye=[{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 ai=e=>!e.isDeleted;var hN=10/1.5;var Em=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 vN=20,IN=15,TN=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 IN;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return vN;default:return 15}},SN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Bt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Ng(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;m2(s.length===6,"Op data length is not 6");let l=wt(s[4],s[5]),c=wt(s[2],s[3]),d=wt(s[0],s[1]),m=i[a-1],p=wt(0,0);if(m.op==="move"){let G=wN(m.data);m2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=wt(m.data[4],m.data[5]));let u=(G,ie)=>Math.pow(1-G,3)*l[ie]+3*G*Math.pow(1-G,2)*c[ie]+3*Math.pow(G,2)*(1-G)*d[ie]+p[ie]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,w]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-w),x=(E-b)/y,I=(g-w)/y,T=TN(o),C=0;{let[G,ie]=t==="end"?e.points[e.points.length-1]:e.points[0],[me,B]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-me,ie-B)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*M*r,_=g-I*M*r,k=D-x*M,L=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let F=SN(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,ie]=Sa(wt(D,_),wt(k,L),jg(-F)),[me,B]=Sa(wt(D,_),wt(k,L),jg(F));return[k,L,G,ie,me,B]}let[Y,z]=Sa(wt(k,L),wt(D,_),-F*Math.PI/180),[U,W]=Sa(wt(k,L),wt(D,_),jg(F));if(o==="diamond"||o==="diamond_outline"){let G,ie;if(t==="start"){let[me,B]=e.points.length>1?e.points[1]:[0,0];[G,ie]=Sa(wt(D+M*2,_),wt(D,_),Math.atan2(B-_,me-D))}else{let[me,B]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,ie]=Sa(wt(D-M*2,_),wt(D,_),Math.atan2(_-B,D-me))}return[D,_,Y,z,G,ie,U,W]}return[D,_,Y,z,U,W]};var CN=typeof document<"u"?document.createElement("img"):{src:""};CN.src=`data:${p2.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 PN=typeof document<"u"?document.createElement("img"):{src:""};PN.src=`data:${p2.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 qg=new WeakMap;var Yt=class Yt{};v(Yt,"rg",new NN),v(Yt,"cache",new WeakMap),v(Yt,"get",(n,t)=>{let o=Yt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Yt,"delete",n=>{Yt.cache.delete(n),qg.delete(n)}),v(Yt,"destroy",()=>{Yt.cache=new WeakMap}),v(Yt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Yt.get(n,t?t.theme:null);if(o!==void 0)return o;qg.delete(n);let r=ON(n,Yt.rg,t||{isExporting:!1,canvasBackgroundColor:_N.white,embedsValidationStatus:null,theme:ef.LIGHT});return t?.isExporting||Yt.cache.set(n,{shape:r,theme:t?.theme||ef.LIGHT}),r});var Ta=Yt,BN=e=>[8,8+e],E2=e=>[1.5,6+e];function FN(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&&Qv(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Do=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?BN(e.strokeWidth):e.strokeStyle==="dotted"?E2(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:FN(e),stroke:Dl(e.strokeColor,t),preserveVertices:n||e.roughness<DN.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Al(e.backgroundColor)?void 0:Dl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return wa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Dl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},h2=(e,n,t)=>Fg(e)&&(n||Gv(e)&&t?.get(e.id)!==!0)&&Al(e.backgroundColor)&&Al(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Bg(e)?{...e,strokeColor:Al(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Al(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ml=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Pm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},li=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=E2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Jg=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},g2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Dl(e.strokeColor,s),c=Dl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Jg(r,i,l,Bt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Bt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y]=p,x={...i,fill:o==="triangle_outline"?c:l,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=Bt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,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 Ml(r,Bt(e,n,t,o),li(e,i));case"cardinality_many":return Pm(r,Bt(e,n,t,o),li(e,i));case"cardinality_one_or_many":{let p=li(e,i);return[...Pm(r,Bt(e,n,t,"cardinality_many"),p),...Ml(r,Bt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=li(e,i);return[...Ml(r,Bt(e,n,t,"cardinality_one",-.5),p),...Ml(r,Bt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=li(e,i);return[...Jg(r,i,l,Bt(e,n,t,"circle_outline",1.5),c,m),...Ml(r,Bt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=li(e,i);return[...Pm(r,Bt(e,n,t,"cardinality_many"),p),...Jg(r,i,l,Bt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return Pm(r,Bt(e,n,t,o),li(e,i))}};var ON=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===ef.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=bl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,Do(h2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Do(h2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=Em(e);if(e.roundness){let b=bl(Math.abs(l-E),e),w=bl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+w} L ${d-b} ${m-w}
5
5
  C ${d} ${m}, ${d} ${m}, ${d-b} ${m+w}
6
6
  L ${p+b} ${u-w}
7
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 ${l-b} ${c+w}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+w}`,Do(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Do(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Do(e,!1,a));case"line":case"arrow":{let s,l=Do(e,!1,a),c=e.points.length?e.points:[P8(0,0)];if(_n(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(B8(c,16),Do(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=u2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=u2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(ya(e.points)){let l=S8(e.points,.75);s.push(n.curve(l,{...Do(e,!1,a),stroke:"none"}))}return s.push(F8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return M8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},B8=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=Tm(s,i),c=Tm(a,s),d=Math.min(n,m2(e[r],a)/2,m2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}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 F8=e=>V8(U8(e)),Qg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},O8={SIZE_FACTOR:1.4},f2=e=>e.strokeOptions?.streamline??D8,z8=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 C8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Qg.SIZE_FACTOR,thinning:Qg.THINNING,smoothing:Qg.SMOOTHING,streamline:f2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},G8=e=>new xa({size:e.strokeWidth*O8.SIZE_FACTOR,streamline:f2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),H8=e=>{let n=G8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},U8=e=>e.strokeOptions?.variability==="constant"?H8(e):z8(e);var h2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],W8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,V8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,h2(o,i[0]),"L",i[0],"Z"):t.push(o,h2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(W8,"$1")};var ai=(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??Y8(),updated:X8()}};import{jsx as x2}from"react/jsx-runtime";var Ca=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&&$8(r[0])&&!K8(r[0]))},perform(e,n,t,o){E2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);E2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:b2.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 x2(Z,{type:"button",icon:g0,title:r,"aria-label":r,onClick:()=>n(null)})}}),uSe=O({name:"togglePolygon",icon:Lu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Sa(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=>Sa(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!Sa(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=Z8(i);return{elements:e.map(l=>!s.has(l.id)||!Sa(l)?l:ai(l,{backgroundColor:a?l.backgroundColor:"transparent",...j8(l,a)})),appState:n,captureUpdate:b2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Sa(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Sa(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return x2(Z,{type:"toggle",icon:Lu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as y2,CANVAS_SEARCH_TAB as w2,CLASSES as q8,DEFAULT_SIDEBAR as v2}from"@excalidraw/common";import{CaptureUpdateAction as J8}from"@excalidraw/element";var Ll=O({name:"searchMenu",icon:to,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===v2.name&&n.openSidebar.tab===w2){let r=o.excalidrawContainerValue.container?.querySelector(`.${q8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:v2.name,tab:w2},openDialog:null},captureUpdate:J8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[y2.CTRL_OR_CMD]&&e.key===y2.F});import{isImageElement as Q8}from"@excalidraw/element";import{CaptureUpdateAction as eN}from"@excalidraw/element";import{jsx as tN}from"react/jsx-runtime";var tf=O({name:"cropEditor",label:"helpDialog.cropStart",icon:nh,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:eN.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&Q8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return tN(Z,{type:"button",icon:nh,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as nN}from"@excalidraw/element";import{mutateElement as oN}from"@excalidraw/element";import{newFrameElement as rN}from"@excalidraw/element";import{isFrameLikeElement as km}from"@excalidraw/element";import{addElementsToFrame as iN,removeAllElementsFromFrame as aN}from"@excalidraw/element";import{getFrameChildren as sN}from"@excalidraw/element";import{getElementsInGroup as lN}from"@excalidraw/element";import{getCommonBounds as cN}from"@excalidraw/element";import{CaptureUpdateAction as Pa}from"@excalidraw/element";var I2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&km(t[0])},T2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(km(r)){let i=sN(nN(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:Pa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Pa.EVENTUALLY}},predicate:(e,n,t,o)=>I2(n,o)}),S2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return km(r)?{elements:aN(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Pa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Pa.EVENTUALLY}},predicate:(e,n,t,o)=>I2(n,o)}),ICe=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:Pa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),C2=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=>km(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=cN(r,i),d=16,m=rN({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=lN(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);oN(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:iN([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Pa.IMMEDIATELY}}});import{KEYS as Ma,matchKey as rf,arrayToMap as P2,MOBILE_ACTION_BUTTON_BG as k2}from"@excalidraw/common";import{CaptureUpdateAction as of}from"@excalidraw/element";import{orderByFractionalIndex as fN}from"@excalidraw/element";import{Emitter as dN}from"@excalidraw/common";import{CaptureUpdateAction as mN,StoreChange as pN,StoreDelta as uN}from"@excalidraw/element";var ka=class extends uN{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}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)}},li=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},_l=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new dN);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 ka)return;let t=ka.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new li(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=mN.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=pN.create(s,p),E=ka.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new li(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=ka.inverse(t);return n.push(o)}};import{useEffect as hN,useState as gN}from"react";var nf=(e,n)=>{let[t,o]=gN(n);return hN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as L2}from"react/jsx-runtime";var M2=(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:of.EVENTUALLY};let[r,i]=o,a=fN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:of.NEVER}}return{captureUpdate:of.EVENTUALLY}},A2=e=>({name:"undo",label:"buttons.undo",icon:Bu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>M2(r,t,()=>e.undo(P2(n),t)),keyTest:n=>n[Ma.CTRL_OR_CMD]&&rf(n,Ma.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=nf(e.onHistoryChangedEmitter,new li(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=dt()==="mobile";return L2(Z,{type:"button",icon:Bu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?k2:{}}})}}),D2=e=>({name:"redo",label:"buttons.redo",icon:Fu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>M2(r,t,()=>e.redo(P2(n),t)),keyTest:n=>n[Ma.CTRL_OR_CMD]&&n.shiftKey&&rf(n,Ma.Z)||n[Ma.CTRL_OR_CMD]&&!n.shiftKey&&rf(n,Ma.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=nf(e.onHistoryChangedEmitter,new li(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=dt()==="mobile";return L2(Z,{type:"button",icon:Fu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?k2:{}}})}});import{getFontString as EN}from"@excalidraw/common";import{getTextAnchorRatios as bN,isExcalidrawElement as xN,isNonDeletedElement as yN,newElementWith as wN,updateBoundElements as vN}from"@excalidraw/element";import{measureText as IN}from"@excalidraw/element";import{isTextElement as af}from"@excalidraw/element";import{CaptureUpdateAction as TN}from"@excalidraw/element";var sf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&af(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=xN(t)&&af(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!af(a))return!1;let s=IN(a.originalText,EN(a),a.lineHeight),l=bN(a),c=wN(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return yN(c)&&vN(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:TN.IMMEDIATELY}}});import{CODES as SN,KEYS as CN}from"@excalidraw/common";import PN from"clsx";import{CaptureUpdateAction as kN}from"@excalidraw/element";import{jsx as MN}from"react/jsx-runtime";var Aa=O({name:"viewMode",label:"labels.viewMode",icon:Wr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:kN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[CN.CTRL_OR_CMD]&&e.altKey&&!e.shiftKey&&e.code===SN.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 MN(Z,{type:"button",icon:t.viewModeEnabled?ah:Wr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:PN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as AN}from"@excalidraw/common";import{jsx as DN}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))&&He(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Mm=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,"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=s=>{this.isActionBlockedByViewportTransition(r)||(lf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return DN(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)});this.updater=i=>{if(AN(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((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.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(),s=null;return lf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,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 cf=e=>{let n=Array.from(e.values());return{x:_2(n,t=>t.x)/n.length,y:_2(n,t=>t.y)/n.length}},df=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),_2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as gr,rangeInclusive as hn,rangeIntersection as Am,rangesOverlap as Dm}from"@excalidraw/math";import{TOOL_TYPE as ci,KEYS as R2}from"@excalidraw/common";import{getCommonBounds as mf,getDraggedElementsBounds as pf,getElementAbsoluteCoords as LN}from"@excalidraw/element";import{isBoundToContainer as O2}from"@excalidraw/element";import{getMaximumGroups as z2}from"@excalidraw/element";import{getSelectedElements as _N,getVisibleAndNonSelectedElements as G2}from"@excalidraw/element";var RN=8,N2=99999,Lm=e=>RN/e,Ft=class Ft{};v(Ft,"referenceSnapPoints",null),v(Ft,"visibleGaps",null),v(Ft,"setReferenceSnapPoints",n=>{Ft.referenceSnapPoints=n}),v(Ft,"getReferenceSnapPoints",()=>Ft.referenceSnapPoints),v(Ft,"setVisibleGaps",n=>{Ft.visibleGaps=n}),v(Ft,"getVisibleGaps",()=>Ft.visibleGaps),v(Ft,"destroy",()=>{Ft.referenceSnapPoints=null,Ft.visibleGaps=null});var gn=Ft,fr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Lo=({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[R2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[R2.CTRL_OR_CMD]&&!fr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},NN=(e,n,t=.01)=>Math.abs(e-n)<=t,Rl=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=LN(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=gr(X(s,l+E),X(m,p),a.angle),b=gr(X(s+u,l),X(m,p),a.angle),w=gr(X(c,l+E),X(m,p),a.angle),y=gr(X(s+u,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=gr(X(s,l),X(m,p),a.angle),b=gr(X(c,l),X(m,p),a.angle),w=gr(X(s,d),X(m,p),a.angle),y=gr(X(c,d),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,s,l,c]=pf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=X(a,s),u=X(l,s),E=X(a,c),g=X(l,c),b=X(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(Ze(a[0]),Ze(a[1])))},H2=(e,n,t,o)=>G2(e,n,t,o),U2=(e,n,t,o)=>{let r=H2(e,n,t,o),i=z2(r,o).filter(m=>!(m.length===1&&O2(m[0]))).map(m=>mf(m).map(p=>Ze(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>N2)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Dm(hn(g,w),hn(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[X(b,g),X(b,w)],endSide:[X(y,x),X(y,I)],length:y-b,overlap:Am(hn(g,w),hn(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>N2)break e;let E=c[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Dm(hn(g,b),hn(y,I))&&d.push({startBounds:p,endBounds:E,startSide:[X(g,w),X(b,w)],endSide:[X(y,x),X(I,x)],length:x-w,overlap:Am(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:d}},B2=(e,n,t,o,r,i,a)=>{if(!Lo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=pf(e,n).map(b=>Ze(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Dm(hn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=Ze(w-E);if(b.length>p-d&&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=d-I,C=Ze(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-p,D=Ze(M-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!Dm(hn(d,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=Ze(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,C=Ze(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=Ze(m-P),D=b.length-M;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},W2=(e,n,t,o)=>{let r=H2(e,n,t,o);return z2(r,o).filter(i=>!(i.length===1&&O2(i[0]))).flatMap(i=>Rl(i,o))},Da=(e,n,t,o,r,i,a)=>{if(!Lo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=gn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},V2=(e,n,t,o,r)=>{let i=t.state,a=_N(e,i);if(!Lo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ze(n.x),n.y=Ze(n.y);let s=[],l=[],c=Lm(i.zoom.value),d={x:c,y:c},m=Rl(a,r,{dragOffset:n});Da(a,m,t,o,s,l,d),B2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:Ze(n.x+p.x),y:Ze(n.y+p.y)};Da(a,Rl(a,r,{dragOffset:u}),t,o,s,l,d),B2(a,u,t,o,s,l,d);let E=uf(s,l),g=FN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ze=e=>Math.round(e*10**6)/10**6,F2=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())},uf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ze(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(Ze(a[0]),Ze(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ze(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(Ze(a[0]),Ze(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:F2(i.map(a=>X(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:F2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},BN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ze(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},FN=(e,n,t)=>{let[o,r,i,a]=pf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,w=Am(hn(r,a),l.gap.overlap),y=Am(hn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(l.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,l.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;s.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;s.push({type:"gap",direction:"horizontal",points:[X(i,x),X(c,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;s.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,d)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;s.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 BN(s.map(l=>({...l,points:l.points.map(c=>X(Ze(c[0]),Ze(c[1])))})))},hf=(e,n,t,o,r,i)=>{if(!Lo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!NN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=mf(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(X(l,s),X(l,c));break}case"w":{d.push(X(a,s),X(a,c));break}case"n":{d.push(X(a,s),X(l,s));break}case"s":{d.push(X(a,c),X(l,c));break}case"ne":{d.push(X(l,s));break}case"nw":{d.push(X(a,s));break}case"se":{d.push(X(l,c));break}case"sw":{d.push(X(a,c));break}}let m=Lm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Da(n,d,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]=mf(e).map(C=>Ze(C)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];Da(e,I,t,o,u,E,p);let T=uf(u,E);return{snapOffset:g,snapLines:T}},Y2=(e,n,t,o,r,i)=>{if(!Lo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],s=Lm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Da([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Rl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Da([e],p,n,t,c,d,l);let u=uf(c,d);return{snapOffset:m,snapLines:u}},X2=(e,n,t,o,r)=>{if(!Lo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=G2(e,[],n.state,r),a=Lm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Rl([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,X(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,X(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},K2=e=>e===ci.rectangle||e===ci.ellipse||e===ci.diamond||e===ci.frame||e===ci.magicframe||e===ci.image||e===ci.text;import{getCommonFrameId as ON,getFrameChildrenInsertionIndex as zN,isElementInViewport as GN}from"@excalidraw/element";import{arrayToMap as HN,memoize as UN,toBrandedType as WN}from"@excalidraw/common";var Nl=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",UN(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});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&&ON(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:s,width:l}){let c=[];for(let d of n.values())GN(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=WN(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=HN(t),i=n.filter(s=>!r.has(s.id)),a=zN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Ex.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as $N,easeOut as j2}from"@excalidraw/common";import{SVG_NS as Z2,getSvgPathFromStroke as XN,sceneCoordsToViewportCoords as KN}from"@excalidraw/common";import{version as VN}from"react";import{unstable_batchedUpdates as $2}from"react-dom";import{throttleRAF as YN}from"@excalidraw/common";var je=e=>n=>{$2(e,n)},_m=e=>YN(n=>{$2(e,n)}),La=(()=>{let e;try{let t=VN.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||(La()?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 lt=he;var Rm=class Rm{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-${Rm.counter++}`,this.trailElement=document.createElementNS(Z2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Z2,"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),lt.running(this.key)||lt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){lt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new xa(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 s=KN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return XN(r,!0)}};v(Rm,"counter",0);var Bn=Rm;var Nm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Bn(n,{...this.getTrailOptions(),fill:()=>$N})}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(j2(i),j2(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 Bn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||ei(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",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as ZN}from"@excalidraw/common";import{pointFrom as Bl,pointRotateRads as Bm}from"@excalidraw/math";var jN=12,gf=16,qN=10,JN=gf+2,QN=.8,ff=e=>ZN*2/e,Ef=(e,n,t)=>{let o=ff(n);if(t!=="desktop"||gf>(e.height+o*2)*n*QN)return null;let r=jN/n,i=gf/n,a=Bl(e.x+e.width/2,e.y+e.height/2),s=Bm(Bl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Bm(Bl(s[0],s[1]-i/2),s,e.angle),end:Bm(Bl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:qN/n,hitboxHeight:JN/n}},q2=(e,n,t,o)=>{let r=Ef(n,t,o);if(!r)return!1;let i=Bm(Bl(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 bf,KEYS as Fl,CLASSES as xf,POINTER_BUTTON as e7,THEME as t7,isWritableElement as n7,getFontString as J2,getFontFamilyString as Q2,isTestEnv as eI,MIME_TYPES as yf,applyDarkModeFilter as o7,isRTL as r7,getViewpointFlipSign as tI}from"@excalidraw/common";import{pointFrom as nI,pointRotateRads as i7}from"@excalidraw/math";import{getTextFromElements as a7,originalContainerCache as s7,updateBoundElements as oI,updateOriginalContainerCache as rI}from"@excalidraw/element";import{LinearElementEditor as l7}from"@excalidraw/element/linearElementEditor";import{bumpVersion as c7}from"@excalidraw/element";import{getBoundTextElementId as d7,getContainerElement as wf,getTextElementAngle as m7,redrawTextBoundingBox as p7,getBoundTextMaxHeight as u7,getBoundTextMaxWidth as iI,computeContainerDimensionForBoundText as aI,computeBoundTextPosition as h7,getBoundTextElement as g7}from"@excalidraw/element";import{getTextWidth as f7}from"@excalidraw/element";import{getLineHeightInPx as E7}from"@excalidraw/element";import{getLineWidth as b7}from"@excalidraw/element";import{normalizeText as sI}from"@excalidraw/element";import{wrapText as x7}from"@excalidraw/element";import{getWrappedTextLines as y7}from"@excalidraw/element";import{isArrowElement as Fm,isBoundToContainer as w7,isTextElement as lI}from"@excalidraw/element";var v7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value*tI(o.viewpointFlip.horizontal)}, ${a.value*tI(o.viewpointFlip.vertical)}) rotate(${s}deg)`},I7=(e,n)=>{let t=e.lastIndexOf(`
11
+ C ${l} ${c}, ${l} ${c}, ${l+b} ${c+w}`,Do(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Do(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Do(e,!1,a));case"line":case"arrow":{let s,l=Do(e,!1,a),c=e.points.length?e.points:[AN(0,0)];if(_n(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(zN(c,16),Do(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=g2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=g2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(wa(e.points)){let l=kN(e.points,.75);s.push(n.curve(l,{...Do(e,!1,a),stroke:"none"}))}return s.push(GN(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return LN(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},zN=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=Tm(s,i),c=Tm(a,s),d=Math.min(n,u2(e[r],a)/2,u2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}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 GN=e=>KN(YN(e)),Qg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},HN={SIZE_FACTOR:1.4},b2=e=>e.strokeOptions?.streamline??RN,UN=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 MN(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Qg.SIZE_FACTOR,thinning:Qg.THINNING,smoothing:Qg.SMOOTHING,streamline:b2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},WN=e=>new ya({size:e.strokeWidth*HN.SIZE_FACTOR,streamline:b2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),VN=e=>{let n=WN(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},YN=e=>e.strokeOptions?.variability==="constant"?VN(e):UN(e);var f2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],XN=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,KN=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,f2(o,i[0]),"L",i[0],"Z"):t.push(o,f2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(XN,"$1")};var si=(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??ZN(),updated:$N()}};import{jsx as w2}from"react/jsx-runtime";var Pa=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&&qN(r[0])&&!jN(r[0]))},perform(e,n,t,o){x2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);x2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:y2.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 w2($,{type:"button",icon:g0,title:r,"aria-label":r,onClick:()=>n(null)})}}),bSe=O({name:"togglePolygon",icon:Lu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!Ca(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=>Ca(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!Ca(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=JN(i);return{elements:e.map(l=>!s.has(l.id)||!Ca(l)?l:si(l,{backgroundColor:a?l.backgroundColor:"transparent",...QN(l,a)})),appState:n,captureUpdate:y2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!Ca(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>Ca(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return w2($,{type:"toggle",icon:Lu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as v2,CANVAS_SEARCH_TAB as I2,CLASSES as e8,DEFAULT_SIDEBAR as T2}from"@excalidraw/common";import{CaptureUpdateAction as t8}from"@excalidraw/element";var Ll=O({name:"searchMenu",icon:to,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===T2.name&&n.openSidebar.tab===I2){let r=o.excalidrawContainerValue.container?.querySelector(`.${e8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:T2.name,tab:I2},openDialog:null},captureUpdate:t8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[v2.CTRL_OR_CMD]&&e.key===v2.F});import{isImageElement as n8}from"@excalidraw/element";import{CaptureUpdateAction as o8}from"@excalidraw/element";import{jsx as r8}from"react/jsx-runtime";var tf=O({name:"cropEditor",label:"helpDialog.cropStart",icon:nh,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:o8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&n8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return r8($,{type:"button",icon:nh,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as i8}from"@excalidraw/element";import{mutateElement as a8}from"@excalidraw/element";import{newFrameElement as s8}from"@excalidraw/element";import{isFrameLikeElement as km}from"@excalidraw/element";import{addElementsToFrame as l8,removeAllElementsFromFrame as c8}from"@excalidraw/element";import{getFrameChildren as d8}from"@excalidraw/element";import{getElementsInGroup as m8}from"@excalidraw/element";import{getCommonBounds as p8}from"@excalidraw/element";import{CaptureUpdateAction as ka}from"@excalidraw/element";var S2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&km(t[0])},C2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(km(r)){let i=d8(i8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:ka.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:ka.EVENTUALLY}},predicate:(e,n,t,o)=>S2(n,o)}),P2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return km(r)?{elements:c8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:ka.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:ka.EVENTUALLY}},predicate:(e,n,t,o)=>S2(n,o)}),kCe=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:ka.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),k2=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=>km(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=p8(r,i),d=16,m=s8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=m8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);a8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:l8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:ka.IMMEDIATELY}}});import{KEYS as Aa,matchKey as rf,arrayToMap as M2,MOBILE_ACTION_BUTTON_BG as A2}from"@excalidraw/common";import{CaptureUpdateAction as of}from"@excalidraw/element";import{orderByFractionalIndex as x8}from"@excalidraw/element";import{Emitter as u8}from"@excalidraw/common";import{CaptureUpdateAction as h8,StoreChange as g8,StoreDelta as f8}from"@excalidraw/element";var Ma=class extends f8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}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)}},ci=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},_l=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new u8);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 Ma)return;let t=Ma.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ci(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=h8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=g8.create(s,p),E=Ma.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new ci(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=Ma.inverse(t);return n.push(o)}};import{useEffect as E8,useState as b8}from"react";var nf=(e,n)=>{let[t,o]=b8(n);return E8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as R2}from"react/jsx-runtime";var D2=(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:of.EVENTUALLY};let[r,i]=o,a=x8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:of.NEVER}}return{captureUpdate:of.EVENTUALLY}},L2=e=>({name:"undo",label:"buttons.undo",icon:Bu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>D2(r,t,()=>e.undo(M2(n),t)),keyTest:n=>n[Aa.CTRL_OR_CMD]&&rf(n,Aa.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=nf(e.onHistoryChangedEmitter,new ci(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=dt()==="mobile";return R2($,{type:"button",icon:Bu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?A2:{}}})}}),_2=e=>({name:"redo",label:"buttons.redo",icon:Fu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>D2(r,t,()=>e.redo(M2(n),t)),keyTest:n=>n[Aa.CTRL_OR_CMD]&&n.shiftKey&&rf(n,Aa.Z)||n[Aa.CTRL_OR_CMD]&&!n.shiftKey&&rf(n,Aa.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=nf(e.onHistoryChangedEmitter,new ci(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=dt()==="mobile";return R2($,{type:"button",icon:Fu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?A2:{}}})}});import{getFontString as y8}from"@excalidraw/common";import{getTextAnchorRatios as w8,isExcalidrawElement as v8,isNonDeletedElement as I8,newElementWith as T8,updateBoundElements as S8}from"@excalidraw/element";import{measureText as C8}from"@excalidraw/element";import{isTextElement as af}from"@excalidraw/element";import{CaptureUpdateAction as P8}from"@excalidraw/element";var sf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&af(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=v8(t)&&af(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!af(a))return!1;let s=C8(a.originalText,y8(a),a.lineHeight),l=w8(a),c=T8(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return I8(c)&&S8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:P8.IMMEDIATELY}}});import{CODES as k8,KEYS as M8}from"@excalidraw/common";import A8 from"clsx";import{CaptureUpdateAction as D8}from"@excalidraw/element";import{jsx as L8}from"react/jsx-runtime";var Da=O({name:"viewMode",label:"labels.viewMode",icon:Wr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:D8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[M8.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 L8($,{type:"button",icon:t.viewModeEnabled?ah:Wr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:A8({enabled:t.viewModeEnabled})})}});import{isPromiseLike as _8}from"@excalidraw/common";import{jsx as R8}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))&&He(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Mm=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,"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=s=>{this.isActionBlockedByViewportTransition(r)||(lf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return R8(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)});this.updater=i=>{if(_8(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((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.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(),s=null;return lf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,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 cf=e=>{let n=Array.from(e.values());return{x:N2(n,t=>t.x)/n.length,y:N2(n,t=>t.y)/n.length}},df=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),N2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as K,pointRotateRads as gr,rangeInclusive as hn,rangeIntersection as Am,rangesOverlap as Dm}from"@excalidraw/math";import{TOOL_TYPE as di,KEYS as B2}from"@excalidraw/common";import{getCommonBounds as mf,getDraggedElementsBounds as pf,getElementAbsoluteCoords as N8}from"@excalidraw/element";import{isBoundToContainer as G2}from"@excalidraw/element";import{getMaximumGroups as H2}from"@excalidraw/element";import{getSelectedElements as B8,getVisibleAndNonSelectedElements as U2}from"@excalidraw/element";var F8=8,F2=99999,Lm=e=>F8/e,Ft=class Ft{};v(Ft,"referenceSnapPoints",null),v(Ft,"visibleGaps",null),v(Ft,"setReferenceSnapPoints",n=>{Ft.referenceSnapPoints=n}),v(Ft,"getReferenceSnapPoints",()=>Ft.referenceSnapPoints),v(Ft,"setVisibleGaps",n=>{Ft.visibleGaps=n}),v(Ft,"getVisibleGaps",()=>Ft.visibleGaps),v(Ft,"destroy",()=>{Ft.referenceSnapPoints=null,Ft.visibleGaps=null});var gn=Ft,fr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Lo=({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[B2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[B2.CTRL_OR_CMD]&&!fr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},O8=(e,n,t=.01)=>Math.abs(e-n)<=t,Rl=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=N8(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=gr(K(s,l+E),K(m,p),a.angle),b=gr(K(s+u,l),K(m,p),a.angle),w=gr(K(c,l+E),K(m,p),a.angle),y=gr(K(s+u,d),K(m,p),a.angle),x=K(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=gr(K(s,l),K(m,p),a.angle),b=gr(K(c,l),K(m,p),a.angle),w=gr(K(s,d),K(m,p),a.angle),y=gr(K(c,d),K(m,p),a.angle),x=K(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}}else if(e.length>1){let[a,s,l,c]=pf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=K(a,s),u=K(l,s),E=K(a,c),g=K(l,c),b=K(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>K($e(a[0]),$e(a[1])))},W2=(e,n,t,o)=>U2(e,n,t,o),V2=(e,n,t,o)=>{let r=W2(e,n,t,o),i=H2(r,o).filter(m=>!(m.length===1&&G2(m[0]))).map(m=>mf(m).map(p=>$e(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>F2)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Dm(hn(g,w),hn(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[K(b,g),K(b,w)],endSide:[K(y,x),K(y,I)],length:y-b,overlap:Am(hn(g,w),hn(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>F2)break e;let E=c[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Dm(hn(g,b),hn(y,I))&&d.push({startBounds:p,endBounds:E,startSide:[K(g,w),K(b,w)],endSide:[K(y,x),K(I,x)],length:x-w,overlap:Am(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:d}},O2=(e,n,t,o,r,i,a)=>{if(!Lo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=pf(e,n).map(b=>$e(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Dm(hn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=$e(w-E);if(b.length>p-d&&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=d-I,C=$e(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-p,D=$e(M-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!Dm(hn(d,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=$e(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,C=$e(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=$e(m-P),D=b.length-M;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},Y2=(e,n,t,o)=>{let r=W2(e,n,t,o);return H2(r,o).filter(i=>!(i.length===1&&G2(i[0]))).flatMap(i=>Rl(i,o))},La=(e,n,t,o,r,i,a)=>{if(!Lo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=gn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},X2=(e,n,t,o,r)=>{let i=t.state,a=B8(e,i);if(!Lo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=$e(n.x),n.y=$e(n.y);let s=[],l=[],c=Lm(i.zoom.value),d={x:c,y:c},m=Rl(a,r,{dragOffset:n});La(a,m,t,o,s,l,d),O2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:$e(n.x+p.x),y:$e(n.y+p.y)};La(a,Rl(a,r,{dragOffset:u}),t,o,s,l,d),O2(a,u,t,o,s,l,d);let E=uf(s,l),g=G8(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},$e=e=>Math.round(e*10**6)/10**6,z2=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())},uf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=$e(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>K($e(a[0]),$e(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=$e(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>K($e(a[0]),$e(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:z2(i.map(a=>K(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:z2(i.map(a=>K(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},z8=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[$e(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},G8=(e,n,t)=>{let[o,r,i,a]=pf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,w=Am(hn(r,a),l.gap.overlap),y=Am(hn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[K(l.gap.startSide[0][0],x),K(o,x)]},{type:"gap",direction:"horizontal",points:[K(i,x),K(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[K(x,l.gap.startSide[0][1]),K(x,r)]},{type:"gap",direction:"vertical",points:[K(x,a),K(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[K(m,x),K(u,x)]},{type:"gap",direction:"horizontal",points:[K(g,x),K(o,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"horizontal",points:[K(i,x),K(c,x)]},{type:"gap",direction:"horizontal",points:[K(m,x),K(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[K(x,a),K(x,d)]},{type:"gap",direction:"vertical",points:[K(x,p),K(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[K(x,p),K(x,E)]},{type:"gap",direction:"vertical",points:[K(x,b),K(x,r)]})}break}}}return z8(s.map(l=>({...l,points:l.points.map(c=>K($e(c[0]),$e(c[1])))})))},hf=(e,n,t,o,r,i)=>{if(!Lo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!O8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=mf(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(K(l,s),K(l,c));break}case"w":{d.push(K(a,s),K(a,c));break}case"n":{d.push(K(a,s),K(l,s));break}case"s":{d.push(K(a,c),K(l,c));break}case"ne":{d.push(K(l,s));break}case"nw":{d.push(K(a,s));break}case"se":{d.push(K(l,c));break}case"sw":{d.push(K(a,c));break}}let m=Lm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];La(n,d,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]=mf(e).map(C=>$e(C)),I=[K(b,w),K(b,x),K(y,w),K(y,x)];La(e,I,t,o,u,E,p);let T=uf(u,E);return{snapOffset:g,snapLines:T}},K2=(e,n,t,o,r,i)=>{if(!Lo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[K(o.x+r.x,o.y+r.y)],s=Lm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];La([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Rl([e],i,{boundingBoxCorners:!0,omitCenter:!0});La([e],p,n,t,c,d,l);let u=uf(c,d);return{snapOffset:m,snapLines:u}},Z2=(e,n,t,o,r)=>{if(!Lo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=U2(e,[],n.state,r),a=Lm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Rl([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,K(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,K(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},$2=e=>e===di.rectangle||e===di.ellipse||e===di.diamond||e===di.frame||e===di.magicframe||e===di.image||e===di.text;import{getCommonFrameId as H8,getFrameChildrenInsertionIndex as U8,isElementInViewport as W8}from"@excalidraw/element";import{arrayToMap as V8,memoize as Y8,toBrandedType as X8}from"@excalidraw/common";var Nl=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",Y8(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});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&&H8(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:s,width:l}){let c=[];for(let d of n.values())W8(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=X8(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=V8(t),i=n.filter(s=>!r.has(s.id)),a=U8(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Ex.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as q8,easeOut as J2}from"@excalidraw/common";import{SVG_NS as q2,getSvgPathFromStroke as $8,sceneCoordsToViewportCoords as j8}from"@excalidraw/common";import{version as K8}from"react";import{unstable_batchedUpdates as j2}from"react-dom";import{throttleRAF as Z8}from"@excalidraw/common";var je=e=>n=>{j2(e,n)},_m=e=>Z8(n=>{j2(e,n)}),_a=(()=>{let e;try{let t=K8.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||(_a()?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 lt=he;var Rm=class Rm{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-${Rm.counter++}`,this.trailElement=document.createElementNS(q2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(q2,"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),lt.running(this.key)||lt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){lt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new ya(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 s=j8({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return $8(r,!0)}};v(Rm,"counter",0);var Bn=Rm;var Nm=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Bn(n,{...this.getTrailOptions(),fill:()=>q8})}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(J2(i),J2(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 Bn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||ei(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",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as J8}from"@excalidraw/common";import{pointFrom as Bl,pointRotateRads as Bm}from"@excalidraw/math";var Q8=12,gf=16,e7=10,t7=gf+2,n7=.8,ff=e=>J8*2/e,Ef=(e,n,t)=>{let o=ff(n);if(t!=="desktop"||gf>(e.height+o*2)*n*n7)return null;let r=Q8/n,i=gf/n,a=Bl(e.x+e.width/2,e.y+e.height/2),s=Bm(Bl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Bm(Bl(s[0],s[1]-i/2),s,e.angle),end:Bm(Bl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:e7/n,hitboxHeight:t7/n}},Q2=(e,n,t,o)=>{let r=Ef(n,t,o);if(!r)return!1;let i=Bm(Bl(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 bf,KEYS as Fl,CLASSES as xf,POINTER_BUTTON as o7,THEME as r7,isWritableElement as i7,getFontString as eI,getFontFamilyString as tI,isTestEnv as nI,MIME_TYPES as yf,applyDarkModeFilter as a7,isRTL as s7,getViewpointFlipSign as oI}from"@excalidraw/common";import{pointFrom as rI,pointRotateRads as l7}from"@excalidraw/math";import{getTextFromElements as c7,originalContainerCache as d7,updateBoundElements as iI,updateOriginalContainerCache as aI}from"@excalidraw/element";import{LinearElementEditor as m7}from"@excalidraw/element/linearElementEditor";import{bumpVersion as p7}from"@excalidraw/element";import{getBoundTextElementId as u7,getContainerElement as wf,getTextElementAngle as h7,redrawTextBoundingBox as g7,getBoundTextMaxHeight as f7,getBoundTextMaxWidth as sI,computeContainerDimensionForBoundText as lI,computeBoundTextPosition as E7,getBoundTextElement as b7}from"@excalidraw/element";import{getTextWidth as x7}from"@excalidraw/element";import{getLineHeightInPx as y7}from"@excalidraw/element";import{getLineWidth as w7}from"@excalidraw/element";import{normalizeText as cI}from"@excalidraw/element";import{wrapText as v7}from"@excalidraw/element";import{getWrappedTextLines as I7}from"@excalidraw/element";import{isArrowElement as Fm,isBoundToContainer as T7,isTextElement as dI}from"@excalidraw/element";var S7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value*oI(o.viewpointFlip.horizontal)}, ${a.value*oI(o.viewpointFlip.vertical)}) rotate(${s}deg)`},C7=(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 r7(r)?"rtl":"ltr"},T7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},S7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=T7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];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(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},cI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(B,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let pe=V.style.fontFamily.replace(/"/g,"");return Q2({fontFamily:B.fontFamily})!==pe||`${B.fontSize}px`!==V.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,V=a.scene.getElement(o.id);if(!V)return;let{textAlign:pe,verticalAlign:ae}=V,be=a.scene.getNonDeletedElementsMap();if(V&&lI(V)){let ce=V.x,Be=V.y,se=wf(V,a.scene.getNonDeletedElementsMap()),De=V.width,Le=V.height,Ce=V.width,At=V.height;if(se&&V.containerId){if(Fm(se)){let Dt=l7.getBoundTextElementPosition(se,V,be);ce=Dt.x,Be=Dt.y}let xs=d(V,u),bo;if(xs?bo=rI(se.id,se.height):(bo=s7[se.id],bo||(bo=rI(se.id,se.height))),Ce=iI(se,V),At=u7(se,V),!Fm(se)&&Le>At){let Dt=aI(Le,se.type);a.scene.mutateElement(se,{height:Dt}),oI(se,a.scene);return}else if(!Fm(se)&&se.height>bo.height&&Le<At){let Dt=aI(Le,se.type);a.scene.mutateElement(se,{height:Dt}),oI(se,a.scene)}else{let{x:Dt,y:ys}=h7(se,V,be);ce=Dt,Be=ys}}let[Cn,Pn]=t(ce,Be);se?De+=.5:(Ce=(B.viewpointFlip.horizontal?Cn-8:B.width-8-Cn)/B.zoom.value,De=Math.min(De,Ce)),Le*=1.05;let Yo=J2(V),Pi=m7(V,se),ki=(B.viewpointFlip.vertical?Pn:B.height-Pn)/B.zoom.value;Object.assign(u.style,{font:Yo,lineHeight:V.lineHeight,width:`${De}px`,height:`${Le}px`,left:`${Cn}px`,top:`${Pn}px`,transform:v7(De,Le,Pi,B,Ce,ki),textAlign:pe,verticalAlign:ae,color:o7(V.strokeColor,B.theme===t7.DARK),opacity:V.opacity/100,maxHeight:`${ki}px`}),c={angle:Pi,font:Yo,height:V.height,lineHeightPx:E7(V.fontSize,V.lineHeight),textAlign:pe,width:V.width,x:ce,y:Be},u.scrollTop=0,eI()&&(u.style.fontFamily=Q2(V)),a.scene.mutateElement(V,{x:ce,y:Be})}},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";(w7(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(!l||!c)return null;let B=c,V=nI(B.x+B.width/2,B.y+B.height/2),[pe,ae]=i7(nI(l.x,l.y),V,-B.angle),be=pe-B.x,ce=ae-B.y,Be=y7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(Be.length-1,Math.floor(ce/B.lineHeightPx))),De=Be[se],Le=I7(u.value,De.start),Ce=b7(De.text,B.font),At=B.textAlign==="center"?(B.width-Ce)/2:B.textAlign==="right"?B.width-Ce:0,Cn=be-At;if(!De.text)return De.start;let Pn=S7({text:De.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:Le,targetX:Cn});return De.start+(Pn||0)},w=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let V=Tw(B),pe=null;if(V.has(yf.excalidrawClipboard)||V.has(yf.excalidraw)){B.preventDefault(),pe=await Zr(B);try{let se=await tm(pe);if(se.elements){let De=a7(se.elements);if(De){let{selectionStart:Le,selectionEnd:Ce,value:At}=u;u.value=At.slice(0,Le)+De+At.slice(Ce);let Cn=Le+De.length;u.selectionStart=u.selectionEnd=Cn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}pe=pe||await Zr(B);let ae=pe.findByType(yf.text);if(!ae)return;let be=sI(ae.value);if(!be)return;let ce=wf(o,a.scene.getNonDeletedElementsMap()),Be=J2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(ce){let se=g7(ce,a.scene.getNonDeletedElementsMap()),De=x7(`${u.value}${be}`,Be,iI(ce,se)),Le=f7(De,Be);u.style.width=`${Le}px`}},u.oninput=()=>{let B=sI(u.value);if(u.value!==B){let V=u.selectionStart;u.value=B,u.selectionStart=V,u.selectionEnd=V}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&Bd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Bd),p();else if(!B.shiftKey&&Fd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Fd),p();else if(!B.shiftKey&&Od.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Od),p();else if(Wh.keyTest(B))a.actionManager.executeAction(Wh);else if(Vh.keyTest(B))a.actionManager.executeAction(Vh);else if(B.key===Fl.ESCAPE)B.preventDefault(),D=!0,_();else if(Jr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(Jr);else if(B.key===Fl.ENTER&&B[Fl.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Fl.TAB||B[Fl.CTRL_OR_CMD]&&(B.code===bf.BRACKET_LEFT||B.code===bf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===bf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:B,selectionEnd:V}=u,pe=P(),ae=u.value;pe.forEach(be=>{let ce=ae.slice(0,be),Be=ae.slice(be);ae=`${ce}${x}${Be}`}),u.value=ae,u.selectionStart=B+y,u.selectionEnd=V+y*pe.length},C=()=>{let{selectionStart:B,selectionEnd:V}=u,pe=P(),ae=[],be=u.value;pe.forEach(ce=>{let Be=be.slice(ce,ce+y).match(I);if(Be){let se=be.slice(0,ce),De=be.slice(ce+Be[0].length);be=`${se}${De}`,ae.push(ce)}}),u.value=be,ae.length&&(B>ae[ae.length-1]?u.selectionStart=Math.max(B-y,ae[ae.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,V-y*ae.length))},P=()=>{let{selectionStart:B,selectionEnd:V,value:pe}=u,ae=pe.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-ae,pe.slice(B,V).split(`
14
- `).reduce((ce,Be,se,De)=>ce.concat(se?ce[se-1]+De[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(ie)return;ie=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let V=wf(B,a.scene.getNonDeletedElementsMap());if(V){if(u.value.trim()){let pe=d7(V);!pe||pe!==o.id?a.scene.mutateElement(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:o.id})}):Fm(V)&&c7(V)}else a.scene.mutateElement(V,{boundElements:V.boundElements?.filter(pe=>!lI(pe))});p7(B,V,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,me&&me.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),W(),G(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let V=B?.target,pe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),ae=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content"),be=(V instanceof HTMLElement||V instanceof SVGElement)&&(!!V.closest(`.${xf.SHAPE_ACTIONS_MENU}`)||!!V.closest(".compact-shape-actions-island"));setTimeout(()=>{be||pe||ae||(u.onblur=_,u.focus(),w&&(u.setSelectionRange(w.start,w.end),w=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},Y=B=>{let V=B?.target;if(B.button===e7.WHEEL){V instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let pe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),ae=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${xf.SHAPE_ACTIONS_MENU}, .${xf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!n7(B.target)||pe||ae?F():B.target instanceof HTMLCanvasElement&&!eI()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=a.onScrollChangeEmitter.on(()=>{p()}),G=a.onStateChange("viewpointFlip",()=>{p()}),ie=!1;s&&!w&&u.select(),L();let me=null;return r&&"ResizeObserver"in window?(me=new window.ResizeObserver(()=>{p()}),me.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",Y,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Om}from"@excalidraw/common";import{getCommonBounds as C7}from"@excalidraw/element";var _o=4,fn=6,dI="rgba(0,0,0,0.3)",mI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=C7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Om("sat"))||0,bottom:parseInt(Om("sab"))||0,left:parseInt(Om("sal"))||0,right:parseInt(Om("sar"))||0},m=jn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=y-b,P=x-w,M=Math.max(_o*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(_o*2,d.top+d.bottom)+fn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===y?null:{x:Math.max(d.left,_o)+fn+(p-b)/C*n,y:t-fn-Math.max(_o,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===w&&g===x?null:{x:m?Math.max(d.left,_o):n-fn-Math.max(d.right,_o),y:Math.max(d.top,_o)+fn+(u-w)/P*t,width:fn,height:k,deltaMultiplier:F}}},vf=(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 Y7}from"@excalidraw/math";import{getElementLineSegments as X7}from"@excalidraw/element";import{LinearElementEditor as K7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as $7,isLinearElement as Z7}from"@excalidraw/element";import{getFrameChildren as j7}from"@excalidraw/element";import{selectGroupsForSelectedElements as q7}from"@excalidraw/element";import{arrayToMap as J7,easeOut as bI,isShallowEqual as Q7}from"@excalidraw/common";import{simplify as P7}from"points-on-curve";import{polygonFromPoints as k7,lineSegment as Gm,pointFrom as _a,pointOnLineSegment as M7,polygonIncludesPointNonZero as A7,PRECISION as zm}from"@excalidraw/math";import{boundsContainBounds as uI,computeBoundTextPosition as D7,doBoundsIntersect as L7,elementOverlapsWithFrame as _7,getBoundTextElement as hI,getContainingFrame as R7,getElementBounds as gI,intersectElementWithLineSegment as N7,isBoundToContainer as fI,pointInsideBoundsInclusive as B7}from"@excalidraw/element";var EI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=P7(n,s));let d=t.filter(g=>!g.locked&&!fI(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=k7(c),u=[m[0]-zm,m[1]-zm,m[2]+zm,m[3]+zm];for(let g of d){let b=gI(g,o),w=F7(g,b,o),y=O7(b,w);if(L7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!uI(u,y))continue;let x=z7(g,o,r,w),I=U7(p,x,y,l);l==="contain"?I&&!pI(c,g,o,w)&&a.add(g.id):I?a.add(g.id):pI(c,g,o,w)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?H7([...a],o):[...i,...a]}},F7=(e,n,t)=>{let o=R7(e,t);if(!o)return null;let r=gI(o,t);return uI(r,n)?null:_7(e,o,t)?r:null},O7=(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,z7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=hI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?G7(s,o):s},G7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,w]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){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(Gm(_a(s+u*m,l+u*p),_a(s+E*m,l+E*p)))}return a},H7=(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||fI(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(s=>o.has(s))})},U7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>A7(a,e)||o==="contain"&&V7(a,e);return n.length===0?W7(t)[r](i):n[r](a=>a[r](i))},W7=([e,n,t,o])=>[_a(e,n),_a(t,n),_a(t,o),_a(e,o)],V7=(e,n)=>n.some((t,o)=>o>0&&M7(e,Gm(n[o-1],t))),pI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Gm(e[l],s)).concat([Gm(e[e.length-1],e[0])]),i=hI(n,t),a=(s,l)=>{let c=N7(s,t,l,0,!o);return o?c.some(d=>B7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...D7(n,i,t)},s))};var Hm=class extends Bn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(bI(s),bI(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((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&$7(c)){let d=j7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=q7({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&Z7(this.app.scene.getNonDeletedElement(a[0]))?new K7(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=>Y7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!Q7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=J7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=X7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=EI({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 eB,easeOut as xI,THEME as tB}from"@excalidraw/common";import{computeBoundTextPosition as nB,doBoundsIntersect as oB,getBoundTextElement as rB,getElementBounds as iB,getElementLineSegments as aB,getFreedrawOutlineAsSegments as sB,getFreedrawOutlinePoints as lB,intersectElementWithLineSegment as yI,isArrowElement as cB,isFreeDrawElement as wI,isLineElement as dB,isPointInElement as mB}from"@excalidraw/element";import{lineSegment as pB,lineSegmentsDistance as vI,pointFrom as kI,polygon as uB,polygonIncludesPointNonZero as hB}from"@excalidraw/math";import{getElementsInGroup as II}from"@excalidraw/element";import{shouldTestInside as gB}from"@excalidraw/element";import{hasBoundTextElement as TI,isBoundToContainer as SI}from"@excalidraw/element";import{getBoundTextElementId as CI}from"@excalidraw/element";var Um=class extends Bn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(xI(s),xI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===tB.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(s=>kI(s[0],s[1]))||[];if(o.length<2)return[];let r=pB(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=eB(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(PI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=II(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(SI(s)&&this.elementsToErase.delete(s.containerId),TI(s)){let d=CI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&PI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=II(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(TI(s)){let d=CI(s);d&&this.elementsToErase.add(d)}SI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},PI=(e,n,t,o)=>{let r=e[1],i=wI(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],s=iB(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!oB(a,l))return!1;if(gB(n)&&mB(r,n,t))return!0;if(wI(n)){let d=lB(n),m=sB(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(vI(E,e)<=p)return!0;let u=uB(...d.map(([E,g])=>kI(n.x+E,n.y+g)));return!!hB(e[0],u)}let c=rB(n,t);if(cB(n)||dB(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=aB(n,t);for(let p of m)if(vI(p,e)<=d)return!0;return!1}return yI(n,t,e,0,!0).length>0||!!c&&yI({...c,...nB(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as DB}from"@excalidraw/common";import{newElement as LB}from"@excalidraw/element";import{COLOR_PALETTE as fB,DEFAULT_FONT_FAMILY as EB,DEFAULT_FONT_SIZE as bB,VERTICAL_ALIGN as xB}from"@excalidraw/common";var MI=44,AI=22,DI=66,LI=48,Ol=14,_I=304,RI=320,If=5.87,NI=28,BI=4,FI=2,Tf=10,OI=10,zI=8,so=12,Ra=256,di=10,Sf=4,Na=so*2,Cf=so*2,GI=100,HI=140,zl=.35,UI=so/2,Er=20,Wm=so*2,Pf=so,Oe={fillStyle:"hachure",fontFamily:EB,fontSize:bB,opacity:100,roughness:1,strokeColor:fB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:xB.MIDDLE,locked:!1};import{pointFrom as Ba}from"@excalidraw/math";import{COLOR_PALETTE as KI,DEFAULT_CHART_COLOR_INDEX as yB,FONT_FAMILY as Af,FONT_SIZES as Vm,ROUNDNESS as WI,DEFAULT_FONT_SIZE as wB,getAllColorsSpecificShade as vB,getFontString as Df,getLineHeight as Lf,ROUGHNESS as VI}from"@excalidraw/common";import{getApproxMinLineWidth as _f,measureText as br,newElement as Mf,newLinearElement as kf,newTextElement as Fa,wrapText as $I}from"@excalidraw/element";var mi=vB(yB),IB=e=>e.labels?.length??e.series[0]?.values.length??0,Oa=(e,n)=>{if(!e)return!1;let t=IB(e);return t<2?!1:n==="radar"?t>=3:!0},YI=(e,n)=>{let t=n<=1?0:Math.min(DI,(n-1)*AI);return e+t},Ym=(e,n)=>{if(e==="line"){let o=YI(LI,n);return{slotWidth:o,gap:Ol,chartHeight:RI,xLabelMaxWidth:o+Ol*3+Tf}}let t=YI(MI,n);return{slotWidth:t,gap:Ol,chartHeight:_I,xLabelMaxWidth:t+Ol*3+Tf}},za=(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}},ZI=()=>{let e=Ra+Cf*2,n=Ra+Cf*2;return{chartWidth:e,chartHeight:n}},TB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Ga=(e,n)=>{if(e<=0||mi.length===0)return[];let t=mi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>TB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>mi[r[l%r.length]])},Ha=e=>{if(mi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*mi.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)%mi.length},Ua=e=>mi[e],jI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=GI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},SB=e=>/\s/.test(e.trim()),Xm=(e,n,t)=>SB(e)?$I(e,n,t):e,qI=(e,n,t,o,r,i)=>{let a=Af.Excalifont,s=Vm.sm,l=Lf(a),c=Df({fontFamily:a,fontSize:s}),d=Math.min(HI,r*(e.length>8?.56:.72)),m=_f(c,l),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>br(z,c,l).width)),x=Math.max(m,d,y),I=Xm(g,c,x),T=br(I,c,l),C=Math.cos(w),P=Math.sin(w),M=C>zl?"left":C<-zl?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Na+_+UI,L=t+C*(r+k),F=o+P*(r+k),Y=P>zl?so/3:P<-zl?-so/3:0;return Fa({backgroundColor:i,...Oe,text:I,originalText:g,x:L,y:F+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:M,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}},Wa=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Af["Lilita One"],s=Vm.lg,l=Lf(a),c=Df({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Xm(C,c,Ra),M=br(P,c,l),D=Er+Pf+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(Er/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Na),u=Wm,E=Er*.6,g=d.reduce((I,T)=>I+T.width,0)+Wm*Math.max(0,d.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Mf({...Oe,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:KI.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:VI.architect,roundness:{type:WI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{y.push(Mf({...Oe,backgroundColor:I.color,type:"rectangle",x,y:p-Er/2,width:Er,height:Er,fillStyle:"solid",strokeColor:I.color,roughness:VI.architect,roundness:{type:WI.PROPORTIONAL_RADIUS}})),y.push(Fa({...Oe,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+Er+Pf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Wm}),y},CB=(e,n,t,o)=>{if(br(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(br(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},PB=(e,n,t,o)=>{if(br(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=>br(a,t,o).width>n)&&n>=_f(t,o)?{wrapped:!0,text:$I(e,t,n)}:{wrapped:!1,text:CB(e,n,t,o)}},JI=(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}},XI=e=>e.includes("..."),kB=(e,n,t,o,r)=>{let i=Math.max(NI,Math.ceil(_f(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=XI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
- `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(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},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=PB(e,u,o,r),b=br(g,o,r),w=JI(b.width,b.height,If),y={originalText:e,text:g,metrics:b,rotatedWidth:w.width,rotatedHeight:w.height,wrapped:E},x=w.width-t;if(x<=0){(!d||c(y,d))&&(d=y);continue}(!m||x<m.overflow||x===m.overflow&&c(y,m.spec))&&(m={overflow:x,spec:y}),!XI(y.text)&&(!p||x<p.overflow||x===p.overflow&&c(y,p.spec))&&(p={overflow:x,spec:y})}return d||(p&&m&&p.overflow<=m.overflow+zI?p.spec:m.spec)},Km=e=>{if(e.type!=="text")return e.y+e.height;let n=JI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Gl=(e,n,t,o,r)=>{let i=Oe.fontFamily,a=Vm.sm,s=Lf(i),l=Df({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-BI*2+OI),d=t;return e.labels?.map((m,p)=>{let u=kB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+FI+(u.rotatedHeight-u.metrics.height)/2;return Fa({backgroundColor:o,...Oe,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:If,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},MB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Fa({backgroundColor:o,...Oe,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Fa({backgroundColor:o,...Oe,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},AB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=za(e,r),s=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t,width:i,points:[Ba(0,0),Ba(i,0)]}),l=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t,height:a,points:[Ba(0,0),Ba(0,-a)]}),c=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:di,points:[Ba(0,0),Ba(i,0)]});return[s,l,c]},$m=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=za(e,r),c=e.title?Fa({backgroundColor:o,...Oe,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-wB,roundness:null,textAlign:"center",fontSize:Vm.xl,fontFamily:Af["Lilita One"]}):null,d=a?Mf({backgroundColor:o,...Oe,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:KI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Gl(e,n,t,o,r),...MB(e,n,t,o,r,i),...AB(e,n,t,o,r)]};var QI=(e,n,t,o)=>{let r=e.series,i=Ym("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Ha(o),l=Ua(s),c=Ga(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return LB({backgroundColor:_,...Oe,type:"rectangle",fillStyle:r.length>1?"solid":Oe.fillStyle,strokeColor:r.length>1?_:Oe.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=$m(e,n,t,l,i,a,DB()),b=Gl(e,n,t,l,i),w=Math.max(t+i.gap/2,...b.map(I=>Km(I))),{chartWidth:y}=za(e,i),x=Wa(r,c,n+y/2,w,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Rf}from"@excalidraw/math";import{isDevEnv as _B}from"@excalidraw/common";import{newElement as RB,newLinearElement as eT}from"@excalidraw/element";var tT=(e,n,t,o)=>{let r=e.series,i=Ym("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Ha(o),l=Ua(s),c=Ga(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Rf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),M=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return eT({backgroundColor:"transparent",...Oe,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(T/a)*i.chartHeight+i.gap/2;return RB({backgroundColor:c[I],...Oe,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+M-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,C=x/a*i.chartHeight+i.gap/2+i.gap;return eT({backgroundColor:l,...Oe,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:di,points:[Rf(0,0),Rf(0,C)]})}),E=$m(e,n,t,l,i,a,_B()),g=Gl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Km(x))),{chartWidth:w}=za(e,i),y=Wa(r,c,n+w/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...y]};var Fn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},NB=(e,n)=>e.slice(1).every(t=>Fn(t[n])!==null),nT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Fn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Fn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Fn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Fn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!NB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Fn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Fn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Fn(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=>Fn(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=>Fn(a[1]))}]}}},Zm=e=>{let n=s=>e.replace(/\r\n?/g,`
13
+ `,n),r=e.slice(t,o===-1?e.length:o);return s7(r)?"rtl":"ltr"},P7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},k7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=P7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];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(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},mI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(B,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let pe=V.style.fontFamily.replace(/"/g,"");return tI({fontFamily:B.fontFamily})!==pe||`${B.fontSize}px`!==V.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,V=a.scene.getElement(o.id);if(!V)return;let{textAlign:pe,verticalAlign:ae}=V,be=a.scene.getNonDeletedElementsMap();if(V&&dI(V)){let ce=V.x,Be=V.y,se=wf(V,a.scene.getNonDeletedElementsMap()),De=V.width,Le=V.height,Ce=V.width,At=V.height;if(se&&V.containerId){if(Fm(se)){let Dt=m7.getBoundTextElementPosition(se,V,be);ce=Dt.x,Be=Dt.y}let ys=d(V,u),bo;if(ys?bo=aI(se.id,se.height):(bo=d7[se.id],bo||(bo=aI(se.id,se.height))),Ce=sI(se,V),At=f7(se,V),!Fm(se)&&Le>At){let Dt=lI(Le,se.type);a.scene.mutateElement(se,{height:Dt}),iI(se,a.scene);return}else if(!Fm(se)&&se.height>bo.height&&Le<At){let Dt=lI(Le,se.type);a.scene.mutateElement(se,{height:Dt}),iI(se,a.scene)}else{let{x:Dt,y:ws}=E7(se,V,be);ce=Dt,Be=ws}}let[Cn,Pn]=t(ce,Be);se?De+=.5:(Ce=(B.viewpointFlip.horizontal?Cn-8:B.width-8-Cn)/B.zoom.value,De=Math.min(De,Ce)),Le*=1.05;let Yo=eI(V),ki=h7(V,se),Mi=(B.viewpointFlip.vertical?Pn:B.height-Pn)/B.zoom.value;Object.assign(u.style,{font:Yo,lineHeight:V.lineHeight,width:`${De}px`,height:`${Le}px`,left:`${Cn}px`,top:`${Pn}px`,transform:S7(De,Le,ki,B,Ce,Mi),textAlign:pe,verticalAlign:ae,color:a7(V.strokeColor,B.theme===r7.DARK),opacity:V.opacity/100,maxHeight:`${Mi}px`}),c={angle:ki,font:Yo,height:V.height,lineHeightPx:y7(V.fontSize,V.lineHeight),textAlign:pe,width:V.width,x:ce,y:Be},u.scrollTop=0,nI()&&(u.style.fontFamily=tI(V)),a.scene.mutateElement(V,{x:ce,y:Be})}},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";(T7(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(!l||!c)return null;let B=c,V=rI(B.x+B.width/2,B.y+B.height/2),[pe,ae]=l7(rI(l.x,l.y),V,-B.angle),be=pe-B.x,ce=ae-B.y,Be=I7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(Be.length-1,Math.floor(ce/B.lineHeightPx))),De=Be[se],Le=C7(u.value,De.start),Ce=w7(De.text,B.font),At=B.textAlign==="center"?(B.width-Ce)/2:B.textAlign==="right"?B.width-Ce:0,Cn=be-At;if(!De.text)return De.start;let Pn=k7({text:De.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:Le,targetX:Cn});return De.start+(Pn||0)},w=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let V=Tw(B),pe=null;if(V.has(yf.excalidrawClipboard)||V.has(yf.excalidraw)){B.preventDefault(),pe=await $r(B);try{let se=await tm(pe);if(se.elements){let De=c7(se.elements);if(De){let{selectionStart:Le,selectionEnd:Ce,value:At}=u;u.value=At.slice(0,Le)+De+At.slice(Ce);let Cn=Le+De.length;u.selectionStart=u.selectionEnd=Cn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}pe=pe||await $r(B);let ae=pe.findByType(yf.text);if(!ae)return;let be=cI(ae.value);if(!be)return;let ce=wf(o,a.scene.getNonDeletedElementsMap()),Be=eI({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(ce){let se=b7(ce,a.scene.getNonDeletedElementsMap()),De=v7(`${u.value}${be}`,Be,sI(ce,se)),Le=x7(De,Be);u.style.width=`${Le}px`}},u.oninput=()=>{let B=cI(u.value);if(u.value!==B){let V=u.selectionStart;u.value=B,u.selectionStart=V,u.selectionEnd=V}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&Bd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Bd),p();else if(!B.shiftKey&&Fd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Fd),p();else if(!B.shiftKey&&Od.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Od),p();else if(Wh.keyTest(B))a.actionManager.executeAction(Wh);else if(Vh.keyTest(B))a.actionManager.executeAction(Vh);else if(B.key===Fl.ESCAPE)B.preventDefault(),D=!0,_();else if(Jr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(Jr);else if(B.key===Fl.ENTER&&B[Fl.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Fl.TAB||B[Fl.CTRL_OR_CMD]&&(B.code===bf.BRACKET_LEFT||B.code===bf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===bf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:B,selectionEnd:V}=u,pe=P(),ae=u.value;pe.forEach(be=>{let ce=ae.slice(0,be),Be=ae.slice(be);ae=`${ce}${x}${Be}`}),u.value=ae,u.selectionStart=B+y,u.selectionEnd=V+y*pe.length},C=()=>{let{selectionStart:B,selectionEnd:V}=u,pe=P(),ae=[],be=u.value;pe.forEach(ce=>{let Be=be.slice(ce,ce+y).match(I);if(Be){let se=be.slice(0,ce),De=be.slice(ce+Be[0].length);be=`${se}${De}`,ae.push(ce)}}),u.value=be,ae.length&&(B>ae[ae.length-1]?u.selectionStart=Math.max(B-y,ae[ae.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,V-y*ae.length))},P=()=>{let{selectionStart:B,selectionEnd:V,value:pe}=u,ae=pe.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-ae,pe.slice(B,V).split(`
14
+ `).reduce((ce,Be,se,De)=>ce.concat(se?ce[se-1]+De[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(ie)return;ie=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let V=wf(B,a.scene.getNonDeletedElementsMap());if(V){if(u.value.trim()){let pe=u7(V);!pe||pe!==o.id?a.scene.mutateElement(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:o.id})}):Fm(V)&&p7(V)}else a.scene.mutateElement(V,{boundElements:V.boundElements?.filter(pe=>!dI(pe))});g7(B,V,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,me&&me.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),W(),G(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let V=B?.target,pe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),ae=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content"),be=(V instanceof HTMLElement||V instanceof SVGElement)&&(!!V.closest(`.${xf.SHAPE_ACTIONS_MENU}`)||!!V.closest(".compact-shape-actions-island"));setTimeout(()=>{be||pe||ae||(u.onblur=_,u.focus(),w&&(u.setSelectionRange(w.start,w.end),w=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},Y=B=>{let V=B?.target;if(B.button===o7.WHEEL){V instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let pe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),ae=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${xf.SHAPE_ACTIONS_MENU}, .${xf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!i7(B.target)||pe||ae?F():B.target instanceof HTMLCanvasElement&&!nI()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=a.onScrollChangeEmitter.on(()=>{p()}),G=a.onStateChange("viewpointFlip",()=>{p()}),ie=!1;s&&!w&&u.select(),L();let me=null;return r&&"ResizeObserver"in window?(me=new window.ResizeObserver(()=>{p()}),me.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",Y,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Om}from"@excalidraw/common";import{getCommonBounds as M7}from"@excalidraw/element";var _o=4,fn=6,pI="rgba(0,0,0,0.3)",uI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=M7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Om("sat"))||0,bottom:parseInt(Om("sab"))||0,left:parseInt(Om("sal"))||0,right:parseInt(Om("sar"))||0},m=jn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=y-b,P=x-w,M=Math.max(_o*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(_o*2,d.top+d.bottom)+fn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===y?null:{x:Math.max(d.left,_o)+fn+(p-b)/C*n,y:t-fn-Math.max(_o,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===w&&g===x?null:{x:m?Math.max(d.left,_o):n-fn-Math.max(d.right,_o),y:Math.max(d.top,_o)+fn+(u-w)/P*t,width:fn,height:k,deltaMultiplier:F}}},vf=(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 Z7}from"@excalidraw/math";import{getElementLineSegments as $7}from"@excalidraw/element";import{LinearElementEditor as j7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as q7,isLinearElement as J7}from"@excalidraw/element";import{getFrameChildren as Q7}from"@excalidraw/element";import{selectGroupsForSelectedElements as eB}from"@excalidraw/element";import{arrayToMap as tB,easeOut as yI,isShallowEqual as nB}from"@excalidraw/common";import{simplify as A7}from"points-on-curve";import{polygonFromPoints as D7,lineSegment as Gm,pointFrom as Ra,pointOnLineSegment as L7,polygonIncludesPointNonZero as _7,PRECISION as zm}from"@excalidraw/math";import{boundsContainBounds as gI,computeBoundTextPosition as R7,doBoundsIntersect as N7,elementOverlapsWithFrame as B7,getBoundTextElement as fI,getContainingFrame as F7,getElementBounds as EI,intersectElementWithLineSegment as O7,isBoundToContainer as bI,pointInsideBoundsInclusive as z7}from"@excalidraw/element";var xI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=A7(n,s));let d=t.filter(g=>!g.locked&&!bI(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=D7(c),u=[m[0]-zm,m[1]-zm,m[2]+zm,m[3]+zm];for(let g of d){let b=EI(g,o),w=G7(g,b,o),y=H7(b,w);if(N7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!gI(u,y))continue;let x=U7(g,o,r,w),I=Y7(p,x,y,l);l==="contain"?I&&!hI(c,g,o,w)&&a.add(g.id):I?a.add(g.id):hI(c,g,o,w)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?V7([...a],o):[...i,...a]}},G7=(e,n,t)=>{let o=F7(e,t);if(!o)return null;let r=EI(o,t);return gI(r,n)?null:B7(e,o,t)?r:null},H7=(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,U7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=fI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?W7(s,o):s},W7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,w]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){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(Gm(Ra(s+u*m,l+u*p),Ra(s+E*m,l+E*p)))}return a},V7=(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||bI(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(s=>o.has(s))})},Y7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>_7(a,e)||o==="contain"&&K7(a,e);return n.length===0?X7(t)[r](i):n[r](a=>a[r](i))},X7=([e,n,t,o])=>[Ra(e,n),Ra(t,n),Ra(t,o),Ra(e,o)],K7=(e,n)=>n.some((t,o)=>o>0&&L7(e,Gm(n[o-1],t))),hI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Gm(e[l],s)).concat([Gm(e[e.length-1],e[0])]),i=fI(n,t),a=(s,l)=>{let c=O7(s,t,l,0,!o);return o?c.some(d=>z7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...R7(n,i,t)},s))};var Hm=class extends Bn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(yI(s),yI(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((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&q7(c)){let d=Q7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=eB({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&J7(this.app.scene.getNonDeletedElement(a[0]))?new j7(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=>Z7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!nB(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=tB(this.app.visibleElements);for(let i of this.app.visibleElements){let a=$7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=xI({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 oB,easeOut as wI,THEME as rB}from"@excalidraw/common";import{computeBoundTextPosition as iB,doBoundsIntersect as aB,getBoundTextElement as sB,getElementBounds as lB,getElementLineSegments as cB,getFreedrawOutlineAsSegments as dB,getFreedrawOutlinePoints as mB,intersectElementWithLineSegment as vI,isArrowElement as pB,isFreeDrawElement as II,isLineElement as uB,isPointInElement as hB}from"@excalidraw/element";import{lineSegment as gB,lineSegmentsDistance as TI,pointFrom as AI,polygon as fB,polygonIncludesPointNonZero as EB}from"@excalidraw/math";import{getElementsInGroup as SI}from"@excalidraw/element";import{shouldTestInside as bB}from"@excalidraw/element";import{hasBoundTextElement as CI,isBoundToContainer as PI}from"@excalidraw/element";import{getBoundTextElementId as kI}from"@excalidraw/element";var Um=class extends Bn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(wI(s),wI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===rB.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(s=>AI(s[0],s[1]))||[];if(o.length<2)return[];let r=gB(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=oB(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(MI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=SI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(PI(s)&&this.elementsToErase.delete(s.containerId),CI(s)){let d=kI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&MI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=SI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(CI(s)){let d=kI(s);d&&this.elementsToErase.add(d)}PI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},MI=(e,n,t,o)=>{let r=e[1],i=II(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],s=lB(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!aB(a,l))return!1;if(bB(n)&&hB(r,n,t))return!0;if(II(n)){let d=mB(n),m=dB(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(TI(E,e)<=p)return!0;let u=fB(...d.map(([E,g])=>AI(n.x+E,n.y+g)));return!!EB(e[0],u)}let c=sB(n,t);if(pB(n)||uB(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=cB(n,t);for(let p of m)if(TI(p,e)<=d)return!0;return!1}return vI(n,t,e,0,!0).length>0||!!c&&vI({...c,...iB(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as RB}from"@excalidraw/common";import{newElement as NB}from"@excalidraw/element";import{COLOR_PALETTE as xB,DEFAULT_FONT_FAMILY as yB,DEFAULT_FONT_SIZE as wB,VERTICAL_ALIGN as vB}from"@excalidraw/common";var DI=44,LI=22,_I=66,RI=48,Ol=14,NI=304,BI=320,If=5.87,FI=28,OI=4,zI=2,Tf=10,GI=10,HI=8,so=12,Na=256,mi=10,Sf=4,Ba=so*2,Cf=so*2,UI=100,WI=140,zl=.35,VI=so/2,Er=20,Wm=so*2,Pf=so,Oe={fillStyle:"hachure",fontFamily:yB,fontSize:wB,opacity:100,roughness:1,strokeColor:xB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:vB.MIDDLE,locked:!1};import{pointFrom as Fa}from"@excalidraw/math";import{COLOR_PALETTE as $I,DEFAULT_CHART_COLOR_INDEX as IB,FONT_FAMILY as Af,FONT_SIZES as Vm,ROUNDNESS as YI,DEFAULT_FONT_SIZE as TB,getAllColorsSpecificShade as SB,getFontString as Df,getLineHeight as Lf,ROUGHNESS as XI}from"@excalidraw/common";import{getApproxMinLineWidth as _f,measureText as br,newElement as Mf,newLinearElement as kf,newTextElement as Oa,wrapText as jI}from"@excalidraw/element";var pi=SB(IB),CB=e=>e.labels?.length??e.series[0]?.values.length??0,za=(e,n)=>{if(!e)return!1;let t=CB(e);return t<2?!1:n==="radar"?t>=3:!0},KI=(e,n)=>{let t=n<=1?0:Math.min(_I,(n-1)*LI);return e+t},Ym=(e,n)=>{if(e==="line"){let o=KI(RI,n);return{slotWidth:o,gap:Ol,chartHeight:BI,xLabelMaxWidth:o+Ol*3+Tf}}let t=KI(DI,n);return{slotWidth:t,gap:Ol,chartHeight:NI,xLabelMaxWidth:t+Ol*3+Tf}},Ga=(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}},qI=()=>{let e=Na+Cf*2,n=Na+Cf*2;return{chartWidth:e,chartHeight:n}},PB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Ha=(e,n)=>{if(e<=0||pi.length===0)return[];let t=pi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>PB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>pi[r[l%r.length]])},Ua=e=>{if(pi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*pi.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)%pi.length},Wa=e=>pi[e],JI=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=UI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},kB=e=>/\s/.test(e.trim()),Xm=(e,n,t)=>kB(e)?jI(e,n,t):e,QI=(e,n,t,o,r,i)=>{let a=Af.Excalifont,s=Vm.sm,l=Lf(a),c=Df({fontFamily:a,fontSize:s}),d=Math.min(WI,r*(e.length>8?.56:.72)),m=_f(c,l),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>br(z,c,l).width)),x=Math.max(m,d,y),I=Xm(g,c,x),T=br(I,c,l),C=Math.cos(w),P=Math.sin(w),M=C>zl?"left":C<-zl?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Ba+_+VI,L=t+C*(r+k),F=o+P*(r+k),Y=P>zl?so/3:P<-zl?-so/3:0;return Oa({backgroundColor:i,...Oe,text:I,originalText:g,x:L,y:F+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:M,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}},Va=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Af["Lilita One"],s=Vm.lg,l=Lf(a),c=Df({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Xm(C,c,Na),M=br(P,c,l),D=Er+Pf+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(Er/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Ba),u=Wm,E=Er*.6,g=d.reduce((I,T)=>I+T.width,0)+Wm*Math.max(0,d.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Mf({...Oe,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:$I.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:XI.architect,roundness:{type:YI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{y.push(Mf({...Oe,backgroundColor:I.color,type:"rectangle",x,y:p-Er/2,width:Er,height:Er,fillStyle:"solid",strokeColor:I.color,roughness:XI.architect,roundness:{type:YI.PROPORTIONAL_RADIUS}})),y.push(Oa({...Oe,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+Er+Pf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Wm}),y},MB=(e,n,t,o)=>{if(br(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(br(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},AB=(e,n,t,o)=>{if(br(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=>br(a,t,o).width>n)&&n>=_f(t,o)?{wrapped:!0,text:jI(e,t,n)}:{wrapped:!1,text:MB(e,n,t,o)}},eT=(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}},ZI=e=>e.includes("..."),DB=(e,n,t,o,r)=>{let i=Math.max(FI,Math.ceil(_f(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=ZI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
+ `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(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},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=AB(e,u,o,r),b=br(g,o,r),w=eT(b.width,b.height,If),y={originalText:e,text:g,metrics:b,rotatedWidth:w.width,rotatedHeight:w.height,wrapped:E},x=w.width-t;if(x<=0){(!d||c(y,d))&&(d=y);continue}(!m||x<m.overflow||x===m.overflow&&c(y,m.spec))&&(m={overflow:x,spec:y}),!ZI(y.text)&&(!p||x<p.overflow||x===p.overflow&&c(y,p.spec))&&(p={overflow:x,spec:y})}return d||(p&&m&&p.overflow<=m.overflow+HI?p.spec:m.spec)},Km=e=>{if(e.type!=="text")return e.y+e.height;let n=eT(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Gl=(e,n,t,o,r)=>{let i=Oe.fontFamily,a=Vm.sm,s=Lf(i),l=Df({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-OI*2+GI),d=t;return e.labels?.map((m,p)=>{let u=DB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+zI+(u.rotatedHeight-u.metrics.height)/2;return Oa({backgroundColor:o,...Oe,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:If,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},LB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Oa({backgroundColor:o,...Oe,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Oa({backgroundColor:o,...Oe,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},_B=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Ga(e,r),s=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t,width:i,points:[Fa(0,0),Fa(i,0)]}),l=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t,height:a,points:[Fa(0,0),Fa(0,-a)]}),c=kf({backgroundColor:o,...Oe,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:mi,points:[Fa(0,0),Fa(i,0)]});return[s,l,c]},Zm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Ga(e,r),c=e.title?Oa({backgroundColor:o,...Oe,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-TB,roundness:null,textAlign:"center",fontSize:Vm.xl,fontFamily:Af["Lilita One"]}):null,d=a?Mf({backgroundColor:o,...Oe,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:$I.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Gl(e,n,t,o,r),...LB(e,n,t,o,r,i),..._B(e,n,t,o,r)]};var tT=(e,n,t,o)=>{let r=e.series,i=Ym("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Ua(o),l=Wa(s),c=Ha(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return NB({backgroundColor:_,...Oe,type:"rectangle",fillStyle:r.length>1?"solid":Oe.fillStyle,strokeColor:r.length>1?_:Oe.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Zm(e,n,t,l,i,a,RB()),b=Gl(e,n,t,l,i),w=Math.max(t+i.gap/2,...b.map(I=>Km(I))),{chartWidth:y}=Ga(e,i),x=Va(r,c,n+y/2,w,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Rf}from"@excalidraw/math";import{isDevEnv as BB}from"@excalidraw/common";import{newElement as FB,newLinearElement as nT}from"@excalidraw/element";var oT=(e,n,t,o)=>{let r=e.series,i=Ym("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Ua(o),l=Wa(s),c=Ha(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Rf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),M=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return nT({backgroundColor:"transparent",...Oe,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(T/a)*i.chartHeight+i.gap/2;return FB({backgroundColor:c[I],...Oe,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+M-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,C=x/a*i.chartHeight+i.gap/2+i.gap;return nT({backgroundColor:l,...Oe,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:mi,points:[Rf(0,0),Rf(0,C)]})}),E=Zm(e,n,t,l,i,a,BB()),g=Gl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Km(x))),{chartWidth:w}=Ga(e,i),y=Va(r,c,n+w/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...y]};var Fn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},OB=(e,n)=>e.slice(1).every(t=>Fn(t[n])!==null),rT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Fn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Fn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Fn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Fn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!OB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Fn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Fn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Fn(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=>Fn(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=>Fn(a[1]))}]}}},$m=e=>{let n=s=>e.replace(/\r\n?/g,`
16
16
  `).split(`
17
- `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?nT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Va}from"@excalidraw/math";import{FONT_FAMILY as BB,FONT_SIZES as FB,getFontString as OB,getLineHeight as zB,ROUGHNESS as oT}from"@excalidraw/common";import{measureText as GB,newLinearElement as Nf,newTextElement as HB}from"@excalidraw/element";var rT=(e,n,t,o)=>{if(!Oa(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=jI(i,r.length),l=Ha(o),c=Ua(l),d=Ga(i.length,l),{chartWidth:m,chartHeight:p}=ZI(),u=n+m/2,E=t-p/2,g=Ra/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=qI(r,b,u,E,g,c),I=BB["Lilita One"],T=FB.xl,C=zB(I),P=OB({fontFamily:I,fontSize:T}),M=e.title?Xm(e.title,P,m+Na*2):null,D=M?GB(M,P,C):null,_=M?HB({backgroundColor:c,...Oe,text:M,originalText:e.title??M,x:n+m/2,y:y-Na-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:Sf},(z,U)=>{let W=(U+1)/Sf,G=g*W,ie=b.map(me=>Va(Math.cos(me)*G,Math.sin(me)*G));return ie.push(Va(ie[0][0],ie[0][1])),Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:oT.architect,opacity:di,polygon:!0,points:ie})}):[],L=b.map(z=>{let U=Math.cos(z)*g,W=Math.sin(z)*g;return Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(W),strokeStyle:"solid",roughness:oT.architect,opacity:di,points:[Va(0,0),Va(U,W)]})}),F=i.map((z,U)=>{let W=b.map((G,ie)=>{let me=z.values[ie]??0,B=a(me,ie)*g;return Va(Math.cos(G)*B,Math.sin(G)*B)});return W.push(Va(W[0][0],W[0][1])),Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:W})}),Y=Wa(i,d,u,x,t+so*5,c);return[..._?[_]:[],...w,...k,...L,...F,...Y]};var Bf=(e,n,t,o,r)=>e==="line"?tT(n,t,o,r):e==="radar"?rT(n,t,o,r):QI(n,t,o,r);import{clamp as jm,pointFrom as Ya,pointsEqual as $B,bezierEquation as hT,pointRotateRads as qm,pointDistance as ZB}from"@excalidraw/math";import{arrayToMap as jB,BIND_MODE_TIMEOUT as Hl,DEFAULT_TRANSFORM_HANDLE_SPACING as gT,FRAME_STYLE as bn,getFeatureFlag as qB,invariant as cT,shouldRotateWithDiscreteAngle as fT,THEME as Ro}from"@excalidraw/common";import{deconstructDiamondElement as Hf,deconstructRectanguloidElement as ET,elementCenterPoint as Xa,getDiamondBaseCorners as JB,FOCUS_POINT_SIZE as QB,getOmitSidesForEditorInterface as Ff,getTransformHandles as eF,getTransformHandlesFromCoords as tF,hasBoundingBox as nF,hitElementItself as oF,isArrowElement as bT,isBindableElement as xT,isElbowArrow as Ka,isFrameLikeElement as $a,isImageElement as Jm,isLinearElement as rF,isLineElement as iF,maxBindingDistance_simple as aF,isTextElement as sF,LinearElementEditor as xn,getActiveTextElement as lF,getElementsInGroup as Uf,getSelectedGroupIds as cF,isSelectedViaGroup as dF,selectGroupsFromGivenElements as mF}from"@excalidraw/element";import{renderSelectionElement as pF}from"@excalidraw/element";import{getCommonBounds as Wf,getElementAbsoluteCoords as Wl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as dT,isFocusPointVisible as uF}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as UB}from"@excalidraw/common";var WB="#ff6b6b",VB="#ff0000",iT=1,aT=2,sT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===UB.LIGHT||n.zenModeEnabled?WB:VB,o=(n.zenModeEnabled?iT*1.5:iT)/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,XB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,KB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,YB(r,e,n));e.restore()},YB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];En(o,r,n)}for(let o of e.points)lT(o,t,n)},XB=(e,n,t)=>{lT(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},lT=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?aT*1.5:aT)/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()},En=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},KB=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||En(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),En(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),En(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(En(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),En(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||En(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),En(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),En(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(En(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),En(e,n,r))}};var hF=(e,n)=>{cT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;cT(t,"midPointCoords is null"),Qm(t,e,n)},gF=(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=xn.getElement(o,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);Qm(a,e,n)},Qm=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",Ss(n,e[0],e[1],xn.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||!bT(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Qm(a,e,n)},Of=(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)"),Ss(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},EF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&$a(a)&&(e.translate(a.x,a.y),e.beginPath(),bn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,bn.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=bn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===Ro.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",bn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,bn.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 s=Xa(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=jm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Ro.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[l,c]=Hf(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;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[l,c]=ET(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;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&&($a(n.element)||xT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&oF({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Ka(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Xa(n.element,t),p;if(n.element.type==="diamond"){let b=Xa(n.element,t);p=JB(n.element).map(w=>{let y=hT(w,.5),x=qm(y,b,n.element.angle);return Ya(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=Ya(w.x+n.element.x,w.y+n.element.y),x=qm(y,m,n.element.angle);return Ya(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=ZB(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=aF(o.zoom)+n.element.strokeWidth/2;p.forEach((b,w)=>{let y=(!c||d)&&u?.idx===w&&u.distance<=g,x=!y&&(d||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Ro.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===Ro.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()}}},bF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Hl-(a?.runtime??(s?0:Hl)),c=jm(1/Hl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&$a(m)&&(n.translate(m.x,m.y),n.beginPath(),bn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,bn.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=bn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===Ro.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,bn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,bn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Xa(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-d,t.y+r.scrollY-d),n.lineWidth=jm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Ro.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=Hf(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,w]=ET(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Hl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!$a(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Hl*l;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-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!fT(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]=Hf(t),x=Xa(t,o);w=y.map(I=>{let T=hT(I,.5),C=qm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=Xa(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=Ya(I.x+t.x,I.y+t.y),C=qm(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===Ro.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,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}},xF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(qB("COMPLEX_BINDINGS"))return bF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ya(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&fT(e.lastPointerMoveEvent);EF(n,t,o,r,s,l),n.restore()},yT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??gT*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=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*I,Cs(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},yF=(e,n,t,o)=>{let[r,i,a,s]=Wl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),Cs(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},mT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=Wf(d);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}},c=d=>{let m=Uf(t,d);return l(m)};Object.entries(mF(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>yT(e,n,d))},zf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=xn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=xn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Ka(t),l=iF(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&$B(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Of(e,n,c,a,p,!1,m)}),Ka(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Of(e,n,Ya((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Ka(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Of(e,n,d,i/2,!1,!0,!1)});e.restore()},wF=(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()},vF=(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)",Ss(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},pT=({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||!xT(a)||a.isDeleted)return;let s=dT(i.fixedPoint,a,r);if(!uF(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&Qm(s,o,n),!(m&&c)){let p=dT(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);wF(o,n,E,p),vF(o,n,p,QB/1.5,u)}},uT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?Ss(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Cs(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},IF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Wl(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/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,C],[P,M],[D,_],[k,L]]=y;e.save(),e.translate(s,l),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+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},TF=(e,n,t,o)=>{n.save();let r=ff(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+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(c,d,i,a),n.restore()},SF=(e,n,t,o,r)=>{let i=Ef(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())},CF=(e,n,t,o,r,i)=>{for(let a of n){if(!Jm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Ul(a,t,r,"center");d&&vT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Ul(a,t,r,"center");m&&wT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Ul(a,t,r,"top-right");d&&kF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Ul=(e,n,t,o)=>{if(!Jm(e))return null;let[r,i,a,s]=Wl(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},wT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===Ro.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=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*jm(i,0,1)),e.stroke()),e.restore()},Gf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,PF=(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()},kF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Gf("--color-primary",s),d=i.color??Gf("--color-warning-darkest","#ec8b14");if(l==="failed"){vT(e,n,t,o,a,{color:i.color??Gf("--color-danger","#e03131")});return}if(l==="uploading"&&wT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),PF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,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 l==="pending"&&(e.save(),e.strokeStyle=c,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())},vT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=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=s,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()},MF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Rc(n,a),E=d,g=Nc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),Bc(g,s);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&zf(g,s,b,t),s.selectionElement&&!s.isCropping)try{pF(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let w=lF(r,s);if(w&&!w.autoResize&&SF(w,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&TF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:xF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&fF(g,s,i),s.frameToHighlight&&yF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&mT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Uf(i,s.activeLockedId);mT(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>$a(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&zf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?hF(g,s):(Ka(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&gF(g,s,t)),bT(I)&&(pT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),pT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=nF(r,s,c),P=r.length===1&&rF(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&zf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=jB(r),_=[];for(let L of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(L.id);if(P&&Ka(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!dF(s,L)&&F.push(M),Y&&F.push(...Y.map(z=>ei(z,s.collaborators.get(z))))),F.length){let[z,U,W,G,ie,me]=Wl(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:W,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!Y||L.locked,cx:ie,cy:me,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Jm(L)?0:void 0})}}let k=L=>{let F=Uf(t,L),[Y,z,U,W]=Wf(F);_.push({angle:0,x1:Y,x2:U,y1:z,y2:W,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(U-Y)/2,cy:z+(W-z)/2,activeEmbeddable:!1})};for(let L of cF(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>yT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=eF(r[0],s.zoom,t,"mouse",Ff(c));if(!s.viewModeEnabled&&C&&!sF(s.editingTextElement)&&!s.croppingElementId&&uT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Jm(_)&&IF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=gT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=Wf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,Cs(g,_-D,k-D,L-_+D*2,F-k+D*2,(_+L)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(Y);let U=tF([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{...Ff(c),rotation:!0}:Ff(c));r.some(W=>!W.locked)&&uT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let D=t.get(C);if(D){let[_,k,,,L,F]=Wl(D,t,!0);g.save(),s.theme===Ro.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 Y=$a(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,F),g.rotate(D.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-L,k+z.offsetY/Y-F,z.width/Y,z.height/Y)}),g.restore()}}),sT(g,s),CF(g,o,t,e,s,l.selectionColor),g.restore(),Ow({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=mI(t,p,u,s),g.save(),g.fillStyle=dI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&cm(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},Vf=e=>{let n=MF(e);return e.callback(n),n};import{useEffect as Kl,useMemo as IT,useRef as Zf,useState as AF}from"react";import{bumpVersion as Vl,getLinearElementSubType as ja,mutateElement as jf,updateElbowArrowPoints as DF}from"@excalidraw/element";import{pointFrom as tp,pointRotateRads as LF}from"@excalidraw/math";import{hasBoundTextElement as _F,isArrowBoundToElement as RF,isArrowElement as NF,isElbowArrow as BF,isLinearElement as eE,isUsingAdaptiveRadius as FF}from"@excalidraw/element";import{getCommonBoundingBox as OF,getElementAbsoluteCoords as zF}from"@excalidraw/element";import{getBoundTextElement as kT,getBoundTextMaxHeight as GF,getBoundTextMaxWidth as HF,redrawTextBoundingBox as UF}from"@excalidraw/element";import{wrapText as WF}from"@excalidraw/element";import{assertNever as VF,CLASSES as YF,getFontString as Yf,isProdEnv as XF,mapFind as KF,reduceToCommonValue as $F,ROUNDNESS as Xf,sceneCoordsToViewportCoords as ZF,updateActiveTool as TT}from"@excalidraw/common";import{measureText as ST}from"@excalidraw/element";import{LinearElementEditor as jF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Kf,newElement as qF,newLinearElement as JF}from"@excalidraw/element";import{ShapeCache as QF}from"@excalidraw/element";import{updateBindings as eO}from"@excalidraw/element";import{jsx as Qf}from"react/jsx-runtime";var tO=8,nO=10,Yl=["rectangle","diamond","ellipse"],Xl=["line","sharpArrow","curvedArrow","elbowArrow"],oO=new Set(Yl),rO=new Set(Xl),qa=e=>oO.has(e),np=e=>e==="arrow"||rO.has(e),lo=et(null),$l=new Map,Zl=new Map,iO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Zf(null);return Kl(()=>{if(n.length===0){e.updateEditorAtom(lo,null);return}let o=op(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(lo,null),t.current=null)},[n,e]),Kl(()=>()=>{$l.clear(),Zl.clear()},[]),Qf(aO,{app:e,elements:n})},aO=({app:e,elements:n})=>{let t=op(n),o=IT(()=>t==="generic"?AT(n):[],[t,n]),r=IT(()=>t==="linear"?Jf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>ja(m)===ja(r[0])):!1,[a,s]=AF({x:0,y:0}),l=Zf(""),c=Zf(null);Kl(()=>{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===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,w,y,x]=zF(m[0],e.scene.getNonDeletedElementsMap());u=LF(tp(b,w),tp(y,x),m[0].angle)}else{let{minX:b,maxY:w}=OF(m);u=tp(b,w)}let{x:E,y:g}=ZF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Kl(()=>{for(let m of r){let p=qf(m.id,mO(m));Zl.has(p)||Zl.set(p,m)}},[r]),Kl(()=>{for(let m of o)if(!$l.has(m.id)){let p=kT(m,e.scene.getNonDeletedElementsMap());p&&$l.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Zo],["sharpArrow",Jo],["curvedArrow",er],["elbowArrow",Qo]]:t==="generic"?[["rectangle",Oi],["diamond",zi],["ellipse",Gi]]:[];return Qf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(nO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-tO}px`,zIndex:2},className:YF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&ja(r[0])===m);return Qf(Z,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&He("convertElementType",m,"ui"),tE(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},sO=(e,n,t)=>{let o=HF(e,n),r=GF(e,n),i=WF(n.text,Yf(n),o),a=ST(i,Yf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=ST(n.text,Yf(l),n.lineHeight)}jf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),UF(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((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=AT(r),c=s.every(d=>d.type===s[0].type)?Yl.indexOf(s[0].type):-1;if(t=t??Yl[(c+Yl.length+a)%Yl.length],t&&qa(t)){let d={};for(let p of s){let u=PT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=kT(p,e.scene.getNonDeletedElementsMap());u&&($l.get(p.id)&&jf(u,e.scene.getNonDeletedElementsMap(),{fontSize:$l.get(p.id)?.fontSize??u.fontSize}),sO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:TT(p,{type:"selection"})}))}}if(n==="linear"){let s=Jf(r);if(!t){let c=$F(s,ja),d=c?Xl.indexOf(c):-1;t=Xl[(d+Xl.length+a)%Xl.length]}if(np(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Zl.get(qf(m.id,t));if(p&&ja(p)===t)d.set(p.id,p),c.push(p);else{let u=PT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(eE(m))if(BF(m)){let p=lO(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=DF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});jf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=KF(["line","sharpArrow","curvedArrow"],u=>Zl.get(qf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Jf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new jF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:TT(c,{type:"selection"})}))}return!0},op=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(qa(t.type))return"generic";MT(t)&&(n=!0)}return n?"linear":null},MT=e=>eE(e)&&(!NF(e)||!RF(e)&&!_F(e)),qf=(e,n)=>`${e}:${n}`,AT=e=>e.filter(n=>qa(n.type)),Jf=e=>e.filter(n=>MT(n)),ep=20,Za=(e,n)=>e[0]===n[0],$f=(e,n)=>e[1]===n[1],CT=(e,n)=>Za(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),lO=e=>{let n=[e.points[0]],t=cO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<ep?s[0]=a[0]:Math.abs(s[1]-a[1])<ep&&(s[1]=a[1]),Za(a,s)||$f(a,s)||n.push(tp(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Za(n[i-1],n[i])&&Za(n[i],n[i+1])||$f(n[i-1],n[i])&&$f(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],s=o[i],l=o[i+1],c=Za(a,s),d=Za(s,l);if(c!==d){let m=CT(a,s),p=CT(s,l);if(m<ep||p<ep){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},cO=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},PT=(e,n,t)=>{if(!dO(e.type,n)){if(!XF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(QF.delete(e),qa(n)){let o=Vl(qF({...e,type:n,roundness:e.roundness?{type:FF(n)?Xf.ADAPTIVE_RADIUS:Xf.PROPORTIONAL_RADIUS}:e.roundness}));return eO(o,t.scene,t.state),o}if(np(n))switch(n){case"line":return Vl(JF({...e,type:"line"}));case"sharpArrow":return Vl(Kf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Vl(Kf({...e,type:"arrow",elbowed:!1,roundness:{type:Xf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Vl(Kf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return VF(n,`unhandled conversion type: ${n}`),e},dO=(e,n)=>!!(qa(e)&&qa(n)||np(e)&&np(n)),mO=e=>eE(e)?ja(e):e.type,DT=iO;import{bindBindingElementToFixedPoint as pO,dragNewTextElement as uO,getBoundTextElement as hO,getEndpointBoundTextDragAnchor as gO,getTextBindingForArrowEndpoint as fO,getUnboundArrowEndpointAtPoint as EO,isArrowElement as bO,isBindingEnabled as xO,isEndpointBoundText as yO,isTextElement as wO}from"@excalidraw/element";import{pointFrom as vO}from"@excalidraw/math";var rp=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(!xO(this.app.state))return null;let o=EO(vO(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!bO(r)||hO(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){pO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!wO(n)||!yO(n,this.app.scene.getNonDeletedElementsMap())?!1:(uO({newElement:n,...gO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as IO,BUCKET_FILL_BACKGROUND_PICKS as TO,COLOR_PALETTE as _T,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as SO,getSizeFromPoints as CO,isTransparent as PO,THEME as kO}from"@excalidraw/common";import{pointFrom as LT}from"@excalidraw/math";import{computeBucketFillPolygon as MO,isBucketFillCompatible as AO,isFrameLikeElement as DO,isRestylableFill as LO,newLinearElement as _O,ShapeCache as RO}from"@excalidraw/element";var nE=TO.filter(e=>e!==_T.white),ip=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=nE.indexOf(n),o=nE[(t+1)%nE.length];this.app.actionManager.executeAction(Ld,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(bt.get(Ut))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Ld,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Ut,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&bt.get(Ut)===n&&this.app.updateEditorAtom(Ut,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}),RO.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=LT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=MO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&AO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&LO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=CO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(y=>LT(y[0]-d,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?DO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=_O({type:"line",x:d,y:m,width:l,height:c,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===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],w<0?null:s.insertion.placement==="above"?w+1:w),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>PO(n)?_T.green[SO]:IO(n,t===kO.DARK))}};import{CURSOR_TYPE as jl,MIME_TYPES as sp,THEME as RT}from"@excalidraw/common";var NT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',NO='<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"/>',BT='<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"/>',BO=`data:${sp.svg},${encodeURIComponent(`${NT}${BT}</svg>`)}`,FO=`data:${sp.svg},${encodeURIComponent(`${NT}${NO}${BT}</svg>`)}`,OO=e=>{let n=Nu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${sp.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>`)}`},ap=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(jl.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(Is({activeTool:n}))this.set(jl.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(jl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${OO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===RT.LIGHT?BO:FO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(jl.AUTO):this.set(jl.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===RT.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(sp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as WO}from"@excalidraw/common";import{bindBindingElement as VO,convertToShape as YO,convertToShapeHandlePointerMoveFromPointerDown as XO,getHoveredElementForBinding as FT,isBindingElement as KO,isLineElement as $O,LinearElementEditor as oE,maxBindingDistance_simple as OT,newArrowElement as ZO,updateBoundPoint as jO}from"@excalidraw/element";import{getStrokeWidthByKey as zO,THEME as GO}from"@excalidraw/common";import{clamp as HO,pointFrom as UO}from"@excalidraw/math";var lp=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Bn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===GO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>HO(zO("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])=>UO(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(ht),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>XO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=OT(t.state.zoom),a=["start","end"].map(d=>{let m=oE.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:FT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&VO(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=jO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&oE.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=OT(t.state.zoom),[a,s]=[0,-1].map(l=>FT(oE.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:ZO({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||YO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:WO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&$O(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&KO(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new lp(n)}};import{isArrowKey as qO,KEYS as pi}from"@excalidraw/common";import{makeNextSelectedElementIds as JO,CaptureUpdateAction as QO,FlowChartCreator as e9,FlowChartNavigator as t9,getSelectedElements as zT,isFlowchartNodeElement as n9}from"@excalidraw/element";var dp=class e{constructor(n){this.app=n;v(this,"creator",new e9);v(this,"navigator",new t9);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(!qO(n.key))return{type:"none"};if(n[pi.CTRL_OR_CMD]&&!n.shiftKey){let a=zT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&n9(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(),s=zT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[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:JO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:QO.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 GT,hasPlayableGif as o9,isInitializedImageElement as r9,newElementWith as HT,ShapeCache as i9}from"@excalidraw/element";import{MIME_TYPES as UT}from"@excalidraw/common";var mp=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||o9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==UT.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:UT.gif,gifDecodeStatus:"pending"});let r=HT(n,{fileId:o,gifPlayback:GT({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:HT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:GT(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(!r9(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),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,i9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as a9,easeOut as $T,isBounds as s9}from"@excalidraw/common";import{clamp as ZT}from"@excalidraw/math";import{getCommonBounds as WT,getElementsInGroup as l9,isElementLink as c9,isExcalidrawElement as d9,parseElementLinkFromURL as m9}from"@excalidraw/element";var pp="animateScrollToContent",Ja="animateScrollConstraintsSnapBack",VT=500,p9=250,u9=200,rE=302,YT={full:216,compact:64},h9=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")},g9=(e,n)=>{let t=n.get(e);return t?[t]:l9(n,e)},XT=(e,n,t)=>{if(typeof e=="string"){let a=c9(e),s=a?"link":"element",l=a?m9(e):e,c=l?g9(l,n):[];return c.length?{bounds:WT(c,n),type:s}:{bounds:null,type:s}}if(s9(e))return{bounds:e,type:"area"};if(h9(e)&&!d9(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}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:WT(r,n),type:"element"}},f9=e=>e===!1?0:e===!0||e==null?Su:Math.max(e,0),E9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Nr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},KT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=E9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:f9(r.overscroll),offsets:o};return{...Kn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},b9=({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}}},x9=e=>e===!1?null:e===!0||e==null?VT:e.duration??VT,y9=(e,n,t,o,r)=>{lt.start(pp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=$T(ZT(l,0,1));return l<1?(o({...b9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},w9=(e,n,t=p9)=>{let o=Kn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||lt.running(pp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;lt.start(Ja,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-$T(ZT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Kn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},up=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=jn().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={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,w]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],w);let y=u.dataset.viewportUiName;y&&(a.add(y),w>0&&this.uiLastMeasured.set(y,{side:b,offset:w}));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"?YT.compact:YT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:rE})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,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}=XT(n.target,t,o);return r?KT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),lt.cancel(Ja),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=XT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=KT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=x9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),lt.cancel(Ja),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),y9(p,d,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||lt.cancel(Ja),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(),Kn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Kn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||w9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",a9(this.snapBack,u9));v(this,"cancelTransition",()=>{this.activeTransition=null,lt.cancel(pp)});v(this,"destroy",()=>{this.cancelTransition(),lt.cancel(Ja),this.snapBackDebounced.cancel()})}get isAnimating(){return lt.running(pp)||lt.running(Ja)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import hp from"react";var v9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,I9=/{{([\w-]+)}}/,T9=/<([\w-]+)>/,S9=/<\/([\w-]+)>/,C9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(v9).filter(Boolean).forEach(o=>{let r=o.match(T9),i=o.match(S9),a=o.match(I9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=hp.createElement(hp.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} 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},P9=({i18nKey:e,children:n,...t})=>{let{t:o}=Re();return hp.createElement(hp.Fragment,{},...C9(o(e),t))},ui=P9;import{jsx as yn,jsxs as jT}from"react/jsx-runtime";var k9=()=>jT("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(ui,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ui,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ui,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>yn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),yn("p",{children:yn(ui,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>jT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),qT=k9;import B9 from"clsx";import F9 from"react";import{isDarwin as JT}from"@excalidraw/common";var M9={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:[JT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[JT?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")]},Je=(e,n=0)=>{let t=M9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as A9,useRef as QT,useEffect as eS}from"react";import{unstable_batchedUpdates as D9}from"react-dom";import{KEYS as L9,queryFocusableElements as _9}from"@excalidraw/common";import{clamp as tS}from"@excalidraw/math";import R9 from"clsx";import{jsx as N9}from"react/jsx-runtime";var xr=10,nS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=QT(null);eS(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===L9.TAB){let u=_9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(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 d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=QT(null);return A9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-xr*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${xr}px`,d.style.overflowX="scroll"):d.style.left=`${tS(n,xr,i-xr-m)}px`;let E=Math.max(0,a-xr*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${xr}px`,d.style.overflowY="scroll"):d.style.top=`${tS(t,xr,a-xr-p)}px`}},[t,n,r,i,a]),eS(()=>{if(o){let d=m=>{l.current?.contains(m.target)||D9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),N9("div",{className:R9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as No,jsxs as rS}from"react/jsx-runtime";var ze="separator",oS=e=>"onSelect"in e,iS=F9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=no(),a=Ki(),s=n.reduce((l,c)=>c?c===ze||oS(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return No(nS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:No("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===ze)return!s[c-1]||s[c-1]===ze?null:No("hr",{className:"context-menu-item-separator"},c);if(oS(l))return No("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:rS("button",{type:"button",className:"context-menu-item",children:[No("div",{className:"context-menu-item__label",children:l.label}),No("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),No("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:rS("button",{type:"button",className:B9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[No("div",{className:"context-menu-item__label",children:m}),No("kbd",{className:"context-menu-item__shortcut",children:d?Je(d):""})]})},c)})})})});import{useId as O9}from"react";import z9 from"clsx";import{Fragment as G9,jsx as ql,jsxs as aS}from"react/jsx-runtime";var gp=({border:e,style:n})=>ql("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),fp=({label:e,border:n})=>{let t=O9(),o=aS(G9,{children:[e.icon&&ql("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return aS("div",{className:z9("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&&ql("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),ql("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&ql("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import ps from"clsx";import mV from"react";import{CLASSES as pV,TOOL_TYPE as Nk,arrayToMap as uV,isShallowEqual as jp}from"@excalidraw/common";import{mutateElement as hV,ShapeCache as gV}from"@excalidraw/element";import{showSelectedShapeActions as fV}from"@excalidraw/element";import{createIsolation as H9}from"jotai-scope";import iE from"react";import Bo from"tunnel-rat";var aE=iE.createContext(null),rt=()=>iE.useContext(aE),U9=H9(),sS=()=>iE.useMemo(()=>({MainMenuTunnel:Bo(),WelcomeScreenMenuHintTunnel:Bo(),WelcomeScreenToolbarHintTunnel:Bo(),WelcomeScreenHelpHintTunnel:Bo(),WelcomeScreenCenterTunnel:Bo(),FooterCenterTunnel:Bo(),DefaultSidebarTriggerTunnel:Bo(),DefaultSidebarTabTriggersTunnel:Bo(),OverwriteConfirmDialogTunnel:Bo(),tunnelsJotai:U9}),[]);import wr from"clsx";import{useRef as q9}from"react";import{Popover as yr}from"radix-ui";import{CLASSES as bS}from"@excalidraw/common";import{isArrowElement as ES}from"@excalidraw/element";import{forwardRef as lS}from"react";import cS from"clsx";import{jsx as dS}from"react/jsx-runtime";var W9=lS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>dS("div",{className:cS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),V9=lS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>dS("div",{className:cS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Ot={Row:W9,Col:V9};import{isTransparent as mS}from"@excalidraw/common";import{shouldAllowVerticalAlign as Y9,suppportsHorizontalAlign as X9,hasBoundTextElement as pS,isElbowArrow as K9,isImageElement as uS,isLinearElement as $9,isTextElement as Z9,hasStrokeColor as hS,toolIsArrow as j9}from"@excalidraw/element";var gS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return hS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>hS(o.type))},fS=(e,n)=>Xo(e.activeTool.type)||n.some(t=>Xo(t.type)),Ep=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(pS(n[0])||pS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:gS(e,n),backgroundColor:fS(e,n),fill:r==="bucketfill"||Xo(r)&&!mS(e.currentItemBackgroundColor)||n.some(d=>Xo(d.type)&&!mS(d.backgroundColor)),strokeWidth:i(cx),freedrawMode:i(dx),strokeStyle:i(Cu),sloppiness:i(Cu),roundness:i(mx),arrowType:i(j9),arrowheads:i(vs),text:r==="text"||n.some(Z9),textAlign:r==="text"||X9(n,t),verticalAlign:Y9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||de(t,e).some(d=>d.type==="freedraw"),align:!s&&st(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(uS)&&st(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&uS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&$9(n[0])&&!K9(n[0])}};import{Fragment as en,jsx as q,jsxs as Te}from"react/jsx-runtime";var sE=wr([bS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),xS=({renderAction:e})=>Te("fieldset",{children:[q("legend",{children:f("labels.layers")}),Te("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),yS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Te("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Te("div",{className:"align-fieldset-header",children:[q("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Te("div",{className:"buttonList",children:[o?Te(en,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Te(en,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Te("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Te(en,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},wS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Di(n,e),i=Ep(e,r,n,o);return e.activeTool.type==="bucketfill"?Te("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Te("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(en,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(en,{children:t("changeSloppiness")}),i.roundness&&q(en,{children:t("changeRoundness")}),i.arrowType&&q(en,{children:t("changeArrowType")}),i.text&&Te(en,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(en,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(xS,{renderAction:t}),i.align&&q(yS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("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")]})]})]})},vS=({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:Te(yr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:x0})}),a&&q(To,{className:sE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(en,{children:n("changeStrokeStyle")}),o.sloppiness&&q(en,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},IS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=pt(o,a,c=>ES(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>ES(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Qo:l==="round"?er:Jo})()})}),s&&q(To,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},TS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=U0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Yx})}),e.openPopup==="compactTextProperties"&&q(To,{className:sE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Te("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},SS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ox})}),s&&q(To,{className:sE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[t.layers&&q(xS,{renderAction:n}),t.align&&q(yS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("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},J9=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,CS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Di(n,e),a=Ep(e,i,n,o),{container:s}=Fe();return Te("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:wr("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(vS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(IS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(TS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),q(SS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},PS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Di(n,e),a=Ep(e,i,n,o),{container:s}=Fe(),l=q9(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Te(Xe,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[Te("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:wr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(vS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(IS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(J9,{renderAction:t,predicates:a}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(TS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(SS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Te("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[q("div",{className:"compact-action-item",children:t("undo")}),q("div",{className:"compact-action-item",children:t("redo")}),b&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},kS=({renderAction:e})=>q(Ot.Col,{gap:1,className:bS.ZOOM_ACTIONS,children:Te(Ot.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),MS=({renderAction:e,className:n})=>Te("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(ut,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Te(ut,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),AS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:wr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import Q9 from"clsx";import{useState as ez,useEffect as tz}from"react";import{THEME as nz}from"@excalidraw/common";import{jsx as lE,jsxs as oz}from"react/jsx-runtime";var bp=({delay:e,theme:n})=>{let[t,o]=ez(!!e);return tz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:oz("div",{className:Q9("LoadingMessage",{"LoadingMessage--dark":n===nz.DARK}),children:[lE("div",{children:lE(Io,{})}),lE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as vp,useEffect as JS}from"react";import Lz from"clsx";import{KEYS as pE,capitalizeString as QS}from"@excalidraw/common";import qS from"react";import{DropdownMenu as kz}from"radix-ui";import{CLASSES as Mz}from"@excalidraw/common";import rz from"clsx";import{useCallback as iz,useEffect as az,useRef as sz}from"react";import{CLASSES as lz,EVENT as DS,KEYS as cz}from"@excalidraw/common";import{DropdownMenu as dz}from"radix-ui";import{jsx as xp}from"react/jsx-runtime";var LS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=Ee(),l=sz(null),c=Xi({onClickOutside:n});Yi(l,iz(m=>{l.current?.closest(`.${lz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),az(()=>{if(!r)return;let m=u=>{u.key===cz.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(DS.KEYDOWN,m,p),()=>{document.removeEventListener(DS.KEYDOWN,m,p)}},[c,r]);let d=rz(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return xp(Ah.Provider,{value:{onSelect:o},children:xp(dz.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?xp(Ot.Col,{className:"dropdown-menu-container",children:e}):xp(Xe,{className:"dropdown-menu-container",padding:2,children:e})})})};LS.displayName="DropdownMenuContent";var _S=LS;import{jsx as pz}from"react/jsx-runtime";var mz=({children:e,className:n="",selected:t,...o})=>pz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),RS=mz;import{DropdownMenu as uz}from"radix-ui";import{jsx as cE}from"react/jsx-runtime";var NS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=wd(r);return cE(uz.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:cE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:rr(i,a),title:l.title??l["aria-label"],children:cE(ir,{icon:e,shortcut:n,children:o})})})},Qa=NS;NS.displayName="DropdownMenuItemLink";import{jsx as hz}from"react/jsx-runtime";var BS=()=>hz("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),FS=BS;BS.displayName="DropdownMenuSeparator";import{DropdownMenu as wz}from"radix-ui";import gz from"clsx";import{DropdownMenu as fz}from"radix-ui";import{useCallback as Ez,useState as OS}from"react";import{jsx as mE}from"react/jsx-runtime";var dE=-4,bz=4,zS=({children:e,className:n})=>{let t=Ee(),o=gz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=Ez(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+dE),l(dE+8))}}},[]),[i,a]=OS(bz),[s,l]=OS(dE);return mE(fz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?mE(Ot.Col,{className:"dropdown-menu-container",children:e}):mE(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},GS=zS;zS.displayName="DropdownMenuSubContent";import{DropdownMenu as xz}from"radix-ui";import{jsx as HS,jsxs as yz}from"react/jsx-runtime";var US=({children:e,icon:n,shortcut:t,className:o})=>yz(xz.SubTrigger,{className:`${rr(o)} dropdown-menu__submenu-trigger`,children:[HS(ir,{icon:n,shortcut:t,children:e}),HS("div",{className:"dropdown-menu__submenu-trigger-icon",children:v0})]}),WS=US;US.displayName="DropdownMenuSubTrigger";import VS from"react";var yp=e=>n=>{let t=VS.Children.toArray(n).find(o=>VS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},YS=yp("DropdownMenuTrigger"),XS=yp("DropdownMenuContent"),KS=yp("DropdownMenuSubTrigger"),$S=yp("DropdownMenuSubContent");import{jsxs as vz}from"react/jsx-runtime";var wp=({children:e})=>{let n=KS(e),t=$S(e);return vz(wz.Sub,{children:[n,t]})};wp.Trigger=WS;wp.Content=GS;wp.displayName="DropdownMenuSub";var vr=wp;import Iz from"clsx";import{DropdownMenu as Tz}from"radix-ui";import{jsx as Sz}from"react/jsx-runtime";var ZS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=Ee(),a=Iz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return Sz(Tz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},jS=ZS;ZS.displayName="DropdownMenuTrigger";import{jsx as Pz}from"react/jsx-runtime";var Cz=e=>Pz(Jt,{...e,icon:e.checked?Xc:Qc}),co=Cz;import{jsx as Dz,jsxs as Az}from"react/jsx-runtime";var On=({children:e,open:n})=>{let t=YS(e),o=XS(e),r=o&&qS.isValidElement(o)?qS.cloneElement(o,{open:n}):o;return Dz(kz.Root,{open:n,modal:!1,children:Az("div",{className:Mz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};On.Trigger=jS;On.Content=_S;On.Item=Jt;On.ItemCheckbox=co;On.ItemLink=Qa;On.ItemCustom=RS;On.Group=Ys;On.Separator=FS;On.Sub=vr;var ge=On;On.displayName="DropdownMenu";import{Fragment as uE,jsx as Ne,jsxs as es}from"react/jsx-runtime";var _z=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=f("buttons.objectsSnapMode");return Ne(Z,{type:"toggle",icon:qo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Rt,"ui")})},Rz=({app:e})=>Ne(Z,{type:"button",icon:Ui,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),eC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=vp(!1),[l,c]=vp("rectangle"),[d,m]=vp("arrow");JS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),JS(()=>{(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(G=>({type:G,icon:$e[G].icon,title:QS(f(`toolBar.${G}`)),fillable:$e[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:$e[G].icon,title:QS(f(`toolBar.${G}`)),fillable:$e[G].fillable})),[x,I]=vp(0),T=36,C=4,P=7,M=P*T+(P-1)*C,D=T+C,_=x>=M+1*D,k=i&&x>=M+2*D,L=x>=M+3*D,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),Y=r&&ia.includes(o.type),z=Y||F.includes(o.type),U=z?Y?$e[o.type].icon:o.type==="text"?Mn:o.type==="image"?zr:o.type==="frame"?Qn:o.type==="embeddable"?jo:o.type==="laser"?eo:o.type==="bucketfill"?Jn:Ms:Ms,W={app:e,activeTool:o,hideShortcut:!0};return es("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Ne(Vd,{...W}),Ne(Yd,{...W,setAppState:t}),r?Ne(el,{...W}):Ne(Xd,{...W}),Ne(ol,{...W}),!r&&Ne(ra,{app:e,options:w,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===l)||w[0]}),!r&&Ne(ra,{app:e,options:y,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===d)||y[0]}),_&&Ne(tl,{...W}),r&&k&&Ne(Rz,{app:e}),k&&Ne(nl,{...W}),!r&&L&&Ne(ow,{...W,hideShortcut:!0}),es(ge,{open:a,children:[Ne(ge.Trigger,{className:Lz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),es(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ia.map(G=>Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:$e[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Wd(G),disabled:Qe(e,G),children:f(`toolBar.${G}`)},G)),!r&&Ne("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Rt)&&Ne(ge.Item,{onSelect:()=>n.executeAction(Rt,"ui"),icon:qo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&es(uE,{children:[r&&Ne("div",{className:"App-toolbar__dropdown-divider"}),Ne(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:vo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:pE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Mn,shortcut:pE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Qe(e,"text"),children:f("toolBar.text")}),i&&!k&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:zr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Qe(e,"image"),children:f("toolBar.image")}),!r&&!L&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Qn,shortcut:pE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Qe(e,"frame"),children:f("toolBar.frame")}),!r&&es(uE,{children:[Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:jo,"data-testid":"toolbar-embeddable",selected:g,disabled:Qe(e,"embeddable"),children:f("toolBar.embeddable")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ur,shortcut:sa("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Qe(e,"autoshape"),children:f("toolBar.autoshape")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:eo,"data-testid":"toolbar-laser",selected:E,disabled:Qe(e,"laser"),children:f("toolBar.laser")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Jn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Qe(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&es(uE,{children:[Ne("div",{className:"App-toolbar__divider"}),Ne(_z,{actionManager:n,app:e})]})]})};import Nz from"clsx";import{jsx as Bz}from"react/jsx-runtime";var Ip=({children:e,side:n,className:t})=>Bz("div",{className:Nz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Fz from"clsx";import{jsx as Oz}from"react/jsx-runtime";var ts=e=>e.penDetected?Oz(Z,{className:Fz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Vx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as tC,jsx as vt,jsxs as hi}from"react/jsx-runtime";var nC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=rt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=vt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&hi(tC,{children:[l&&vt(ts,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),vt(E.Out,{})]}))}),M=hi("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),vt(u.Out,{})]});return hi("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>vt(eC,{app:d,actionManager:t,setAppState:o}),w=c&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=w&&!e.openMenu&&!e.openSidebar?vt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Ai(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?vt(fp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return hi(tC,{children:[a(),vt("div",{className:"App-welcome-screen",children:s&&vt(p.Out,{})}),x&&hi("div",{className:"App-bottom-bar",style:{marginBottom:fn+_o,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&vt("div",{className:"floating-status-stack",children:I}),hi("div",{className:"App-bottom-bar__actions-row",children:[y&&hi(Xe,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&vt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),vt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&vt(PS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&vt(Xe,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&vt("div",{className:"floating-status-stack",children:I}),C&&vt("div",{className:"viewport-status-frame__badge-row",children:C}),vt(Ip,{side:"top",className:"App-top-bar",children:g()})]})};import cC,{useLayoutEffect as dC,useRef as mC,useState as pC}from"react";import{newTextElement as uC}from"@excalidraw/element";import Yz from"clsx";import{useEffect as Xz,useState as Kz}from"react";import{KEYS as $z,queryFocusableElements as sC}from"@excalidraw/common";import{useCallback as zz,useState as Gz}from"react";var oC=()=>{let[e,n]=Gz(null),t=zz(o=>n(o),[]);return[e,t]};import rC from"clsx";import{useRef as Hz}from"react";import{createPortal as Uz}from"react-dom";import{KEYS as Wz}from"@excalidraw/common";import{jsx as iC,jsxs as Vz}from"react/jsx-runtime";var aC=e=>{let{closeOnClickOutside:n=!0}=e,t=dd({className:rC("excalidraw-modal-container",e.portalContainerClassName)}),o=Hz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Wz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return Uz(Vz("div",{className:rC("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 Tp,jsxs as lC}from"react/jsx-runtime";function Zz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var wn=e=>{let[n,t]=oC(),[o]=Kz(document.activeElement),{id:r}=Fe(),i=Ee().formFactor==="phone";Xz(()=>{if(!n)return;let l=sC(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===$z.TAB){let m=sC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ue(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return Tp(aC,{className:Yz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Zz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:lC(Xe,{ref:t,children:[e.title&&lC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[Tp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Tp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),Tp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Fo,jsxs as Sp}from"react/jsx-runtime";var jz=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}},qz=e=>{let n=mC(null),[t,o]=pC(null),{theme:r}=xe();dC(()=>{if(!e.spreadsheet){o(null);return}let a=Bf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Br(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=jz(e.chartType);return Sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Fo("div",{className:"ChartPreview__canvas",ref:n}),Fo("div",{className:"ChartPreview__label",children:i})]})},Jz=e=>{let n=mC(null),{theme:t}=xe();return dC(()=>{if(!e.rawText)return;let o=uC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Br([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]),Sp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Fo("div",{className:"ChartPreview__canvas",ref:n}),Fo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},hC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=pC(Math.random()),s=cC.useCallback(()=>{a(Math.random())},[]),l=cC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),He("paste","chart",m),t(),r()},d=m=>{let p=uC({text:m,x:0,y:0});o([p]),He("paste","chart","plaintext"),t(),r()};return Fo(wn,{size:"regular",onCloseRequest:l,title:Sp("div",{className:"PasteChartDialog__title",children:[Fo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Fo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Jn})]}),className:"PasteChartDialog",autofocus:!1,children:Sp("div",{className:"container",children:[["bar","line","radar"].map(m=>Oa(e,m)?Fo(qz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Fo(Jz,{rawText:n,onClick:d})]})})};import{Fragment as Qz,jsx as gC,jsxs as eG}from"react/jsx-runtime";var Jl=({heading:e,children:n,...t})=>{let{id:o}=Fe(),r=gC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return gC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):eG(Qz,{children:[r,n]})})};import{Popover as Ql}from"radix-ui";import fC from"clsx";import Cp,{useLayoutEffect as tG}from"react";import{supportsResizeObserver as nG,isShallowEqual as oG}from"@excalidraw/common";import{Fragment as fE,jsx as It,jsxs as ns}from"react/jsx-runtime";var rG=4,iG=8,hE=38,EC=21,aG=({shouldWrap:e,children:n,username:t})=>e?It(ut,{label:t||"Unknown user",children:n}):It(fE,{children:n}),gE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return It(aG,{username:n.username,shouldWrap:r,children:s},t)},sG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Pp=Cp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=it(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=Cp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=Cp.useRef(null);tG(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!nG)return;let P=new ResizeObserver(M=>{for(let D of M){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=Cp.useState(rG*hE),b=l?E-EC:E,w=Math.max(1,Math.min(8,Math.floor(b/hE))),y=l?Math.max(0,w-1):w,x=c.slice(0,y),I=l?[...x,l]:x,T=I.map(C=>{let P=gE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?ns(Ql.Root,{children:[It(Ql.Trigger,{asChild:!0,children:ns("div",{className:"UserList__pill",children:[P,It("div",{className:"UserList__pill-chevron",children:w0})]})}),It(Ql.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:ns(Xe,{padding:2,children:[s.length>=iG&&It(xd,{placeholder:f("quickSearch.placeholder"),onChange:m}),It(yd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[It("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>gE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&ns(fE,{children:[It("div",{className:"UserList__menu-divider"}),It(Ql.Close,{asChild:!0,children:It("div",{className:"dropdown-menu",children:a})})]}),It(Ql.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):P});return n?ns("div",{className:fC("UserList UserList_mobile",e),children:[It("div",{className:"UserList_mobile__avatars",children:s.map(C=>gE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&ns(fE,{children:[It("div",{className:"UserList__menu-divider"}),a]})]}):It("div",{className:"UserList__wrapper",ref:u,children:It("div",{className:fC("UserList",e),style:{"--max-avatars":I.length+(l?EC/hE:0)},children:T})})},(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||!oG(r,i,sG))return!1}return!0});import ec from"clsx";import{jsx as bC}from"react/jsx-runtime";var xC=e=>bC(ut,{label:`${f("helpDialog.title")} \u2014 ?`,children:bC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Hi})});import{jsx as tn,jsxs as EE}from"react/jsx-runtime";var yC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=rt(),l=St();return EE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&tn("div",{className:ec("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:tn(Ot.Col,{gap:2,children:EE(Jl,{heading:"canvasActions",children:[!e.viewModeOnly&&tn(ut,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:tn("div",{className:ec("view-mode-button"),children:n.renderAction("viewMode")})}),tn(ut,{label:f("buttons.smartZoom"),children:tn("div",{className:ec("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&tn(kS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&tn(MS,{renderAction:n.renderAction,className:ec("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),tn(a.Out,{}),(r||o)&&tn("div",{className:ec("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:EE("div",{style:{position:"relative"},children:[o&&tn(s.Out,{}),r&&tn(xC,{onClick:()=>n.executeAction(Qr)})]})}),r&&tn(AS,{showExitZenModeBtn:t})]})},wC=yC;yC.displayName="Footer";import{composeEventHandlers as gG}from"@excalidraw/common";import{useLayoutEffect as lG,useRef as cG}from"react";import{jsx as dG}from"react/jsx-runtime";var gi=(e,n)=>{let t=et(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=rt(),[,a]=i(t),s=cG({preferHost:!1,counter:0});return lG(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:dG(n,{...r})};return o.displayName=e,o};var wE={};AA(wE,{ChangeCanvasBackground:()=>LC,Export:()=>_C,Help:()=>AC,LiveCollaborationTrigger:()=>NC,LoadScene:()=>CC,Preferences:()=>mo,PreferencesToggleGridModeItem:()=>yE,SaveAsImage:()=>kC,SaveToActiveFile:()=>PC,SearchMenu:()=>MC,Socials:()=>RC,ToggleTheme:()=>DC});import hG from"clsx";import{THEME as nc}from"@excalidraw/common";var bE=et({active:!1});async function vC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{bt.set(bE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import mG from"clsx";import{jsx as IC,jsxs as pG}from"react/jsx-runtime";var kp=function({onChange:e,value:n,choices:t,name:o}){return IC("div",{className:"RadioGroup",children:t.map(r=>pG("div",{className:mG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[IC("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 uG,jsx as tc,jsxs as TC}from"react/jsx-runtime";var SC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=Ee();return TC(uG,{children:[TC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&tc("div",{className:"dropdown-menu-item__icon",children:a}),tc("label",{className:"dropdown-menu-item__text",children:tc(Xs,{children:r})}),tc(kp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&tc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};SC.displayName="DropdownMenuItemContentRadio";var xE=SC;import{Fragment as WC,jsx as ye,jsxs as oc}from"react/jsx-runtime";var CC=()=>{let{t:e}=Re(),n=it(),t=Ki();return n.isActionEnabled(ca)?ye(Jt,{icon:Kc,onSelect:async()=>{(!t.length||await vC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(ui,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&n.executeAction(ca)},"data-testid":"load-button",shortcut:Je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};CC.displayName="LoadScene";var PC=()=>{let{t:e}=Re(),n=it();return n.isActionEnabled(Jr)?ye(Jt,{shortcut:Je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Jr),icon:Jx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};PC.displayName="SaveToActiveFile";var kC=()=>{let e=Ue(),{t:n}=Re();return ye(Jt,{icon:t1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};kC.displayName="SaveAsImage";var MC=e=>{let{t:n}=Re(),t=it();return ye(Jt,{icon:to,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ll)},shortcut:Je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};MC.displayName="SearchMenu";var AC=()=>{let{t:e}=Re(),n=it();return ye(Jt,{"data-testid":"help-menu-item",icon:Hi,onSelect:()=>n.executeAction(Qr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};AC.displayName="Help";var DC=e=>{let{t:n}=Re(),t=xe(),o=it(),r=Je("toggleTheme"),i=An();return o.isActionEnabled(zd)?e?.allowSystemTheme?ye(xE,{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:nc.LIGHT,label:Ls,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:nc.DARK,label:Ds,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:u0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):ye(Jt,{onSelect:a=>{a.preventDefault(),o.executeAction(zd)},icon:t.theme===nc.DARK?Ls:Ds,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===nc.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===nc.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};DC.displayName="ToggleTheme";var LC=()=>{let{t:e}=Re(),n=xe(),t=it(),o=An();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:oc("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};LC.displayName="ChangeCanvasBackground";var _C=()=>{let{t:e}=Re(),n=Ue();return ye(Jt,{icon:_s,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};_C.displayName="Export";var RC=()=>{let{t:e}=Re();return oc(WC,{children:[ye(Qa,{icon:Zx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ye(Qa,{icon:qx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ye(Qa,{icon:jx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};RC.displayName="Socials";var NC=({onSelect:e,isCollaborating:n})=>{let{t}=Re();return ye(Jt,{"data-testid":"collab-button",icon:$c,className:hG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};NC.displayName="LiveCollaborationTrigger";var BC=()=>{let{t:e}=Re(),n=St(),t=xe();return ye(co,{checked:t.activeTool.locked,shortcut:Je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},FC=()=>{let{t:e}=Re(),n=xe(),t=Ue();return ye(xE,{name:"boxSelectionMode",icon:Qc,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")})},OC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),onSelect:o=>{n.executeAction(Rt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},zC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(pl),o.preventDefault()},children:e("labels.arrowBinding")})},GC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ul),o.preventDefault()},children:e("labels.midpointSnapping")})},yE=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.gridModeEnabled,shortcut:Je("gridMode"),onSelect:o=>{n.executeAction(fa),o.preventDefault()},children:e("labels.toggleGrid")})},HC=()=>{let{t:e}=Re(),n=it(),t=xe();return t.viewModeOnly?null:ye(co,{checked:t.viewModeEnabled,shortcut:Je("viewMode"),onSelect:o=>{n.executeAction(Aa),o.preventDefault()},children:e("labels.viewMode")})},UC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.stats.open,shortcut:Je("stats"),onSelect:o=>{n.executeAction(ur),o.preventDefault()},children:e("stats.fullTitle")})},mo=({children:e,additionalItems:n})=>{let{t}=Re();return oc(vr,{children:[ye(vr.Trigger,{icon:I0,children:t("labels.preferences")}),oc(vr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||oc(WC,{children:[ye(FC,{}),ye(BC,{}),ye(OC,{}),ye(yE,{}),ye(HC,{}),ye(UC,{}),ye(zC,{}),ye(GC,{})]}),n]})]})};mo.ToggleToolLock=BC;mo.BoxSelectionMode=FC;mo.ToggleSnapMode=OC;mo.ToggleArrowBinding=zC;mo.ToggleMidpointSnapping=GC;mo.ToggleGridMode=yE;mo.ToggleViewMode=HC;mo.ToggleElementProperties=UC;mo.displayName="Preferences";import{jsx as Mp,jsxs as vE}from"react/jsx-runtime";var fG=Object.assign(gi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=rt(),o=Ee(),r=xe(),i=An(),a=Ue();return Mp(t.In,{children:vE(ge,{open:r.openMenu==="canvas",children:[Mp(ge.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Kx}),vE(ge.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:gG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&vE("fieldset",{className:"UserList-Wrapper",children:[Mp("legend",{children:f("labels.collaborators")}),Mp(Pp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,Sub:vr,DefaultItems:wE}),zt=fG;import EG from"clsx";import{forwardRef as bG,useState as xG}from"react";import{isPromiseLike as yG}from"@excalidraw/common";import{jsx as Ap,jsxs as wG}from"react/jsx-runtime";var Ir=bG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=xG(!1),E=async b=>{let w=t?.(b);if(yG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Dc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Ap("button",{className:EG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:wG("div",{className:"ExcButton__contents",children:[g==="loading"?Ap(Io,{className:"ExcButton__statusIcon"}):g==="success"&&Ap("div",{className:"ExcButton__statusIcon",children:n0}),n&&Ap("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as os,jsxs as TG}from"react/jsx-runtime";var Dp=({title:e,children:n,actionLabel:t,onClick:o})=>TG("div",{className:"OverwriteConfirm__Actions__Action",children:[os("h4",{children:e}),os("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),os(Ir,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),vG=()=>{let{t:e}=Re(),n=it(),t=Ue();return os(Dp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(rm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},IG=()=>{let{t:e}=Re(),n=it();return os(Dp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(cl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},IE=Object.assign(({children:e})=>os("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:vG,SaveToDisk:IG});import{jsx as Tr,jsxs as VC}from"react/jsx-runtime";var Lp=Object.assign(gi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=rt(),[t,o]=Ye(bE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Tr(n.In,{children:Tr(wn,{onCloseRequest:r,title:!1,size:916,children:VC("div",{className:"OverwriteConfirm",children:[Tr("h3",{children:t.title}),VC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Tr("div",{className:"OverwriteConfirm__Description__icon",children:o0}),Tr("div",{children:t.description}),Tr("div",{className:"OverwriteConfirm__Description__spacer"}),Tr(Ir,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Tr(IE,{children:e})]})})})}),{Actions:IE,Action:Dp});import{round as RP}from"@excalidraw/math";import UH from"clsx";import WH from"lodash.throttle";import{useEffect as NP,useMemo as FE,useState as VH,memo as YH}from"react";import{STATS_PANELS as Hp}from"@excalidraw/common";import{getCommonBounds as XH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as KH}from"@excalidraw/element";import{isImageElement as OE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as $H}from"@excalidraw/element";import{elementsAreInSameGroup as ZH}from"@excalidraw/element";import{degreesToRadians as JC,radiansToDegrees as nP}from"@excalidraw/math";import{getBoundTextElement as QC}from"@excalidraw/element";import{isArrowElement as eP,isElbowArrow as OG}from"@excalidraw/element";import{updateBindings as tP}from"@excalidraw/element";import LG from"clsx";import{useEffect as jC,useRef as Rp,useState as _G}from"react";import{EVENT as as,KEYS as RG,cloneJSON as TE}from"@excalidraw/common";import{deepCopyElement as NG}from"@excalidraw/element";import{CaptureUpdateAction as qC}from"@excalidraw/element";import{pointFrom as Sr,pointRotateRads as _p}from"@excalidraw/math";import{getBoundTextElement as SG,getNonDeletedElements as CG,isBindingElement as PG,unbindBindingElement as YC}from"@excalidraw/element";import{isFrameLikeElement as $C}from"@excalidraw/element";import{getSelectedGroupIds as kG,getElementsInGroup as MG,isInGroup as AG}from"@excalidraw/element";import{getFrameChildren as DG}from"@excalidraw/element";import{updateBindings as XC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as KC}from"@excalidraw/common";var ZC=.01,rc=10,Xt=(e,n)=>!(n==="angle"&&$C(e)),Ke=(e,n)=>{let t=e+n/2;return t-t%n},rs=(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 fi=(e,n,t,o,r,i,a=!0)=>{if(PG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<KC&&Math.abs(n-t.y)<KC)return;YC(t,"start",o),YC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=_p(Sr(t.x,t.y),Sr(c,d),t.angle),u=e-m,E=n-p,[g,b]=_p(Sr(e,n),Sr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),XC(l,o,r);let w=SG(t,i);if(w){let y=s.get(w.id);y&&o.mutateElement(y,{x:w.x+u,y:w.y+E},{informMutation:a,isDragging:!1})}if($C(t)){let y=DG(i,t.id);y.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=_p(Sr(x.x,x.y),Sr(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=_p(Sr(D,_),Sr(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),XC(I,o,r,{simultaneouslyUpdated:CG(y)})})}},is=(e,n)=>{let o=kG(n).map(r=>MG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!AG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as SE,jsxs as FG}from"react/jsx-runtime";var BG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=Ue(),E=Rp(null),g=Rp(null),[b,w]=_G(o.toString()),y=Rp(null);y.current||(y.current={originalAppState:TE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),jC(()=>{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 D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=ZC)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>w(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:qC.IMMEDIATELY}))},I=Rp({});return I.current.handleInputValue=x,jC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(as.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(as.POINTER_UP,C.onPointerUp,!1)}},[i]),i?FG("div",{className:LG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[SE("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=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,NG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=TE(c),k=0,L=0,F=z=>{if(P&&M!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:W=>w(String(W)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(as.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:qC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(as.POINTER_UP,Y,!1)};I.current.onPointerMove=F,I.current.onPointerUp=Y,window.addEventListener(as.POINTER_MOVE,F,!1),window.addEventListener(as.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?SE(Td,{icon:n}):e}),SE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===RG.ENTER&&(x(C.value,r,c),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=TE(c)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},ft=BG;import{jsx as UG}from"react/jsx-runtime";var zG=15,GG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!OG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=JC(o);r.mutateElement(l,{angle:E}),tP(l,r,i.state);let g=QC(l,a);g&&!eP(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(nP(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=Ke(m,zG)),m=m<0?m+360:m;let p=JC(m);r.mutateElement(l,{angle:p}),tP(l,r,i.state);let u=QC(l,a);u&&!eP(l)&&r.mutateElement(u,{angle:p})}},HG=({element:e,scene:n,appState:t,property:o})=>UG(ft,{label:"A",icon:jc,value:Math.round(nP(e.angle)%360*100)/100,elements:[e],dragInputCallback:GG,editable:Xt(e,"angle"),scene:n,appState:t,property:o}),oP=HG;import{jsx as VG}from"react/jsx-runtime";var rP=5,WG=({property:e,scene:n,appState:t,setAppState:o})=>VG(ft,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?Ke(l.gridStep+rP*Math.sign(i),rP):l.gridStep+i),c?(c=sx(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),iP=WG;import{clamp as Np,round as CE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Bp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as aP,getNonDeletedElements as YG,getUncroppedWidthAndHeight as cP}from"@excalidraw/element";import{resizeSingleElement as sP}from"@excalidraw/element";import{isImageElement as dP}from"@excalidraw/element";import{isFrameLikeElement as PE}from"@excalidraw/element";import{getElementsInResizingFrame as kE}from"@excalidraw/element";import{replaceAllElementsInFrame as mP}from"@excalidraw/element";import{jsx as jG}from"react/jsx-runtime";var lP=10,XG=e=>e.type==="image",KG=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||XG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let w=p.get(u.id);if(!w||!dP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:C,height:P}=cP(w),M=y.naturalWidth/C,D=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=T?y.height+y.y:y.naturalHeight-y.y,L=aP*M,F=aP*D;if(i!==void 0){if(a==="width"){let G=i*M,ie=Np(G,L,_);x={...x,width:ie,x:I?y.x+y.width-ie:y.x}}else if(a==="height"){let G=i*D,ie=Np(G,F,k);x={...x,height:ie,y:T?y.y+y.height-ie:y.y}}c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,U=Np(y.width+Y,L,_),W=Np(y.height+z,L,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},c.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,Bp),y=Math.max(a==="height"?i:g?i/b:u.height,Bp);if(sP(w,y,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),PE(E)){let x=kE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=mP(c.getElementsIncludingDeleted(),x,E);c.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=Ke(x,lP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=Ke(I,lP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Bp,I),x=Math.max(Bp,x),sP(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),PE(E)){let T=YG(kE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},$G=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&PE(a)){let s=kE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=mP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},ZG=({property:e,element:n,scene:t,appState:o})=>{let r=CE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&dP(n)&&n.crop){let{width:i,height:a}=cP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=CE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=CE(n.crop.height*s,2)}}return jG(ft,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:KG,value:r,editable:Xt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:$G})},ME=ZG;import{getBoundTextElement as qG,redrawTextBoundingBox as JG}from"@excalidraw/element";import{hasBoundTextElement as QG,isTextElement as uP}from"@excalidraw/element";import{jsx as oH}from"react/jsx-runtime";var pP=4,eH=4,tH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!uP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),pP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,pP),t&&(l=Ke(l,eH))}l&&(r.mutateElement(s,{fontSize:l}),JG(s,r.getContainerElement(s),r))}},nH=({element:e,scene:n,appState:t,property:o})=>{let r=uP(e)?e:QG(e)?qG(e,n.getNonDeletedElementsMap()):null;return r?oH(ft,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:tH,icon:Hr,appState:t,scene:n,property:o}):null},hP=nH;import{degreesToRadians as gP,radiansToDegrees as bP}from"@excalidraw/math";import{getBoundTextElement as fP}from"@excalidraw/element";import{isArrowElement as EP}from"@excalidraw/element";import{isInGroup as AE}from"@excalidraw/element";import{jsx as sH}from"react/jsx-runtime";var rH=15,iH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!AE(c)&&Xt(c,r)),l=n.filter(c=>!AE(c)&&Xt(c,r));if(o!==void 0){let c=gP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=fP(d,a);m&&!EP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(bP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=Ke(E,rH)),E=E<0?E+360:E;let g=gP(E);i.mutateElement(d,{angle:g});let b=fP(d,a);b&&!EP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},aH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!AE(l)&&Xt(l,"angle")),i=r.map(l=>Math.round(bP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Xt(l,"angle"));return sH(ft,{label:"A",icon:jc,value:a,elements:e,dragInputCallback:iH,editable:s,appState:t,scene:n,property:o})},xP=aH;import{pointFrom as IP}from"@excalidraw/math";import{useMemo as cH}from"react";import{MIN_WIDTH_OR_HEIGHT as Cr}from"@excalidraw/common";import{getElementsInResizingFrame as DE,getNonDeletedElements as dH,isFrameLikeElement as LE,replaceAllElementsInFrame as CP,updateBoundElements as mH}from"@excalidraw/element";import{rescalePointsInElement as pH,resizeSingleElement as TP}from"@excalidraw/element";import{getBoundTextElement as uH,handleBindTextResize as hH}from"@excalidraw/element";import{isTextElement as PP}from"@excalidraw/element";import{MIME_TYPES as Ei}from"@excalidraw/common";import{getNonDeletedElements as yP}from"@excalidraw/element";var Fp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=yP(Fr(e,null,{deleteInvisibleElements:!0})),l=_i(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Fc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,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}})},wP=async e=>{let{mimeType:n=Ei.png,quality:t}=e;n===Ei.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Ei.png}" mimeType`),n==="image/jpg"&&(n=Ei.jpg),n===Ei.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Ei.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Fp(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===Ei.png&&e.appState?.exportEmbedScene&&(a=await xx({blob:a,metadata:Ts(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},vP=async({elements:e,appState:n=Ko(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=yP(Fr(e,null,{deleteInvisibleElements:!0})),d={..._i(n,null),exportPadding:o};return Br(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},lH=async e=>{if(e.type==="svg"){let n=await vP(e);await ko(n.outerHTML)}else if(e.type==="png")await nm(wP(e));else if(e.type==="json")await Qd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as DNe}from"@excalidraw/element";import{getCommonBounds as Op}from"@excalidraw/element";import{jsx as yH}from"react/jsx-runtime";var ss=10,gH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...pH(o,a,s,!1),...PP(o)?{fontSize:o.fontSize*t}:{}}},fH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=gH(e,n,o,i);s.mutateElement(r,c);let d=uH(i,a);if(d){let m=d.fontSize*o;mH(r,s);let p=l.get(d.id);p&&PP(p)&&(s.mutateElement(p,{fontSize:m}),hH(r,s,t==="width"?"e":"s",!0))}},SP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];fH(r[0],r[1],i,d,u,p,l,c)}},EH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=is(n,o);if(i!==void 0){for(let g of m){let b=rs(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Op(y),P=T-x,M=C-I,D=P/M,_=Math.max(Cr,s==="width"?Math.max(0,i):P),k=Math.max(Cr,s==="height"?Math.max(0,i):M);SP(_,k,M,D,IP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Xt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=Ke(I,ss):I=Math.round(I));let T=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?T=Ke(T,ss):T=Math.round(T)),I=Math.max(Cr,I),T=Math.max(Cr,T),TP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),LE(y)){let C=DE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=CP(a.getElementsIncludingDeleted(),C,y);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=rs(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Op(y),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=Ke(_,ss):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=Ke(k,ss):k=Math.round(k)),_=Math.max(Cr,_),k=Math.max(Cr,k),SP(_,k,M,D,IP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Xt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=Ke(I,ss):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=Ke(T,ss):T=Math.round(T)),I=Math.max(Cr,I),T=Math.max(Cr,T),TP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),LE(y)){let C=dH(DE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},bH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&LE(a)){let s=DE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=CP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},xH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=cH(()=>o.map(c=>{let d=rs(c,t);if(d.length>1){let[p,u,E,g]=Op(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return yH(ft,{label:e==="width"?"W":"H",elements:n,dragInputCallback:EH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:bH})},_E=xH;import{getBoundTextElement as wH,redrawTextBoundingBox as kP}from"@excalidraw/element";import{hasBoundTextElement as vH,isTextElement as IH}from"@excalidraw/element";import{isInGroup as TH}from"@excalidraw/element";import{jsx as MH}from"react/jsx-runtime";var MP=4,SH=4,CH=(e,n)=>e.reduce((t,o)=>{if(!o||TH(o))return t;if(IH(o))return t.push(o),t;if(vH(o)){let r=wH(o,n);if(r)return t.push(r),t}return t},[]),PH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),MP);for(let l of a)r.mutateElement(l,{fontSize:s}),kP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,MP);t&&(E=Ke(E,SH)),r.mutateElement(d,{fontSize:E}),kP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},kH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=CH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return MH(ft,{label:"F",icon:Hr,elements:i,dragInputCallback:PH,value:s,editable:l,scene:n,property:o,appState:t})},AP=kH;import{pointFrom as Pr,pointRotateRads as zp}from"@excalidraw/math";import{useMemo as AH}from"react";import{isTextElement as DH}from"@excalidraw/element";import{getCommonBounds as RE}from"@excalidraw/element";import{jsx as BH}from"react/jsx-runtime";var LH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=zp(Pr(l.x,l.y),Pr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;fi(u,E,l,i,a,r,!1)}},_H=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=RE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!DH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=zp(Pr(u.x,u.y),Pr(E,g),u.angle);fi(b+c,w+d,p,r,i,o,!1)}}},RH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of is(n,s)){let E=rs(u,c,t);if(E.length>1){let[g,b,,]=RE(E.map(x=>x.latest));_H(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Xt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=zp(Pr(g.x,g.y),Pr(w,y),g.angle);fi(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?Ke(e,rc):e;LH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},NH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=AH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=RE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=zp(Pr(d.x,d.y),Pr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return BH(ft,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:RH,value:s,property:e,scene:r,appState:i})},NE=NH;import{clamp as ic,pointFrom as Gp,pointRotateRads as LP,round as DP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as FH,getUncroppedWidthAndHeight as OH}from"@excalidraw/element";import{isImageElement as _P}from"@excalidraw/element";import{jsx as HH}from"react/jsx-runtime";var zH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=LP(Gp(m.x,m.y),Gp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!_P(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=OH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:ic(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:ic(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:ic(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(M?-1:1);C={...T,x:ic(T.x+k,0,T.naturalWidth-T.width),y:ic(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){fi(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?Ke(m.x+b,rc):E+b):E,x=a==="y"?Math.round(r?Ke(m.y+w,rc):g+w):g;fi(y,x,m,s,c.state,o)},GH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=LP(Gp(n.x,n.y),Gp(n.x+n.width/2,n.y+n.height/2),n.angle),a=DP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&_P(n)&&n.crop){let s=FH(n);s&&(a=DP(e==="x"?s.x:s.y,2))}return HH(ft,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:zH,scene:t,value:a,property:e,appState:o})},BE=GH;import{Fragment as zE,jsx as ne,jsxs as Kt}from"react/jsx-runtime";var jH=50,ac=e=>{let n=no(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=fr(e.app);return ne(qH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},We=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:UH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});We.displayName="StatsRow";var Up=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Up.displayName="StatsRows";ac.StatsRow=We;ac.StatsRows=Up;var qH=YH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Ue(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&OE(m),E=u?KH(m):null,[g,b]=VH({width:0,height:0}),w=FE(()=>WH(I=>{let T=XH(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},jH),[]);NP(()=>{w(l)},[i,l,w]),NP(()=>()=>w.cancel(),[w]);let y=FE(()=>is(o,r),[o,r]),x=FE(()=>$H(o),[o]);return ne("div",{className:"exc-stats",children:Kt(Xe,{padding:3,children:[Kt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Kt(Zs,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Hp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Hp.generalStats}})),children:[Kt(Up,{children:[ne(We,{heading:!0,children:f("stats.scene")}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Kt(zE,{children:[ne(We,{heading:!0,children:"Canvas"}),ne(We,{children:ne(iP,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Zs,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Hp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Hp.elementProperties}})),children:Kt(Up,{children:[m&&Kt(zE,{children:[u&&ne(We,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&OE(m)&&E&&Kt(We,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:RP(E.width,2)})]}),r.croppingElementId&&OE(m)&&E&&Kt(We,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:RP(E.height,2)})]}),ne(We,{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}`)}),ne(We,{children:ne(BE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(We,{children:ne(BE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(We,{children:ne(ME,{property:"width",element:m,scene:s,appState:r})}),ne(We,{children:ne(ME,{property:"height",element:m,scene:s,appState:r})}),ne(We,{children:ne(oP,{property:"angle",element:m,scene:s,appState:r})}),ne(We,{children:ne(hP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Kt(zE,{children:[ZH(p)&&ne(We,{heading:!0,children:f("element.group")}),Kt(We,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(We,{children:ne(NE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(NE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(_E,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(_E,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(xP,{property:"angle",elements:p,scene:s,appState:r})}),ne(We,{children:ne(AP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(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 cU,useEffect as FP,useState as OP}from"react";import{normalizeLink as dU,KEYS as WE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as mU,getLinkIdAndTypeFromSelection as pU}from"@excalidraw/element";import JH from"clsx";import{jsx as Wp,jsxs as eU}from"react/jsx-runtime";var QH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return eU("button",{className:JH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Wp("div",{style:a?{visibility:"hidden"}:{},children:o}),Wp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Wp("div",{style:{position:"absolute",inset:0},children:Wp(Io,{})})]})},GE=QH;import HE from"clsx";import{forwardRef as rU,useRef as iU,useImperativeHandle as aU,useLayoutEffect as sU,useState as lU}from"react";import tU from"clsx";import{composeEventHandlers as nU}from"@excalidraw/common";import{jsx as oU}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>oU("button",{onClick:nU(i.onClick,a=>{n()}),type:e,className:tU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as UE,jsxs as BP}from"react/jsx-runtime";var Vp=rU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=iU(null);aU(p,()=>u.current),sU(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=lU(!1);return BP("div",{className:HE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&UE("div",{className:"ExcTextField__label",children:n}),BP("div",{className:HE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[UE("input",{className:HE({"is-redacted":"value"in m&&m.value&&s&&!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:d}),s&&UE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?r0:Wr})]})]})});import{jsx as ls,jsxs as Yp}from"react/jsx-runtime";var uU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=mU})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=OP(a),[c,d]=OP(!1);FP(()=>{let p=de(i,t),u=a;if(p.length>0&&r){let E=pU(p,t);E&&(u=dU(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=cU(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return FP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===WE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===WE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Yp("div",{className:"ElementLinkDialog",children:[Yp("div",{className:"ElementLinkDialog__header",children:[ls("h2",{children:f("elementLink.title")}),ls("p",{children:f("elementLink.desc")})]}),Yp("div",{className:"ElementLinkDialog__input",children:[ls(Vp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===WE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&ls(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Gr})]}),Yp("div",{className:"ElementLinkDialog__actions",children:[ls(GE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),ls(GE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},zP=uU;import hU,{useState as gU}from"react";import{Fragment as fU,jsx as VE}from"react/jsx-runtime";var GP=({children:e,onClose:n})=>{let[t,o]=gU(!!e),{container:r}=Fe(),i=hU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return VE(fU,{children:t&&VE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:VE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import YE from"clsx";import zn from"react";import{MIME_TYPES as HP,sceneCoordsToViewportCoords as XE}from"@excalidraw/common";import{getCommonBounds as YP,isInitializedImageElement as UP,ShapeCache as EU}from"@excalidraw/element";import{Fragment as vU,jsx as kt,jsxs as bi}from"react/jsx-runtime";var bU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),xU=bi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),yU=76,XP=4,sc=yU+XP,WP=8,xi=8,wU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+xi),window.innerWidth-t-xi)},VP=(e,n)=>{let[,,t,o]=YP([e]),r=XE({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)}},KP=({app:e,files:n,setAppState:t})=>{let o=no(),[,r]=zn.useReducer(T=>T+1,0),[i,a]=zn.useState(0),[s,l]=zn.useState(!1),c=zn.useRef(null),d=zn.useRef(null),m=zn.useRef(null),p=zn.useRef(null),u=zn.useRef(null),E=zn.useRef(!1),[g,b]=zn.useState(null);zn.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?c.current:d.current,P=T==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=wU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(xi,M.top-D.height-xi):Math.min(window.innerHeight-D.height-xi,M.bottom+xi),L={left:_,top:Math.max(xi,k)};b(F=>F?.left===L.left&&F.top===L.top?F:L)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let w=(T,C)=>{EU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().filter(T=>UP(T)&&!o.selectedElementIds[T.id]&&n[T.fileId]?.mimeType===HP.gif&&e.imageCache.get(T.fileId)?.gifDecodeStatus==="deferred").map(T=>{let C=VP(T,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:C,children:Fx},T.id)}),x=e.scene.getSelectedElements(o);return bi(vU,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!UP(T)||n[T.fileId]?.mimeType!==HP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=YP([T]),k=XE({sceneX:M,sceneY:_},o),F=XE({sceneX:D,sceneY:_},o).x-k.x,Y=k.x-o.offsetLeft+F/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="deferred"){let K=VP(T,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:K,onPointerDown:ve=>ve.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})})}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,ie=e.getGifPlaybackFrameIndex(T)??W.frameIndex,me=Math.min(Math.max(ie,0),U-1),B=Math.min(G.height-120,z+48),V=Math.max(12,z-52),pe=K=>{let ve=(K+U)%U;e.setGifPlaybackFrameIndex(T,ve),w(T,{...W,frameIndex:ve,playing:!1})},ae=K=>{K.stopPropagation(),pe(me+(K.deltaY<0?1:-1))},be=K=>{e.setGifPlaybackFrameIndex(T,me),w(T,{...W,frameIndex:me,playing:K})},ce=[.25,.5,.75,1,1.25,1.5,1.75,2,4],Be=K=>{let ve=ce.indexOf(K);return ve!==-1?ve:ce.reduce((Lt,ws,Ac)=>Math.abs(ws-K)<Math.abs(ce[Lt]-K)?Ac:Lt,0)},se=K=>{w(T,{...W,speed:K})},De=K=>{let ve=Be(W.speed);se(ce[Math.min(Math.max(ve+K,0),ce.length-1)])},Le=Number.isInteger(W.speed)?`${W.speed}`:`${W.speed}`,Ce=U*sc-XP,At=Math.min(Math.max(G.width*.9,1),Ce),Cn=Math.max(Ce-At,0),Pn=Math.min(i,Cn),Yo=Math.max(Math.floor(Pn/sc)-WP,0),Pi=Math.ceil(At/sc)+WP*2,ki=Math.min(Yo+Pi,U),xs=P.frames.slice(Yo,ki),bo=K=>{K.pointerType!=="mouse"||K.button!==0||(u.current={pointerId:K.pointerId,startClientX:K.clientX,startScrollLeft:K.currentTarget.scrollLeft,didDrag:!1},K.stopPropagation())},Dt=K=>{let ve=u.current;if(!ve||ve.pointerId!==K.pointerId)return;let Lt=K.clientX-ve.startClientX;!ve.didDrag&&Math.abs(Lt)<=3||(ve.didDrag||(ve.didDrag=!0,K.currentTarget.setPointerCapture?.(K.pointerId),l(!0)),K.currentTarget.scrollLeft=ve.startScrollLeft-Lt,a(K.currentTarget.scrollLeft),K.preventDefault(),K.stopPropagation())},ys=K=>{let ve=u.current;!ve||ve.pointerId!==K.pointerId||(E.current=ve.didDrag,u.current=null,K.currentTarget.hasPointerCapture?.(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),l(!1),K.stopPropagation())},Mi=K=>{let ve=u.current;!ve||ve.pointerId!==K.pointerId||(u.current=null,l(!1),K.stopPropagation())},xo=K=>{K.pointerType!=="mouse"&&K.stopPropagation()};return bi("div",{className:"gif-playback-controls",style:{left:Y,top:z},onPointerDown:K=>K.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&kt("div",{className:"gif-speed-picker",ref:m,style:g??{left:Y,top:V},children:ce.map(K=>{let ve=Number.isInteger(K)?`${K}`:`${K}`;return bi("button",{type:"button",className:YE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":K===W.speed}),onClick:()=>se(K),title:`${ve}x`,children:["x",ve]},K)})}),bi("div",{className:"gif-playback-controls__bar",children:[bi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:c,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:K=>{K.stopPropagation(),De(K.deltaY<0?1:-1)},title:"Speed",children:["x",Le]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me-1),onWheel:ae,title:"Previous frame",children:Q1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>be(!W.playing),onWheel:ae,title:W.playing?"Pause":"Play",children:W.playing?xU:bU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me+1),onWheel:ae,title:"Next frame",children:e0}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(me*sc-At/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:ae,title:"Frames",children:t0})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:YE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:Y,top:B},width:At},ref:K=>{p.current=K,K&&K.scrollLeft!==Pn&&(K.scrollLeft=Pn)},onScroll:K=>{a(K.currentTarget.scrollLeft)},onPointerDownCapture:xo,onPointerMoveCapture:xo,onPointerUpCapture:xo,onPointerCancelCapture:xo,onPointerDown:bo,onPointerMove:Dt,onPointerUp:ys,onPointerCancel:Mi,onLostPointerCapture:Mi,onClickCapture:K=>{if(E.current){E.current=!1,K.preventDefault(),K.stopPropagation();return}E.current=!1},onWheelCapture:K=>{K.stopPropagation(),K.currentTarget.scrollLeft+=K.deltaY,a(K.currentTarget.scrollLeft)},children:kt("div",{className:"gif-frame-gallery__spacer",style:{width:Ce},children:xs.map((K,ve)=>{let Lt=Yo+ve;return bi("button",{type:"button",className:YE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Lt===me}),style:{left:Lt*sc},onClick:()=>pe(Lt),title:`Frame ${Lt+1}`,children:[kt("canvas",{width:K.width,height:K.height,ref:ws=>{ws?.getContext("2d")?.drawImage(K,0,0)}}),kt("span",{children:Lt+1})]},Lt)})})})]})})()]})};import $P,{useMemo as AU}from"react";import ZP from"clsx";import{isDarwin as jP,isFirefox as DU,isWindows as LU}from"@excalidraw/common";import{KEYS as cs}from"@excalidraw/common";import{SHAPES as _U}from"@excalidraw/element/shapes";import{isFirefox as IU,KEYS as KE}from"@excalidraw/common";import{SHAPES as TU}from"@excalidraw/element/shapes";import{Fragment as MU,jsx as Ge,jsxs as yi}from"react/jsx-runtime";var SU=e=>yi(MU,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),$E=e=>yi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*CU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var PU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),mt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(kU,{children:PU(a)},a)));return yi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...CU(o,t?f("helpDialog.or"):null)]})]})},kU=e=>Ge("kbd",{className:"HelpDialog__key",...e});function ZE(){return yi(SU,{title:f("helpDialog.shortcuts"),children:[yi($E,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(mt,{label:f("toolBar.hand"),shortcuts:[KE.H]}),TU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(mt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(mt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(mt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),yi($E,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(mt,{label:f("helpDialog.smartZoom"),shortcuts:[KE.F]}),Ge(mt,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),Ge(mt,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),Ge(mt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${KE.Z}+${f("helpDialog.drag")}`]}),Ge(mt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),yi($E,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(mt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(mt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(mt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(mt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(cr||IU)&&Ge(mt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(mt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(mt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(mt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(mt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(mt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as JP,jsx as j,jsxs as wi}from"react/jsx-runtime";var RU=e=>wi(JP,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),jE=e=>wi("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*NU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var BU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),J=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(FU,{children:BU(a)},a)));return wi("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...NU(o,t?f("helpDialog.or"):null)]})]})},FU=e=>j("kbd",{className:"HelpDialog__key",...e}),qP=({onClose:e})=>{let[n,t]=$P.useState(!1),o=$P.useCallback(()=>{e&&e()},[e]),r=AU(()=>n?j("button",{className:ZP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:ZP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(JP,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?wi(RU,{title:f("helpDialog.shortcuts"),children:[wi(jE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[cs.H]}),_U.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[cs.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[cs.I,"Shift+S","Shift+I"]}),j(J,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(J,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(J,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(J,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(J,{label:f("toolBar.lock"),shortcuts:[cs.Q]}),j(J,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(J,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(J,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),wi(jE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[cs.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${cs.Z}+${f("helpDialog.drag")}`]}),j(J,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(J,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(J,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(J,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(J,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(J,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(J,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(J,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(J,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),j(J,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),j(J,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[Je("searchMenu")]})]}),wi(jE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(J,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(J,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(J,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(J,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(J,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(J,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(J,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(J,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(cr||DU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[jP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[jP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(J,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(J,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(J,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(J,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(J,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(J,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(J,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+A")]}),j(J,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(J,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(J,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(J,{label:f("buttons.redo"),shortcuts:LU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(J,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(J,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(J,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(J,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(J,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(J,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(J,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(J,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(J,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j(ZE,{})})})};import{useEffect as ek,useRef as tk,useState as vi}from"react";import{DEFAULT_EXPORT_PADDING as UU,EXPORT_IMAGE_TYPES as qE,isFirefox as WU,EXPORT_SCALES as VU,cloneJSON as nk}from"@excalidraw/common";import{useCallback as OU,useRef as zU,useState as GU}from"react";var HU=2e3,QP=()=>{let[e,n]=GU(null),t=zU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},HU)},r=OU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ve,jsxs as kr}from"react/jsx-runtime";var YU=()=>kr("div",{children:[Ve("h3",{children:f("canvasError.cannotShowPreview")}),Ve("p",{children:Ve("span",{children:f("canvasError.canvasTooBig")})}),kr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),XU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=_e(n,e),[l,c]=vi(i),[d,m]=vi(s),[p,u]=vi(e.exportBackground),[E,g]=vi(e.exportEmbedScene),[b,w]=vi(e.exportScale),y=tk(null),x=tk(0),[I,T]=vi(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=QP();ek(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=jr(n,e,d);return ek(()=>{let k=y.current;if(!k)return;let L=k.offsetWidth,F=k.offsetHeight;if(!L)return;let Y=++x.current,z=()=>Y!==x.current;return Fp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:UU,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await ks(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,D,_,l,p,a,b,E]),kr("div",{className:"ImageExportModal",children:[Ve("h3",{children:f("imageExportDialog.header")}),kr("div",{className:"ImageExportModal__preview",children:[Ve("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ve(YU,{})}),Ve("div",{className:"ImageExportModal__preview__filename",children:!Li&&Ve("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(rg,"ui",k.target.value)}})})]}),kr("div",{className:"ImageExportModal__settings",children:[Ve("h3",{children:f("imageExportDialog.header")}),s&&Ve(lc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ve(ti,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ve(lc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ve(ti,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(ig,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ve(ti,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Mw,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ve(ti,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(rm,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ve(kp,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(Pw,"ui",k)},choices:VU.map(k=>({value:k,label:`${k}\xD7`}))})}),kr("div",{className:"ImageExportModal__settings__buttons",children:[Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(qE.png,D,{exportingFrame:_}),icon:Qu,children:f("imageExportDialog.button.exportToPng")}),Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(qE.svg,D,{exportingFrame:_}),icon:Qu,children:f("imageExportDialog.button.exportToSvg")}),(cr||WU)&&Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(qE.clipboard,D,{exportingFrame:_}),C()},icon:j1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},lc=({label:e,children:n,tooltip:t,name:o})=>kr("div",{className:"ImageExportModal__settings__setting",title:e,children:[kr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ve(ut,{label:t,long:!0,children:J1})]}),Ve("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),ok=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=vi(()=>({appStateSnapshot:nk(n),elementsSnapshot:nk(e)}));return Ve(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ve(XU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import RW from"clsx";import{CANVAS_SEARCH_TAB as vk,DEFAULT_SIDEBAR as NW}from"@excalidraw/common";import KU from"clsx";import $U from"lodash.debounce";import{Fragment as ZU,memo as jU,useEffect as cc,useMemo as rk,useRef as JE,useState as ik}from"react";import{CLASSES as qU,EVENT as JU,FONT_FAMILY as QE,FRAME_STYLE as eb,getLineHeight as QU}from"@excalidraw/common";import{getCommonBounds as eW,isElementCompletelyInViewport as tW}from"@excalidraw/element";import{measureText as dc}from"@excalidraw/element";import{KEYS as ds,randomInteger as ak,addEventListener as nW,getFontString as Xp}from"@excalidraw/common";import{newTextElement as oW}from"@excalidraw/element";import{isTextElement as dk,isFrameLikeElement as Kp}from"@excalidraw/element";import{getDefaultFrameName as mk}from"@excalidraw/element/frame";import{Fragment as uW,jsx as Et,jsxs as Gn}from"react/jsx-runtime";var rW=et(""),tb=et(null),iW=350,pk=()=>{let e=St(),n=Ue(),t=JE(null),[o,r]=Ye(rW),i=o.trim(),[a,s]=ik(!1),[l,c]=ik({nonce:null,items:[]}),d=JE(null),m=JE(void 0),[p,u]=Ye(tb),E=e.scene.getNonDeletedElementsMap();cc(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,ck(i,e,(x,I)=>{c({nonce:ak(),items:x}),d.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=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};cc(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),cc(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=oW({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:Kp(x.element)?eb.nameFontSize:x.element.fontSize,fontFamily:Kp(x.element)?QE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!tW([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 D=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:eW([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),cc(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let w=Xi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});cc(()=>{let x=I=>{if(I.key===ds.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[ds.CTRL_OR_CMD]&&I.key===ds.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===ds.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===ds.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===ds.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return nW(window,JU.KEYDOWN,x,{capture:!0,passive:!1})},[n,w,e]);let y=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Gn("div",{className:"layer-ui__search",children:[Gn("div",{className:"layer-ui__search-header",children:[Et(Vp,{className:qU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:to,onChange:x=>{r(x),s(!0);let I=x.trim();ck(I,e,(T,C)=>{c({nonce:ak(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),Et(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),Gn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Gn(uW,{children:[p!==null&&p>-1?Gn("div",{children:[p+1," / ",y]}):Et("div",{children:y}),Gn("div",{className:"result-nav",children:[Et(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:Jc}),Et(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:E0})]})]}),l.items.length===0&&i&&d.current&&Et("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Et(lW,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},sk=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 Et("div",{tabIndex:-1,className:KU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Et("div",{className:"preview-text",children:n.flatMap((t,o)=>Et(ZU,{children:o===2?Et("b",{children:t}):t},o))})})},aW=e=>{let n=rk(()=>e.matches.items.filter(o=>Kp(o.element)),[e.matches]),t=rk(()=>e.matches.items.filter(o=>dk(o.element)),[e.matches]);return Gn("div",{className:"layer-ui__search-results",children:[n.length>0&&Gn("div",{className:"layer-ui__search-result-container",children:[Gn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Qn}),Et("div",{children:f("search.frames")})]}),n.map((o,r)=>Et(sk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&Et("div",{className:"layer-ui__divider"})]}),t.length>0&&Gn("div",{className:"layer-ui__search-result-container",children:[Gn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Mn}),Et("div",{children:f("search.texts")})]}),t.map((o,r)=>Et(sk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},sW=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,lW=jU(aW,sW),lk=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;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:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},cW=(e,n)=>{let t=e.split(`
17
+ `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?rT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ya}from"@excalidraw/math";import{FONT_FAMILY as zB,FONT_SIZES as GB,getFontString as HB,getLineHeight as UB,ROUGHNESS as iT}from"@excalidraw/common";import{measureText as WB,newLinearElement as Nf,newTextElement as VB}from"@excalidraw/element";var aT=(e,n,t,o)=>{if(!za(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=JI(i,r.length),l=Ua(o),c=Wa(l),d=Ha(i.length,l),{chartWidth:m,chartHeight:p}=qI(),u=n+m/2,E=t-p/2,g=Na/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=QI(r,b,u,E,g,c),I=zB["Lilita One"],T=GB.xl,C=UB(I),P=HB({fontFamily:I,fontSize:T}),M=e.title?Xm(e.title,P,m+Ba*2):null,D=M?WB(M,P,C):null,_=M?VB({backgroundColor:c,...Oe,text:M,originalText:e.title??M,x:n+m/2,y:y-Ba-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:Sf},(z,U)=>{let W=(U+1)/Sf,G=g*W,ie=b.map(me=>Ya(Math.cos(me)*G,Math.sin(me)*G));return ie.push(Ya(ie[0][0],ie[0][1])),Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:iT.architect,opacity:mi,polygon:!0,points:ie})}):[],L=b.map(z=>{let U=Math.cos(z)*g,W=Math.sin(z)*g;return Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(W),strokeStyle:"solid",roughness:iT.architect,opacity:mi,points:[Ya(0,0),Ya(U,W)]})}),F=i.map((z,U)=>{let W=b.map((G,ie)=>{let me=z.values[ie]??0,B=a(me,ie)*g;return Ya(Math.cos(G)*B,Math.sin(G)*B)});return W.push(Ya(W[0][0],W[0][1])),Nf({backgroundColor:"transparent",...Oe,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:W})}),Y=Va(i,d,u,x,t+so*5,c);return[..._?[_]:[],...w,...k,...L,...F,...Y]};var Bf=(e,n,t,o,r)=>e==="line"?oT(n,t,o,r):e==="radar"?aT(n,t,o,r):tT(n,t,o,r);import{clamp as jm,pointFrom as Xa,pointsEqual as qB,bezierEquation as fT,pointRotateRads as qm,pointDistance as JB}from"@excalidraw/math";import{arrayToMap as QB,BIND_MODE_TIMEOUT as Hl,DEFAULT_TRANSFORM_HANDLE_SPACING as ET,FRAME_STYLE as bn,getFeatureFlag as eF,invariant as mT,shouldRotateWithDiscreteAngle as bT,THEME as Ro}from"@excalidraw/common";import{deconstructDiamondElement as Hf,deconstructRectanguloidElement as xT,elementCenterPoint as Ka,getDiamondBaseCorners as tF,FOCUS_POINT_SIZE as nF,getOmitSidesForEditorInterface as Ff,getTransformHandles as oF,getTransformHandlesFromCoords as rF,hasBoundingBox as iF,hitElementItself as aF,isArrowElement as yT,isBindableElement as wT,isElbowArrow as Za,isFrameLikeElement as $a,isImageElement as Jm,isLinearElement as sF,isLineElement as lF,maxBindingDistance_simple as cF,isTextElement as dF,LinearElementEditor as xn,getActiveTextElement as mF,getElementsInGroup as Uf,getSelectedGroupIds as pF,isSelectedViaGroup as uF,selectGroupsFromGivenElements as hF}from"@excalidraw/element";import{renderSelectionElement as gF}from"@excalidraw/element";import{getCommonBounds as Wf,getElementAbsoluteCoords as Wl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as pT,isFocusPointVisible as fF}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as YB}from"@excalidraw/common";var XB="#ff6b6b",KB="#ff0000",sT=1,lT=2,cT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===YB.LIGHT||n.zenModeEnabled?XB:KB,o=(n.zenModeEnabled?sT*1.5:sT)/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,$B(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,jB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,ZB(r,e,n));e.restore()},ZB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];En(o,r,n)}for(let o of e.points)dT(o,t,n)},$B=(e,n,t)=>{dT(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},dT=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?lT*1.5:lT)/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()},En=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},jB=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||En(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),En(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),En(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(En(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),En(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||En(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),En(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),En(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(En(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),En(e,n,r))}};var EF=(e,n)=>{mT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;mT(t,"midPointCoords is null"),Qm(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=xn.getElement(o,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);Qm(a,e,n)},Qm=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",Cs(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},xF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!yT(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Qm(a,e,n)},Of=(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)"),Cs(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},yF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&$a(a)&&(e.translate(a.x,a.y),e.beginPath(),bn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,bn.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=bn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===Ro.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",bn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,bn.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 s=Ka(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=jm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Ro.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[l,c]=Hf(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;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[l,c]=xT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;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&&($a(n.element)||wT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&aF({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Za(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Ka(n.element,t),p;if(n.element.type==="diamond"){let b=Ka(n.element,t);p=tF(n.element).map(w=>{let y=fT(w,.5),x=qm(y,b,n.element.angle);return Xa(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=Xa(w.x+n.element.x,w.y+n.element.y),x=qm(y,m,n.element.angle);return Xa(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=JB(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=cF(o.zoom)+n.element.strokeWidth/2;p.forEach((b,w)=>{let y=(!c||d)&&u?.idx===w&&u.distance<=g,x=!y&&(d||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Ro.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===Ro.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()}}},wF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Hl-(a?.runtime??(s?0:Hl)),c=jm(1/Hl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&$a(m)&&(n.translate(m.x,m.y),n.beginPath(),bn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,bn.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=bn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===Ro.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,bn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,bn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Ka(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-d,t.y+r.scrollY-d),n.lineWidth=jm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Ro.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=Hf(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,w]=xT(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),w.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Hl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!$a(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Hl*l;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-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!bT(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]=Hf(t),x=Ka(t,o);w=y.map(I=>{let T=fT(I,.5),C=qm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=Ka(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=Xa(I.x+t.x,I.y+t.y),C=qm(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===Ro.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,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}},vF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(eF("COMPLEX_BINDINGS"))return wF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Xa(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&bT(e.lastPointerMoveEvent);yF(n,t,o,r,s,l),n.restore()},vT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??ET*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=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*I,Ps(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},IF=(e,n,t,o)=>{let[r,i,a,s]=Wl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),Ps(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},uT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=Wf(d);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}},c=d=>{let m=Uf(t,d);return l(m)};Object.entries(hF(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>vT(e,n,d))},zf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=xn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=xn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Za(t),l=lF(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&qB(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Of(e,n,c,a,p,!1,m)}),Za(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Of(e,n,Xa((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Za(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Of(e,n,d,i/2,!1,!0,!1)});e.restore()},TF=(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()},SF=(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)",Cs(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},hT=({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||!wT(a)||a.isDeleted)return;let s=pT(i.fixedPoint,a,r);if(!fF(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&Qm(s,o,n),!(m&&c)){let p=pT(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);TF(o,n,E,p),SF(o,n,p,nF/1.5,u)}},gT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?Cs(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Ps(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},CF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Wl(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/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,C],[P,M],[D,_],[k,L]]=y;e.save(),e.translate(s,l),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+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},PF=(e,n,t,o)=>{n.save();let r=ff(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+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(c,d,i,a),n.restore()},kF=(e,n,t,o,r)=>{let i=Ef(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())},MF=(e,n,t,o,r,i)=>{for(let a of n){if(!Jm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Ul(a,t,r,"center");d&&TT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Ul(a,t,r,"center");m&&IT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Ul(a,t,r,"top-right");d&&DF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Ul=(e,n,t,o)=>{if(!Jm(e))return null;let[r,i,a,s]=Wl(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},IT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===Ro.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=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*jm(i,0,1)),e.stroke()),e.restore()},Gf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,AF=(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()},DF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Gf("--color-primary",s),d=i.color??Gf("--color-warning-darkest","#ec8b14");if(l==="failed"){TT(e,n,t,o,a,{color:i.color??Gf("--color-danger","#e03131")});return}if(l==="uploading"&&IT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),AF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,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 l==="pending"&&(e.save(),e.strokeStyle=c,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())},TT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=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=s,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()},LF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Rc(n,a),E=d,g=Nc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),Bc(g,s);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&zf(g,s,b,t),s.selectionElement&&!s.isCropping)try{gF(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let w=mF(r,s);if(w&&!w.autoResize&&kF(w,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&PF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:vF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&xF(g,s,i),s.frameToHighlight&&IF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&uT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Uf(i,s.activeLockedId);uT(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>$a(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&zf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?EF(g,s):(Za(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&bF(g,s,t)),yT(I)&&(hT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),hT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=iF(r,s,c),P=r.length===1&&sF(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&zf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=QB(r),_=[];for(let L of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(L.id);if(P&&Za(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!uF(s,L)&&F.push(M),Y&&F.push(...Y.map(z=>ei(z,s.collaborators.get(z))))),F.length){let[z,U,W,G,ie,me]=Wl(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:W,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!Y||L.locked,cx:ie,cy:me,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Jm(L)?0:void 0})}}let k=L=>{let F=Uf(t,L),[Y,z,U,W]=Wf(F);_.push({angle:0,x1:Y,x2:U,y1:z,y2:W,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(U-Y)/2,cy:z+(W-z)/2,activeEmbeddable:!1})};for(let L of pF(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>vT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=oF(r[0],s.zoom,t,"mouse",Ff(c));if(!s.viewModeEnabled&&C&&!dF(s.editingTextElement)&&!s.croppingElementId&&gT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Jm(_)&&CF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=ET*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=Wf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,Ps(g,_-D,k-D,L-_+D*2,F-k+D*2,(_+L)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(Y);let U=rF([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{...Ff(c),rotation:!0}:Ff(c));r.some(W=>!W.locked)&&gT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let D=t.get(C);if(D){let[_,k,,,L,F]=Wl(D,t,!0);g.save(),s.theme===Ro.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 Y=$a(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,F),g.rotate(D.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-L,k+z.offsetY/Y-F,z.width/Y,z.height/Y)}),g.restore()}}),cT(g,s),MF(g,o,t,e,s,l.selectionColor),g.restore(),Ow({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=uI(t,p,u,s),g.save(),g.fillStyle=pI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&cm(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},Vf=e=>{let n=LF(e);return e.callback(n),n};import{useEffect as Kl,useMemo as ST,useRef as $f,useState as _F}from"react";import{bumpVersion as Vl,getLinearElementSubType as qa,mutateElement as jf,updateElbowArrowPoints as RF}from"@excalidraw/element";import{pointFrom as tp,pointRotateRads as NF}from"@excalidraw/math";import{hasBoundTextElement as BF,isArrowBoundToElement as FF,isArrowElement as OF,isElbowArrow as zF,isLinearElement as eE,isUsingAdaptiveRadius as GF}from"@excalidraw/element";import{getCommonBoundingBox as HF,getElementAbsoluteCoords as UF}from"@excalidraw/element";import{getBoundTextElement as AT,getBoundTextMaxHeight as WF,getBoundTextMaxWidth as VF,redrawTextBoundingBox as YF}from"@excalidraw/element";import{wrapText as XF}from"@excalidraw/element";import{assertNever as KF,CLASSES as ZF,getFontString as Yf,isProdEnv as $F,mapFind as jF,reduceToCommonValue as qF,ROUNDNESS as Xf,sceneCoordsToViewportCoords as JF,updateActiveTool as CT}from"@excalidraw/common";import{measureText as PT}from"@excalidraw/element";import{LinearElementEditor as QF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Kf,newElement as eO,newLinearElement as tO}from"@excalidraw/element";import{ShapeCache as nO}from"@excalidraw/element";import{updateBindings as oO}from"@excalidraw/element";import{jsx as Qf}from"react/jsx-runtime";var rO=8,iO=10,Yl=["rectangle","diamond","ellipse"],Xl=["line","sharpArrow","curvedArrow","elbowArrow"],aO=new Set(Yl),sO=new Set(Xl),Ja=e=>aO.has(e),np=e=>e==="arrow"||sO.has(e),lo=et(null),Zl=new Map,$l=new Map,lO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=$f(null);return Kl(()=>{if(n.length===0){e.updateEditorAtom(lo,null);return}let o=op(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(lo,null),t.current=null)},[n,e]),Kl(()=>()=>{Zl.clear(),$l.clear()},[]),Qf(cO,{app:e,elements:n})},cO=({app:e,elements:n})=>{let t=op(n),o=ST(()=>t==="generic"?LT(n):[],[t,n]),r=ST(()=>t==="linear"?Jf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>qa(m)===qa(r[0])):!1,[a,s]=_F({x:0,y:0}),l=$f(""),c=$f(null);Kl(()=>{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===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,w,y,x]=UF(m[0],e.scene.getNonDeletedElementsMap());u=NF(tp(b,w),tp(y,x),m[0].angle)}else{let{minX:b,maxY:w}=HF(m);u=tp(b,w)}let{x:E,y:g}=JF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Kl(()=>{for(let m of r){let p=qf(m.id,hO(m));$l.has(p)||$l.set(p,m)}},[r]),Kl(()=>{for(let m of o)if(!Zl.has(m.id)){let p=AT(m,e.scene.getNonDeletedElementsMap());p&&Zl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",$o],["sharpArrow",Jo],["curvedArrow",er],["elbowArrow",Qo]]:t==="generic"?[["rectangle",zi],["diamond",Gi],["ellipse",Hi]]:[];return Qf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(iO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-rO}px`,zIndex:2},className:ZF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&qa(r[0])===m);return Qf($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&He("convertElementType",m,"ui"),tE(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},dO=(e,n,t)=>{let o=VF(e,n),r=WF(e,n),i=XF(n.text,Yf(n),o),a=PT(i,Yf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=PT(n.text,Yf(l),n.lineHeight)}jf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),YF(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((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=LT(r),c=s.every(d=>d.type===s[0].type)?Yl.indexOf(s[0].type):-1;if(t=t??Yl[(c+Yl.length+a)%Yl.length],t&&Ja(t)){let d={};for(let p of s){let u=MT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=AT(p,e.scene.getNonDeletedElementsMap());u&&(Zl.get(p.id)&&jf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Zl.get(p.id)?.fontSize??u.fontSize}),dO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:CT(p,{type:"selection"})}))}}if(n==="linear"){let s=Jf(r);if(!t){let c=qF(s,qa),d=c?Xl.indexOf(c):-1;t=Xl[(d+Xl.length+a)%Xl.length]}if(np(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=$l.get(qf(m.id,t));if(p&&qa(p)===t)d.set(p.id,p),c.push(p);else{let u=MT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(eE(m))if(zF(m)){let p=mO(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=RF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});jf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=jF(["line","sharpArrow","curvedArrow"],u=>$l.get(qf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Jf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new QF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:CT(c,{type:"selection"})}))}return!0},op=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Ja(t.type))return"generic";DT(t)&&(n=!0)}return n?"linear":null},DT=e=>eE(e)&&(!OF(e)||!FF(e)&&!BF(e)),qf=(e,n)=>`${e}:${n}`,LT=e=>e.filter(n=>Ja(n.type)),Jf=e=>e.filter(n=>DT(n)),ep=20,ja=(e,n)=>e[0]===n[0],Zf=(e,n)=>e[1]===n[1],kT=(e,n)=>ja(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),mO=e=>{let n=[e.points[0]],t=pO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<ep?s[0]=a[0]:Math.abs(s[1]-a[1])<ep&&(s[1]=a[1]),ja(a,s)||Zf(a,s)||n.push(tp(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)ja(n[i-1],n[i])&&ja(n[i],n[i+1])||Zf(n[i-1],n[i])&&Zf(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],s=o[i],l=o[i+1],c=ja(a,s),d=ja(s,l);if(c!==d){let m=kT(a,s),p=kT(s,l);if(m<ep||p<ep){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},pO=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},MT=(e,n,t)=>{if(!uO(e.type,n)){if(!$F())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(nO.delete(e),Ja(n)){let o=Vl(eO({...e,type:n,roundness:e.roundness?{type:GF(n)?Xf.ADAPTIVE_RADIUS:Xf.PROPORTIONAL_RADIUS}:e.roundness}));return oO(o,t.scene,t.state),o}if(np(n))switch(n){case"line":return Vl(tO({...e,type:"line"}));case"sharpArrow":return Vl(Kf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Vl(Kf({...e,type:"arrow",elbowed:!1,roundness:{type:Xf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Vl(Kf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return KF(n,`unhandled conversion type: ${n}`),e},uO=(e,n)=>!!(Ja(e)&&Ja(n)||np(e)&&np(n)),hO=e=>eE(e)?qa(e):e.type,_T=lO;import{bindBindingElementToFixedPoint as gO,dragNewTextElement as fO,getBoundTextElement as EO,getEndpointBoundTextDragAnchor as bO,getTextBindingForArrowEndpoint as xO,getUnboundArrowEndpointAtPoint as yO,isArrowElement as wO,isBindingEnabled as vO,isEndpointBoundText as IO,isTextElement as TO}from"@excalidraw/element";import{pointFrom as SO}from"@excalidraw/math";var rp=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(!vO(this.app.state))return null;let o=yO(SO(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!wO(r)||EO(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 xO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){gO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!TO(n)||!IO(n,this.app.scene.getNonDeletedElementsMap())?!1:(fO({newElement:n,...bO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as CO,BUCKET_FILL_BACKGROUND_PICKS as PO,COLOR_PALETTE as NT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as kO,getSizeFromPoints as MO,isTransparent as AO,THEME as DO}from"@excalidraw/common";import{pointFrom as RT}from"@excalidraw/math";import{computeBucketFillPolygon as LO,isBucketFillCompatible as _O,isFrameLikeElement as RO,isRestylableFill as NO,newLinearElement as BO,ShapeCache as FO}from"@excalidraw/element";var nE=PO.filter(e=>e!==NT.white),ip=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=nE.indexOf(n),o=nE[(t+1)%nE.length];this.app.actionManager.executeAction(Ld,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(bt.get(Ut))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Ld,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Ut,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&bt.get(Ut)===n&&this.app.updateEditorAtom(Ut,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}),FO.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=RT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=LO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&_O(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&NO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=MO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(y=>RT(y[0]-d,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?RO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=BO({type:"line",x:d,y:m,width:l,height:c,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===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],w<0?null:s.insertion.placement==="above"?w+1:w),this.app.scheduleCapture()});v(this,"getBucketFillBackgroundColor",(n,t)=>AO(n)?NT.green[kO]:CO(n,t===DO.DARK))}};import{CURSOR_TYPE as jl,MIME_TYPES as sp,THEME as BT}from"@excalidraw/common";var FT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',OO='<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"/>',OT='<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"/>',zO=`data:${sp.svg},${encodeURIComponent(`${FT}${OT}</svg>`)}`,GO=`data:${sp.svg},${encodeURIComponent(`${FT}${OO}${OT}</svg>`)}`,HO=e=>{let n=Nu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${sp.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>`)}`},ap=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(jl.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(Ts({activeTool:n}))this.set(jl.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(jl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${HO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===BT.LIGHT?zO:GO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(jl.AUTO):this.set(jl.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===BT.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(sp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as XO}from"@excalidraw/common";import{bindBindingElement as KO,convertToShape as ZO,convertToShapeHandlePointerMoveFromPointerDown as $O,getHoveredElementForBinding as zT,isBindingElement as jO,isLineElement as qO,LinearElementEditor as oE,maxBindingDistance_simple as GT,newArrowElement as JO,updateBoundPoint as QO}from"@excalidraw/element";import{getStrokeWidthByKey as UO,THEME as WO}from"@excalidraw/common";import{clamp as VO,pointFrom as YO}from"@excalidraw/math";var lp=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Bn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===WO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>VO(UO("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])=>YO(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(ht),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>$O(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=GT(t.state.zoom),a=["start","end"].map(d=>{let m=oE.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:zT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&KO(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=QO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&oE.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=GT(t.state.zoom),[a,s]=[0,-1].map(l=>zT(oE.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:JO({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||ZO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:XO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&qO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&jO(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new lp(n)}};import{isArrowKey as e9,KEYS as ui}from"@excalidraw/common";import{makeNextSelectedElementIds as t9,CaptureUpdateAction as n9,FlowChartCreator as o9,FlowChartNavigator as r9,getSelectedElements as HT,isFlowchartNodeElement as i9}from"@excalidraw/element";var dp=class e{constructor(n){this.app=n;v(this,"creator",new o9);v(this,"navigator",new r9);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===ui.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!e9(n.key))return{type:"none"};if(n[ui.CTRL_OR_CMD]&&!n.shiftKey){let a=HT(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(),s=HT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[ui.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:t9({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:n9.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case ui.ARROW_UP:return"up";case ui.ARROW_DOWN:return"down";case ui.ARROW_RIGHT:return"right";case ui.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as UT,hasPlayableGif as a9,isInitializedImageElement as s9,newElementWith as WT,ShapeCache as l9}from"@excalidraw/element";import{MIME_TYPES as VT}from"@excalidraw/common";var mp=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||a9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==VT.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:VT.gif,gifDecodeStatus:"pending"});let r=WT(n,{fileId:o,gifPlayback:UT({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:WT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:UT(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),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,l9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as c9,easeOut as jT,isBounds as d9}from"@excalidraw/common";import{clamp as qT}from"@excalidraw/math";import{getCommonBounds as YT,getElementsInGroup as m9,isElementLink as p9,isExcalidrawElement as u9,parseElementLinkFromURL as h9}from"@excalidraw/element";var pp="animateScrollToContent",Qa="animateScrollConstraintsSnapBack",XT=500,g9=250,f9=200,rE=302,KT={full:216,compact:64},E9=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)},ZT=(e,n,t)=>{if(typeof e=="string"){let a=p9(e),s=a?"link":"element",l=a?h9(e):e,c=l?b9(l,n):[];return c.length?{bounds:YT(c,n),type:s}:{bounds:null,type:s}}if(d9(e))return{bounds:e,type:"area"};if(E9(e)&&!u9(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}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:YT(r,n),type:"element"}},x9=e=>e===!1?0:e===!0||e==null?Su:Math.max(e,0),y9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Nr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},$T=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=y9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:x9(r.overscroll),offsets:o};return{...Kn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},w9=({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}}},v9=e=>e===!1?null:e===!0||e==null?XT:e.duration??XT,I9=(e,n,t,o,r)=>{lt.start(pp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=jT(qT(l,0,1));return l<1?(o({...w9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},T9=(e,n,t=g9)=>{let o=Kn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||lt.running(pp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;lt.start(Qa,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-jT(qT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Kn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},up=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=jn().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={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,w]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],w);let y=u.dataset.viewportUiName;y&&(a.add(y),w>0&&this.uiLastMeasured.set(y,{side:b,offset:w}));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"?KT.compact:KT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:rE})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,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}=ZT(n.target,t,o);return r?$T(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),lt.cancel(Qa),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=ZT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=$T(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=v9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),lt.cancel(Qa),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),I9(p,d,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||lt.cancel(Qa),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(),Kn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Kn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||T9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",c9(this.snapBack,f9));v(this,"cancelTransition",()=>{this.activeTransition=null,lt.cancel(pp)});v(this,"destroy",()=>{this.cancelTransition(),lt.cancel(Qa),this.snapBackDebounced.cancel()})}get isAnimating(){return lt.running(pp)||lt.running(Qa)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import hp from"react";var S9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,C9=/{{([\w-]+)}}/,P9=/<([\w-]+)>/,k9=/<\/([\w-]+)>/,M9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(S9).filter(Boolean).forEach(o=>{let r=o.match(P9),i=o.match(k9),a=o.match(C9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=hp.createElement(hp.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} 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},A9=({i18nKey:e,children:n,...t})=>{let{t:o}=Re();return hp.createElement(hp.Fragment,{},...M9(o(e),t))},hi=A9;import{jsx as yn,jsxs as JT}from"react/jsx-runtime";var D9=()=>JT("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>yn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>JT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),QT=D9;import z9 from"clsx";import G9 from"react";import{isDarwin as eS}from"@excalidraw/common";var L9={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:[eS?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[eS?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")]},Je=(e,n=0)=>{let t=L9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as _9,useRef as tS,useEffect as nS}from"react";import{unstable_batchedUpdates as R9}from"react-dom";import{KEYS as N9,queryFocusableElements as B9}from"@excalidraw/common";import{clamp as oS}from"@excalidraw/math";import F9 from"clsx";import{jsx as O9}from"react/jsx-runtime";var xr=10,rS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=tS(null);nS(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===N9.TAB){let u=B9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(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 d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=tS(null);return _9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-xr*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${xr}px`,d.style.overflowX="scroll"):d.style.left=`${oS(n,xr,i-xr-m)}px`;let E=Math.max(0,a-xr*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${xr}px`,d.style.overflowY="scroll"):d.style.top=`${oS(t,xr,a-xr-p)}px`}},[t,n,r,i,a]),nS(()=>{if(o){let d=m=>{l.current?.contains(m.target)||R9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),O9("div",{className:F9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as No,jsxs as aS}from"react/jsx-runtime";var ze="separator",iS=e=>"onSelect"in e,sS=G9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=no(),a=Zi(),s=n.reduce((l,c)=>c?c===ze||iS(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return No(rS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:No("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===ze)return!s[c-1]||s[c-1]===ze?null:No("hr",{className:"context-menu-item-separator"},c);if(iS(l))return No("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:aS("button",{type:"button",className:"context-menu-item",children:[No("div",{className:"context-menu-item__label",children:l.label}),No("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),No("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:aS("button",{type:"button",className:z9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[No("div",{className:"context-menu-item__label",children:m}),No("kbd",{className:"context-menu-item__shortcut",children:d?Je(d):""})]})},c)})})})});import{useId as H9}from"react";import U9 from"clsx";import{Fragment as W9,jsx as ql,jsxs as lS}from"react/jsx-runtime";var gp=({border:e,style:n})=>ql("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),fp=({label:e,border:n})=>{let t=H9(),o=lS(W9,{children:[e.icon&&ql("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return lS("div",{className:U9("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&&ql("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),ql("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&ql("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import us from"clsx";import hV from"react";import{CLASSES as gV,TOOL_TYPE as Fk,arrayToMap as fV,isShallowEqual as jp}from"@excalidraw/common";import{mutateElement as EV,ShapeCache as bV}from"@excalidraw/element";import{showSelectedShapeActions as xV}from"@excalidraw/element";import{createIsolation as V9}from"jotai-scope";import iE from"react";import Bo from"tunnel-rat";var aE=iE.createContext(null),rt=()=>iE.useContext(aE),Y9=V9(),cS=()=>iE.useMemo(()=>({MainMenuTunnel:Bo(),WelcomeScreenMenuHintTunnel:Bo(),WelcomeScreenToolbarHintTunnel:Bo(),WelcomeScreenHelpHintTunnel:Bo(),WelcomeScreenCenterTunnel:Bo(),FooterCenterTunnel:Bo(),DefaultSidebarTriggerTunnel:Bo(),DefaultSidebarTabTriggersTunnel:Bo(),OverwriteConfirmDialogTunnel:Bo(),tunnelsJotai:Y9}),[]);import wr from"clsx";import{useRef as ez}from"react";import{Popover as yr}from"radix-ui";import{CLASSES as yS}from"@excalidraw/common";import{isArrowElement as xS}from"@excalidraw/element";import{forwardRef as dS}from"react";import mS from"clsx";import{jsx as pS}from"react/jsx-runtime";var X9=dS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>pS("div",{className:mS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),K9=dS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>pS("div",{className:mS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Ot={Row:X9,Col:K9};import{isTransparent as uS}from"@excalidraw/common";import{shouldAllowVerticalAlign as Z9,suppportsHorizontalAlign as $9,hasBoundTextElement as hS,isElbowArrow as j9,isImageElement as gS,isLinearElement as q9,isTextElement as J9,hasStrokeColor as fS,toolIsArrow as Q9}from"@excalidraw/element";var ES=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return fS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>fS(o.type))},bS=(e,n)=>Xo(e.activeTool.type)||n.some(t=>Xo(t.type)),Ep=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(hS(n[0])||hS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:ES(e,n),backgroundColor:bS(e,n),fill:r==="bucketfill"||Xo(r)&&!uS(e.currentItemBackgroundColor)||n.some(d=>Xo(d.type)&&!uS(d.backgroundColor)),strokeWidth:i(cx),freedrawMode:i(dx),strokeStyle:i(Cu),sloppiness:i(Cu),roundness:i(mx),arrowType:i(Q9),arrowheads:i(Is),text:r==="text"||n.some(J9),textAlign:r==="text"||$9(n,t),verticalAlign:Z9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||de(t,e).some(d=>d.type==="freedraw"),align:!s&&st(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(gS)&&st(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&gS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&q9(n[0])&&!j9(n[0])}};import{Fragment as en,jsx as q,jsxs as Te}from"react/jsx-runtime";var sE=wr([yS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),wS=({renderAction:e})=>Te("fieldset",{children:[q("legend",{children:f("labels.layers")}),Te("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),vS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Te("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Te("div",{className:"align-fieldset-header",children:[q("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Te("div",{className:"buttonList",children:[o?Te(en,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Te(en,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Te("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Te(en,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},IS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Li(n,e),i=Ep(e,r,n,o);return e.activeTool.type==="bucketfill"?Te("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Te("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(en,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(en,{children:t("changeSloppiness")}),i.roundness&&q(en,{children:t("changeRoundness")}),i.arrowType&&q(en,{children:t("changeArrowType")}),i.text&&Te(en,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(en,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(wS,{renderAction:t}),i.align&&q(vS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("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")]})]})]})},TS=({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:Te(yr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:x0})}),a&&q(To,{className:sE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(en,{children:n("changeStrokeStyle")}),o.sloppiness&&q(en,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},SS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=pt(o,a,c=>xS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>xS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Qo:l==="round"?er:Jo})()})}),s&&q(To,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},CS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=U0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:Yx})}),e.openPopup==="compactTextProperties"&&q(To,{className:sE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Te("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},PS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?q("div",{className:"compact-action-item",children:Te(yr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(yr.Trigger,{asChild:!0,children:q("button",{type:"button",className:wr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ox})}),s&&q(To,{className:sE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[t.layers&&q(wS,{renderAction:n}),t.align&&q(vS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("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},tz=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,kS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Li(n,e),a=Ep(e,i,n,o),{container:s}=Fe();return Te("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:wr("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(TS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(SS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(CS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),q(PS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},MS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Li(n,e),a=Ep(e,i,n,o),{container:s}=Fe(),l=ez(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Te(Xe,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[Te("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:wr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(TS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(SS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(tz,{renderAction:t,predicates:a}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(CS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(PS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Te("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[q("div",{className:"compact-action-item",children:t("undo")}),q("div",{className:"compact-action-item",children:t("redo")}),b&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},AS=({renderAction:e})=>q(Ot.Col,{gap:1,className:yS.ZOOM_ACTIONS,children:Te(Ot.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),DS=({renderAction:e,className:n})=>Te("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(ut,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Te(ut,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),LS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:wr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import nz from"clsx";import{useState as oz,useEffect as rz}from"react";import{THEME as iz}from"@excalidraw/common";import{jsx as lE,jsxs as az}from"react/jsx-runtime";var bp=({delay:e,theme:n})=>{let[t,o]=oz(!!e);return rz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:az("div",{className:nz("LoadingMessage",{"LoadingMessage--dark":n===iz.DARK}),children:[lE("div",{children:lE(Io,{})}),lE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as vp,useEffect as eC}from"react";import Nz from"clsx";import{KEYS as pE,capitalizeString as tC}from"@excalidraw/common";import QS from"react";import{DropdownMenu as Dz}from"radix-ui";import{CLASSES as Lz}from"@excalidraw/common";import sz from"clsx";import{useCallback as lz,useEffect as cz,useRef as dz}from"react";import{CLASSES as mz,EVENT as _S,KEYS as pz}from"@excalidraw/common";import{DropdownMenu as uz}from"radix-ui";import{jsx as xp}from"react/jsx-runtime";var RS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=Ee(),l=dz(null),c=Ki({onClickOutside:n});Xi(l,lz(m=>{l.current?.closest(`.${mz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),cz(()=>{if(!r)return;let m=u=>{u.key===pz.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(_S.KEYDOWN,m,p),()=>{document.removeEventListener(_S.KEYDOWN,m,p)}},[c,r]);let d=sz(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return xp(Ah.Provider,{value:{onSelect:o},children:xp(uz.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?xp(Ot.Col,{className:"dropdown-menu-container",children:e}):xp(Xe,{className:"dropdown-menu-container",padding:2,children:e})})})};RS.displayName="DropdownMenuContent";var NS=RS;import{jsx as gz}from"react/jsx-runtime";var hz=({children:e,className:n="",selected:t,...o})=>gz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),BS=hz;import{DropdownMenu as fz}from"radix-ui";import{jsx as cE}from"react/jsx-runtime";var FS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=wd(r);return cE(fz.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:cE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:rr(i,a),title:l.title??l["aria-label"],children:cE(ir,{icon:e,shortcut:n,children:o})})})},es=FS;FS.displayName="DropdownMenuItemLink";import{jsx as Ez}from"react/jsx-runtime";var OS=()=>Ez("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),zS=OS;OS.displayName="DropdownMenuSeparator";import{DropdownMenu as Tz}from"radix-ui";import bz from"clsx";import{DropdownMenu as xz}from"radix-ui";import{useCallback as yz,useState as GS}from"react";import{jsx as mE}from"react/jsx-runtime";var dE=-4,wz=4,HS=({children:e,className:n})=>{let t=Ee(),o=bz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=yz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+dE),l(dE+8))}}},[]),[i,a]=GS(wz),[s,l]=GS(dE);return mE(xz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?mE(Ot.Col,{className:"dropdown-menu-container",children:e}):mE(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},US=HS;HS.displayName="DropdownMenuSubContent";import{DropdownMenu as vz}from"radix-ui";import{jsx as WS,jsxs as Iz}from"react/jsx-runtime";var VS=({children:e,icon:n,shortcut:t,className:o})=>Iz(vz.SubTrigger,{className:`${rr(o)} dropdown-menu__submenu-trigger`,children:[WS(ir,{icon:n,shortcut:t,children:e}),WS("div",{className:"dropdown-menu__submenu-trigger-icon",children:v0})]}),YS=VS;VS.displayName="DropdownMenuSubTrigger";import XS from"react";var yp=e=>n=>{let t=XS.Children.toArray(n).find(o=>XS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},KS=yp("DropdownMenuTrigger"),ZS=yp("DropdownMenuContent"),$S=yp("DropdownMenuSubTrigger"),jS=yp("DropdownMenuSubContent");import{jsxs as Sz}from"react/jsx-runtime";var wp=({children:e})=>{let n=$S(e),t=jS(e);return Sz(Tz.Sub,{children:[n,t]})};wp.Trigger=YS;wp.Content=US;wp.displayName="DropdownMenuSub";var vr=wp;import Cz from"clsx";import{DropdownMenu as Pz}from"radix-ui";import{jsx as kz}from"react/jsx-runtime";var qS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=Ee(),a=Cz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return kz(Pz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},JS=qS;qS.displayName="DropdownMenuTrigger";import{jsx as Az}from"react/jsx-runtime";var Mz=e=>Az(Jt,{...e,icon:e.checked?Xc:Qc}),co=Mz;import{jsx as Rz,jsxs as _z}from"react/jsx-runtime";var On=({children:e,open:n})=>{let t=KS(e),o=ZS(e),r=o&&QS.isValidElement(o)?QS.cloneElement(o,{open:n}):o;return Rz(Dz.Root,{open:n,modal:!1,children:_z("div",{className:Lz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};On.Trigger=JS;On.Content=NS;On.Item=Jt;On.ItemCheckbox=co;On.ItemLink=es;On.ItemCustom=BS;On.Group=Xs;On.Separator=zS;On.Sub=vr;var ge=On;On.displayName="DropdownMenu";import{Fragment as uE,jsx as Ne,jsxs as ts}from"react/jsx-runtime";var Bz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=f("buttons.objectsSnapMode");return Ne($,{type:"toggle",icon:qo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Rt,"ui")})},Fz=({app:e})=>Ne($,{type:"button",icon:Wi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),nC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=vp(!1),[l,c]=vp("rectangle"),[d,m]=vp("arrow");eC(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),eC(()=>{(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(G=>({type:G,icon:Ze[G].icon,title:tC(f(`toolBar.${G}`)),fillable:Ze[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:Ze[G].icon,title:tC(f(`toolBar.${G}`)),fillable:Ze[G].fillable})),[x,I]=vp(0),T=36,C=4,P=7,M=P*T+(P-1)*C,D=T+C,_=x>=M+1*D,k=i&&x>=M+2*D,L=x>=M+3*D,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),Y=r&&aa.includes(o.type),z=Y||F.includes(o.type),U=z?Y?Ze[o.type].icon:o.type==="text"?Mn:o.type==="image"?zr:o.type==="frame"?Qn:o.type==="embeddable"?jo:o.type==="laser"?eo:o.type==="bucketfill"?Jn:As:As,W={app:e,activeTool:o,hideShortcut:!0};return ts("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Ne(Vd,{...W}),Ne(Yd,{...W,setAppState:t}),r?Ne(tl,{...W}):Ne(Xd,{...W}),Ne(rl,{...W}),!r&&Ne(ia,{app:e,options:w,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===l)||w[0]}),!r&&Ne(ia,{app:e,options:y,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===d)||y[0]}),_&&Ne(nl,{...W}),r&&k&&Ne(Fz,{app:e}),k&&Ne(ol,{...W}),!r&&L&&Ne(ow,{...W,hideShortcut:!0}),ts(ge,{open:a,children:[Ne(ge.Trigger,{className:Nz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),ts(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&aa.map(G=>Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Ze[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Wd(G),disabled:Qe(e,G),children:f(`toolBar.${G}`)},G)),!r&&Ne("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Rt)&&Ne(ge.Item,{onSelect:()=>n.executeAction(Rt,"ui"),icon:qo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&ts(uE,{children:[r&&Ne("div",{className:"App-toolbar__dropdown-divider"}),Ne(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Zo:vo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:pE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Mn,shortcut:pE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Qe(e,"text"),children:f("toolBar.text")}),i&&!k&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:zr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Qe(e,"image"),children:f("toolBar.image")}),!r&&!L&&Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Qn,shortcut:pE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Qe(e,"frame"),children:f("toolBar.frame")}),!r&&ts(uE,{children:[Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:jo,"data-testid":"toolbar-embeddable",selected:g,disabled:Qe(e,"embeddable"),children:f("toolBar.embeddable")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ur,shortcut:la("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Qe(e,"autoshape"),children:f("toolBar.autoshape")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:eo,"data-testid":"toolbar-laser",selected:E,disabled:Qe(e,"laser"),children:f("toolBar.laser")}),Ne(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Jn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Qe(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&ts(uE,{children:[Ne("div",{className:"App-toolbar__divider"}),Ne(Bz,{actionManager:n,app:e})]})]})};import Oz from"clsx";import{jsx as zz}from"react/jsx-runtime";var Ip=({children:e,side:n,className:t})=>zz("div",{className:Oz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Gz from"clsx";import{jsx as Hz}from"react/jsx-runtime";var ns=e=>e.penDetected?Hz($,{className:Gz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Vx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as oC,jsx as vt,jsxs as gi}from"react/jsx-runtime";var rC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=rt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=vt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&gi(oC,{children:[l&&vt(ns,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),vt(E.Out,{})]}))}),M=gi("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),vt(u.Out,{})]});return gi("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>vt(nC,{app:d,actionManager:t,setAppState:o}),w=c&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=w&&!e.openMenu&&!e.openSidebar?vt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Di(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?vt(fp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return gi(oC,{children:[a(),vt("div",{className:"App-welcome-screen",children:s&&vt(p.Out,{})}),x&&gi("div",{className:"App-bottom-bar",style:{marginBottom:fn+_o,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&vt("div",{className:"floating-status-stack",children:I}),gi("div",{className:"App-bottom-bar__actions-row",children:[y&&gi(Xe,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&vt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),vt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&vt(MS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&vt(Xe,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&vt("div",{className:"floating-status-stack",children:I}),C&&vt("div",{className:"viewport-status-frame__badge-row",children:C}),vt(Ip,{side:"top",className:"App-top-bar",children:g()})]})};import mC,{useLayoutEffect as pC,useRef as uC,useState as hC}from"react";import{newTextElement as gC}from"@excalidraw/element";import Zz from"clsx";import{useEffect as $z,useState as jz}from"react";import{KEYS as qz,queryFocusableElements as cC}from"@excalidraw/common";import{useCallback as Uz,useState as Wz}from"react";var iC=()=>{let[e,n]=Wz(null),t=Uz(o=>n(o),[]);return[e,t]};import aC from"clsx";import{useRef as Vz}from"react";import{createPortal as Yz}from"react-dom";import{KEYS as Xz}from"@excalidraw/common";import{jsx as sC,jsxs as Kz}from"react/jsx-runtime";var lC=e=>{let{closeOnClickOutside:n=!0}=e,t=dd({className:aC("excalidraw-modal-container",e.portalContainerClassName)}),o=Vz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Xz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return Yz(Kz("div",{className:aC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[sC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),sC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Tp,jsxs as dC}from"react/jsx-runtime";function Jz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var wn=e=>{let[n,t]=iC(),[o]=jz(document.activeElement),{id:r}=Fe(),i=Ee().formFactor==="phone";$z(()=>{if(!n)return;let l=cC(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===qz.TAB){let m=cC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ue(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return Tp(lC,{className:Zz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Jz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:dC(Xe,{ref:t,children:[e.title&&dC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[Tp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Tp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),Tp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Fo,jsxs as Sp}from"react/jsx-runtime";var Qz=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}},eG=e=>{let n=uC(null),[t,o]=hC(null),{theme:r}=xe();pC(()=>{if(!e.spreadsheet){o(null);return}let a=Bf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Br(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=Qz(e.chartType);return Sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Fo("div",{className:"ChartPreview__canvas",ref:n}),Fo("div",{className:"ChartPreview__label",children:i})]})},tG=e=>{let n=uC(null),{theme:t}=xe();return pC(()=>{if(!e.rawText)return;let o=gC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Br([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]),Sp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Fo("div",{className:"ChartPreview__canvas",ref:n}),Fo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},fC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=hC(Math.random()),s=mC.useCallback(()=>{a(Math.random())},[]),l=mC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),He("paste","chart",m),t(),r()},d=m=>{let p=gC({text:m,x:0,y:0});o([p]),He("paste","chart","plaintext"),t(),r()};return Fo(wn,{size:"regular",onCloseRequest:l,title:Sp("div",{className:"PasteChartDialog__title",children:[Fo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Fo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Jn})]}),className:"PasteChartDialog",autofocus:!1,children:Sp("div",{className:"container",children:[["bar","line","radar"].map(m=>za(e,m)?Fo(eG,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Fo(tG,{rawText:n,onClick:d})]})})};import{Fragment as nG,jsx as EC,jsxs as oG}from"react/jsx-runtime";var Jl=({heading:e,children:n,...t})=>{let{id:o}=Fe(),r=EC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return EC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):oG(nG,{children:[r,n]})})};import{Popover as Ql}from"radix-ui";import bC from"clsx";import Cp,{useLayoutEffect as rG}from"react";import{supportsResizeObserver as iG,isShallowEqual as aG}from"@excalidraw/common";import{Fragment as fE,jsx as It,jsxs as os}from"react/jsx-runtime";var sG=4,lG=8,hE=38,xC=21,cG=({shouldWrap:e,children:n,username:t})=>e?It(ut,{label:t||"Unknown user",children:n}):It(fE,{children:n}),gE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return It(cG,{username:n.username,shouldWrap:r,children:s},t)},dG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Pp=Cp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=it(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=Cp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=Cp.useRef(null);rG(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!iG)return;let P=new ResizeObserver(M=>{for(let D of M){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=Cp.useState(sG*hE),b=l?E-xC:E,w=Math.max(1,Math.min(8,Math.floor(b/hE))),y=l?Math.max(0,w-1):w,x=c.slice(0,y),I=l?[...x,l]:x,T=I.map(C=>{let P=gE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?os(Ql.Root,{children:[It(Ql.Trigger,{asChild:!0,children:os("div",{className:"UserList__pill",children:[P,It("div",{className:"UserList__pill-chevron",children:w0})]})}),It(Ql.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:os(Xe,{padding:2,children:[s.length>=lG&&It(xd,{placeholder:f("quickSearch.placeholder"),onChange:m}),It(yd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[It("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>gE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&os(fE,{children:[It("div",{className:"UserList__menu-divider"}),It(Ql.Close,{asChild:!0,children:It("div",{className:"dropdown-menu",children:a})})]}),It(Ql.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):P});return n?os("div",{className:bC("UserList UserList_mobile",e),children:[It("div",{className:"UserList_mobile__avatars",children:s.map(C=>gE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&os(fE,{children:[It("div",{className:"UserList__menu-divider"}),a]})]}):It("div",{className:"UserList__wrapper",ref:u,children:It("div",{className:bC("UserList",e),style:{"--max-avatars":I.length+(l?xC/hE:0)},children:T})})},(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||!aG(r,i,dG))return!1}return!0});import ec from"clsx";import{jsx as yC}from"react/jsx-runtime";var wC=e=>yC(ut,{label:`${f("helpDialog.title")} \u2014 ?`,children:yC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Ui})});import{jsx as tn,jsxs as EE}from"react/jsx-runtime";var vC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=rt(),l=St();return EE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&tn("div",{className:ec("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:tn(Ot.Col,{gap:2,children:EE(Jl,{heading:"canvasActions",children:[!e.viewModeOnly&&tn(ut,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:tn("div",{className:ec("view-mode-button"),children:n.renderAction("viewMode")})}),tn(ut,{label:f("buttons.smartZoom"),children:tn("div",{className:ec("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&tn(AS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&tn(DS,{renderAction:n.renderAction,className:ec("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),tn(a.Out,{}),(r||o)&&tn("div",{className:ec("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:EE("div",{style:{position:"relative"},children:[o&&tn(s.Out,{}),r&&tn(wC,{onClick:()=>n.executeAction(Qr)})]})}),r&&tn(LS,{showExitZenModeBtn:t})]})},IC=vC;vC.displayName="Footer";import{composeEventHandlers as bG}from"@excalidraw/common";import{useLayoutEffect as mG,useRef as pG}from"react";import{jsx as uG}from"react/jsx-runtime";var fi=(e,n)=>{let t=et(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=rt(),[,a]=i(t),s=pG({preferHost:!1,counter:0});return mG(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:uG(n,{...r})};return o.displayName=e,o};var wE={};LA(wE,{ChangeCanvasBackground:()=>RC,Export:()=>NC,Help:()=>LC,LiveCollaborationTrigger:()=>FC,LoadScene:()=>kC,Preferences:()=>mo,PreferencesToggleGridModeItem:()=>yE,SaveAsImage:()=>AC,SaveToActiveFile:()=>MC,SearchMenu:()=>DC,Socials:()=>BC,ToggleTheme:()=>_C});import EG from"clsx";import{THEME as nc}from"@excalidraw/common";var bE=et({active:!1});async function TC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{bt.set(bE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import hG from"clsx";import{jsx as SC,jsxs as gG}from"react/jsx-runtime";var kp=function({onChange:e,value:n,choices:t,name:o}){return SC("div",{className:"RadioGroup",children:t.map(r=>gG("div",{className:hG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[SC("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 fG,jsx as tc,jsxs as CC}from"react/jsx-runtime";var PC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=Ee();return CC(fG,{children:[CC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&tc("div",{className:"dropdown-menu-item__icon",children:a}),tc("label",{className:"dropdown-menu-item__text",children:tc(Ks,{children:r})}),tc(kp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&tc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};PC.displayName="DropdownMenuItemContentRadio";var xE=PC;import{Fragment as YC,jsx as ye,jsxs as oc}from"react/jsx-runtime";var kC=()=>{let{t:e}=Re(),n=it(),t=Zi();return n.isActionEnabled(da)?ye(Jt,{icon:Kc,onSelect:async()=>{(!t.length||await TC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(hi,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&n.executeAction(da)},"data-testid":"load-button",shortcut:Je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};kC.displayName="LoadScene";var MC=()=>{let{t:e}=Re(),n=it();return n.isActionEnabled(Jr)?ye(Jt,{shortcut:Je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Jr),icon:Jx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};MC.displayName="SaveToActiveFile";var AC=()=>{let e=Ue(),{t:n}=Re();return ye(Jt,{icon:t1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};AC.displayName="SaveAsImage";var DC=e=>{let{t:n}=Re(),t=it();return ye(Jt,{icon:to,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Ll)},shortcut:Je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};DC.displayName="SearchMenu";var LC=()=>{let{t:e}=Re(),n=it();return ye(Jt,{"data-testid":"help-menu-item",icon:Ui,onSelect:()=>n.executeAction(Qr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};LC.displayName="Help";var _C=e=>{let{t:n}=Re(),t=xe(),o=it(),r=Je("toggleTheme"),i=An();return o.isActionEnabled(zd)?e?.allowSystemTheme?ye(xE,{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:nc.LIGHT,label:_s,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:nc.DARK,label:Ls,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:u0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):ye(Jt,{onSelect:a=>{a.preventDefault(),o.executeAction(zd)},icon:t.theme===nc.DARK?_s:Ls,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===nc.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===nc.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};_C.displayName="ToggleTheme";var RC=()=>{let{t:e}=Re(),n=xe(),t=it(),o=An();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:oc("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};RC.displayName="ChangeCanvasBackground";var NC=()=>{let{t:e}=Re(),n=Ue();return ye(Jt,{icon:Rs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};NC.displayName="Export";var BC=()=>{let{t:e}=Re();return oc(YC,{children:[ye(es,{icon:$x,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ye(es,{icon:qx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ye(es,{icon:jx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};BC.displayName="Socials";var FC=({onSelect:e,isCollaborating:n})=>{let{t}=Re();return ye(Jt,{"data-testid":"collab-button",icon:Zc,className:EG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};FC.displayName="LiveCollaborationTrigger";var OC=()=>{let{t:e}=Re(),n=St(),t=xe();return ye(co,{checked:t.activeTool.locked,shortcut:Je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},zC=()=>{let{t:e}=Re(),n=xe(),t=Ue();return ye(xE,{name:"boxSelectionMode",icon:Qc,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")})},GC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),onSelect:o=>{n.executeAction(Rt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},HC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(pl),o.preventDefault()},children:e("labels.arrowBinding")})},UC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ul),o.preventDefault()},children:e("labels.midpointSnapping")})},yE=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.gridModeEnabled,shortcut:Je("gridMode"),onSelect:o=>{n.executeAction(Ea),o.preventDefault()},children:e("labels.toggleGrid")})},WC=()=>{let{t:e}=Re(),n=it(),t=xe();return t.viewModeOnly?null:ye(co,{checked:t.viewModeEnabled,shortcut:Je("viewMode"),onSelect:o=>{n.executeAction(Da),o.preventDefault()},children:e("labels.viewMode")})},VC=()=>{let{t:e}=Re(),n=it(),t=xe();return ye(co,{checked:t.stats.open,shortcut:Je("stats"),onSelect:o=>{n.executeAction(ur),o.preventDefault()},children:e("stats.fullTitle")})},mo=({children:e,additionalItems:n})=>{let{t}=Re();return oc(vr,{children:[ye(vr.Trigger,{icon:I0,children:t("labels.preferences")}),oc(vr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||oc(YC,{children:[ye(zC,{}),ye(OC,{}),ye(GC,{}),ye(yE,{}),ye(WC,{}),ye(VC,{}),ye(HC,{}),ye(UC,{})]}),n]})]})};mo.ToggleToolLock=OC;mo.BoxSelectionMode=zC;mo.ToggleSnapMode=GC;mo.ToggleArrowBinding=HC;mo.ToggleMidpointSnapping=UC;mo.ToggleGridMode=yE;mo.ToggleViewMode=WC;mo.ToggleElementProperties=VC;mo.displayName="Preferences";import{jsx as Mp,jsxs as vE}from"react/jsx-runtime";var xG=Object.assign(fi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=rt(),o=Ee(),r=xe(),i=An(),a=Ue();return Mp(t.In,{children:vE(ge,{open:r.openMenu==="canvas",children:[Mp(ge.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Kx}),vE(ge.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:bG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&vE("fieldset",{className:"UserList-Wrapper",children:[Mp("legend",{children:f("labels.collaborators")}),Mp(Pp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,Sub:vr,DefaultItems:wE}),zt=xG;import yG from"clsx";import{forwardRef as wG,useState as vG}from"react";import{isPromiseLike as IG}from"@excalidraw/common";import{jsx as Ap,jsxs as TG}from"react/jsx-runtime";var Ir=wG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=vG(!1),E=async b=>{let w=t?.(b);if(IG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Dc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Ap("button",{className:yG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:TG("div",{className:"ExcButton__contents",children:[g==="loading"?Ap(Io,{className:"ExcButton__statusIcon"}):g==="success"&&Ap("div",{className:"ExcButton__statusIcon",children:n0}),n&&Ap("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as rs,jsxs as PG}from"react/jsx-runtime";var Dp=({title:e,children:n,actionLabel:t,onClick:o})=>PG("div",{className:"OverwriteConfirm__Actions__Action",children:[rs("h4",{children:e}),rs("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),rs(Ir,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),SG=()=>{let{t:e}=Re(),n=it(),t=Ue();return rs(Dp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(rm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},CG=()=>{let{t:e}=Re(),n=it();return rs(Dp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(dl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},IE=Object.assign(({children:e})=>rs("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:SG,SaveToDisk:CG});import{jsx as Tr,jsxs as XC}from"react/jsx-runtime";var Lp=Object.assign(fi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=rt(),[t,o]=Ye(bE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Tr(n.In,{children:Tr(wn,{onCloseRequest:r,title:!1,size:916,children:XC("div",{className:"OverwriteConfirm",children:[Tr("h3",{children:t.title}),XC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Tr("div",{className:"OverwriteConfirm__Description__icon",children:o0}),Tr("div",{children:t.description}),Tr("div",{className:"OverwriteConfirm__Description__spacer"}),Tr(Ir,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Tr(IE,{children:e})]})})})}),{Actions:IE,Action:Dp});import{round as BP}from"@excalidraw/math";import YH from"clsx";import XH from"lodash.throttle";import{useEffect as FP,useMemo as FE,useState as KH,memo as ZH}from"react";import{STATS_PANELS as Hp}from"@excalidraw/common";import{getCommonBounds as $H}from"@excalidraw/element";import{getUncroppedWidthAndHeight as jH}from"@excalidraw/element";import{isImageElement as OE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as qH}from"@excalidraw/element";import{elementsAreInSameGroup as JH}from"@excalidraw/element";import{degreesToRadians as eP,radiansToDegrees as rP}from"@excalidraw/math";import{getBoundTextElement as tP}from"@excalidraw/element";import{isArrowElement as nP,isElbowArrow as HG}from"@excalidraw/element";import{updateBindings as oP}from"@excalidraw/element";import NG from"clsx";import{useEffect as JC,useRef as Rp,useState as BG}from"react";import{EVENT as ss,KEYS as FG,cloneJSON as TE}from"@excalidraw/common";import{deepCopyElement as OG}from"@excalidraw/element";import{CaptureUpdateAction as QC}from"@excalidraw/element";import{pointFrom as Sr,pointRotateRads as _p}from"@excalidraw/math";import{getBoundTextElement as kG,getNonDeletedElements as MG,isBindingElement as AG,unbindBindingElement as KC}from"@excalidraw/element";import{isFrameLikeElement as jC}from"@excalidraw/element";import{getSelectedGroupIds as DG,getElementsInGroup as LG,isInGroup as _G}from"@excalidraw/element";import{getFrameChildren as RG}from"@excalidraw/element";import{updateBindings as ZC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as $C}from"@excalidraw/common";var qC=.01,rc=10,Xt=(e,n)=>!(n==="angle"&&jC(e)),Ke=(e,n)=>{let t=e+n/2;return t-t%n},is=(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 Ei=(e,n,t,o,r,i,a=!0)=>{if(AG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<$C&&Math.abs(n-t.y)<$C)return;KC(t,"start",o),KC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=_p(Sr(t.x,t.y),Sr(c,d),t.angle),u=e-m,E=n-p,[g,b]=_p(Sr(e,n),Sr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),ZC(l,o,r);let w=kG(t,i);if(w){let y=s.get(w.id);y&&o.mutateElement(y,{x:w.x+u,y:w.y+E},{informMutation:a,isDragging:!1})}if(jC(t)){let y=RG(i,t.id);y.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=_p(Sr(x.x,x.y),Sr(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=_p(Sr(D,_),Sr(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),ZC(I,o,r,{simultaneouslyUpdated:MG(y)})})}},as=(e,n)=>{let o=DG(n).map(r=>LG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!_G(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as SE,jsxs as GG}from"react/jsx-runtime";var zG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=Ue(),E=Rp(null),g=Rp(null),[b,w]=BG(o.toString()),y=Rp(null);y.current||(y.current={originalAppState:TE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),JC(()=>{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 D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=qC)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>w(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:QC.IMMEDIATELY}))},I=Rp({});return I.current.handleInputValue=x,JC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(ss.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(ss.POINTER_UP,C.onPointerUp,!1)}},[i]),i?GG("div",{className:NG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[SE("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=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,OG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=TE(c),k=0,L=0,F=z=>{if(P&&M!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:W=>w(String(W)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(ss.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:QC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ss.POINTER_UP,Y,!1)};I.current.onPointerMove=F,I.current.onPointerUp=Y,window.addEventListener(ss.POINTER_MOVE,F,!1),window.addEventListener(ss.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?SE(Td,{icon:n}):e}),SE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===FG.ENTER&&(x(C.value,r,c),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=TE(c)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},ft=zG;import{jsx as YG}from"react/jsx-runtime";var UG=15,WG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!HG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=eP(o);r.mutateElement(l,{angle:E}),oP(l,r,i.state);let g=tP(l,a);g&&!nP(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(rP(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=Ke(m,UG)),m=m<0?m+360:m;let p=eP(m);r.mutateElement(l,{angle:p}),oP(l,r,i.state);let u=tP(l,a);u&&!nP(l)&&r.mutateElement(u,{angle:p})}},VG=({element:e,scene:n,appState:t,property:o})=>YG(ft,{label:"A",icon:jc,value:Math.round(rP(e.angle)%360*100)/100,elements:[e],dragInputCallback:WG,editable:Xt(e,"angle"),scene:n,appState:t,property:o}),iP=VG;import{jsx as KG}from"react/jsx-runtime";var aP=5,XG=({property:e,scene:n,appState:t,setAppState:o})=>KG(ft,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?Ke(l.gridStep+aP*Math.sign(i),aP):l.gridStep+i),c?(c=sx(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),sP=XG;import{clamp as Np,round as CE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Bp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as lP,getNonDeletedElements as ZG,getUncroppedWidthAndHeight as mP}from"@excalidraw/element";import{resizeSingleElement as cP}from"@excalidraw/element";import{isImageElement as pP}from"@excalidraw/element";import{isFrameLikeElement as PE}from"@excalidraw/element";import{getElementsInResizingFrame as kE}from"@excalidraw/element";import{replaceAllElementsInFrame as uP}from"@excalidraw/element";import{jsx as QG}from"react/jsx-runtime";var dP=10,$G=e=>e.type==="image",jG=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||$G(u),b=u.width/u.height;if(s.croppingElementId===u.id){let w=p.get(u.id);if(!w||!pP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:C,height:P}=mP(w),M=y.naturalWidth/C,D=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=T?y.height+y.y:y.naturalHeight-y.y,L=lP*M,F=lP*D;if(i!==void 0){if(a==="width"){let G=i*M,ie=Np(G,L,_);x={...x,width:ie,x:I?y.x+y.width-ie:y.x}}else if(a==="height"){let G=i*D,ie=Np(G,F,k);x={...x,height:ie,y:T?y.y+y.height-ie:y.y}}c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,U=Np(y.width+Y,L,_),W=Np(y.height+z,L,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},c.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,Bp),y=Math.max(a==="height"?i:g?i/b:u.height,Bp);if(cP(w,y,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),PE(E)){let x=kE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=uP(c.getElementsIncludingDeleted(),x,E);c.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=Ke(x,dP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=Ke(I,dP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Bp,I),x=Math.max(Bp,x),cP(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),PE(E)){let T=ZG(kE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},qG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&PE(a)){let s=kE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=uP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},JG=({property:e,element:n,scene:t,appState:o})=>{let r=CE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&pP(n)&&n.crop){let{width:i,height:a}=mP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=CE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=CE(n.crop.height*s,2)}}return QG(ft,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:jG,value:r,editable:Xt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:qG})},ME=JG;import{getBoundTextElement as eH,redrawTextBoundingBox as tH}from"@excalidraw/element";import{hasBoundTextElement as nH,isTextElement as gP}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var hP=4,oH=4,rH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!gP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),hP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,hP),t&&(l=Ke(l,oH))}l&&(r.mutateElement(s,{fontSize:l}),tH(s,r.getContainerElement(s),r))}},iH=({element:e,scene:n,appState:t,property:o})=>{let r=gP(e)?e:nH(e)?eH(e,n.getNonDeletedElementsMap()):null;return r?aH(ft,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:rH,icon:Hr,appState:t,scene:n,property:o}):null},fP=iH;import{degreesToRadians as EP,radiansToDegrees as yP}from"@excalidraw/math";import{getBoundTextElement as bP}from"@excalidraw/element";import{isArrowElement as xP}from"@excalidraw/element";import{isInGroup as AE}from"@excalidraw/element";import{jsx as dH}from"react/jsx-runtime";var sH=15,lH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!AE(c)&&Xt(c,r)),l=n.filter(c=>!AE(c)&&Xt(c,r));if(o!==void 0){let c=EP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=bP(d,a);m&&!xP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(yP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=Ke(E,sH)),E=E<0?E+360:E;let g=EP(E);i.mutateElement(d,{angle:g});let b=bP(d,a);b&&!xP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},cH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!AE(l)&&Xt(l,"angle")),i=r.map(l=>Math.round(yP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Xt(l,"angle"));return dH(ft,{label:"A",icon:jc,value:a,elements:e,dragInputCallback:lH,editable:s,appState:t,scene:n,property:o})},wP=cH;import{pointFrom as SP}from"@excalidraw/math";import{useMemo as pH}from"react";import{MIN_WIDTH_OR_HEIGHT as Cr}from"@excalidraw/common";import{getElementsInResizingFrame as DE,getNonDeletedElements as uH,isFrameLikeElement as LE,replaceAllElementsInFrame as kP,updateBoundElements as hH}from"@excalidraw/element";import{rescalePointsInElement as gH,resizeSingleElement as CP}from"@excalidraw/element";import{getBoundTextElement as fH,handleBindTextResize as EH}from"@excalidraw/element";import{isTextElement as MP}from"@excalidraw/element";import{MIME_TYPES as bi}from"@excalidraw/common";import{getNonDeletedElements as vP}from"@excalidraw/element";var Fp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=vP(Fr(e,null,{deleteInvisibleElements:!0})),l=Ri(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Fc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,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}})},IP=async e=>{let{mimeType:n=bi.png,quality:t}=e;n===bi.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${bi.png}" mimeType`),n==="image/jpg"&&(n=bi.jpg),n===bi.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${bi.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Fp(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===bi.png&&e.appState?.exportEmbedScene&&(a=await xx({blob:a,metadata:Ss(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},TP=async({elements:e,appState:n=Ko(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=vP(Fr(e,null,{deleteInvisibleElements:!0})),d={...Ri(n,null),exportPadding:o};return Br(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},mH=async e=>{if(e.type==="svg"){let n=await TP(e);await ko(n.outerHTML)}else if(e.type==="png")await nm(IP(e));else if(e.type==="json")await Qd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as B8e}from"@excalidraw/element";import{getCommonBounds as Op}from"@excalidraw/element";import{jsx as IH}from"react/jsx-runtime";var ls=10,bH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...gH(o,a,s,!1),...MP(o)?{fontSize:o.fontSize*t}:{}}},xH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=bH(e,n,o,i);s.mutateElement(r,c);let d=fH(i,a);if(d){let m=d.fontSize*o;hH(r,s);let p=l.get(d.id);p&&MP(p)&&(s.mutateElement(p,{fontSize:m}),EH(r,s,t==="width"?"e":"s",!0))}},PP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];xH(r[0],r[1],i,d,u,p,l,c)}},yH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=as(n,o);if(i!==void 0){for(let g of m){let b=is(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Op(y),P=T-x,M=C-I,D=P/M,_=Math.max(Cr,s==="width"?Math.max(0,i):P),k=Math.max(Cr,s==="height"?Math.max(0,i):M);PP(_,k,M,D,SP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Xt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=Ke(I,ls):I=Math.round(I));let T=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?T=Ke(T,ls):T=Math.round(T)),I=Math.max(Cr,I),T=Math.max(Cr,T),CP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),LE(y)){let C=DE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=kP(a.getElementsIncludingDeleted(),C,y);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=is(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Op(y),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=Ke(_,ls):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=Ke(k,ls):k=Math.round(k)),_=Math.max(Cr,_),k=Math.max(Cr,k),PP(_,k,M,D,SP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Xt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=Ke(I,ls):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=Ke(T,ls):T=Math.round(T)),I=Math.max(Cr,I),T=Math.max(Cr,T),CP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),LE(y)){let C=uH(DE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},wH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&LE(a)){let s=DE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=kP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},vH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=pH(()=>o.map(c=>{let d=is(c,t);if(d.length>1){let[p,u,E,g]=Op(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return IH(ft,{label:e==="width"?"W":"H",elements:n,dragInputCallback:yH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:wH})},_E=vH;import{getBoundTextElement as TH,redrawTextBoundingBox as AP}from"@excalidraw/element";import{hasBoundTextElement as SH,isTextElement as CH}from"@excalidraw/element";import{isInGroup as PH}from"@excalidraw/element";import{jsx as LH}from"react/jsx-runtime";var DP=4,kH=4,MH=(e,n)=>e.reduce((t,o)=>{if(!o||PH(o))return t;if(CH(o))return t.push(o),t;if(SH(o)){let r=TH(o,n);if(r)return t.push(r),t}return t},[]),AH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),DP);for(let l of a)r.mutateElement(l,{fontSize:s}),AP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,DP);t&&(E=Ke(E,kH)),r.mutateElement(d,{fontSize:E}),AP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},DH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=MH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return LH(ft,{label:"F",icon:Hr,elements:i,dragInputCallback:AH,value:s,editable:l,scene:n,property:o,appState:t})},LP=DH;import{pointFrom as Pr,pointRotateRads as zp}from"@excalidraw/math";import{useMemo as _H}from"react";import{isTextElement as RH}from"@excalidraw/element";import{getCommonBounds as RE}from"@excalidraw/element";import{jsx as zH}from"react/jsx-runtime";var NH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=zp(Pr(l.x,l.y),Pr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;Ei(u,E,l,i,a,r,!1)}},BH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=RE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!RH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=zp(Pr(u.x,u.y),Pr(E,g),u.angle);Ei(b+c,w+d,p,r,i,o,!1)}}},FH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of as(n,s)){let E=is(u,c,t);if(E.length>1){let[g,b,,]=RE(E.map(x=>x.latest));BH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Xt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=zp(Pr(g.x,g.y),Pr(w,y),g.angle);Ei(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?Ke(e,rc):e;NH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},OH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=_H(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=RE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=zp(Pr(d.x,d.y),Pr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return zH(ft,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:FH,value:s,property:e,scene:r,appState:i})},NE=OH;import{clamp as ic,pointFrom as Gp,pointRotateRads as RP,round as _P}from"@excalidraw/math";import{getFlipAdjustedCropPosition as GH,getUncroppedWidthAndHeight as HH}from"@excalidraw/element";import{isImageElement as NP}from"@excalidraw/element";import{jsx as VH}from"react/jsx-runtime";var UH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=RP(Gp(m.x,m.y),Gp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!NP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=HH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:ic(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:ic(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:ic(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(M?-1:1);C={...T,x:ic(T.x+k,0,T.naturalWidth-T.width),y:ic(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){Ei(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?Ke(m.x+b,rc):E+b):E,x=a==="y"?Math.round(r?Ke(m.y+w,rc):g+w):g;Ei(y,x,m,s,c.state,o)},WH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=RP(Gp(n.x,n.y),Gp(n.x+n.width/2,n.y+n.height/2),n.angle),a=_P(e==="x"?r:i,2);if(o.croppingElementId===n.id&&NP(n)&&n.crop){let s=GH(n);s&&(a=_P(e==="x"?s.x:s.y,2))}return VH(ft,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:UH,scene:t,value:a,property:e,appState:o})},BE=WH;import{Fragment as zE,jsx as ne,jsxs as Kt}from"react/jsx-runtime";var QH=50,ac=e=>{let n=no(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=fr(e.app);return ne(eU,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},We=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:YH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});We.displayName="StatsRow";var Up=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Up.displayName="StatsRows";ac.StatsRow=We;ac.StatsRows=Up;var eU=ZH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Ue(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&OE(m),E=u?jH(m):null,[g,b]=KH({width:0,height:0}),w=FE(()=>XH(I=>{let T=$H(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},QH),[]);FP(()=>{w(l)},[i,l,w]),FP(()=>()=>w.cancel(),[w]);let y=FE(()=>as(o,r),[o,r]),x=FE(()=>qH(o),[o]);return ne("div",{className:"exc-stats",children:Kt(Xe,{padding:3,children:[Kt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Kt(js,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Hp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Hp.generalStats}})),children:[Kt(Up,{children:[ne(We,{heading:!0,children:f("stats.scene")}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Kt(We,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Kt(zE,{children:[ne(We,{heading:!0,children:"Canvas"}),ne(We,{children:ne(sP,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(js,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Hp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Hp.elementProperties}})),children:Kt(Up,{children:[m&&Kt(zE,{children:[u&&ne(We,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&OE(m)&&E&&Kt(We,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:BP(E.width,2)})]}),r.croppingElementId&&OE(m)&&E&&Kt(We,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:BP(E.height,2)})]}),ne(We,{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}`)}),ne(We,{children:ne(BE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(We,{children:ne(BE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(We,{children:ne(ME,{property:"width",element:m,scene:s,appState:r})}),ne(We,{children:ne(ME,{property:"height",element:m,scene:s,appState:r})}),ne(We,{children:ne(iP,{property:"angle",element:m,scene:s,appState:r})}),ne(We,{children:ne(fP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Kt(zE,{children:[JH(p)&&ne(We,{heading:!0,children:f("element.group")}),Kt(We,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(We,{children:ne(NE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(NE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(_E,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(_E,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(We,{children:ne(wP,{property:"angle",elements:p,scene:s,appState:r})}),ne(We,{children:ne(LP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(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 pU,useEffect as zP,useState as GP}from"react";import{normalizeLink as uU,KEYS as WE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as hU,getLinkIdAndTypeFromSelection as gU}from"@excalidraw/element";import tU from"clsx";import{jsx as Wp,jsxs as oU}from"react/jsx-runtime";var nU=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return oU("button",{className:tU("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Wp("div",{style:a?{visibility:"hidden"}:{},children:o}),Wp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Wp("div",{style:{position:"absolute",inset:0},children:Wp(Io,{})})]})},GE=nU;import HE from"clsx";import{forwardRef as sU,useRef as lU,useImperativeHandle as cU,useLayoutEffect as dU,useState as mU}from"react";import rU from"clsx";import{composeEventHandlers as iU}from"@excalidraw/common";import{jsx as aU}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>aU("button",{onClick:iU(i.onClick,a=>{n()}),type:e,className:rU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as UE,jsxs as OP}from"react/jsx-runtime";var Vp=sU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=lU(null);cU(p,()=>u.current),dU(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=mU(!1);return OP("div",{className:HE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&UE("div",{className:"ExcTextField__label",children:n}),OP("div",{className:HE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[UE("input",{className:HE({"is-redacted":"value"in m&&m.value&&s&&!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:d}),s&&UE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?r0:Wr})]})]})});import{jsx as cs,jsxs as Yp}from"react/jsx-runtime";var fU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=hU})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=GP(a),[c,d]=GP(!1);zP(()=>{let p=de(i,t),u=a;if(p.length>0&&r){let E=gU(p,t);E&&(u=uU(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=pU(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return zP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===WE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===WE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Yp("div",{className:"ElementLinkDialog",children:[Yp("div",{className:"ElementLinkDialog__header",children:[cs("h2",{children:f("elementLink.title")}),cs("p",{children:f("elementLink.desc")})]}),Yp("div",{className:"ElementLinkDialog__input",children:[cs(Vp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===WE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&cs($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Gr})]}),Yp("div",{className:"ElementLinkDialog__actions",children:[cs(GE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),cs(GE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},HP=fU;import EU,{useState as bU}from"react";import{Fragment as xU,jsx as VE}from"react/jsx-runtime";var UP=({children:e,onClose:n})=>{let[t,o]=bU(!!e),{container:r}=Fe(),i=EU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return VE(xU,{children:t&&VE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:VE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import YE from"clsx";import zn from"react";import{MIME_TYPES as WP,sceneCoordsToViewportCoords as XE}from"@excalidraw/common";import{getCommonBounds as KP,isInitializedImageElement as VP,ShapeCache as yU}from"@excalidraw/element";import{Fragment as SU,jsx as kt,jsxs as xi}from"react/jsx-runtime";var wU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),vU=xi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),IU=76,ZP=4,sc=IU+ZP,YP=8,yi=8,TU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+yi),window.innerWidth-t-yi)},XP=(e,n)=>{let[,,t,o]=KP([e]),r=XE({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)}},$P=({app:e,files:n,setAppState:t})=>{let o=no(),[,r]=zn.useReducer(T=>T+1,0),[i,a]=zn.useState(0),[s,l]=zn.useState(!1),c=zn.useRef(null),d=zn.useRef(null),m=zn.useRef(null),p=zn.useRef(null),u=zn.useRef(null),E=zn.useRef(!1),[g,b]=zn.useState(null);zn.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?c.current:d.current,P=T==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=TU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(yi,M.top-D.height-yi):Math.min(window.innerHeight-D.height-yi,M.bottom+yi),L={left:_,top:Math.max(yi,k)};b(F=>F?.left===L.left&&F.top===L.top?F:L)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let w=(T,C)=>{yU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().filter(T=>VP(T)&&!o.selectedElementIds[T.id]&&n[T.fileId]?.mimeType===WP.gif&&e.imageCache.get(T.fileId)?.gifDecodeStatus==="deferred").map(T=>{let C=XP(T,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:C,children:Fx},T.id)}),x=e.scene.getSelectedElements(o);return xi(SU,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!VP(T)||n[T.fileId]?.mimeType!==WP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=KP([T]),k=XE({sceneX:M,sceneY:_},o),F=XE({sceneX:D,sceneY:_},o).x-k.x,Y=k.x-o.offsetLeft+F/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="deferred"){let Z=XP(T,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:Z,onPointerDown:ve=>ve.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})})}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,ie=e.getGifPlaybackFrameIndex(T)??W.frameIndex,me=Math.min(Math.max(ie,0),U-1),B=Math.min(G.height-120,z+48),V=Math.max(12,z-52),pe=Z=>{let ve=(Z+U)%U;e.setGifPlaybackFrameIndex(T,ve),w(T,{...W,frameIndex:ve,playing:!1})},ae=Z=>{Z.stopPropagation(),pe(me+(Z.deltaY<0?1:-1))},be=Z=>{e.setGifPlaybackFrameIndex(T,me),w(T,{...W,frameIndex:me,playing:Z})},ce=[.25,.5,.75,1,1.25,1.5,1.75,2,4],Be=Z=>{let ve=ce.indexOf(Z);return ve!==-1?ve:ce.reduce((Lt,vs,Ac)=>Math.abs(vs-Z)<Math.abs(ce[Lt]-Z)?Ac:Lt,0)},se=Z=>{w(T,{...W,speed:Z})},De=Z=>{let ve=Be(W.speed);se(ce[Math.min(Math.max(ve+Z,0),ce.length-1)])},Le=Number.isInteger(W.speed)?`${W.speed}`:`${W.speed}`,Ce=U*sc-ZP,At=Math.min(Math.max(G.width*.9,1),Ce),Cn=Math.max(Ce-At,0),Pn=Math.min(i,Cn),Yo=Math.max(Math.floor(Pn/sc)-YP,0),ki=Math.ceil(At/sc)+YP*2,Mi=Math.min(Yo+ki,U),ys=P.frames.slice(Yo,Mi),bo=Z=>{Z.pointerType!=="mouse"||Z.button!==0||(u.current={pointerId:Z.pointerId,startClientX:Z.clientX,startScrollLeft:Z.currentTarget.scrollLeft,didDrag:!1},Z.stopPropagation())},Dt=Z=>{let ve=u.current;if(!ve||ve.pointerId!==Z.pointerId)return;let Lt=Z.clientX-ve.startClientX;!ve.didDrag&&Math.abs(Lt)<=3||(ve.didDrag||(ve.didDrag=!0,Z.currentTarget.setPointerCapture?.(Z.pointerId),l(!0)),Z.currentTarget.scrollLeft=ve.startScrollLeft-Lt,a(Z.currentTarget.scrollLeft),Z.preventDefault(),Z.stopPropagation())},ws=Z=>{let ve=u.current;!ve||ve.pointerId!==Z.pointerId||(E.current=ve.didDrag,u.current=null,Z.currentTarget.hasPointerCapture?.(Z.pointerId)&&Z.currentTarget.releasePointerCapture(Z.pointerId),l(!1),Z.stopPropagation())},Ai=Z=>{let ve=u.current;!ve||ve.pointerId!==Z.pointerId||(u.current=null,l(!1),Z.stopPropagation())},xo=Z=>{Z.pointerType!=="mouse"&&Z.stopPropagation()};return xi("div",{className:"gif-playback-controls",style:{left:Y,top:z},onPointerDown:Z=>Z.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&kt("div",{className:"gif-speed-picker",ref:m,style:g??{left:Y,top:V},children:ce.map(Z=>{let ve=Number.isInteger(Z)?`${Z}`:`${Z}`;return xi("button",{type:"button",className:YE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":Z===W.speed}),onClick:()=>se(Z),title:`${ve}x`,children:["x",ve]},Z)})}),xi("div",{className:"gif-playback-controls__bar",children:[xi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:c,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:Z=>{Z.stopPropagation(),De(Z.deltaY<0?1:-1)},title:"Speed",children:["x",Le]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me-1),onWheel:ae,title:"Previous frame",children:Q1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>be(!W.playing),onWheel:ae,title:W.playing?"Pause":"Play",children:W.playing?vU:wU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me+1),onWheel:ae,title:"Next frame",children:e0}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(me*sc-At/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:ae,title:"Frames",children:t0})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:YE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:Y,top:B},width:At},ref:Z=>{p.current=Z,Z&&Z.scrollLeft!==Pn&&(Z.scrollLeft=Pn)},onScroll:Z=>{a(Z.currentTarget.scrollLeft)},onPointerDownCapture:xo,onPointerMoveCapture:xo,onPointerUpCapture:xo,onPointerCancelCapture:xo,onPointerDown:bo,onPointerMove:Dt,onPointerUp:ws,onPointerCancel:Ai,onLostPointerCapture:Ai,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:kt("div",{className:"gif-frame-gallery__spacer",style:{width:Ce},children:ys.map((Z,ve)=>{let Lt=Yo+ve;return xi("button",{type:"button",className:YE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Lt===me}),style:{left:Lt*sc},onClick:()=>pe(Lt),title:`Frame ${Lt+1}`,children:[kt("canvas",{width:Z.width,height:Z.height,ref:vs=>{vs?.getContext("2d")?.drawImage(Z,0,0)}}),kt("span",{children:Lt+1})]},Lt)})})})]})})()]})};import jP,{useMemo as _U}from"react";import qP from"clsx";import{isDarwin as JP,isFirefox as RU,isWindows as NU}from"@excalidraw/common";import{KEYS as ds}from"@excalidraw/common";import{SHAPES as BU}from"@excalidraw/element/shapes";import{isFirefox as CU,KEYS as KE}from"@excalidraw/common";import{SHAPES as PU}from"@excalidraw/element/shapes";import{Fragment as LU,jsx as Ge,jsxs as wi}from"react/jsx-runtime";var kU=e=>wi(LU,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),ZE=e=>wi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*MU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var AU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),mt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(DU,{children:AU(a)},a)));return wi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...MU(o,t?f("helpDialog.or"):null)]})]})},DU=e=>Ge("kbd",{className:"HelpDialog__key",...e});function $E(){return wi(kU,{title:f("helpDialog.shortcuts"),children:[wi(ZE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(mt,{label:f("toolBar.hand"),shortcuts:[KE.H]}),PU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(mt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(mt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(mt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),wi(ZE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(mt,{label:f("helpDialog.smartZoom"),shortcuts:[KE.F]}),Ge(mt,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),Ge(mt,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),Ge(mt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${KE.Z}+${f("helpDialog.drag")}`]}),Ge(mt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),wi(ZE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(mt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(mt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(mt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(mt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(cr||CU)&&Ge(mt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(mt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(mt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(mt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(mt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(mt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as ek,jsx as j,jsxs as vi}from"react/jsx-runtime";var FU=e=>vi(ek,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),jE=e=>vi("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*OU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var zU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),J=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(GU,{children:zU(a)},a)));return vi("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...OU(o,t?f("helpDialog.or"):null)]})]})},GU=e=>j("kbd",{className:"HelpDialog__key",...e}),QP=({onClose:e})=>{let[n,t]=jP.useState(!1),o=jP.useCallback(()=>{e&&e()},[e]),r=_U(()=>n?j("button",{className:qP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:qP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(ek,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?vi(FU,{title:f("helpDialog.shortcuts"),children:[vi(jE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[ds.H]}),BU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[ds.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[ds.I,"Shift+S","Shift+I"]}),j(J,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(J,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(J,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(J,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(J,{label:f("toolBar.lock"),shortcuts:[ds.Q]}),j(J,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(J,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(J,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),vi(jE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[ds.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ds.Z}+${f("helpDialog.drag")}`]}),j(J,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(J,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(J,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(J,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(J,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(J,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(J,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(J,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(J,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),j(J,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),j(J,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[Je("searchMenu")]})]}),vi(jE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(J,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(J,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(J,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(J,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(J,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(J,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(J,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(J,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(cr||RU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[JP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[JP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(J,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(J,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(J,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(J,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(J,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(J,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(J,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+A")]}),j(J,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(J,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(J,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(J,{label:f("buttons.redo"),shortcuts:NU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(J,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(J,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(J,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(J,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(J,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(J,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(J,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(J,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(J,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j($E,{})})})};import{useEffect as nk,useRef as ok,useState as Ii}from"react";import{DEFAULT_EXPORT_PADDING as YU,EXPORT_IMAGE_TYPES as qE,isFirefox as XU,EXPORT_SCALES as KU,cloneJSON as rk}from"@excalidraw/common";import{useCallback as HU,useRef as UU,useState as WU}from"react";var VU=2e3,tk=()=>{let[e,n]=WU(null),t=UU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},VU)},r=HU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ve,jsxs as kr}from"react/jsx-runtime";var ZU=()=>kr("div",{children:[Ve("h3",{children:f("canvasError.cannotShowPreview")}),Ve("p",{children:Ve("span",{children:f("canvasError.canvasTooBig")})}),kr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),$U=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=_e(n,e),[l,c]=Ii(i),[d,m]=Ii(s),[p,u]=Ii(e.exportBackground),[E,g]=Ii(e.exportEmbedScene),[b,w]=Ii(e.exportScale),y=ok(null),x=ok(0),[I,T]=Ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=tk();nk(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=jr(n,e,d);return nk(()=>{let k=y.current;if(!k)return;let L=k.offsetWidth,F=k.offsetHeight;if(!L)return;let Y=++x.current,z=()=>Y!==x.current;return Fp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:YU,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Ms(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,D,_,l,p,a,b,E]),kr("div",{className:"ImageExportModal",children:[Ve("h3",{children:f("imageExportDialog.header")}),kr("div",{className:"ImageExportModal__preview",children:[Ve("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ve(ZU,{})}),Ve("div",{className:"ImageExportModal__preview__filename",children:!_i&&Ve("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(rg,"ui",k.target.value)}})})]}),kr("div",{className:"ImageExportModal__settings",children:[Ve("h3",{children:f("imageExportDialog.header")}),s&&Ve(lc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ve(ti,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ve(lc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ve(ti,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(ig,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ve(ti,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Mw,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ve(ti,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(rm,"ui",k)}})}),Ve(lc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ve(kp,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(Pw,"ui",k)},choices:KU.map(k=>({value:k,label:`${k}\xD7`}))})}),kr("div",{className:"ImageExportModal__settings__buttons",children:[Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(qE.png,D,{exportingFrame:_}),icon:Qu,children:f("imageExportDialog.button.exportToPng")}),Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(qE.svg,D,{exportingFrame:_}),icon:Qu,children:f("imageExportDialog.button.exportToSvg")}),(cr||XU)&&Ve(Ir,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(qE.clipboard,D,{exportingFrame:_}),C()},icon:j1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},lc=({label:e,children:n,tooltip:t,name:o})=>kr("div",{className:"ImageExportModal__settings__setting",title:e,children:[kr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ve(ut,{label:t,long:!0,children:J1})]}),Ve("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),ik=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=Ii(()=>({appStateSnapshot:rk(n),elementsSnapshot:rk(e)}));return Ve(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ve($U,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import FW from"clsx";import{CANVAS_SEARCH_TAB as Tk,DEFAULT_SIDEBAR as OW}from"@excalidraw/common";import jU from"clsx";import qU from"lodash.debounce";import{Fragment as JU,memo as QU,useEffect as cc,useMemo as ak,useRef as JE,useState as sk}from"react";import{CLASSES as eW,EVENT as tW,FONT_FAMILY as QE,FRAME_STYLE as eb,getLineHeight as nW}from"@excalidraw/common";import{getCommonBounds as oW,isElementCompletelyInViewport as rW}from"@excalidraw/element";import{measureText as dc}from"@excalidraw/element";import{KEYS as ms,randomInteger as lk,addEventListener as iW,getFontString as Xp}from"@excalidraw/common";import{newTextElement as aW}from"@excalidraw/element";import{isTextElement as pk,isFrameLikeElement as Kp}from"@excalidraw/element";import{getDefaultFrameName as uk}from"@excalidraw/element/frame";import{Fragment as fW,jsx as Et,jsxs as Gn}from"react/jsx-runtime";var sW=et(""),tb=et(null),lW=350,hk=()=>{let e=St(),n=Ue(),t=JE(null),[o,r]=Ye(sW),i=o.trim(),[a,s]=sk(!1),[l,c]=sk({nonce:null,items:[]}),d=JE(null),m=JE(void 0),[p,u]=Ye(tb),E=e.scene.getNonDeletedElementsMap();cc(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,mk(i,e,(x,I)=>{c({nonce:lk(),items:x}),d.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=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};cc(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),cc(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=aW({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:Kp(x.element)?eb.nameFontSize:x.element.fontSize,fontFamily:Kp(x.element)?QE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!rW([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 D=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:oW([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),cc(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let w=Ki({goToNextItem:g,goToPreviousItem:b,searchMatches:l});cc(()=>{let x=I=>{if(I.key===ms.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[ms.CTRL_OR_CMD]&&I.key===ms.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===ms.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===ms.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===ms.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return iW(window,tW.KEYDOWN,x,{capture:!0,passive:!1})},[n,w,e]);let y=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Gn("div",{className:"layer-ui__search",children:[Gn("div",{className:"layer-ui__search-header",children:[Et(Vp,{className:eW.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:to,onChange:x=>{r(x),s(!0);let I=x.trim();mk(I,e,(T,C)=>{c({nonce:lk(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),Et(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),Gn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Gn(fW,{children:[p!==null&&p>-1?Gn("div",{children:[p+1," / ",y]}):Et("div",{children:y}),Gn("div",{className:"result-nav",children:[Et(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:Jc}),Et(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:E0})]})]}),l.items.length===0&&i&&d.current&&Et("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Et(mW,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},ck=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 Et("div",{tabIndex:-1,className:jU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Et("div",{className:"preview-text",children:n.flatMap((t,o)=>Et(JU,{children:o===2?Et("b",{children:t}):t},o))})})},cW=e=>{let n=ak(()=>e.matches.items.filter(o=>Kp(o.element)),[e.matches]),t=ak(()=>e.matches.items.filter(o=>pk(o.element)),[e.matches]);return Gn("div",{className:"layer-ui__search-results",children:[n.length>0&&Gn("div",{className:"layer-ui__search-result-container",children:[Gn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Qn}),Et("div",{children:f("search.frames")})]}),n.map((o,r)=>Et(ck,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&Et("div",{className:"layer-ui__divider"})]}),t.length>0&&Gn("div",{className:"layer-ui__search-result-container",children:[Gn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Mn}),Et("div",{children:f("search.texts")})]}),t.map((o,r)=>Et(ck,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},dW=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,mW=QU(cW,dW),dk=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;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:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},pW=(e,n)=>{let t=e.split(`
19
19
  `),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=n.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}o.push(a),r=r+a.length}return o.join(`
20
- `)},dW=(e,n,t)=>{let r=cW(e.text,e.originalText).split(`
21
- `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=dc(u,Xp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=dc(m.line,Xp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=dc(E,Xp(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;d.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),l+=p}}return d},mW=(e,n,t,o)=>{let r=e.name??mk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Xp({fontSize:eb.nameFontSize,fontFamily:QE.Assistant}),l=QU(QE.Assistant),c=dc(a,s,l);a===""&&(c.width=0);let d=dc(i,s,l),m=c.width,p=-c.height-eb.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},pW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),ck=$U((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>dk(p)),i=o.filter(p=>Kp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(pW(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=lk(E,u.index,e),b=dW(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??mk(p);for(;(u=s.exec(E))!==null;){let g=lk(E,u.index,e),b=mW(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},iW);import CW from"clsx";import{useEffect as bk,useLayoutEffect as xk,useRef as db,useState as PW,forwardRef as yk,useImperativeHandle as kW,useCallback as gk}from"react";import{CLASSES as MW,EVENT as fk,isDevEnv as AW,KEYS as DW,updateObject as LW}from"@excalidraw/common";import gW from"clsx";import{useContext as fW}from"react";import hW from"react";var $p=hW.createContext({});import{jsx as nb,jsxs as uk}from"react/jsx-runtime";var ob=({children:e,className:n})=>{let t=Ee(),o=fW($p),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return uk("div",{className:gW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,uk("div",{className:"sidebar__header__buttons",children:[r&&nb(ut,{label:f("labels.sidebarLock"),children:nb(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:zx})}),nb(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};ob.displayName="SidebarHeader";import{Tabs as EW}from"radix-ui";import{jsx as hk}from"react/jsx-runtime";var rb=({children:e,tab:n,onSelect:t,...o})=>hk(EW.Trigger,{value:n,asChild:!0,onSelect:t,children:hk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});rb.displayName="SidebarTabTrigger";import{Tabs as bW}from"radix-ui";import{jsx as xW}from"react/jsx-runtime";var ib=({children:e,...n})=>xW(bW.List,{className:"sidebar-triggers",...n,children:e});ib.displayName="SidebarTabTriggers";import yW from"clsx";import{jsx as ab,jsxs as wW}from"react/jsx-runtime";var sb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ue(),d=xe().openSidebar?.name===e;return ab("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:wW("div",{className:yW("sidebar-trigger",a),style:s,children:[t&&ab("div",{children:t}),r&&ab("div",{className:"sidebar-trigger__label",children:r})]})})};sb.displayName="SidebarTrigger";import{Tabs as vW}from"radix-ui";import{jsx as IW}from"react/jsx-runtime";var lb=({children:e,...n})=>{let t=xe(),o=Ue();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return IW(vW.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 TW}from"radix-ui";import{jsx as SW}from"react/jsx-runtime";var cb=({tab:e,children:n,...t})=>SW(TW.Content,{...t,value:e,"data-testid":e,children:n});cb.displayName="SidebarTab";import{jsx as Ek}from"react/jsx-runtime";import{createElement as _W}from"react";var mb=et(!1),wk=yk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{AW()&&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 s=Ue(),l=Dx(mb);xk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=db({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=LW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=db(null);kW(a,()=>d.current);let m=Ee(),p=gk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Yi(d,gk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),bk(()=>{let u=E=>{E.key===DW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(fk.KEYDOWN,u),()=>{document.removeEventListener(fk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),Ek(Xe,{...i,className:CW(MW.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:d,children:Ek($p.Provider,{value:c.current,children:n})})});wk.displayName="SidebarInner";var Mr=Object.assign(yk((e,n)=>{let t=xe(),{onStateChange:o}=e,r=db(t.openSidebar);bk(()=>{(!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]=PW(!1);return xk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?_W(wk,{...e,ref:n,key:e.name}):null}),{Header:ob,TabTriggers:ib,TabTrigger:rb,Tabs:lb,Tab:cb,Trigger:sb});Mr.displayName="Sidebar";import{jsx as ms,jsxs as BW}from"react/jsx-runtime";import{createElement as FW}from"react";var Ik=gi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=rt();return ms(n.In,{children:ms(Mr.Trigger,{...e,className:"default-sidebar-trigger",name:NW.name})})});Ik.displayName="DefaultSidebarTrigger";var Tk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=rt();return ms(n.In,{children:e})};Tk.displayName="DefaultTabTriggers";var pb=Object.assign(gi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=xe(),a=Ue(),s=i.openSidebar?.tab===vk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return FW(Mr,{...r,name:"default",key:"default",className:RW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},BW(Mr.Tabs,{children:[!s&&ms(Mr.Header,{}),ms(Mr.Tab,{tab:vk,children:ms(pk,{})}),!s&&e]}))}),{Trigger:Ik,TabTriggers:Tk});import zW from"react";import{getFrame as GW}from"@excalidraw/common";import{jsx as OW}from"react/jsx-runtime";var ub={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"}},hb=({children:e,color:n})=>OW("div",{className:"Card",style:{"--card-color":ub[n].base,"--card-color-darker":ub[n].darker,"--card-color-darkest":ub[n].darkest},children:e});import{Fragment as UW,jsx as Hn,jsxs as Zp}from"react/jsx-runtime";var HW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Hn("div",{className:"ExportDialog ExportDialog--json",children:Zp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Zp(hb,{color:"lime",children:[Hn("div",{className:"Card-icon",children:n1}),Hn("h2",{children:f("exportDialog.disk_title")}),Zp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Li&&r.renderAction("changeProjectName")]}),Hn(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(cl,"ui")}})]}),l&&Zp(hb,{color:"pink",children:[Hn("div",{className:"Card-icon",children:Rs}),Hn("h2",{children:f("exportDialog.link_title")}),Hn("div",{className:"Card-details",children:f("exportDialog.link_details")}),Hn(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{He("export","link",`ui (${GW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Sk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=zW.useCallback(()=>{a({openDialog:null})},[a]);return Hn(UW,{children:n.openDialog?.name==="jsonExport"&&Hn(wn,{onCloseRequest:s,title:f("buttons.export"),children:Hn(HW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import WW from"clsx";import{jsx as VW}from"react/jsx-runtime";var Ck=e=>VW(Z,{className:WW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:eo,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import _k from"clsx";import{useState as nV}from"react";import{CANVAS_SEARCH_TAB as oV,DEFAULT_SIDEBAR as rV,KEYS as mc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as YW,DEFAULT_SIDEBAR as XW}from"@excalidraw/common";import{isArrowElement as KW,isFlowchartNodeElement as $W,isImageElement as Pk,isLinearElement as kk,isLineElement as ZW,isTextBindableContainer as jW,isTextElement as qW}from"@excalidraw/element";import{isNodeInFlowchart as JW}from"@excalidraw/element";import{jsx as gb}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,QW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===XW.name&&e.openSidebar.tab===YW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Se("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(rn(e))return f("hints.eraserRevert",{shortcut:Se("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Se("Ctrl"),shortcut_2:Se("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Se("Escape"),shortcut_2:Se("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Se("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&&s==="mouse"&&c.length===1){let d=c[0];return kk(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Se("Shift")}):Pk(d)?f("hints.resizeImage",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):f("hints.resize",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Se("Shift")});if(c.length===1&&qW(c[0]))return f("hints.text_selected",{shortcut:Se("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Se("Escape"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Se("Enter"),shortcut_2:Se("Escape")});if(c.length===1&&Pk(c[0]))return f("hints.enterCropEditor",{shortcut:Se("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Se("CtrlOrCmd")});if(fr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Se("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Se(f("keys.mmb")),shortcut_2:Se("Space")});if(c.length===1){if(kk(c[0]))return KW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Se("Delete"),shortcut_2:Se(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):ZW(c[0])?f("hints.lineEditor_line_info",{shortcut:Se("Enter")}):f("hints.lineEditor_info",{shortcut_1:Se("CtrlOrCmd"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&jW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Se("Enter")}),m=f("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return $W(c[0])?JW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},Mk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=QW({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return gb("kbd",{children:c?c[1]:s},l)}return s});return gb("div",{className:"HintViewer",children:gb("span",{children:a})})};import eV from"clsx";import{jsx as tV}from"react/jsx-runtime";var Ak=e=>tV(Z,{className:eV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?$o:vo,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 Ii,jsx as re,jsxs as Oo}from"react/jsx-runtime";var iV=(e,n)=>e==="image"&&n.tools?.image===!1,aV=({app:e,activeTool:n,type:t,shortcut:o})=>re(ge.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:$e[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??sa(t),disabled:Qe(e,t),children:f(`toolBar.${t}`)}),Dk=({app:e})=>re(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:vo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:mc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),sV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=Je("objectsSnapMode");return re(ge.Item,{onSelect:()=>e.executeAction(Rt,"ui"),icon:qo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},lV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=f("buttons.objectsSnapMode"),o=Je("objectsSnapMode");return re(Z,{type:"toggle",icon:qo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Rt,"ui")})},Lk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Je("searchMenu");return re(ge.Item,{onSelect:()=>e.executeAction(Ll,"ui"),icon:to,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===rV.name&&n.openSidebar.tab===oV,shortcut:o,children:t})},cV=({app:e})=>re(Z,{type:"button",icon:Ui,title:`${f("labels.eyeDropper")} - ${mc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":mc.I.toLocaleUpperCase(),keyBindingLabel:mc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),dV=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=nV(!1),l=dt()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&ia.includes(n.type);return Oo(ge,{open:a,children:[re(ge.Trigger,{className:_k("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?$e[n.type].icon:c?Qn:E?jo:!r&&l&&d?Ur:m&&!e.props.isCollaborating?eo:u?Fi:p?Jn:Ms}),re(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Oo(Ii,{children:[l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Fi,"data-testid":"toolbar-lasso",selected:u,disabled:Qe(e,"lasso"),children:f("toolBar.lasso")}),ia.filter(b=>!iV(b,o)).map(b=>re(aV,{app:e,activeTool:n,type:b},b)),re("div",{className:"App-toolbar__dropdown-divider"}),re(Lk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Ii,{children:re(Dk,{app:e})})]}):Oo(Ii,{children:[re(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Qn,shortcut:mc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Qe(e,"frame"),children:f("toolBar.frame")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:jo,"data-testid":"toolbar-embeddable",selected:E,disabled:Qe(e,"embeddable"),children:f("toolBar.embeddable")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ur,shortcut:sa("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Qe(e,"autoshape"),children:f("toolBar.autoshape")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:eo,"data-testid":"toolbar-laser",selected:m,disabled:Qe(e,"laser"),children:f("toolBar.laser")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Jn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Qe(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Fi,"data-testid":"toolbar-lasso",selected:u,disabled:Qe(e,"lasso"),children:f("toolBar.lasso")}),re("div",{className:"App-toolbar__dropdown-divider"}),re(sV,{actionManager:i,app:e}),re(Lk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Dk,{app:e})]})})]})},Rk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=Ee(),c=dt()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?re(Yd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?re(iw,{...m}):re(rw,{...m});return Oo(Xe,{padding:1,className:_k("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[re(Mk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Oo(Ot.Row,{gap:c?.5:1,children:[!c&&re(ts,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Oo(Ii,{children:[re(Ak,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),re("div",{className:"App-toolbar__divider"})]}),re(Vd,{...m}),u,p?Oo(Ii,{children:[re(el,{...m}),re(tl,{...m}),re(cV,{app:e}),o.tools?.image!==!1&&re(nl,{...m}),re(ol,{...m})]}):Oo(Ii,{children:[re(Jy,{...m}),re(Qy,{...m}),re(ew,{...m}),re(tw,{...m}),re(nw,{...m}),c?re(Xd,{...m}):re(el,{...m}),re(tl,{...m}),o.tools?.image!==!1&&re(nl,{...m}),re(ol,{...m})]}),re("div",{className:"App-toolbar__divider"}),re(dV,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Oo(Ii,{children:[re("div",{className:"App-toolbar__divider"}),re(lV,{actionManager:r,app:e})]})]})]})};import{Fragment as fb,jsx as te,jsxs as nn}from"react/jsx-runtime";var EV=({UIOptions:e})=>nn(zt,{__fallback:!0,children:[te(zt.DefaultItems.LoadScene,{}),te(zt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(zt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(zt.DefaultItems.SaveAsImage,{}),te(zt.DefaultItems.SearchMenu,{}),te(zt.DefaultItems.Help,{}),te(zt.Separator,{}),te(zt.Group,{title:"Excalidraw links",children:te(zt.DefaultItems.Socials,{})}),te(zt.Separator,{}),te(zt.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(zt.DefaultItems.ChangeCanvasBackground,{})]}),bV=()=>nn(Lp,{__fallback:!0,children:[te(Lp.Actions.SaveToDisk,{}),te(Lp.Actions.ExportToImage,{})]}),xV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=Ee(),M=An(),_=dt()==="compact",k=sS(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},F=k.tunnelsJotai.Provider,[Y,z]=Ye(Ut),U=()=>p.canvasActions.export?te(Sk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,W=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(ok,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>nn("div",{style:{position:"relative"},children:[nn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),ie=()=>te(Jl,{heading:"selectedShapeActions",className:ps("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Xe,{className:ps("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(CS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Xe,{className:pV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(wS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),me=()=>{let ae=w&&fV(n,r),be=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(Ip,{side:"top",children:nn("div",{className:"App-menu App-menu_top",children:[nn(Ot.Col,{gap:L.menuTopGap,className:ps("App-menu_top__left"),children:[G(),w&&te("div",{className:ps("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:ae&&ie()}),w&&_&&!n.viewModeEnabled&&ae&&te(ts,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(Jl,{heading:"shapes",className:"shapes-section",children:ce=>nn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Ot.Col,{gap:L.toolbarColGap,align:"start",children:nn(Ot.Row,{gap:L.toolbarRowGap,className:ps("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Rk,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ce}),I&&te(Xe,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(Ck,{title:f("toolBar.laser"),checked:n.activeTool.type===Nk.laser,onChange:()=>b.setActiveTool({type:Nk.laser}),isMobile:!0})})]})})]})}),nn("div",{className:ps("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[w&&n.collaborators.size>0&&te(Pp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),be&&te(ac,{app:b,onClose:()=>{e.executeAction(ur)},renderCustomStats:m})]})]})})},B=()=>te(pb,{}),V=!1,pe=nn(fb,{children:[g,w&&te(fb,{children:te(EV,{UIOptions:p})}),te(bV,{}),w&&n.isLoading&&te(bp,{delay:250}),w&&n.errorMessage&&te(GP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&Y&&P.formFactor!=="phone"&&te(H0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(ae,be,ce,{altKey:Be})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(ce.length){for(let se of ce)hV(se,uV(r),{[Be&&Y.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:be}),gV.delete(se);b.scene.triggerUpdate()}else o(ae==="elementBackground"?{currentItemBackgroundColor:be}:{currentItemStrokeColor:be})},onSelect:(ae,be)=>{z(ce=>ce?.keepOpenOnAlt&&be.altKey?ce:null),Y?.onSelect?.(ae,be)}}),n.openDialog?.name==="help"&&te(qP,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&te(zP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),W(),U(),w&&n.openDialog?.name==="charts"&&te(hC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&te(KP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(nC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:W,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:B,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&nn(fb,{children:[M.viewportStatusFrame?.border&&te(gp,{border:M.viewportStatusFrame.border,style:V?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),nn("div",{className:"layer-ui__wrapper",style:V?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),me(),te(wC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:w,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&nn("div",{className:"floating-status-stack",children:[n.toast&&te(jd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(ae=>({...Ai(r,ae)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(fp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),B()]});return te(bh.Provider,{value:n,children:te(F,{children:te(aE.Provider,{value:k,children:pe})})})},Bk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},yV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return jp(Bk(o),Bk(a),{selectedElementIds:jp,selectedGroupIds:jp})&&jp(r,s)},Fk=mV.memo(xV,yV);import{useEffect as wV,useRef as vV}from"react";import{jsx as Ok}from"react/jsx-runtime";var zk=({trails:e})=>{let n=vV(null);return wV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Ok("div",{className:"SVGLayer",children:Ok("svg",{ref:n})})};import IV,{useEffect as Gk,useRef as Hk}from"react";import{isShallowEqual as TV,sceneCoordsToViewportCoords as SV}from"@excalidraw/common";import{jsx as kV}from"react/jsx-runtime";var Uk="animateInteractiveScene",CV=e=>{let n=Hk(!1),t=Hk(null);return Gk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Vf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Gk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,SV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=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:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},lt.running(Uk)||lt.start(Uk,({deltaTime:c,state:d})=>{let m=Vf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),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.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},Wk=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}),PV=(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:TV(Wk(e.appState),Wk(n.appState)),Eb=IV.memo(CV,PV);import Xk,{useEffect as qp,useRef as pc}from"react";import{isShallowEqual as Vk}from"@excalidraw/common";import{hasActiveGifDecode as MV}from"@excalidraw/element";import{jsx as LV}from"react/jsx-runtime";var AV=e=>{let n=pc(null),t=pc(!1),o=pc(e),r=pc(()=>{}),i=pc(null);o.current=e;let a=Xk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();bx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},La());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=MV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,qp(()=>{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]),qp(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),qp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),qp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),LV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Yk=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}),DV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Vk(Yk(e.appState),Yk(n.appState))&&Vk(e.renderConfig,n.renderConfig),bb=Xk.memo(AV,DV);import{useEffect as zV,useRef as GV}from"react";import{throttleRAF as _V}from"@excalidraw/common";import{getTargetFrame as RV,isInvisiblySmallElement as NV,renderElement as BV,shouldApplyFrameClip as FV}from"@excalidraw/element";var Kk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Rc(e,i),d=Nc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),Bc(d,a),t&&t.type!=="selection"){if(NV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=RV(t,o,a);u&&FV(t,u,a,o)&&fx(u,d,s,a)}BV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},OV=_V(e=>{Kk(e)}),$k=(e,n)=>{if(n){OV(e);return}Kk(e)};import{jsx as UV}from"react/jsx-runtime";var HV=e=>{let n=GV(null);return zV(()=>{n.current&&$k({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},La())}),UV("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})},Zk=HV;import WV from"clsx";import{useLayoutEffect as VV,useEffect as jk,useRef as YV,useState as XV}from"react";import{ARROW_TYPE as qk,EVENT as Jp}from"@excalidraw/common";import{jsx as jV}from"react/jsx-runtime";var Jk=700,KV=100,$V=16,ZV=5*60*1e3,eM=et(null),Qk=e=>e===qk.elbow?Qo:e===qk.round?er:Jo,Qp=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(eM,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<ZV);v(this,"onArrowTypeCycled",n=>{this.show(Qk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Zo:Qk(this.app.state.currentItemArrowType))});this.app=n}},tM=()=>{let[e,n]=Ye(eM),t=St(),{container:o}=Fe(),r=YV(null),[i,a]=XV(!1),s=e?.nonce;return VV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=pd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:$V});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Jp.POINTER_MOVE,c),()=>{window.removeEventListener(Jp.POINTER_MOVE,c)}},[s,o,t]),jk(()=>()=>{n(null)},[n]),jk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Jk),c=window.setTimeout(()=>{n(null)},Jk+KV),d=()=>{n(null)};return window.addEventListener(Jp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Jp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?jV("div",{ref:r,className:WV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var eu=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),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,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}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 qV,getElementsInGroup as JV,isNonDeletedElement as nM,selectGroupsFromGivenElements as QV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as eY}from"@excalidraw/common";import{flushSync as tY}from"react-dom";import{jsx as oY}from"react/jsx-runtime";var nY=({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]:JV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=qV(r),{x:s,y:l}=eY({sceneX:i,sceneY:a},e.state);return oY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{tY(()=>{let c=QV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(fl)},title:f("labels.elementLock.unlock"),children:Gx})},oM=nY;import{Fragment as tK,jsx as Pe,jsxs as Hb}from"react/jsx-runtime";var pA=In.createContext(null),uA=In.createContext(null),Ub={formFactor:"desktop",desktopUIMode:"full",userAgent:dA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Vb=In.createContext(Ub);Vb.displayName="EditorInterfaceContext";var JX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Yb=In.createContext({container:null,id:null});Yb.displayName="ExcalidrawContainerContext";var Xb=In.createContext([]);Xb.displayName="ExcalidrawElementsContext";var Kb=In.createContext({...Ko(),width:0,height:0,offsetLeft:0,offsetTop:0});Kb.displayName="ExcalidrawAppStateContext";var $b=In.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});$b.displayName="ExcalidrawSetAppStateContext";var Zb=In.createContext(null);Zb.displayName="ExcalidrawActionManagerContext";var Es=In.createContext(null);Es.displayName="ExcalidrawAPIContext";var Eu=In.createContext(null);Eu.displayName="ExcalidrawAPISetContext";var St=()=>Vo(pA),An=()=>Vo(uA),Ee=()=>Vo(Vb),dt=()=>fu(Ee()),Fe=()=>Vo(Yb),Ki=()=>Vo(Xb),no=()=>Vo(Kb),Ue=()=>Vo($b),it=()=>Vo(Zb),Rd=()=>Vo(Es),vc=!1,Ic=0,Tc=null,Uo=!1,pu=!1,Wo=!1,uu=!1,Sc={horizontal:null,vertical:null},_r=0,Cc=!1,Gb=new Map,QX=4,aA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,hu=!1,gu=0,sA=!1,fs=null,ue={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Wb=class e extends In.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",Ub);v(this,"stylesPanelMode",fu(Ub));v(this,"excalidrawContainerRef",In.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 ho);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new ho);v(this,"imagePlaceholderUpdateEmitter",new ho);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 _Y(JX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new eu(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new ip(this));v(this,"flowchart",new dp(this));v(this,"cursor",new ap(this));v(this,"gifPlayback",new mp(this));v(this,"zDragZoom",null);v(this,"arrowText",new rp(this));v(this,"viewport",new up(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>ue.pointers.size>=2||Wo}));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,"previousPointerMoveCoords",null);v(this,"drawShape",new cp(this));v(this,"laserTrails",new Nm(this));v(this,"eraserTrail",new Um(this));v(this,"lassoTrail",new Hm(this));v(this,"cursorHints",new Qp(this));v(this,"onChangeEmitter",new ho);v(this,"onPointerDownEmitter",new ho);v(this,"onPointerUpEmitter",new ho);v(this,"onUserFollowEmitter",new ho);v(this,"onScrollChangeEmitter",new ho);v(this,"missingPointerEventCleanupEmitter",new ho);v(this,"onRemoveEventListenersEmitter",new ho);v(this,"api");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=bt.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>fr(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&&yc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.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<=hM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Si.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Ho(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Mb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Pb(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=ke({clientX:i.x,clientY:i.y},this.state),s=ke({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),width:Math.abs(s.x-a.x),height:Math.abs(s.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===gc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!LM(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:s}=ru({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),l=6,c,d=EX(i);if(i.id===this.state.editingFrame){let m=d;c=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===$.ESCAPE||p.key===$.ENTER)&&this.resetEditingFrame(i)},style:{background:LY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${zo.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Pe("div",{id:this.getFrameNameDOMId(i),className:Cb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+zo.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:zo.nameFontSize,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,lineHeight:zo.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:Me.MOVE,pointerEvents:this.state.viewModeEnabled?us.disabled:us.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},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)=>{He("export",t,"ui");let i=await qr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(AY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Oc(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Ut,{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(l=>this.state.selectedElementIds[l.id]?fo(l,{[a?"strokeColor":"backgroundColor"]:r}):l),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||gc.LIGHT,s=t?.appState?.name??this.state.name,l=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 c=r.id,d=t.elements.find(m=>m.id===c);r=d&&mu(d)&&Zt(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(jt.NEVER));v(this,"onBlur",je(()=>{Uo=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[$.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!==$.PAGE_UP&&t.key!==$.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===$.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[$.CTRL_OR_CMD]&&(t.code===Ar.EQUAL||t.code===Ar.MINUS||t.code===Ar.ZERO||t.code===Ar.NUM_ADD||t.code===Ar.NUM_SUBTRACT||t.code===Ar.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Uo=!1,pu=!1,Wo=!1,uu=!1,fs=null,ue.pointers.clear(),ue.lastCenter=null,ue.initialDistance=null,ue.initialScale=null,clearTimeout(Ic),Ic=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(gu),gu=0,hu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),bt.set(Ut,null),bt.set(lo,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(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,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,fm(),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:on(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=>({...Ko(),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 l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Fr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=_i(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},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=bc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...Ai(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),UM(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)??FY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=HY(),a=dA(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:hY,l=Sb(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});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=UY(t);this.editorInterface=Sb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",je(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Si.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&&(Sc=t),this.scheduleImageRefresh()});v(this,"onScroll",EM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},gY));v(this,"onCut",je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||fc(t.target)||(this.actionManager.executeAction(pm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||fc(t.target)||(this.actionManager.executeAction(ga,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(OY&&t.preventDefault(),!vc){vc=!0,t.touches.length===1&&(Tc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Ic),Ic=window.setTimeout(e.resetTapTwice,hM);return}if(vc&&t.touches.length===1&&Tc){let o=t.touches[0];po(oe(o.clientX,o.clientY),oe(Tc.x,Tc.y))<=wM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),vc=!1,clearTimeout(Ic)}t.touches.length===2&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}):ue.pointers.clear())});v(this,"pasteFromClipboard",je(async t=>{if(!this.isInteractionEnabled())return;let o=!!hu,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)||fc(r)))return;let s=await Zr(t),l=s.getFiles(),c=await tm(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Fr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=gs(o),l=hs(r,a)/2,c=hs(i,s)/2,d=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}=ke({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,w]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=kM({type:"everything",elements:o.map(M=>fo(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,XM(I,bc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=bX(y,C);I=Rb(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if(Zt(M)&&AM(M)){let D=BM(M,this.scene.getElementsMapIncludingDeleted());dX(M,D,this.scene)}}),GY&&wo.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=RX(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&bt.get(mb)?this.state.openSidebar:null,...KM(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,s)=>r(t(a,s)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{_r&&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||He("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...on(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||iX(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:gs(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:$n(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 s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Ab({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}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:s,customData:l})=>({file:await Or(s),customData:l??{}}))),a=i.find(({file:s})=>!Ri(s));if(a)throw new Pu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Or(o);if(!Ri(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===uo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await zc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=uc(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,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:uc(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())Ti(o)&&o.fileId===t&&Si.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===uo.svg))try{let l=Tx(NM(Sx(s.dataURL)),uo.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});v(this,"updateScene",je(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?VY({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}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=QM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return QM.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,"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(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!bM(t.target)){if((t.key===$.ESCAPE||t.key===$.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=de(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Yn(l[0])&&t.key===$.ENTER){this.startImageCropping(l[0]);return}if(t.key===$.ESCAPE)this.updateEditorAtom(lo,null);else if(t.key===$.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Cb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=op(l);bt.get(lo)?.type==="panel"&&tE(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(lo,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[$.CTRL_OR_CMD]&&t.key.toLowerCase()===$.V&&(hu=t.shiftKey,clearTimeout(gu),gu=window.setTimeout(()=>{hu=!1},100)),t[$.CTRL_OR_CMD]&&fc(t.target)&&(t.code===Ar.MINUS||t.code===Ar.EQUAL)){t.preventDefault();return}if(fc(t.target)&&t.key!==$.ESCAPE||wb(t.key)&&bM(t.target))return;if(t.key===$.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===$.E&&t.shiftKey&&t[$.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===$.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Go("COMPLEX_BINDINGS")?this.handleSkipBindMode():du({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===$.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=qy(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!vM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&He("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Dr.sharp?Dr.round:this.state.currentItemArrowType===Dr.round?Dr.elbow:Dr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===$.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[$.CTRL_OR_CMD]&&!t.repeat&&(Go("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),du({app:this,event:t})),wb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>Eo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?uM:this.getEffectiveGridSize())||(t.shiftKey?mY:uM),m=0,p=0;t.key===$.ARROW_LEFT?m=-d:t.key===$.ARROW_RIGHT?m=d:t.key===$.ARROW_UP?p=-d:t.key===$.ARROW_DOWN&&(p=d),m*=Vn(this.state.viewpointFlip.horizontal),p*=Vn(this.state.viewpointFlip.vertical),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),su(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===$.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[$.CTRL_OR_CMD]||Fb(c))Ht(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),$t(c)||this.actionManager.executeAction(Ca));else if(Zt(c)||FM(c)){let d;Zt(c)||(d=c);let m=Lb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===$.SPACE&&ue.pointers.size===0&&(Uo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===$.Z&&!t[$.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(pu=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===$.G||t.key===$.S)&&!t.altKey&&!t[$.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===$.G&&(Xo(this.state.activeTool.type)||l.some(c=>Xo(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===$.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[$.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===$.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Zt(c)||Db(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===$.I&&!t.shiftKey&&!t[$.CTRL_OR_CMD],a=r===$.S&&t.shiftKey&&!t[$.CTRL_OR_CMD]||i,s=r===$.I&&t.shiftKey&&!t[$.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",je(t=>{if(this.isInteractionEnabled()){if(t.key===$.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):iu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Uo=!1),t.key.toLowerCase()===$.Z&&(pu=!1,this.cursor.reset()),t.key===$.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),du({app:this,event:t})),(t.key===$.ALT&&this.state.bindMode==="skip"||!t[$.CTRL_OR_CMD]&&!au(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Go("COMPLEX_BINDINGS"))){let o=ke({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Lr(oe(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());Eo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[$.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),du({app:this,event:t})}if(wb(t.key)){TM(this.scene.getSelectedElements(this.state).filter(xc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Ob).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...tA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...tA(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(ht);let i=aa.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?on(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?on(this.state,{...t,lastActiveTool:this.state.activeTool}):on(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Uo||this.cursor.applyForTool(s),PY(document.activeElement)&&this.focusContainer(),nX(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:iu(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});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")}-${xM()}`);v(this,"onGestureStart",je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ae({},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=>({...yo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:$n(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}),ue.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=iA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&q2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=iA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(sf,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(Db(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||fM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!xc(i)){let C=CX(Ib({fontSize:g,fontFamily:u}),E),P=PX(g,E),M=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:D}),t=i.x+D/2,o=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),w=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-VM(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!c||!i||i.frameId===y.id)?y.id:null,I=p||CM({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:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?bY.MIDDLE:mM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?xc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s: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 po(oe(o.x,o.y),oe(r.x,r.y))<=wM});v(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||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}=ke(t,this.state);if(o.length===1&&Ht(o[0])){let s=o[0];if((t[$.CTRL_OR_CMD]&&Ob(s)||Fb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(Ca);return}else if(this.state.selectedLinearElement&&$t(o[0])){let l=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,c);let d=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Fb(s))return}if(o.length===1&&Yn(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),LX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&DX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Xn({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(yc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[$.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||MM(l)||!MY(l.backgroundColor)||wc({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=Lb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Un.MAIN){this.lastCompletedCanvasClicks=[];return}let o=ke(t,this.state),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(!Yn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Ul(o,r,this.state,i);return!!a&&po(oe(t.x,t.y),oe(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 s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&_c(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});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,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===Un.MAIN||d===Un.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=po(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>pM)return;let i=ke(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=_c(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=ke(this.lastPointerUpEvent,this.state),c=_c(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(fm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=ou(r);let i;if(this.props.onLinkOpen&&o&&(i=kY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=TY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),Cv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(fm(),!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=ke(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=ke(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(l=>!l.locked&&zM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.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&&jX(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?pX(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&&Tt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=$n(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...yo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),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())&&!Wo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=ke(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),Uo||Wo||uu||Is(this.state))return;let s=vf(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&K2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=X2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=Ec(w.snapLines,b),x=w.originSnapOffset?Ec(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&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(tX(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&au(this.state)){let b=oe(r,i),w=this.scene.getNonDeletedElementsMap(),y=Lr(b,this.scene.getNonDeletedElements(),w,rA(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:zb(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)po(oe(r-w,i-y),I)>=vb?(this.store.scheduleCapture(),Gt(()=>{go(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,oe(r-w,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&po(oe(r-w,i-y),T)<vb){this.cursor.set(Me.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{RM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Ob(g)){let M=Lr(oe(r,i),this.scene.getNonDeletedElements(),C);Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}go(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=fe.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=oe(r,i),b=Lr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),rA(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!oA(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:zb(g,b,w,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&$t(m[0]))&&!(Ht(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=ZM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(aA($M(g),this.state.viewpointFlip));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=jM(gs(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(aA($M({transformHandleType:g}),this.state.viewpointFlip));return}}if(rn(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(c)return;u&&(u.link||Ho(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?Me.POINTER:Zt(u)?Me.TEXT:Me.CROSSHAIR):!t[$.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[$.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!$t(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Ec(g.hoveredElementIds,Xn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Ec(g.hoveredElementIds,{})}))});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()&&(Cc=!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),Wo||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=ke(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.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)),bt.get(lo)&&this.updateEditorAtom(lo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),pu){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:Ae(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 l=document.getSelection();if(l?.anchorNode&&l.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=Sb(this.editorInterface,{isTouchScreen:!0})),Wo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Un.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Wn.eraser){this.setState({activeTool:on(this.state,{type:Wn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),rn(this.state)&&this.setState({activeTool:on(this.state,{...this.state.activeTool.lastActiveTool||{type:Wn.selection},lastActiveTool:null})})},b=we(window,Q.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Un.MAIN&&t.button!==Un.TOUCH&&t.button!==Un.ERASER||ue.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[$.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))_b(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=>Ci(this.scene.getNonDeletedElements(),M)).filter(M=>Tt(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(D=>Ci(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Xn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Ho(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Wn.frame||this.state.activeTool.type===Wn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Wn.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,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Go("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=ke({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"&&(Cc=!1,_r?Cc=!0:_r=window.setTimeout(()=>{_r=0,Cc||this.handleCanvasContextMenu(t)},EY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(_r),_r=0,Cc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{fs?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ue.pointers.size<=1&&((t.button===Un.WHEEL||t.button===Un.MAIN&&Uo||Is(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Wo=!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(Me.GRABBING);let{clientX:i,clientY:a}=t,s=_m(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(Q.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,p),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,p),window.addEventListener(Q.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d*Vn(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-m*Vn(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),l=je(fs=()=>{fs=null,Wo=!1,Uo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,l),window.removeEventListener(Q.BLUR,l),s.flush()});return window.addEventListener(Q.BLUR,l),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,l),!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=cf(ue.pointers),i=r.x-ue.lastCenter.x,a=r.y-ue.lastCenter.y;ue.lastCenter=r;let s=df(Array.from(ue.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/ue.initialDistance,c=l?$n(o*l):this.state.zoom.value;this.setState(d=>{let m=yo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i*Vn(d.viewpointFlip.horizontal)/p,scrollY:m.scrollY+2*a*Vn(d.viewpointFlip.vertical)/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else ue.lastCenter=ue.initialDistance=ue.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{iu(this.state.activeTool.type)||this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(iu(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&&!$t(a[0])&&!(Ht(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=ZM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=jM(gs(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=Tb(NX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ht(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=BX(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&&Eo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=KX(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 s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.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,c),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=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Ae({[p.selectedLinearElement.elementId]:!0},this.state):Ae({},p)}));else if(d!=null){if(t[$.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[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...AX(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!YM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))_b(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(w=>Ci(this.scene.getNonDeletedElements(),w)).filter(w=>Tt(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=>Ci(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Xn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Ho(d)?"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 s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);MM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Mt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=KY({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:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?cY:lY},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Ae(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ZY({type:"iframe",x:a,y:s,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(l),l});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=SM({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:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return JY({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:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(go(a,"selectedLinearElement is expected to be set"),i.type==="line"&&RM(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ht);return}if($t(i)&&i.points.length>1){this.actionManager.executeAction(ht,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=ke(t,this.state),{start:m,end:p}=Eo(i)&&au(this.state)?qX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.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&&!oA(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&po(oe(r.origin.x-s,r.origin.y-l),c)<vb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ht,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:Ae({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Me.POINTER)}else{let[i,a]=Mt(r.origin.x,r.origin.y,t[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?jY({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===Dr.round?{type:tu.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Dr.elbow,fixedSegments:this.state.currentItemArrowType===Dr.elbow?[]:null}):QY({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:tu.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=au(this.state)?Lr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),Eo(p)&&UX(p,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:dM(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(Ht(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:oe(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:Ae({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&Eo(p)?{element:g,midPoint:zb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),Eo(p)&&Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={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},l;t==="embeddable"?l=SM({type:"embeddable",...s}):l=qY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Mt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...zo},s=o===Wn.magicframe?$Y(a):XY(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});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(Eo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);cu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);cu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else kb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&cu(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&cu(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||AM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,fo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Ri(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===uo.svg)try{o=Du(NM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==uo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Cx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===uo.gif,s=await(this.props.generateIdForFile?.(o)||Ix(o));if(!s)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[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await zc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,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(s)){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(s)?.image,E=u?aX(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=fo(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(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 fo(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}=ke({clientX:t,clientY:o},this.state),a=await ux({description:"Image",extensions:Object.keys(pY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ht)})}});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),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Ti(o)&&o.fileId===t&&Si.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await Ab({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(Ti(s)){if(a.has(s.fileId))return fo(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return fo(s,{status:"saved"})}return s}))),{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!==uo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Ab({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=cX(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)&&Si.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",rY(()=>{this.addNewImagesToImageCache()},uY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=eA(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Or(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),fo(u,{isDeleted:!0})}})),c=bc(l),d=eA(l.filter(u=>!u.isDeleted),o,r,a),m=bc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ae(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ht)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=ke(t,this.state),i=tg(t),a=await Zr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Ri(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,em(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===uo.png||d.type===uo.svg))try{let p=await Ps(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,em(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(uo.text);if(c){let d=c.value;if(d&&Mb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:ou(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Or(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Ps(t,this.state,r,o)}catch(a){let s=a instanceof px;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;mA(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!==Un.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=ke(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;He("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Xn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ht(d)?new fe(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});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"){qM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:hs(t.origin.x,a.x),height:hs(t.origin.y,a.y),shouldMaintainAspectRatio:hc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Mt(a.x,a.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Ti(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=Y2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),Eo(s)||qM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:hs(t.originInGrid.x,l),height:hs(t.originInGrid.y,c),shouldMaintainAspectRatio:Yn(s)?!hc(o):hc(o),shouldResizeFromCenter:cM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Wn.frame||this.state.activeTool.type===Wn.magicframe)&&this.setState({elementsToHighlight:Nb(this.scene.getNonDeletedElements(),s,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,s]=Mt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Yn(l)){let c=t.originalElements.get(l.id),d=Ti(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Yn(c)&&d&&!(d instanceof Promise)){let[m,p]=Mt(i.x,i.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=hf([l],[c],this,o,u,r);this.scene.mutateElement(l,vX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),su(l,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(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&$t(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{_b(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Mt(s.x,s.y,o[$.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}=hf(r,de(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(FX(t.originalElements,a,r,this.scene,dM(o),cM(o),r.some(m=>Yn(m))?!hc(o):hc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Nb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{mu(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=>Yn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Yn(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Yn(r))&&(!t||this.state.selectedElementIds[t.id])?[pg,ug]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=ou(t.link),r=UM(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 ko(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?[ml,ua,ha,ze,fa,Aa,ur]:[fg,ze,gh,Rv,ze,fa,Rt,pl,ul,ze,ua,ha,ze,Aa,ur];if(this.state.viewModeEnabled)return[...a,a.length>0&&ze,ml,ua,ha,ze,ga,r.length>0&&ze,...r];let s=this.editorInterface.formFactor==="desktop"?[ze,mh,ph,uh,hh]:[];return[ze,ml,ua,ha,ze,pm,ga,fg,r.length>0&&ze,...r,i.length>0&&ze,...i,ze,T2,S2,C2,ze,tf,ze,cg,sf,xg,yg,Ev,dg,ze,...s,ze,hg,gg,ze,Ca,ze,Mg,a.length>0&&ze,...a,ze,fh,fl,ze,Fs]});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(Cb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[$.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Wo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=xY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:yY;c=Math.max(c,d),this.viewport.translate(p=>({...yo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:$n(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:s})=>({scrollX:a-(r||o)*Vn(s.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s,viewpointFlip:l})=>({scrollX:a-o*Vn(l.horizontal)/i.value,scrollY:s-r*Vn(l.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}=ke({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:ue.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",EM(()=>{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:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=Ko(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${xM()}`,wheelZoomsOnDefault:d=!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=on(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:l,exportWithDarkMode:l===gc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=fu(this.editorInterface),this.id=aY(),this.actionManager=new Mm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new JM,this.canvas=document.createElement("canvas"),this.rc=iY.canvas(this.canvas),this.renderer=new Nl(this.scene),this.visibleElements=[],this.store=new GX(this),this.history=new _l(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new wo(this.scene),this.history=new _l(this.store),this.actionManager.registerAll(td),this.actionManager.registerAction(A2(this.history)),this.actionManager.registerAction(D2(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)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange: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(nu).includes(i)&&Gb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){go(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Lr(oe(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),Gt(()=>{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;go(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?fe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):fe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||$t(t))return;let r=()=>{if(this.bindModeHandler=null,go(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=Lr(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){go(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;Gt(()=>{go(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;go(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&&WX(b,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],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"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,BY)),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!==Un.MAIN||Uo||!vM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(ke({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(ke({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(po(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&&yc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),Pb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Gb.get(s.id);switch(c||(Gb.set(s.id,nu.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case nu.PLAYING:case nu.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.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=>Ho(a)&&this.embedsValidationStatus.get(a.id)===!0||Pb(a));return Pe(tK,{children:i.map(a=>{let{x:s,y:l}=ru({sceneX:a.x,sceneY:a.y},this.state),c=LM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=lu(SY(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=uc(g?t:1,.75,QX);return Pe("div",{className:rM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t*Vn(this.state.viewpointFlip.horizontal)}, ${t*Vn(this.state.viewpointFlip.vertical)})`:"none",display:c?"block":"none",opacity:MX(a,Bb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?IY:1),"--embeddable-radius":`${sX(Math.min(a.width,a.height),a)}px`},children:Hb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?us.enabled:us.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:(Ho(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:s,canvasNonce:l,newElementCanvasElement:c}=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=s,this.hasRenderableElements=a.size>0;let d=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=bt.get(lo)?.type==="panel";return Pe("div",{translate:"no",className:rM("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?us.disabled:us.enabled,"--right-sidebar-width":`${rE}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(Es.Provider,{value:this.api,children:Pe(pA.Provider,{value:this,children:Pe(uA.Provider,{value:this.props,children:Pe(Yb.Provider,{value:this.excalidrawContainerValue,children:Pe(Vb.Provider,{value:this.editorInterface,children:Pe($b.Provider,{value:this.setAppState,children:Pe(Kb.Provider,{value:this.state,children:Hb(Xb.Provider,{value:this.scene.getNonDeletedElements(),children:[Hb(Zb.Provider,{value:this.actionManager,children:[Pe(Fk,{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:jn().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,children:this.props.children}),Pe("div",{className:"excalidraw-textEditorContainer"}),Pe("div",{className:"excalidraw-contextMenuContainer"}),Pe("div",{className:"excalidraw-eye-dropper-container"}),Pe(zk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(tM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(Tv,{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(iS,{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(bb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:fr(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}}),c&&Pe(Zk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,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(Eb,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,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(gp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(oM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(DT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ti(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Si.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,lA()||cA()){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(),wY&&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),zY()&&!TX()&&this.setState({errorMessage:Pe(qT,{})});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 JM,this.fonts=new wo(this.scene),this.renderer=new Nl(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(),Si.destroy(),gn.destroy(),clearTimeout(_r),_e.clearCache(),Xn.clearCache(),_r=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(window,Q.MESSAGE,this.onWindowMessage,!1),we(document,Q.POINTER_UP,this.removePointer,{passive:!1}),we(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),we(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),we(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(document,Q.COPY,this.onCopy,{passive:!1}),we(document,Q.KEYUP,this.onKeyUp,{passive:!0}),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1),we(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),we(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(document,Q.CUT,this.onCut,{passive:!1}),we(window,Q.RESIZE,this.onResize,!1),we(window,Q.UNLOAD,this.onUnload,!1),we(window,Q.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(CY(this.excalidrawContainerRef.current),Q.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)===gc.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&&rn(this.state)&&this.setState({activeTool:on(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(),rn(o)&&!rn(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===gc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ht)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Ae(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),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(){vc=!1,Tc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=ke({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 d=Zm(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(Du(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?VX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=DY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>lX(d)).filter(d=>Mb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:ou(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Ri(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):(Gt(()=>{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(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await Px(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
20
+ `)},uW=(e,n,t)=>{let r=pW(e.text,e.originalText).split(`
21
+ `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=dc(u,Xp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=dc(m.line,Xp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=dc(E,Xp(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;d.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),l+=p}}return d},hW=(e,n,t,o)=>{let r=e.name??uk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Xp({fontSize:eb.nameFontSize,fontFamily:QE.Assistant}),l=nW(QE.Assistant),c=dc(a,s,l);a===""&&(c.width=0);let d=dc(i,s,l),m=c.width,p=-c.height-eb.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},gW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),mk=qU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>pk(p)),i=o.filter(p=>Kp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(gW(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=dk(E,u.index,e),b=uW(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??uk(p);for(;(u=s.exec(E))!==null;){let g=dk(E,u.index,e),b=hW(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},lW);import MW from"clsx";import{useEffect as yk,useLayoutEffect as wk,useRef as db,useState as AW,forwardRef as vk,useImperativeHandle as DW,useCallback as Ek}from"react";import{CLASSES as LW,EVENT as bk,isDevEnv as _W,KEYS as RW,updateObject as NW}from"@excalidraw/common";import bW from"clsx";import{useContext as xW}from"react";import EW from"react";var Zp=EW.createContext({});import{jsx as nb,jsxs as gk}from"react/jsx-runtime";var ob=({children:e,className:n})=>{let t=Ee(),o=xW(Zp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return gk("div",{className:bW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,gk("div",{className:"sidebar__header__buttons",children:[r&&nb(ut,{label:f("labels.sidebarLock"),children:nb(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:zx})}),nb(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};ob.displayName="SidebarHeader";import{Tabs as yW}from"radix-ui";import{jsx as fk}from"react/jsx-runtime";var rb=({children:e,tab:n,onSelect:t,...o})=>fk(yW.Trigger,{value:n,asChild:!0,onSelect:t,children:fk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});rb.displayName="SidebarTabTrigger";import{Tabs as wW}from"radix-ui";import{jsx as vW}from"react/jsx-runtime";var ib=({children:e,...n})=>vW(wW.List,{className:"sidebar-triggers",...n,children:e});ib.displayName="SidebarTabTriggers";import IW from"clsx";import{jsx as ab,jsxs as TW}from"react/jsx-runtime";var sb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ue(),d=xe().openSidebar?.name===e;return ab("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:TW("div",{className:IW("sidebar-trigger",a),style:s,children:[t&&ab("div",{children:t}),r&&ab("div",{className:"sidebar-trigger__label",children:r})]})})};sb.displayName="SidebarTrigger";import{Tabs as SW}from"radix-ui";import{jsx as CW}from"react/jsx-runtime";var lb=({children:e,...n})=>{let t=xe(),o=Ue();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return CW(SW.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 PW}from"radix-ui";import{jsx as kW}from"react/jsx-runtime";var cb=({tab:e,children:n,...t})=>kW(PW.Content,{...t,value:e,"data-testid":e,children:n});cb.displayName="SidebarTab";import{jsx as xk}from"react/jsx-runtime";import{createElement as BW}from"react";var mb=et(!1),Ik=vk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{_W()&&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 s=Ue(),l=Dx(mb);wk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=db({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=NW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=db(null);DW(a,()=>d.current);let m=Ee(),p=Ek(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Xi(d,Ek(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),yk(()=>{let u=E=>{E.key===RW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(bk.KEYDOWN,u),()=>{document.removeEventListener(bk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),xk(Xe,{...i,className:MW(LW.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:d,children:xk(Zp.Provider,{value:c.current,children:n})})});Ik.displayName="SidebarInner";var Mr=Object.assign(vk((e,n)=>{let t=xe(),{onStateChange:o}=e,r=db(t.openSidebar);yk(()=>{(!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]=AW(!1);return wk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?BW(Ik,{...e,ref:n,key:e.name}):null}),{Header:ob,TabTriggers:ib,TabTrigger:rb,Tabs:lb,Tab:cb,Trigger:sb});Mr.displayName="Sidebar";import{jsx as ps,jsxs as zW}from"react/jsx-runtime";import{createElement as GW}from"react";var Sk=fi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=rt();return ps(n.In,{children:ps(Mr.Trigger,{...e,className:"default-sidebar-trigger",name:OW.name})})});Sk.displayName="DefaultSidebarTrigger";var Ck=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=rt();return ps(n.In,{children:e})};Ck.displayName="DefaultTabTriggers";var pb=Object.assign(fi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=xe(),a=Ue(),s=i.openSidebar?.tab===Tk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return GW(Mr,{...r,name:"default",key:"default",className:FW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},zW(Mr.Tabs,{children:[!s&&ps(Mr.Header,{}),ps(Mr.Tab,{tab:Tk,children:ps(hk,{})}),!s&&e]}))}),{Trigger:Sk,TabTriggers:Ck});import UW from"react";import{getFrame as WW}from"@excalidraw/common";import{jsx as HW}from"react/jsx-runtime";var ub={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"}},hb=({children:e,color:n})=>HW("div",{className:"Card",style:{"--card-color":ub[n].base,"--card-color-darker":ub[n].darker,"--card-color-darkest":ub[n].darkest},children:e});import{Fragment as YW,jsx as Hn,jsxs as $p}from"react/jsx-runtime";var VW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Hn("div",{className:"ExportDialog ExportDialog--json",children:$p("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&$p(hb,{color:"lime",children:[Hn("div",{className:"Card-icon",children:n1}),Hn("h2",{children:f("exportDialog.disk_title")}),$p("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!_i&&r.renderAction("changeProjectName")]}),Hn($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(dl,"ui")}})]}),l&&$p(hb,{color:"pink",children:[Hn("div",{className:"Card-icon",children:Ns}),Hn("h2",{children:f("exportDialog.link_title")}),Hn("div",{className:"Card-details",children:f("exportDialog.link_details")}),Hn($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{He("export","link",`ui (${WW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Pk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=UW.useCallback(()=>{a({openDialog:null})},[a]);return Hn(YW,{children:n.openDialog?.name==="jsonExport"&&Hn(wn,{onCloseRequest:s,title:f("buttons.export"),children:Hn(VW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import XW from"clsx";import{jsx as KW}from"react/jsx-runtime";var kk=e=>KW($,{className:XW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:eo,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Nk from"clsx";import{useState as iV}from"react";import{CANVAS_SEARCH_TAB as aV,DEFAULT_SIDEBAR as sV,KEYS as mc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as ZW,DEFAULT_SIDEBAR as $W}from"@excalidraw/common";import{isArrowElement as jW,isFlowchartNodeElement as qW,isImageElement as Mk,isLinearElement as Ak,isLineElement as JW,isTextBindableContainer as QW,isTextElement as eV}from"@excalidraw/element";import{isNodeInFlowchart as tV}from"@excalidraw/element";import{jsx as gb}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,nV=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===$W.name&&e.openSidebar.tab===ZW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Se("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(rn(e))return f("hints.eraserRevert",{shortcut:Se("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Se("Ctrl"),shortcut_2:Se("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Se("Escape"),shortcut_2:Se("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Se("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&&s==="mouse"&&c.length===1){let d=c[0];return Ak(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Se("Shift")}):Mk(d)?f("hints.resizeImage",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):f("hints.resize",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Se("Shift")});if(c.length===1&&eV(c[0]))return f("hints.text_selected",{shortcut:Se("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Se("Escape"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Se("Enter"),shortcut_2:Se("Escape")});if(c.length===1&&Mk(c[0]))return f("hints.enterCropEditor",{shortcut:Se("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Se("CtrlOrCmd")});if(fr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Se("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Se(f("keys.mmb")),shortcut_2:Se("Space")});if(c.length===1){if(Ak(c[0]))return jW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Se("Delete"),shortcut_2:Se(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):JW(c[0])?f("hints.lineEditor_line_info",{shortcut:Se("Enter")}):f("hints.lineEditor_info",{shortcut_1:Se("CtrlOrCmd"),shortcut_2:Se(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&QW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Se("Enter")}),m=f("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return qW(c[0])?tV(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},Dk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=nV({appState:e,isMobile:n,editorInterface:t,app:o});if(!r)return null;let a=(Array.isArray(r)?r.map(s=>s.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((s,l)=>{if(l%2===1){let c=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return gb("kbd",{children:c?c[1]:s},l)}return s});return gb("div",{className:"HintViewer",children:gb("span",{children:a})})};import oV from"clsx";import{jsx as rV}from"react/jsx-runtime";var Lk=e=>rV($,{className:oV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Zo:vo,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 Ti,jsx as re,jsxs as Oo}from"react/jsx-runtime";var lV=(e,n)=>e==="image"&&n.tools?.image===!1,cV=({app:e,activeTool:n,type:t,shortcut:o})=>re(ge.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ze[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??la(t),disabled:Qe(e,t),children:f(`toolBar.${t}`)}),_k=({app:e})=>re(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Zo:vo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:mc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),dV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=Je("objectsSnapMode");return re(ge.Item,{onSelect:()=>e.executeAction(Rt,"ui"),icon:qo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},mV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Rt))return null;let t=f("buttons.objectsSnapMode"),o=Je("objectsSnapMode");return re($,{type:"toggle",icon:qo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Rt,"ui")})},Rk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Je("searchMenu");return re(ge.Item,{onSelect:()=>e.executeAction(Ll,"ui"),icon:to,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===sV.name&&n.openSidebar.tab===aV,shortcut:o,children:t})},pV=({app:e})=>re($,{type:"button",icon:Wi,title:`${f("labels.eyeDropper")} - ${mc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":mc.I.toLocaleUpperCase(),keyBindingLabel:mc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),uV=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=iV(!1),l=dt()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&aa.includes(n.type);return Oo(ge,{open:a,children:[re(ge.Trigger,{className:Nk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?Ze[n.type].icon:c?Qn:E?jo:!r&&l&&d?Ur:m&&!e.props.isCollaborating?eo:u?Oi:p?Jn:As}),re(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Oo(Ti,{children:[l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Oi,"data-testid":"toolbar-lasso",selected:u,disabled:Qe(e,"lasso"),children:f("toolBar.lasso")}),aa.filter(b=>!lV(b,o)).map(b=>re(cV,{app:e,activeTool:n,type:b},b)),re("div",{className:"App-toolbar__dropdown-divider"}),re(Rk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Ti,{children:re(_k,{app:e})})]}):Oo(Ti,{children:[re(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Qn,shortcut:mc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Qe(e,"frame"),children:f("toolBar.frame")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:jo,"data-testid":"toolbar-embeddable",selected:E,disabled:Qe(e,"embeddable"),children:f("toolBar.embeddable")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ur,shortcut:la("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Qe(e,"autoshape"),children:f("toolBar.autoshape")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:eo,"data-testid":"toolbar-laser",selected:m,disabled:Qe(e,"laser"),children:f("toolBar.laser")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Jn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Qe(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Oi,"data-testid":"toolbar-lasso",selected:u,disabled:Qe(e,"lasso"),children:f("toolBar.lasso")}),re("div",{className:"App-toolbar__dropdown-divider"}),re(dV,{actionManager:i,app:e}),re(Rk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(_k,{app:e})]})})]})},Bk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=Ee(),c=dt()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?re(Yd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?re(iw,{...m}):re(rw,{...m});return Oo(Xe,{padding:1,className:Nk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[re(Dk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Oo(Ot.Row,{gap:c?.5:1,children:[!c&&re(ns,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Oo(Ti,{children:[re(Lk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),re("div",{className:"App-toolbar__divider"})]}),re(Vd,{...m}),u,p?Oo(Ti,{children:[re(tl,{...m}),re(nl,{...m}),re(pV,{app:e}),o.tools?.image!==!1&&re(ol,{...m}),re(rl,{...m})]}):Oo(Ti,{children:[re(Jy,{...m}),re(Qy,{...m}),re(ew,{...m}),re(tw,{...m}),re(nw,{...m}),c?re(Xd,{...m}):re(tl,{...m}),re(nl,{...m}),o.tools?.image!==!1&&re(ol,{...m}),re(rl,{...m})]}),re("div",{className:"App-toolbar__divider"}),re(uV,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Oo(Ti,{children:[re("div",{className:"App-toolbar__divider"}),re(mV,{actionManager:r,app:e})]})]})]})};import{Fragment as fb,jsx as te,jsxs as nn}from"react/jsx-runtime";var yV=({UIOptions:e})=>nn(zt,{__fallback:!0,children:[te(zt.DefaultItems.LoadScene,{}),te(zt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(zt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(zt.DefaultItems.SaveAsImage,{}),te(zt.DefaultItems.SearchMenu,{}),te(zt.DefaultItems.Help,{}),te(zt.Separator,{}),te(zt.Group,{title:"Excalidraw links",children:te(zt.DefaultItems.Socials,{})}),te(zt.Separator,{}),te(zt.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(zt.DefaultItems.ChangeCanvasBackground,{})]}),wV=()=>nn(Lp,{__fallback:!0,children:[te(Lp.Actions.SaveToDisk,{}),te(Lp.Actions.ExportToImage,{})]}),vV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=Ee(),M=An(),_=dt()==="compact",k=cS(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},F=k.tunnelsJotai.Provider,[Y,z]=Ye(Ut),U=()=>p.canvasActions.export?te(Pk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,W=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(ik,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>nn("div",{style:{position:"relative"},children:[nn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),ie=()=>te(Jl,{heading:"selectedShapeActions",className:us("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Xe,{className:us("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(kS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Xe,{className:gV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(IS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),me=()=>{let ae=w&&xV(n,r),be=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(Ip,{side:"top",children:nn("div",{className:"App-menu App-menu_top",children:[nn(Ot.Col,{gap:L.menuTopGap,className:us("App-menu_top__left"),children:[G(),w&&te("div",{className:us("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:ae&&ie()}),w&&_&&!n.viewModeEnabled&&ae&&te(ns,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(Jl,{heading:"shapes",className:"shapes-section",children:ce=>nn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Ot.Col,{gap:L.toolbarColGap,align:"start",children:nn(Ot.Row,{gap:L.toolbarRowGap,className:us("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Bk,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ce}),I&&te(Xe,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(kk,{title:f("toolBar.laser"),checked:n.activeTool.type===Fk.laser,onChange:()=>b.setActiveTool({type:Fk.laser}),isMobile:!0})})]})})]})}),nn("div",{className:us("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[w&&n.collaborators.size>0&&te(Pp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),be&&te(ac,{app:b,onClose:()=>{e.executeAction(ur)},renderCustomStats:m})]})]})})},B=()=>te(pb,{}),V=!1,pe=nn(fb,{children:[g,w&&te(fb,{children:te(yV,{UIOptions:p})}),te(wV,{}),w&&n.isLoading&&te(bp,{delay:250}),w&&n.errorMessage&&te(UP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&Y&&P.formFactor!=="phone"&&te(H0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(ae,be,ce,{altKey:Be})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(ce.length){for(let se of ce)EV(se,fV(r),{[Be&&Y.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:be}),bV.delete(se);b.scene.triggerUpdate()}else o(ae==="elementBackground"?{currentItemBackgroundColor:be}:{currentItemStrokeColor:be})},onSelect:(ae,be)=>{z(ce=>ce?.keepOpenOnAlt&&be.altKey?ce:null),Y?.onSelect?.(ae,be)}}),n.openDialog?.name==="help"&&te(QP,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&te(HP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),W(),U(),w&&n.openDialog?.name==="charts"&&te(fC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&te($P,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(rC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:W,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:B,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&nn(fb,{children:[M.viewportStatusFrame?.border&&te(gp,{border:M.viewportStatusFrame.border,style:V?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),nn("div",{className:"layer-ui__wrapper",style:V?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),me(),te(IC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:w,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&nn("div",{className:"floating-status-stack",children:[n.toast&&te(jd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(ae=>({...Di(r,ae)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(fp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),B()]});return te(bh.Provider,{value:n,children:te(F,{children:te(aE.Provider,{value:k,children:pe})})})},Ok=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},IV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return jp(Ok(o),Ok(a),{selectedElementIds:jp,selectedGroupIds:jp})&&jp(r,s)},zk=hV.memo(vV,IV);import{useEffect as TV,useRef as SV}from"react";import{jsx as Gk}from"react/jsx-runtime";var Hk=({trails:e})=>{let n=SV(null);return TV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Gk("div",{className:"SVGLayer",children:Gk("svg",{ref:n})})};import CV,{useEffect as Uk,useRef as Wk}from"react";import{isShallowEqual as PV,sceneCoordsToViewportCoords as kV}from"@excalidraw/common";import{jsx as DV}from"react/jsx-runtime";var Vk="animateInteractiveScene",MV=e=>{let n=Wk(!1),t=Wk(null);return Uk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Vf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Uk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,kV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=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:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},lt.running(Vk)||lt.start(Vk,({deltaTime:c,state:d})=>{let m=Vf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),DV("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")})},Yk=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}),AV=(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:PV(Yk(e.appState),Yk(n.appState)),Eb=CV.memo(MV,AV);import Zk,{useEffect as qp,useRef as pc}from"react";import{isShallowEqual as Xk}from"@excalidraw/common";import{hasActiveGifDecode as LV}from"@excalidraw/element";import{jsx as NV}from"react/jsx-runtime";var _V=e=>{let n=pc(null),t=pc(!1),o=pc(e),r=pc(()=>{}),i=pc(null);o.current=e;let a=Zk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();bx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},_a());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=LV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,qp(()=>{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]),qp(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),qp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),qp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),NV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Kk=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}),RV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Xk(Kk(e.appState),Kk(n.appState))&&Xk(e.renderConfig,n.renderConfig),bb=Zk.memo(_V,RV);import{useEffect as UV,useRef as WV}from"react";import{throttleRAF as BV}from"@excalidraw/common";import{getTargetFrame as FV,isInvisiblySmallElement as OV,renderElement as zV,shouldApplyFrameClip as GV}from"@excalidraw/element";var $k=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Rc(e,i),d=Nc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),Bc(d,a),t&&t.type!=="selection"){if(OV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=FV(t,o,a);u&&GV(t,u,a,o)&&fx(u,d,s,a)}zV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},HV=BV(e=>{$k(e)}),jk=(e,n)=>{if(n){HV(e);return}$k(e)};import{jsx as YV}from"react/jsx-runtime";var VV=e=>{let n=WV(null);return UV(()=>{n.current&&jk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},_a())}),YV("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})},qk=VV;import XV from"clsx";import{useLayoutEffect as KV,useEffect as Jk,useRef as ZV,useState as $V}from"react";import{ARROW_TYPE as Qk,EVENT as Jp}from"@excalidraw/common";import{jsx as QV}from"react/jsx-runtime";var eM=700,jV=100,qV=16,JV=5*60*1e3,nM=et(null),tM=e=>e===Qk.elbow?Qo:e===Qk.round?er:Jo,Qp=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(nM,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<JV);v(this,"onArrowTypeCycled",n=>{this.show(tM(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?$o:tM(this.app.state.currentItemArrowType))});this.app=n}},oM=()=>{let[e,n]=Ye(nM),t=St(),{container:o}=Fe(),r=ZV(null),[i,a]=$V(!1),s=e?.nonce;return KV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=pd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:qV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(Jp.POINTER_MOVE,c),()=>{window.removeEventListener(Jp.POINTER_MOVE,c)}},[s,o,t]),Jk(()=>()=>{n(null)},[n]),Jk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},eM),c=window.setTimeout(()=>{n(null)},eM+jV),d=()=>{n(null)};return window.addEventListener(Jp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Jp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?QV("div",{ref:r,className:XV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var eu=class{constructor(n){this.getState=n;v(this,"listeners",[]);v(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),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,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}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 eY,getElementsInGroup as tY,isNonDeletedElement as rM,selectGroupsFromGivenElements as nY}from"@excalidraw/element";import{sceneCoordsToViewportCoords as oY}from"@excalidraw/common";import{flushSync as rY}from"react-dom";import{jsx as aY}from"react/jsx-runtime";var iY=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!rM(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&rM(t)?t:null,r=o?[o]:tY(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=eY(r),{x:s,y:l}=oY({sceneX:i,sceneY:a},e.state);return aY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{rY(()=>{let c=nY(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(fl)},title:f("labels.elementLock.unlock"),children:Gx})},iM=iY;import{Fragment as rK,jsx as ke,jsxs as Hb}from"react/jsx-runtime";var hA=In.createContext(null),gA=In.createContext(null),Ub={formFactor:"desktop",desktopUIMode:"full",userAgent:pA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Vb=In.createContext(Ub);Vb.displayName="EditorInterfaceContext";var tK={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Yb=In.createContext({container:null,id:null});Yb.displayName="ExcalidrawContainerContext";var Xb=In.createContext([]);Xb.displayName="ExcalidrawElementsContext";var Kb=In.createContext({...Ko(),width:0,height:0,offsetLeft:0,offsetTop:0});Kb.displayName="ExcalidrawAppStateContext";var Zb=In.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Zb.displayName="ExcalidrawSetAppStateContext";var $b=In.createContext(null);$b.displayName="ExcalidrawActionManagerContext";var bs=In.createContext(null);bs.displayName="ExcalidrawAPIContext";var Eu=In.createContext(null);Eu.displayName="ExcalidrawAPISetContext";var St=()=>Vo(hA),An=()=>Vo(gA),Ee=()=>Vo(Vb),dt=()=>fu(Ee()),Fe=()=>Vo(Yb),Zi=()=>Vo(Xb),no=()=>Vo(Kb),Ue=()=>Vo(Zb),it=()=>Vo($b),Rd=()=>Vo(bs),vc=!1,Ic=0,Tc=null,Uo=!1,pu=!1,Wo=!1,uu=!1,Sc={horizontal:null,vertical:null},_r=0,Cc=!1,Gb=new Map,nK=4,lA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,hu=!1,gu=0,cA=!1,Es=null,ue={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Wb=class e extends In.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",Ub);v(this,"stylesPanelMode",fu(Ub));v(this,"excalidrawContainerRef",In.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 ho);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new ho);v(this,"imagePlaceholderUpdateEmitter",new ho);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 BY(tK));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new eu(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new ip(this));v(this,"flowchart",new dp(this));v(this,"cursor",new ap(this));v(this,"gifPlayback",new mp(this));v(this,"zDragZoom",null);v(this,"arrowText",new rp(this));v(this,"viewport",new up(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>ue.pointers.size>=2||Wo}));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,"previousPointerMoveCoords",null);v(this,"drawShape",new cp(this));v(this,"laserTrails",new Nm(this));v(this,"eraserTrail",new Um(this));v(this,"lassoTrail",new Hm(this));v(this,"cursorHints",new Qp(this));v(this,"onChangeEmitter",new ho);v(this,"onPointerDownEmitter",new ho);v(this,"onPointerUpEmitter",new ho);v(this,"onUserFollowEmitter",new ho);v(this,"onScrollChangeEmitter",new ho);v(this,"missingPointerEventCleanupEmitter",new ho);v(this,"onRemoveEventListenersEmitter",new ho);v(this,"api");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=bt.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>fr(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&&yc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.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<=fM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ci.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Ho(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Mb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Pb(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=Pe({clientX:i.x,clientY:i.y},this.state),s=Pe({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),width:Math.abs(s.x-a.x),height:Math.abs(s.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===gc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!RM(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:s}=ru({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),l=6,c,d=yX(i);if(i.id===this.state.editingFrame){let m=d;c=ke("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===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:NY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${zo.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return ke("div",{id:this.getFrameNameDOMId(i),className:Cb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+zo.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:zo.nameFontSize,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,lineHeight:zo.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:Me.MOVE,pointerEvents:this.state.viewModeEnabled?hs.disabled:hs.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},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)=>{He("export",t,"ui");let i=await qr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(_Y).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Oc(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Ut,{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(l=>this.state.selectedElementIds[l.id]?fo(l,{[a?"strokeColor":"backgroundColor"]:r}):l),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||gc.LIGHT,s=t?.appState?.name??this.state.name,l=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 c=r.id,d=t.elements.find(m=>m.id===c);r=d&&mu(d)&&$t(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));v(this,"scheduleCapture",()=>this.store.scheduleCapture());v(this,"scheduleUpdate",()=>this.store.scheduleAction(jt.NEVER));v(this,"onBlur",je(()=>{Uo=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));v(this,"onUnload",()=>{this.onBlur()});v(this,"disableEvent",t=>{t.preventDefault()});v(this,"preventBrowserZoomWheel",t=>{t[X.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!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.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[X.CTRL_OR_CMD]&&(t.code===Ar.EQUAL||t.code===Ar.MINUS||t.code===Ar.ZERO||t.code===Ar.NUM_ADD||t.code===Ar.NUM_SUBTRACT||t.code===Ar.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Uo=!1,pu=!1,Wo=!1,uu=!1,Es=null,ue.pointers.clear(),ue.lastCenter=null,ue.initialDistance=null,ue.initialScale=null,clearTimeout(Ic),Ic=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(gu),gu=0,hu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),bt.set(Ut,null),bt.set(lo,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(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,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,fm(),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:on(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=>({...Ko(),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 l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),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(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Fr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ri(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},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=bc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...Di(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),VM(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)??GY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=VY(),a=pA(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:EY,l=Sb(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});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=YY(t);this.editorInterface=Sb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",je(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ci.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&&(Sc=t),this.scheduleImageRefresh()});v(this,"onScroll",xM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},bY));v(this,"onCut",je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||fc(t.target)||(this.actionManager.executeAction(pm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",je(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||fc(t.target)||(this.actionManager.executeAction(fa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(HY&&t.preventDefault(),!vc){vc=!0,t.touches.length===1&&(Tc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Ic),Ic=window.setTimeout(e.resetTapTwice,fM);return}if(vc&&t.touches.length===1&&Tc){let o=t.touches[0];po(oe(o.clientX,o.clientY),oe(Tc.x,Tc.y))<=IM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),vc=!1,clearTimeout(Ic)}t.touches.length===2&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}):ue.pointers.clear())});v(this,"pasteFromClipboard",je(async t=>{if(!this.isInteractionEnabled())return;let o=!!hu,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)||fc(r)))return;let s=await $r(t),l=s.getFiles(),c=await tm(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Fr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=fs(o),l=gs(r,a)/2,c=gs(i,s)/2,d=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}=Pe({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,w]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=AM({type:"everything",elements:o.map(M=>fo(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,ZM(I,bc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=wX(y,C);I=Rb(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if($t(M)&&LM(M)){let D=OM(M,this.scene.getElementsMapIncludingDeleted());uX(M,D,this.scene)}}),WY&&wo.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=FX(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&bt.get(mb)?this.state.openSidebar:null,...$M(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,s)=>r(t(a,s)):r(t);this.setState(i,o)});v(this,"removePointer",t=>{_r&&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||He("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...on(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||lX(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:fs(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:Zn(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,dY,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",je(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Ab({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}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:s,customData:l})=>({file:await Or(s),customData:l??{}}))),a=i.find(({file:s})=>!Ni(s));if(a)throw new Pu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});v(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Or(o);if(!Ni(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===uo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await zc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});v(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=uc(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,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:uc(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())Si(o)&&o.fileId===t&&Ci.delete(o)});v(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===uo.svg))try{let l=Tx(FM(Sx(s.dataURL)),uo.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});v(this,"updateScene",je(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?KY({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}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=tA.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return tA.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,"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(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!yM(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=de(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Yn(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(l.length===0&&(t.key===X.ARROW_LEFT||t.key===X.ARROW_RIGHT)&&!t[X.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey){let c=this.scene.getNonDeletedElementsMap(),d=lv(this.scene.getNonDeletedElements(),c,this.lastKeyboardSmartZoomImageId,t.key===X.ARROW_RIGHT?"next":"previous");if(d){this.lastKeyboardSmartZoomImageId=d.id,this.actionManager.executeAction(oi,"keyboard",[d]),t.preventDefault(),t.stopPropagation();return}}if(t.key===X.ESCAPE)this.updateEditorAtom(lo,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Cb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=op(l);bt.get(lo)?.type==="panel"&&tE(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(lo,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(hu=t.shiftKey,clearTimeout(gu),gu=window.setTimeout(()=>{hu=!1},100)),t[X.CTRL_OR_CMD]&&fc(t.target)&&(t.code===Ar.MINUS||t.code===Ar.EQUAL)){t.preventDefault();return}if(fc(t.target)&&t.key!==X.ESCAPE||wb(t.key)&&yM(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.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===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Go("COMPLEX_BINDINGS")?this.handleSkipBindMode():du({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=qy(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!TM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&He("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Dr.sharp?Dr.round:this.state.currentItemArrowType===Dr.round?Dr.elbow:Dr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Go("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),du({app:this,event:t})),wb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>Eo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?gM:this.getEffectiveGridSize())||(t.shiftKey?hY:gM),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),m*=Vn(this.state.viewpointFlip.horizontal),p*=Vn(this.state.viewpointFlip.vertical),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),su(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[X.CTRL_OR_CMD]||Fb(c))Ht(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Zt(c)||this.actionManager.executeAction(Pa));else if($t(c)||zM(c)){let d;$t(c)||(d=c);let m=Lb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&ue.pointers.size===0&&(Uo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(pu=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(Xo(this.state.activeTool.type)||l.some(c=>Xo(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>$t(c)||Db(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",je(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):iu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Uo=!1),t.key.toLowerCase()===X.Z&&(pu=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),du({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!au(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Go("COMPLEX_BINDINGS"))){let o=Pe({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Lr(oe(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());Eo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),du({app:this,event:t})}if(wb(t.key)){CM(this.scene.getSelectedElements(this.state).filter(xc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Ob).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...oA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...oA(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(ht);let i=sa.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?on(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?on(this.state,{...t,lastActiveTool:this.state.activeTool}):on(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Uo||this.cursor.applyForTool(s),AY(document.activeElement)&&this.focusContainer(),iX(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:iu(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:Ae({},l),selectedGroupIds:Ae({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});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")}-${wM()}`);v(this,"onGestureStart",je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ae({},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=>({...yo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Zn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",je(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}),ue.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=sA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&Q2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=sA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(sf,"ui",r),this.cursor.reset(),!0)});v(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(Db(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||bM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!xc(i)){let C=MX(Ib({fontSize:g,fontFamily:u}),E),P=AX(g,E),M=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:D}),t=i.x+D/2,o=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),w=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-XM(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!c||!i||i.frameId===y.id)?y.id:null,I=p||kM({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:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?wY.MIDDLE:uM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?xc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s: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 po(oe(o.x,o.y),oe(r.x,r.y))<=IM});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:l}=Pe(t,this.state),c=this.getElementAtPosition(s,l,{includeLockedElements:!0});c&&(this.cursor.reset(),this.actionManager.executeAction(oi,"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}=Pe(t,this.state);if(o.length===1&&Ht(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&Ob(s)||Fb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(Pa);return}else if(this.state.selectedLinearElement&&Zt(o[0])){let l=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,c);let d=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Fb(s))return}if(o.length===1&&Yn(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),NX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&RX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Xn({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(yc(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[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(c&&(this.state.activeTool.type==="autoshape"||DM(c)||!LY(c.backgroundColor)||wc({point:oe(r,i),element:c,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(c)}))){let d=Lb(c,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:c||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Un.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Pe(t,this.state),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(!Yn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Ul(o,r,this.state,i);return!!a&&po(oe(t.x,t.y),oe(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 s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&_c(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});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,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===Un.MAIN||d===Un.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=po(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>hM)return;let i=Pe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=_c(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Pe(this.lastPointerUpEvent,this.state),c=_c(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(fm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=ou(r);let i;if(this.props.onLinkOpen&&o&&(i=DY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=PY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});v(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),kv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(fm(),!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=Pe(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=Pe(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(l=>!l.locked&&HM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.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&&QX(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?gX(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&&Tt(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Zn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...yo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),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())&&!Wo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Pe(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),Uo||Wo||uu||Ts(this.state))return;let s=vf(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&$2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=Z2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=Ec(w.snapLines,b),x=w.originSnapOffset?Ec(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&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(rX(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&au(this.state)){let b=oe(r,i),w=this.scene.getNonDeletedElementsMap(),y=Lr(b,this.scene.getNonDeletedElements(),w,aA(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:zb(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)po(oe(r-w,i-y),I)>=vb?(this.store.scheduleCapture(),Gt(()=>{go(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,oe(r-w,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&po(oe(r-w,i-y),T)<vb){this.cursor.set(Me.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{BM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Ob(g)){let M=Lr(oe(r,i),this.scene.getNonDeletedElements(),C);Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}go(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=fe.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=oe(r,i),b=Lr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),aA(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!iA(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:zb(g,b,w,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Zt(m[0]))&&!(Ht(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=qM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(lA(jM(g),this.state.viewpointFlip));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=JM(fs(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(lA(jM({transformHandleType:g}),this.state.viewpointFlip));return}}if(rn(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(c)return;u&&(u.link||Ho(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?Me.POINTER:$t(u)?Me.TEXT:Me.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Zt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Ec(g.hoveredElementIds,Xn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Ec(g.hoveredElementIds,{})}))});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()&&(Cc=!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),Wo||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=Pe(t,this.state),{x:i,y:a}=r;this.lastPointerMoveCoords={x:i,y:a};let s=t.target;if(s.setPointerCapture&&s.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)),bt.get(lo)&&this.updateEditorAtom(lo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),pu){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:Ae(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 l=document.getSelection();if(l?.anchorNode&&l.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=Sb(this.editorInterface,{isTouchScreen:!0})),Wo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Un.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Wn.eraser){this.setState({activeTool:on(this.state,{type:Wn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),rn(this.state)&&this.setState({activeTool:on(this.state,{...this.state.activeTool.lastActiveTool||{type:Wn.selection},lastActiveTool:null})})},b=we(window,Q.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Un.MAIN&&t.button!==Un.TOUCH&&t.button!==Un.ERASER||ue.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!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=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))_b(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=>Pi(this.scene.getNonDeletedElements(),M)).filter(M=>Tt(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(D=>Pi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Xn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Ho(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Wn.frame||this.state.activeTool.type===Wn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Wn.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,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Go("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=Pe({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"&&(Cc=!1,_r?Cc=!0:_r=window.setTimeout(()=>{_r=0,Cc||this.handleCanvasContextMenu(t)},yY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(_r),_r=0,Cc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{Es?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ue.pointers.size<=1&&((t.button===Un.WHEEL||t.button===Un.MAIN&&Uo||Ts(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Wo=!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(Me.GRABBING);let{clientX:i,clientY:a}=t,s=_m(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(Q.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,p),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,p),window.addEventListener(Q.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d*Vn(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-m*Vn(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),l=je(Es=()=>{Es=null,Wo=!1,Uo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,l),window.removeEventListener(Q.BLUR,l),s.flush()});return window.addEventListener(Q.BLUR,l),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,l),!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=cf(ue.pointers),i=r.x-ue.lastCenter.x,a=r.y-ue.lastCenter.y;ue.lastCenter=r;let s=df(Array.from(ue.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/ue.initialDistance,c=l?Zn(o*l):this.state.zoom.value;this.setState(d=>{let m=yo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i*Vn(d.viewpointFlip.horizontal)/p,scrollY:m.scrollY+2*a*Vn(d.viewpointFlip.vertical)/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else ue.lastCenter=ue.initialDistance=ue.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{iu(this.state.activeTool.type)||this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(iu(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&&!Zt(a[0])&&!(Ht(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=qM(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=JM(fs(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=Tb(OX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ht(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=zX(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&&Eo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=jX(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 s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.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,c),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=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Ae({[p.selectedLinearElement.elementId]:!0},this.state):Ae({},p)}));else if(d!=null){if(t[X.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[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({..._X(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!KM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))_b(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(w=>Pi(this.scene.getNonDeletedElements(),w)).filter(w=>Tt(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=>Pi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Xn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Ho(d)?"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 s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);DM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});v(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Mt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=jY({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:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?pY:mY},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Ae(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});v(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=JY({type:"iframe",x:a,y:s,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(l),l});v(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=PM({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:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});v(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Mt(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return tX({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:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(go(a,"selectedLinearElement is expected to be set"),i.type==="line"&&BM(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ht);return}if(Zt(i)&&i.points.length>1){this.actionManager.executeAction(ht,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Pe(t,this.state),{start:m,end:p}=Eo(i)&&au(this.state)?eK(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.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&&!iA(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&po(oe(r.origin.x-s,r.origin.y-l),c)<vb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ht,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:Ae({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Me.POINTER)}else{let[i,a]=Mt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?QY({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===Dr.round?{type:tu.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Dr.elbow,fixedSegments:this.state.currentItemArrowType===Dr.elbow?[]:null}):nX({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:tu.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=au(this.state)?Lr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),Eo(p)&&YX(p,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:pM(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(Ht(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:oe(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:Ae({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&Eo(p)?{element:g,midPoint:zb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),Eo(p)&&Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});v(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Mt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={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},l;t==="embeddable"?l=PM({type:"embeddable",...s}):l=eX({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});v(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Mt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...zo},s=o===Wn.magicframe?qY(a):$Y(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});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(Eo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);cu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);cu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else kb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&cu(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&cu(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||LM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,fo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Ni(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===uo.svg)try{o=Du(FM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==uo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Cx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===uo.gif,s=await(this.props.generateIdForFile?.(o)||Ix(o));if(!s)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[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await zc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,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(s)){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(s)?.image,E=u?cX(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=fo(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(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 fo(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}=Pe({clientX:t,clientY:o},this.state),a=await ux({description:"Image",extensions:Object.keys(gY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ht)})}});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),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Si(o)&&o.fileId===t&&Ci.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});v(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await Ab({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(Si(s)){if(a.has(s.fileId))return fo(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return fo(s,{status:"saved"})}return s}))),{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!==uo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Ab({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=pX(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)&&Ci.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",sY(()=>{this.addNewImagesToImageCache()},fY));v(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});v(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=nA(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Or(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),fo(u,{isDeleted:!0})}})),c=bc(l),d=nA(l.filter(u=>!u.isDeleted),o,r,a),m=bc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Ae(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ht)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Pe(t,this.state),i=tg(t),a=await $r(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Ni(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,em(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===uo.png||d.type===uo.svg))try{let p=await ks(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,em(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(uo.text);if(c){let d=c.value;if(d&&Mb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:ou(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Or(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await ks(t,this.state,r,o)}catch(a){let s=a instanceof px;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;uA(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!==Un.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Pe(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;He("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Xn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ht(d)?new fe(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});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"){QM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:gs(t.origin.x,a.x),height:gs(t.origin.y,a.y),shouldMaintainAspectRatio:hc(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=Mt(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Si(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=K2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),Eo(s)||QM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:gs(t.originInGrid.x,l),height:gs(t.originInGrid.y,c),shouldMaintainAspectRatio:Yn(s)?!hc(o):hc(o),shouldResizeFromCenter:mM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Wn.frame||this.state.activeTool.type===Wn.magicframe)&&this.setState({elementsToHighlight:Nb(this.scene.getNonDeletedElements(),s,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,s]=Mt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Yn(l)){let c=t.originalElements.get(l.id),d=Si(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Yn(c)&&d&&!(d instanceof Promise)){let[m,p]=Mt(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=hf([l],[c],this,o,u,r);this.scene.mutateElement(l,SX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),su(l,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(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Zt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{_b(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Mt(s.x,s.y,o[X.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}=hf(r,de(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(GX(t.originalElements,a,r,this.scene,pM(o),mM(o),r.some(m=>Yn(m))?!hc(o):hc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Nb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{mu(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=>Yn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Yn(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Yn(r))&&(!t||this.state.selectedElementIds[t.id])?[pg,ug]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=ou(t.link),r=VM(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 ko(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?[oi,ha,ga,ze,Ea,Da,ur]:[fg,ze,gh,Bv,ze,Ea,Rt,pl,ul,ze,ha,ga,ze,Da,ur];if(this.state.viewModeEnabled)return[...a,a.length>0&&ze,oi,ha,ga,ze,fa,r.length>0&&ze,...r];let s=this.editorInterface.formFactor==="desktop"?[ze,mh,ph,uh,hh]:[];return[ze,oi,ha,ga,ze,pm,fa,fg,r.length>0&&ze,...r,i.length>0&&ze,...i,ze,C2,P2,k2,ze,tf,ze,cg,sf,xg,yg,xv,dg,ze,...s,ze,hg,gg,ze,Pa,ze,Mg,a.length>0&&ze,...a,ze,fh,fl,ze,Os]});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(Cb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Wo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=vY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:IY;c=Math.max(c,d),this.viewport.translate(p=>({...yo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Zn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:s})=>({scrollX:a-(r||o)*Vn(s.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s,viewpointFlip:l})=>({scrollX:a-o*Vn(l.horizontal)/i.value,scrollY:s-r*Vn(l.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}=Pe({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:ue.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",xM(()=>{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:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});v(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});v(this,"watchState",()=>{});let o=Ko(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${wM()}`,wheelZoomsOnDefault:d=!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=on(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:l,exportWithDarkMode:l===gc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=fu(this.editorInterface),this.id=cY(),this.actionManager=new Mm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new eA,this.canvas=document.createElement("canvas"),this.rc=lY.canvas(this.canvas),this.renderer=new Nl(this.scene),this.visibleElements=[],this.store=new WX(this),this.history=new _l(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new wo(this.scene),this.history=new _l(this.store),this.actionManager.registerAll(td),this.actionManager.registerAction(L2(this.history)),this.actionManager.registerAction(_2(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)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange: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(nu).includes(i)&&Gb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){go(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Lr(oe(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),Gt(()=>{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;go(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?fe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):fe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Zt(t))return;let r=()=>{if(this.bindModeHandler=null,go(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=Lr(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){go(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;Gt(()=>{go(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;go(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&&rA(E,m),w=g&&rA(g,m);i=!!(b&&w&&E.id!==g.id&&XX(b,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],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"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,zY)),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!==Un.MAIN||Uo||!TM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Pe({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Pe({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(po(t,o)>hM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ue.pointers.size<2&&yc(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),Pb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Gb.get(s.id);switch(c||(Gb.set(s.id,nu.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case nu.PLAYING:case nu.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.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=>Ho(a)&&this.embedsValidationStatus.get(a.id)===!0||Pb(a));return ke(rK,{children:i.map(a=>{let{x:s,y:l}=ru({sceneX:a.x,sceneY:a.y},this.state),c=RM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=lu(kY(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=uc(g?t:1,.75,nK);return ke("div",{className:aM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t*Vn(this.state.viewpointFlip.horizontal)}, ${t*Vn(this.state.viewpointFlip.vertical)})`:"none",display:c?"block":"none",opacity:LX(a,Bb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?CY:1),"--embeddable-radius":`${dX(Math.min(a.width,a.height),a)}px`},children:Hb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?hs.enabled:hs.disabled},children:[E&&ke("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),ke("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:ke("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Ho(a)?this.props.renderEmbeddable?.(a,this.state):null)??ke("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:s,canvasNonce:l,newElementCanvasElement:c}=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=s,this.hasRenderableElements=a.size>0;let d=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=bt.get(lo)?.type==="panel";return ke("div",{translate:"no",className:aM("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?hs.disabled:hs.enabled,"--right-sidebar-width":`${rE}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:ke(bs.Provider,{value:this.api,children:ke(hA.Provider,{value:this,children:ke(gA.Provider,{value:this.props,children:ke(Yb.Provider,{value:this.excalidrawContainerValue,children:ke(Vb.Provider,{value:this.editorInterface,children:ke(Zb.Provider,{value:this.setAppState,children:ke(Kb.Provider,{value:this.state,children:Hb(Xb.Provider,{value:this.scene.getNonDeletedElements(),children:[Hb($b.Provider,{value:this.actionManager,children:[ke(zk,{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:jn().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,children:this.props.children}),ke("div",{className:"excalidraw-textEditorContainer"}),ke("div",{className:"excalidraw-contextMenuContainer"}),ke("div",{className:"excalidraw-eye-dropper-container"}),ke(Hk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&ke(oM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ke(Cv,{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&&ke(sS,{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?.()})}}),ke(bb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:fr(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}}),c&&ke(qk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,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}}),ke(Eb,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,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"&&ke(gp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&ke(iM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&ke(_T,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Si(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ci.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,dA()||mA()){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(),TY&&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),UY()&&!PX()&&this.setState({errorMessage:ke(QT,{})});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 eA,this.fonts=new wo(this.scene),this.renderer=new Nl(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(),Ci.destroy(),gn.destroy(),clearTimeout(_r),_e.clearCache(),Xn.clearCache(),_r=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(window,Q.MESSAGE,this.onWindowMessage,!1),we(document,Q.POINTER_UP,this.removePointer,{passive:!1}),we(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),we(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),we(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(document,Q.COPY,this.onCopy,{passive:!1}),we(document,Q.KEYUP,this.onKeyUp,{passive:!0}),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1),we(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),we(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(document,Q.CUT,this.onCut,{passive:!1}),we(window,Q.RESIZE,this.onResize,!1),we(window,Q.UNLOAD,this.onUnload,!1),we(window,Q.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(MY(this.excalidrawContainerRef.current),Q.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)===gc.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&&rn(this.state)&&this.setState({activeTool:on(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(),rn(o)&&!rn(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===gc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ht)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Ae(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),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(){vc=!1,Tc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Pe({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 d=$m(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(Du(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?KX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=RY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>mX(d)).filter(d=>Mb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:ou(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Ni(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):(Gt(()=>{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(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await Px(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
22
22
 
23
- `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=ke({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:vY,verticalAlign:mM,locked:!1},s=Ib({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=fM(a.fontFamily),[c,,d]=wX(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
- `),g=E.reduce((b,w,y)=>{let x=SX(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=WM(x,s,l),C=T.width>m,P=C?IX(x,s,m):x;T=C?WM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=CM({...a,x:M,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[y-1]?.trim()&&(u+=VM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ae(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&sA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),sA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&Zt(c)?fo(c,{originalText:s,isDeleted:l??c.isDeleted,...eX(c,BM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=cI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=ru({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:je(s=>{a(s,!1),mu(t)&&su(t,this.scene)}),onSubmit:je(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:Ae({...m.selectedElementIds,[d]:!0},m)}))}),c&&YY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{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:Ae({},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 Zt(r)?r:t?Db(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(Zt(i))return null;if(!FM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&Zt(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 s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return wc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(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(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!(Zt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Bb(l,a);return c&&!mu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!yc(l)?zM({x:t,y:o},c,a):!0}).filter(l=>yc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(gM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&mX([r],this.state,this.editorInterface)&&HX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||xX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:wc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(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 DM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=IM(r[s],this.scene.getNonDeletedElementsMap());if(xc(r[s])&&wc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return DM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Zt(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 s=-1,l=null;wc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=fe.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=fe.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),($t(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!$t(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!$t(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),fe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=XX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ue.pointers.size===2&&(ue.lastCenter=cf(ue.pointers),ue.initialScale=this.state.zoom.value,ue.initialDistance=df(Array.from(ue.pointers.values())))}initialPointerDownState(t){let o=ke(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=gs(r),c=r.findIndex($t)===0;return{origin:o,withCmdOrCtrl:t[$.CTRL_OR_CMD],originInGrid:Tb(Mt(o.x,o.y,t[$.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:vf(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,PM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+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;uu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=_m(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=je(()=>{fs=null,uu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,r),window.removeEventListener(Q.POINTER_UP,i),r.flush()});return fs=i,window.addEventListener(Q.POINTER_MOVE,r),window.addEventListener(Q.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(gM/this.state.zoom.value,1),i=dY*2/this.state.zoom.value,[a,s,l,c]=gs(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:oX(t)?tu.ADAPTIVE_RADIUS:tu.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return WY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Lo({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(W2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Lo({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(U2(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===$.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return _m(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=ke(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]=Mt(r.x,r.y,o[$.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=Tb(zX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(rn(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[s,l]=Mt(r.x,r.y,o[$.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 c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){YX(p,c,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,c)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[$.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{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,c);if(u?.isDeleted)return;if(Eo(u)){let g=Lr(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Go("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||!yM(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 d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||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=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:OM(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),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&&Yn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=Ti(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=ZX(I),M=iM(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[D,_,k,L,F,Y]=IM(I,c),z=yb(xb(oe(D,_),oe(F,Y),I.angle)),U=yb(xb(oe(k,_),oe(F,Y),I.angle)),W=yb(xb(oe(D,L),oe(F,Y),I.angle)),G=lM(aM(U,z)),ie=lM(aM(W,z)),me=iM(sM(M,G),sM(M,ie)),B={...T,x:uc(T.x-me[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:uc(T.y-me[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:B});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=V2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||OX(t,p,g,this.scene,y,o[$.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:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=kM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:RY()})});M.forEach(z=>{t.originalElements.set(z.id,PM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return fo(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),Y=XM(F||L,bc(M));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let W=k.get(U.id),G=W&&D.get(W);return G&&z.push(G),z},[]),t.drag.origin=ke(o,this.state),this.setState(z=>({...KM(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{kb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&su(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 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,oe(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ht(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;go(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,s,l,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&&_e(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Xn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?lx(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},{...Xn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ht(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Ho(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*(Sc.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*(Sc.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===Wn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,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:Ec(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,gn.setReferenceSnapPoints(null),gn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=ke({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(Go("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);kb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>$t(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(ht);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ht,"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?($X(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(ht,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ht(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(Q.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(Q.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(Q.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(Q.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=ke(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,oe(T,C)],pressures:P}),this.actionManager.executeAction(ht);return}if(Ht(i)&&this.state.activeTool.type!=="autoshape"){let x=ke(o,this.state),I=po(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<NY)&&i&&!l)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:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ht)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ht(i)&&this.actionManager.executeAction(ht,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ae({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Zt(i)){let x=kX(Ib({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(c.type!=="selection"&&i&&_M(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(Tt(i)){let x=gX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Rb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,rX(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=ke(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=Bb(I,r);T&&I&&(fX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),hX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:OM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let D of M){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&Ci(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(D=>HM(D,C,this.state));this.state.editingGroupId&&P(M),C=Rb(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!HM(D,C,this.state));P(M)}C=GM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&_M(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=GM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=uX(x,Nb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ht(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new fe(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rn(this.state)&&b&&w){if(this.eraserTrail.endPath(),po(oe(b.clientX,b.clientY),oe(w.clientX,w.clientY))===0){let I=ke({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]?_X(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>Ci(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Ae(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{...Xn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ht(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=>Ci(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Xn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Ho(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Xn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ht(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&$t(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&yX({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ca):this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[$.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Zt(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()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Ho(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||_e(this.scene.getNonDeletedElements(),this.state)||!yM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(xc);TM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ht);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Wn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ae({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&YM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=Lb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<fY){let{x:m,y:p}=ru({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}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=Bi.find(o=>o.code===this.props.langCode)||Zn;await Uc(t),this.setAppState({})}},eK=()=>{(lA()||cA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(mA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};eK();var hA=Wb;import{useEffect as nK,useState as oK}from"react";import{jsx as rK}from"react/jsx-runtime";var gA=e=>{let[n,t]=oK(!0);return nK(()=>{let o=async()=>{await Uc(r),t(!1)},r=Bi.find(i=>i.code===e.langCode)||Zn;o()},[e.langCode]),n?rK(bp,{theme:e.theme}):e.children};import iK from"clsx";import{jsx as fA}from"react/jsx-runtime";var EA=({children:e})=>{let{FooterCenterTunnel:n}=rt(),t=xe();return fA(n.In,{children:fA("div",{className:iK("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},aK=EA;EA.displayName="FooterCenter";import sK from"clsx";import{MQ_MIN_WIDTH_DESKTOP as lK}from"@excalidraw/common";import{jsx as dK,jsxs as mK}from"react/jsx-runtime";var bA=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=xe(),i=t?.formFactor!=="desktop"||r.width<lK;return mK(vn,{...o,className:sK("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?i1:f("labels.share"),r.collaborators.size>0&&dK("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},cK=bA;bA.displayName="LiveCollaborationTrigger";import{jsx as Rr,jsxs as yA}from"react/jsx-runtime";var pK=()=>Rr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rr("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"})}),uK=()=>yA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rr("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)"}),Rr("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)"}),Rr("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)"}),Rr("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)"})]}),xA=({style:e,size:n="small",withText:t})=>yA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Rr(pK,{}),t&&Rr(uK,{})]});import{Fragment as IA,jsx as ct,jsxs as jb}from"react/jsx-runtime";var qb=({icon:e,shortcut:n,children:t})=>{let o=Ee();return jb(IA,{children:[ct("div",{className:"welcome-screen-menu-item__icon",children:e}),ct("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&ct("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};qb.displayName="WelcomeScreenMenuItemContent";var Pc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>ct("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:ct(qb,{icon:t,shortcut:o,children:n})});Pc.displayName="WelcomeScreenMenuItem";var wA=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>ct("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:ct(qb,{icon:t,shortcut:o,children:e})});wA.displayName="WelcomeScreenMenuItemLink";var Tn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=rt();return ct(n.In,{children:ct("div",{className:"welcome-screen-center",children:e||jb(IA,{children:[ct(Jb,{}),ct(Qb,{children:f("welcomeScreen.defaults.center_heading")}),jb(ex,{children:[ct(nx,{}),ct(tx,{})]})]})})})};Tn.displayName="Center";var Jb=({children:e})=>ct("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||ct(xA,{withText:!0})});Jb.displayName="Logo";var Qb=({children:e})=>ct("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Qb.displayName="Heading";var ex=({children:e})=>ct("div",{className:"welcome-screen-menu",children:e});ex.displayName="Menu";var tx=()=>{let e=it();return ct(Pc,{onSelect:()=>e.executeAction(Qr),shortcut:"?",icon:Hi,children:f("helpDialog.title")})};tx.displayName="MenuItemHelp";var nx=()=>{let e=xe(),n=it();return e.viewModeEnabled?null:ct(Pc,{onSelect:()=>n.executeAction(ca),shortcut:Je("loadScene"),icon:Kc,children:f("buttons.load")})};nx.displayName="MenuItemLoadScene";var vA=({onSelect:e})=>{let{t:n}=Re();return ct(Pc,{shortcut:null,onSelect:e,icon:$c,children:n("labels.liveCollaboration")})};vA.displayName="MenuItemLiveCollaborationTrigger";Tn.Logo=Jb;Tn.Heading=Qb;Tn.Menu=ex;Tn.MenuItem=Pc;Tn.MenuItemLink=wA;Tn.MenuItemHelp=tx;Tn.MenuItemLoadScene=nx;Tn.MenuItemLiveCollaborationTrigger=vA;import{jsx as bs,jsxs as ox}from"react/jsx-runtime";var bu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=rt();return bs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Hx,bs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};bu.displayName="MenuHint";var xu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=rt();return bs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[bs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Wx]})})};xu.displayName="ToolbarHint";var yu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=rt();return bs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[bs("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Ux]})})};yu.displayName="HelpHint";import{Fragment as TA,jsx as kc,jsxs as gK}from"react/jsx-runtime";var wu=e=>kc(TA,{children:e.children||gK(TA,{children:[kc(Tn,{}),kc(bu,{}),kc(xu,{}),kc(yu,{})]})});wu.displayName="WelcomeScreen";wu.Center=Tn;wu.Hints={MenuHint:bu,ToolbarHint:xu,HelpHint:yu};var hK=wu;var fK=()=>{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)})},SA=fK;import{configureGifWorkerUrl as yYe,getSceneVersion as wYe,hashElementsVersion as vYe,hashString as IYe,getNonDeletedElements as TYe}from"@excalidraw/element";import{getTextFromElements as CYe}from"@excalidraw/element";import{isInvisiblySmallElement as kYe}from"@excalidraw/element";import EK from"lodash.throttle";import{arrayToMap as bK,isDevEnv as CA,isTestEnv as PA}from"@excalidraw/common";import{orderByFractionalIndex as xK,syncInvalidIndices as kA,validateFractionalIndices as yK}from"@excalidraw/element";var wK=(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)),vK=EK((e,n,t)=>{if(CA()||PA()||window?.DEBUG_FRACTIONAL_INDICES){let o=kA(e.map(r=>({...r})));yK(o,{shouldThrow:PA()||CA(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),IK=(e,n,t)=>{let o=bK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=wK(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=xK(r);return vK(a,e,n),kA(a),a};import{isLinearElement as OYe}from"@excalidraw/element";import{FONT_FAMILY as GYe,THEME as HYe,MIME_TYPES as UYe,ROUNDNESS as WYe,DEFAULT_LASER_COLOR as VYe,UserIdleState as YYe,normalizeLink as XYe,sceneCoordsToViewportCoords as KYe,viewportCoordsToSceneCoords as $Ye,getFormFactor as ZYe,throttleRAF as jYe}from"@excalidraw/common";import{mutateElement as JYe,newElementWith as QYe,bumpVersion as eXe}from"@excalidraw/element";import{CaptureUpdateAction as nXe}from"@excalidraw/element";import{getCommonBounds as mXe,getVisibleSceneBounds as pXe,convertToExcalidrawElements as uXe}from"@excalidraw/element";import{elementsOverlappingBBox as gXe}from"@excalidraw/element";import{isElementLink as bXe}from"@excalidraw/element";import{setCustomTextMetricsProvider as wXe}from"@excalidraw/element";import{jsx as Mc}from"react/jsx-runtime";SA();var gYe=({children:e})=>{let[n,t]=MK(null);return Mc(Es.Provider,{value:n,children:Mc(Eu.Provider,{value:t,children:e})})},DK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Zn.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:W=!1,autoFocus:G=!1,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:V,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Be,onDuplicate:se,imageContextMenuItems:De,children:Le,validateEmbeddable:Ce,renderEmbeddable:At,showDeprecatedFonts:Cn,wheelZoomsOnDefault:Pn,strokeColorTopPicks:Yo,backgroundColorTopPicks:Pi,renderScrollbars:ki,viewportStatusFrame:xs,currentUserControls:bo,imageOptions:Dt,showDropEventDebugAlert:ys}=e,Mi=e.UIOptions?.canvasActions,xo={...e.UIOptions,canvasActions:{...MA.canvasActions,...Mi},tools:{image:e.UIOptions?.tools?.image??!0}};Mi?.export&&(xo.canvasActions.export.saveFileToDisk=Mi.export?.saveFileToDisk??MA.canvasActions.export.saveFileToDisk),xo.canvasActions.toggleTheme===null&&(P==null||r)&&(xo.canvasActions.toggleTheme=!0);let K={maxFileSizeBytes:Dt?.maxFileSizeBytes??Sn.maxFileSizeBytes,maxWidthOrHeight:Dt?.maxWidthOrHeight??Sn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:Dt?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:Dt?.placeholderTransitionDuration??Sn.placeholderTransitionDuration},ve=CK(Eu),Lt=kK(l);Lt.current=l;let ws=SK(vu=>{ve?.(vu),Lt.current?.(vu)},[ve]),Ac=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return PK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Ac)return;let rx=Iu=>{typeof Iu.scale=="number"&&Iu.scale!==1&&Iu.preventDefault()};return document.addEventListener("touchmove",rx,{passive:!1}),()=>{document.removeEventListener("touchmove",rx)}},[Ac]),Mc(_x,{store:bt,children:Mc(gA,{langCode:b,theme:P,children:Mc(hA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:ws,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,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:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:xo,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:W,autoFocus:G,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:V,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Be,onDuplicate:se,imageContextMenuItems:De,validateEmbeddable:Ce,renderEmbeddable:At,showDeprecatedFonts:Cn,wheelZoomsOnDefault:Pn,strokeColorTopPicks:Yo,backgroundColorTopPicks:Pi,renderScrollbars:ki,viewportStatusFrame:xs,currentUserControls:bo,imageOptions:K,showDropEventDebugAlert:ys,children:Le})})})},LK=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.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(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Sn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Sn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Sn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Sn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Sn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Sn.placeholderTransitionDuration);return T&&C&&AK(l,g)},_K=TK.memo(DK,LK);_K.displayName="Excalidraw";function fYe(e){return na(e,!1)}export{vn as Button,nXe as CaptureUpdateAction,VYe as DEFAULT_LASER_COLOR,Su as DEFAULT_OVERSCROLL,pb as DefaultSidebar,Xs as Ellipsify,_K as Excalidraw,Es as ExcalidrawAPIContext,gYe as ExcalidrawAPIProvider,GYe as FONT_FAMILY,wo as Fonts,aK as Footer,cK as LiveCollaborationTrigger,UYe as MIME_TYPES,zt as MainMenu,WYe as ROUNDNESS,Mr as Sidebar,ac as Stats,HYe as THEME,Pu as UnsupportedImageFileTypeError,YYe as UserIdleState,hK as WelcomeScreen,eYe as applyDarkModeFilter,eXe as bumpVersion,tg as captureDragEventData,yYe as configureGifWorkerUrl,uXe as convertToExcalidrawElements,Zn as defaultLang,gXe as elementsOverlappingBBox,wP as exportToBlob,Fp as exportToCanvas,lH as exportToClipboard,vP as exportToSvg,mXe as getCommonBounds,zc as getDataURL,ZYe as getFormFactor,TYe as getNonDeletedElements,wYe as getSceneVersion,tYe as getStrokeWidthByKey,CYe as getTextFromElements,pXe as getVisibleSceneBounds,vYe as hashElementsVersion,IYe as hashString,bXe as isElementLink,kYe as isInvisiblySmallElement,OYe as isLinearElement,Oa as isSpreadsheetValidForChartType,Bi as languages,Ps as loadFromBlob,JYe as mutateElement,QYe as newElementWith,XYe as normalizeLink,Zr as parseDataTransferEvent,em as parseDragImageMetadata,IK as reconcileElements,Bf as renderSpreadsheet,_i as restoreAppState,DA as restoreElement,Fr as restoreElements,KYe as sceneCoordsToViewportCoords,Ts as serializeAsJSON,wXe as setCustomTextMetricsProvider,jYe as throttleRAF,Zm as tryParseSpreadsheet,Ee as useEditorInterface,Rd as useExcalidrawAPI,fYe as useExcalidrawStateValue,Re as useI18n,H6 as useOnExcalidrawStateChange,dt as useStylesPanelMode,$Ye as viewportCoordsToSceneCoords,Nr as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Pe({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:SY,verticalAlign:uM,locked:!1},s=Ib({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=bM(a.fontFamily),[c,,d]=TX(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
+ `),g=E.reduce((b,w,y)=>{let x=kX(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=YM(x,s,l),C=T.width>m,P=C?CX(x,s,m):x;T=C?YM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=kM({...a,x:M,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[y-1]?.trim()&&(u+=XM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Ae(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&cA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),cA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&$t(c)?fo(c,{originalText:s,isDeleted:l??c.isDeleted,...oX(c,OM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=mI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=ru({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:je(s=>{a(s,!1),mu(t)&&su(t,this.scene)}),onSubmit:je(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:Ae({...m.selectedElementIds,[d]:!0},m)}))}),c&&ZY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{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:Ae({},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 $t(r)?r:t?Db(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($t(i))return null;if(!zM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&$t(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 s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return wc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(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(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!($t(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Bb(l,a);return c&&!mu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!yc(l)?HM({x:t,y:o},c,a):!0}).filter(l=>yc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(EM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&hX([r],this.state,this.editorInterface)&&VX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||vX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:wc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(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 _M(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=SM(r[s],this.scene.getNonDeletedElementsMap());if(xc(r[s])&&wc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return _M(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||$t(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 s=-1,l=null;wc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=fe.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=fe.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Zt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),fe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=$X(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ue.pointers.size===2&&(ue.lastCenter=cf(ue.pointers),ue.initialScale=this.state.zoom.value,ue.initialDistance=df(Array.from(ue.pointers.values())))}initialPointerDownState(t){let o=Pe(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=fs(r),c=r.findIndex(Zt)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:Tb(Mt(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:vf(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,MM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+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;uu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=_m(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=je(()=>{Es=null,uu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,r),window.removeEventListener(Q.POINTER_UP,i),r.flush()});return Es=i,window.addEventListener(Q.POINTER_MOVE,r),window.addEventListener(Q.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(EM/this.state.zoom.value,1),i=uY*2/this.state.zoom.value,[a,s,l,c]=fs(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:aX(t)?tu.ADAPTIVE_RADIUS:tu.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return XY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Lo({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(Y2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Lo({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(V2(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===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return _m(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Pe(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]=Mt(r.x,r.y,o[X.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=Tb(UX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(rn(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[s,l]=Mt(r.x,r.y,o[X.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 c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){ZX(p,c,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,c)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{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,c);if(u?.isDeleted)return;if(Eo(u)){let g=Lr(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Go("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Go("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||!vM(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 d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||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=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:GM(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),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&&Yn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=Si(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=JX(I),M=sM(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[D,_,k,L,F,Y]=SM(I,c),z=yb(xb(oe(D,_),oe(F,Y),I.angle)),U=yb(xb(oe(k,_),oe(F,Y),I.angle)),W=yb(xb(oe(D,L),oe(F,Y),I.angle)),G=dM(lM(U,z)),ie=dM(lM(W,z)),me=sM(cM(M,G),cM(M,ie)),B={...T,x:uc(T.x-me[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:uc(T.y-me[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:B});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=X2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||HX(t,p,g,this.scene,y,o[X.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:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=AM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:FY()})});M.forEach(z=>{t.originalElements.set(z.id,MM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return fo(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),Y=ZM(F||L,bc(M));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let W=k.get(U.id),G=W&&D.get(W);return G&&z.push(G),z},[]),t.drag.origin=Pe(o,this.state),this.setState(z=>({...$M(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{kb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&su(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 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,oe(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ht(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;go(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,s,l,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&&_e(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Xn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?lx(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},{...Xn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ht(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Ho(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*(Sc.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*(Sc.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===Wn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,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:Ec(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,gn.setReferenceSnapPoints(null),gn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Pe({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(Go("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);kb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Zt(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(ht);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ht,"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?(qX(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(ht,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ht(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(Q.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(Q.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(Q.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(Q.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Pe(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,oe(T,C)],pressures:P}),this.actionManager.executeAction(ht);return}if(Ht(i)&&this.state.activeTool.type!=="autoshape"){let x=Pe(o,this.state),I=po(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<OY)&&i&&!l)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:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ht)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ht(i)&&this.actionManager.executeAction(ht,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Ae({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if($t(i)){let x=DX(Ib({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(c.type!=="selection"&&i&&NM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(Tt(i)){let x=bX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Rb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,sX(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Pe(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=Bb(I,r);T&&I&&(xX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),EX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:GM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let D of M){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&Pi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(D=>WM(D,C,this.state));this.state.editingGroupId&&P(M),C=Rb(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!WM(D,C,this.state));P(M)}C=UM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&NM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=UM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=fX(x,Nb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ht(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new fe(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rn(this.state)&&b&&w){if(this.eraserTrail.endPath(),po(oe(b.clientX,b.clientY),oe(w.clientX,w.clientY))===0){let I=Pe({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]?BX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>Pi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Ae(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{...Xn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ht(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=>Pi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Xn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Ho(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Xn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ht(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Zt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&IX({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Pa):this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&($t(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()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Ae({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Ho(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||_e(this.scene.getNonDeletedElements(),this.state)||!vM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(xc);CM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ht);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Wn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Ae({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&KM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=Lb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<xY){let{x:m,y:p}=ru({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}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=Fi.find(o=>o.code===this.props.langCode)||$n;await Uc(t),this.setAppState({})}},oK=()=>{(dA()||mA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(uA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};oK();var fA=Wb;import{useEffect as iK,useState as aK}from"react";import{jsx as sK}from"react/jsx-runtime";var EA=e=>{let[n,t]=aK(!0);return iK(()=>{let o=async()=>{await Uc(r),t(!1)},r=Fi.find(i=>i.code===e.langCode)||$n;o()},[e.langCode]),n?sK(bp,{theme:e.theme}):e.children};import lK from"clsx";import{jsx as bA}from"react/jsx-runtime";var xA=({children:e})=>{let{FooterCenterTunnel:n}=rt(),t=xe();return bA(n.In,{children:bA("div",{className:lK("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},cK=xA;xA.displayName="FooterCenter";import dK from"clsx";import{MQ_MIN_WIDTH_DESKTOP as mK}from"@excalidraw/common";import{jsx as uK,jsxs as hK}from"react/jsx-runtime";var yA=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=xe(),i=t?.formFactor!=="desktop"||r.width<mK;return hK(vn,{...o,className:dK("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?i1:f("labels.share"),r.collaborators.size>0&&uK("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},pK=yA;yA.displayName="LiveCollaborationTrigger";import{jsx as Rr,jsxs as vA}from"react/jsx-runtime";var gK=()=>Rr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rr("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"})}),fK=()=>vA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rr("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)"}),Rr("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)"}),Rr("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)"}),Rr("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)"})]}),wA=({style:e,size:n="small",withText:t})=>vA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Rr(gK,{}),t&&Rr(fK,{})]});import{Fragment as SA,jsx as ct,jsxs as jb}from"react/jsx-runtime";var qb=({icon:e,shortcut:n,children:t})=>{let o=Ee();return jb(SA,{children:[ct("div",{className:"welcome-screen-menu-item__icon",children:e}),ct("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&ct("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};qb.displayName="WelcomeScreenMenuItemContent";var Pc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>ct("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:ct(qb,{icon:t,shortcut:o,children:n})});Pc.displayName="WelcomeScreenMenuItem";var IA=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>ct("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:ct(qb,{icon:t,shortcut:o,children:e})});IA.displayName="WelcomeScreenMenuItemLink";var Tn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=rt();return ct(n.In,{children:ct("div",{className:"welcome-screen-center",children:e||jb(SA,{children:[ct(Jb,{}),ct(Qb,{children:f("welcomeScreen.defaults.center_heading")}),jb(ex,{children:[ct(nx,{}),ct(tx,{})]})]})})})};Tn.displayName="Center";var Jb=({children:e})=>ct("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||ct(wA,{withText:!0})});Jb.displayName="Logo";var Qb=({children:e})=>ct("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Qb.displayName="Heading";var ex=({children:e})=>ct("div",{className:"welcome-screen-menu",children:e});ex.displayName="Menu";var tx=()=>{let e=it();return ct(Pc,{onSelect:()=>e.executeAction(Qr),shortcut:"?",icon:Ui,children:f("helpDialog.title")})};tx.displayName="MenuItemHelp";var nx=()=>{let e=xe(),n=it();return e.viewModeEnabled?null:ct(Pc,{onSelect:()=>n.executeAction(da),shortcut:Je("loadScene"),icon:Kc,children:f("buttons.load")})};nx.displayName="MenuItemLoadScene";var TA=({onSelect:e})=>{let{t:n}=Re();return ct(Pc,{shortcut:null,onSelect:e,icon:Zc,children:n("labels.liveCollaboration")})};TA.displayName="MenuItemLiveCollaborationTrigger";Tn.Logo=Jb;Tn.Heading=Qb;Tn.Menu=ex;Tn.MenuItem=Pc;Tn.MenuItemLink=IA;Tn.MenuItemHelp=tx;Tn.MenuItemLoadScene=nx;Tn.MenuItemLiveCollaborationTrigger=TA;import{jsx as xs,jsxs as ox}from"react/jsx-runtime";var bu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=rt();return xs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Hx,xs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};bu.displayName="MenuHint";var xu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=rt();return xs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[xs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Wx]})})};xu.displayName="ToolbarHint";var yu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=rt();return xs(n.In,{children:ox("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[xs("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Ux]})})};yu.displayName="HelpHint";import{Fragment as CA,jsx as kc,jsxs as bK}from"react/jsx-runtime";var wu=e=>kc(CA,{children:e.children||bK(CA,{children:[kc(Tn,{}),kc(bu,{}),kc(xu,{}),kc(yu,{})]})});wu.displayName="WelcomeScreen";wu.Center=Tn;wu.Hints={MenuHint:bu,ToolbarHint:xu,HelpHint:yu};var EK=wu;var xK=()=>{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)})},PA=xK;import{configureGifWorkerUrl as CYe,getSceneVersion as PYe,hashElementsVersion as kYe,hashString as MYe,getNonDeletedElements as AYe}from"@excalidraw/element";import{getTextFromElements as LYe}from"@excalidraw/element";import{isInvisiblySmallElement as RYe}from"@excalidraw/element";import yK from"lodash.throttle";import{arrayToMap as wK,isDevEnv as kA,isTestEnv as MA}from"@excalidraw/common";import{orderByFractionalIndex as vK,syncInvalidIndices as AA,validateFractionalIndices as IK}from"@excalidraw/element";var TK=(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)),SK=yK((e,n,t)=>{if(kA()||MA()||window?.DEBUG_FRACTIONAL_INDICES){let o=AA(e.map(r=>({...r})));IK(o,{shouldThrow:MA()||kA(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),CK=(e,n,t)=>{let o=wK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=TK(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=vK(r);return SK(a,e,n),AA(a),a};import{isLinearElement as VYe}from"@excalidraw/element";import{FONT_FAMILY as XYe,THEME as KYe,MIME_TYPES as ZYe,ROUNDNESS as $Ye,DEFAULT_LASER_COLOR as jYe,UserIdleState as qYe,normalizeLink as JYe,sceneCoordsToViewportCoords as QYe,viewportCoordsToSceneCoords as eXe,getFormFactor as tXe,throttleRAF as nXe}from"@excalidraw/common";import{mutateElement as rXe,newElementWith as iXe,bumpVersion as aXe}from"@excalidraw/element";import{CaptureUpdateAction as lXe}from"@excalidraw/element";import{getCommonBounds as EXe,getVisibleSceneBounds as bXe,convertToExcalidrawElements as xXe}from"@excalidraw/element";import{elementsOverlappingBBox as wXe}from"@excalidraw/element";import{isElementLink as TXe}from"@excalidraw/element";import{setCustomTextMetricsProvider as PXe}from"@excalidraw/element";import{jsx as Mc}from"react/jsx-runtime";PA();var wYe=({children:e})=>{let[n,t]=LK(null);return Mc(bs.Provider,{value:n,children:Mc(Eu.Provider,{value:t,children:e})})},RK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=$n.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:W=!1,autoFocus:G=!1,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:V,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Be,onDuplicate:se,imageContextMenuItems:De,children:Le,validateEmbeddable:Ce,renderEmbeddable:At,showDeprecatedFonts:Cn,wheelZoomsOnDefault:Pn,strokeColorTopPicks:Yo,backgroundColorTopPicks:ki,renderScrollbars:Mi,viewportStatusFrame:ys,currentUserControls:bo,imageOptions:Dt,showDropEventDebugAlert:ws}=e,Ai=e.UIOptions?.canvasActions,xo={...e.UIOptions,canvasActions:{...DA.canvasActions,...Ai},tools:{image:e.UIOptions?.tools?.image??!0}};Ai?.export&&(xo.canvasActions.export.saveFileToDisk=Ai.export?.saveFileToDisk??DA.canvasActions.export.saveFileToDisk),xo.canvasActions.toggleTheme===null&&(P==null||r)&&(xo.canvasActions.toggleTheme=!0);let Z={maxFileSizeBytes:Dt?.maxFileSizeBytes??Sn.maxFileSizeBytes,maxWidthOrHeight:Dt?.maxWidthOrHeight??Sn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:Dt?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:Dt?.placeholderTransitionDuration??Sn.placeholderTransitionDuration},ve=MK(Eu),Lt=DK(l);Lt.current=l;let vs=kK(vu=>{ve?.(vu),Lt.current?.(vu)},[ve]),Ac=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return AK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Ac)return;let rx=Iu=>{typeof Iu.scale=="number"&&Iu.scale!==1&&Iu.preventDefault()};return document.addEventListener("touchmove",rx,{passive:!1}),()=>{document.removeEventListener("touchmove",rx)}},[Ac]),Mc(_x,{store:bt,children:Mc(EA,{langCode:b,theme:P,children:Mc(fA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:vs,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,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:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:xo,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:W,autoFocus:G,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:V,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Be,onDuplicate:se,imageContextMenuItems:De,validateEmbeddable:Ce,renderEmbeddable:At,showDeprecatedFonts:Cn,wheelZoomsOnDefault:Pn,strokeColorTopPicks:Yo,backgroundColorTopPicks:ki,renderScrollbars:Mi,viewportStatusFrame:ys,currentUserControls:bo,imageOptions:Z,showDropEventDebugAlert:ws,children:Le})})})},NK=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.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(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Sn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Sn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Sn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Sn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Sn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Sn.placeholderTransitionDuration);return T&&C&&_K(l,g)},BK=PK.memo(RK,NK);BK.displayName="Excalidraw";function vYe(e){return oa(e,!1)}export{vn as Button,lXe as CaptureUpdateAction,jYe as DEFAULT_LASER_COLOR,Su as DEFAULT_OVERSCROLL,pb as DefaultSidebar,Ks as Ellipsify,BK as Excalidraw,bs as ExcalidrawAPIContext,wYe as ExcalidrawAPIProvider,XYe as FONT_FAMILY,wo as Fonts,cK as Footer,pK as LiveCollaborationTrigger,ZYe as MIME_TYPES,zt as MainMenu,$Ye as ROUNDNESS,Mr as Sidebar,ac as Stats,KYe as THEME,Pu as UnsupportedImageFileTypeError,qYe as UserIdleState,EK as WelcomeScreen,aYe as applyDarkModeFilter,aXe as bumpVersion,tg as captureDragEventData,CYe as configureGifWorkerUrl,xXe as convertToExcalidrawElements,$n as defaultLang,wXe as elementsOverlappingBBox,IP as exportToBlob,Fp as exportToCanvas,mH as exportToClipboard,TP as exportToSvg,EXe as getCommonBounds,zc as getDataURL,tXe as getFormFactor,AYe as getNonDeletedElements,PYe as getSceneVersion,sYe as getStrokeWidthByKey,LYe as getTextFromElements,bXe as getVisibleSceneBounds,kYe as hashElementsVersion,MYe as hashString,TXe as isElementLink,RYe as isInvisiblySmallElement,VYe as isLinearElement,za as isSpreadsheetValidForChartType,Fi as languages,ks as loadFromBlob,rXe as mutateElement,iXe as newElementWith,JYe as normalizeLink,$r as parseDataTransferEvent,em as parseDragImageMetadata,CK as reconcileElements,Bf as renderSpreadsheet,Ri as restoreAppState,_A as restoreElement,Fr as restoreElements,QYe as sceneCoordsToViewportCoords,Ss as serializeAsJSON,PXe as setCustomTextMetricsProvider,nXe as throttleRAF,$m as tryParseSpreadsheet,Ee as useEditorInterface,Rd as useExcalidrawAPI,vYe as useExcalidrawStateValue,Re as useI18n,W6 as useOnExcalidrawStateChange,dt as useStylesPanelMode,eXe as viewportCoordsToSceneCoords,Nr as zoomToFitBounds};